]> git.openstreetmap.org Git - rails.git/commitdiff
Improve system tests for issues
authorTom Hughes <tom@compton.nu>
Sun, 10 Jun 2018 18:03:33 +0000 (19:03 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 10 Jun 2018 18:03:47 +0000 (19:03 +0100)
test/system/issues_test.rb
test/system/report_diary_comment_test.rb
test/system/report_diary_entry_test.rb
test/system/report_note_test.rb
test/system/report_user_test.rb

index b77908f076dbf2fbf5f0fe03ce121bb7e63b4175..3cecf58d99d07dd938301292bb043dc70ac63a77 100644 (file)
@@ -53,6 +53,7 @@ class IssuesTest < ApplicationSystemTestCase
     visit issues_path
     fill_in "search_by_user", :with => good_user.display_name
     click_on "Search"
+    assert_not page.has_content?(I18n.t("issues.index.user_not_found"))
     assert page.has_content?(I18n.t("issues.index.issues_not_found"))
 
     # User doesn't exist
@@ -60,11 +61,13 @@ class IssuesTest < ApplicationSystemTestCase
     fill_in "search_by_user", :with => "Nonexistant User"
     click_on "Search"
     assert page.has_content?(I18n.t("issues.index.user_not_found"))
+    assert page.has_content?(I18n.t("issues.index.issues_not_found"))
 
     # Find Issue against bad_user
     visit issues_path
     fill_in "search_by_user", :with => bad_user.display_name
     click_on "Search"
+    assert_not page.has_content?(I18n.t("issues.index.user_not_found"))
     assert_not page.has_content?(I18n.t("issues.index.issues_not_found"))
   end
 
index 852bcfa65d6d3a7fece6d822db7d8a8e571c6fd3..356aac016ce9c3f655fe0a266c83bdb6f0db5a20 100644 (file)
@@ -25,11 +25,12 @@ class ReportDiaryCommentTest < ApplicationSystemTestCase
 
     choose I18n.t("reports.new.categories.diary_comment.spam")
     fill_in "report_details", :with => "This comment is spam"
-    click_on "Create Report"
+    assert_difference "Issue.count", 1 do
+      click_on "Create Report"
+    end
 
     assert page.has_content? "Your report has been registered sucessfully"
 
-    assert_equal 1, Issue.count
-    assert Issue.last.reportable == @comment
+    assert_equal @comment, Issue.last.reportable
   end
 end
index 15752777c5517f193afdcaee27a0d4fc3fa9e1d5..950deb6950855b77e696d6584df557260059ace2 100644 (file)
@@ -24,9 +24,13 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
 
     choose I18n.t("reports.new.categories.diary_entry.spam")
     fill_in "report_details", :with => "This is advertising"
-    click_on "Create Report"
+    assert_difference "Issue.count", 1 do
+      click_on "Create Report"
+    end
 
     assert page.has_content? "Your report has been registered sucessfully"
+
+    assert_equal @diary_entry, Issue.last.reportable
   end
 
   def test_it_reopens_issue
@@ -43,7 +47,9 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
 
     choose I18n.t("reports.new.categories.diary_entry.spam")
     fill_in "report_details", :with => "This is advertising"
-    click_on "Create Report"
+    assert_no_difference "Issue.count" do
+      click_on "Create Report"
+    end
 
     issue.reload
     assert_not issue.resolved?
index 759306e08f30dbc573782ece28576a3ab9d77f08..a18366d011d37e3a73186c3576f47e5a760b50b7 100644 (file)
@@ -20,12 +20,13 @@ class ReportNoteTest < ApplicationSystemTestCase
 
     choose I18n.t("reports.new.categories.note.spam")
     fill_in "report_details", :with => "This is spam"
-    click_on "Create Report"
+    assert_difference "Issue.count", 1 do
+      click_on "Create Report"
+    end
 
     assert page.has_content? "Your report has been registered sucessfully"
 
-    assert_equal 1, Issue.count
-    assert Issue.last.reportable == note
+    assert_equal note, Issue.last.reportable
   end
 
   def test_can_report_notes_with_author
@@ -39,11 +40,12 @@ class ReportNoteTest < ApplicationSystemTestCase
 
     choose I18n.t("reports.new.categories.note.spam")
     fill_in "report_details", :with => "This is spam"
-    click_on "Create Report"
+    assert_difference "Issue.count", 1 do
+      click_on "Create Report"
+    end
 
     assert page.has_content? "Your report has been registered sucessfully"
 
-    assert_equal 1, Issue.count
-    assert Issue.last.reportable == note
+    assert_equal note, Issue.last.reportable
   end
 end
index 8bb7d9dd7ed397284faa97ee1952ebecfc0f6c68..758c91eda16e6e2668fb5b050b5eb7f4c50bc93b 100644 (file)
@@ -20,11 +20,12 @@ class ReportUserTest < ApplicationSystemTestCase
 
     choose I18n.t("reports.new.categories.user.vandal")
     fill_in "report_details", :with => "This user is a vandal"
-    click_on "Create Report"
+    assert_difference "Issue.count", 1 do
+      click_on "Create Report"
+    end
 
     assert page.has_content? "Your report has been registered sucessfully"
 
-    assert_equal 1, Issue.count
-    assert Issue.last.reportable == user
+    assert_equal user, Issue.last.reportable
   end
 end