X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d3700e6201b4b78a70bbb2941572edc985b63c2c..3ece776664381794b5e342e82ed2be3f47f120b5:/test/controllers/reports_controller_test.rb?ds=inline diff --git a/test/controllers/reports_controller_test.rb b/test/controllers/reports_controller_test.rb index d9bc190d8..612ead2e6 100644 --- a/test/controllers/reports_controller_test.rb +++ b/test/controllers/reports_controller_test.rb @@ -13,8 +13,6 @@ class ReportsControllerTest < ActionController::TestCase session[:user] = create(:user).id - assert_equal 0, Issue.count - # Create an Issue and a report get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } assert_response :success @@ -30,9 +28,8 @@ class ReportsControllerTest < ActionController::TestCase } } end - assert_equal 1, Issue.count assert_response :redirect - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) end def test_new_report_with_incomplete_details @@ -42,8 +39,6 @@ class ReportsControllerTest < ActionController::TestCase # Login session[:user] = create(:user).id - assert_equal 0, Issue.count - # Create an Issue and a report get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } assert_response :success @@ -59,9 +54,12 @@ class ReportsControllerTest < ActionController::TestCase } } end - assert_equal 1, Issue.count assert_response :redirect - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) + + issue = Issue.last + + assert_equal 1, issue.reports.count get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } assert_response :success @@ -78,7 +76,8 @@ class ReportsControllerTest < ActionController::TestCase } end assert_response :redirect - assert_equal 1, Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count + + assert_equal 1, issue.reports.count end def test_new_report_with_complete_details @@ -88,8 +87,6 @@ class ReportsControllerTest < ActionController::TestCase # Login session[:user] = create(:user).id - assert_equal 0, Issue.count - # Create an Issue and a report get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } assert_response :success @@ -105,9 +102,12 @@ class ReportsControllerTest < ActionController::TestCase } } end - assert_equal 1, Issue.count assert_response :redirect - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) + + issue = Issue.last + + assert_equal 1, issue.reports.count # Create a report for an existing Issue get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } @@ -125,7 +125,7 @@ class ReportsControllerTest < ActionController::TestCase } end assert_response :redirect - report_count = Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count - assert_equal 2, report_count + + assert_equal 2, issue.reports.count end end