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 b77908f..3cecf58 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 852bcfa..356aac0 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 1575277..950deb6 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 759306e..a18366d 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 8bb7d9d..758c91e 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