- # and when accessed via history
- get api_way_history_path(way), :headers => auth_header
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0,
- "redacted way #{way_v3.way_id} version #{way_v3.version} shouldn't be present in the history."
+ post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header
+
+ assert_response :forbidden, "should need to be moderator to redact."
+ assert_nil old_way.reload.redaction
+ end
+
+ def test_redact_way_by_moderator_without_write_redactions_scope
+ way = create(:way, :with_history, :version => 2)
+ old_way = way.old_ways.find_by(:version => 1)
+ redaction = create(:redaction)
+ auth_header = bearer_authorization_header(create(:moderator_user), :scopes => %w[read_prefs write_api])
+
+ post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header
+
+ assert_response :forbidden, "should need to have write_redactions scope to redact."
+ assert_nil old_way.reload.redaction
+ end
+
+ def test_redact_way_by_moderator_with_write_redactions_scope
+ way = create(:way, :with_history, :version => 2)
+ old_way = way.old_ways.find_by(:version => 1)
+ redaction = create(:redaction)
+ auth_header = bearer_authorization_header(create(:moderator_user), :scopes => %w[write_redactions])
+
+ post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header
+
+ assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
+ assert_equal redaction, old_way.reload.redaction