X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a20e28809f5ca1e3f3579faeaf118fff3ecc4994..71cbb003f8a8db1b077ebeefb776033a3e31ee9a:/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 206958ab8..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 root_path + 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 root_path + 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 root_path + 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