]> git.openstreetmap.org Git - rails.git/commitdiff
Convert issue search tests to system tests
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 29 Nov 2017 18:58:51 +0000 (18:58 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 29 Nov 2017 18:58:51 +0000 (18:58 +0000)
test/controllers/issues_controller_test.rb
test/system/issues_test.rb

index 6df5e8bf36cebe152f6a3bc3967a97d398e4703d..ff99b0cdcef37af48b6ab54ae8e13698efbda296 100644 (file)
@@ -66,26 +66,4 @@ class IssuesControllerTest < ActionController::TestCase
     assert_equal true, Issue.find_by(:reportable_id => target_user, :reportable_type => "User").ignored?
     assert_response :redirect
   end
-
-  def test_search_issues
-    good_user = create(:user)
-    bad_user = create(:user)
-    create(:issue, :reportable => bad_user, :reported_user => bad_user, :issue_type => "administrator")
-    # Login as administrator
-    session[:user] = create(:administrator_user).id
-
-    # No issues against the user
-    get :index, :params => { :search_by_user => good_user.display_name }
-    assert_response :redirect
-    assert_redirected_to issues_path
-
-    # User doesn't exist
-    get :index, :params => { :search_by_user => "test1000" }
-    assert_response :redirect
-    assert_redirected_to issues_path
-
-    # Find Issue against bad_user
-    get :index, :params => { :search_by_user => bad_user.display_name }
-    assert_response :success
-  end
 end
index 1c42bc10b5a7c8c646ee6581bfb9f168c07dbcd2..9eb2fbbcb27925d047674fe55395dba573474b2f 100644 (file)
@@ -23,6 +23,32 @@ class IssuesTest < ApplicationSystemTestCase
     assert page.has_content?(issues.first.reported_user.display_name)
   end
 
+  def test_search_issues_by_user
+    good_user = create(:user)
+    bad_user = create(:user)
+    create(:issue, :reportable => bad_user, :reported_user => bad_user, :issue_type => "administrator")
+
+    sign_in_as(create(:administrator_user))
+
+    # No issues against the user
+    visit issues_path
+    fill_in "search_by_user", :with => good_user.display_name
+    click_on "Search"
+    assert page.has_content?(I18n.t(".issues.index.search.issues_not_found"))
+
+    # User doesn't exist
+    visit issues_path
+    fill_in "search_by_user", :with => "Nonexistant User"
+    click_on "Search"
+    assert page.has_content?(I18n.t(".issues.index.search.user_not_found"))
+
+    # Find Issue against bad_user
+    visit issues_path
+    fill_in "search_by_user", :with => bad_user.display_name
+    click_on "Search"
+    assert !page.has_content?(I18n.t(".issues.index.search.issues_not_found"))
+  end
+
   def test_commenting
     issue = create(:issue)
     sign_in_as(create(:moderator_user))