From: Tom Hughes Date: Sun, 10 Jun 2018 18:03:33 +0000 (+0100) Subject: Improve system tests for issues X-Git-Tag: live~2981^2~1 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/29f12c454799ed62745803f2d8423d9c59ed1a93?hp=518cf69b3429d12b22efe52b5be8fd3e910b7ac4 Improve system tests for issues --- diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index b77908f07..3cecf58d9 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -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 diff --git a/test/system/report_diary_comment_test.rb b/test/system/report_diary_comment_test.rb index 852bcfa65..356aac016 100644 --- a/test/system/report_diary_comment_test.rb +++ b/test/system/report_diary_comment_test.rb @@ -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 diff --git a/test/system/report_diary_entry_test.rb b/test/system/report_diary_entry_test.rb index 15752777c..950deb695 100644 --- a/test/system/report_diary_entry_test.rb +++ b/test/system/report_diary_entry_test.rb @@ -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? diff --git a/test/system/report_note_test.rb b/test/system/report_note_test.rb index 759306e08..a18366d01 100644 --- a/test/system/report_note_test.rb +++ b/test/system/report_note_test.rb @@ -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 diff --git a/test/system/report_user_test.rb b/test/system/report_user_test.rb index 8bb7d9dd7..758c91eda 100644 --- a/test/system/report_user_test.rb +++ b/test/system/report_user_test.rb @@ -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