X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/03ebd2ac5e8048fcf7c5dea1cbdde6d90f606402..f5a573ab4aab064db68853dede1fc8bfa370ddec:/test/controllers/api/old_ways_controller_test.rb diff --git a/test/controllers/api/old_ways_controller_test.rb b/test/controllers/api/old_ways_controller_test.rb index d695311fc..6946d2ab1 100644 --- a/test/controllers/api/old_ways_controller_test.rb +++ b/test/controllers/api/old_ways_controller_test.rb @@ -196,31 +196,31 @@ module Api end ## - # test the redaction of an old version of a way, while not being - # authorised. - def test_redact_way_unauthorised + # test that, even as moderator, the current version of a way + # can't be redacted. + def test_redact_way_current_version way = create(:way, :with_history, :version => 2) - old_way = way.old_ways.find_by(:version => 1) + old_way = way.old_ways.find_by(:version => 2) redaction = create(:redaction) + auth_header = bearer_authorization_header create(:moderator_user) - post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id } + post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header - assert_response :unauthorized, "should need to be authenticated to redact." + assert_response :bad_request, "shouldn't be OK to redact current version as moderator." assert_nil old_way.reload.redaction end ## - # test that, even as moderator, the current version of a way - # can't be redacted. - def test_redact_way_current_version + # test the redaction of an old version of a way, while not being + # authorised. + def test_redact_way_unauthorised way = create(:way, :with_history, :version => 2) - old_way = way.old_ways.find_by(:version => 2) + old_way = way.old_ways.find_by(:version => 1) redaction = create(:redaction) - auth_header = bearer_authorization_header create(:moderator_user) - post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header + post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id } - assert_response :bad_request, "shouldn't be OK to redact current version as moderator." + assert_response :unauthorized, "should need to be authenticated to redact." assert_nil old_way.reload.redaction end @@ -307,11 +307,10 @@ module Api # test the unredaction of an old version of a way, while being # authorised as a moderator. def test_unredact_way_moderator - moderator_user = create(:moderator_user) way = create(:way, :with_history, :version => 2) old_way = way.old_ways.find_by(:version => 1) old_way.redact!(create(:redaction)) - auth_header = bearer_authorization_header moderator_user + auth_header = bearer_authorization_header create(:moderator_user) post way_version_redact_path(*old_way.id), :headers => auth_header