]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/old_relations_controller_test.rb
Split api old element redacted show tests
[rails.git] / test / controllers / api / old_relations_controller_test.rb
index 137a1bb33127389e00b04c8d9faaf1f81ba8d209..b5600ad379fc93b25e02853e944a5084c417b55c 100644 (file)
@@ -114,17 +114,21 @@ module Api
     ##
     # test that redacted relations aren't visible, regardless of
     # authorisation except as moderator...
-    def test_show_redacted
+    def test_show_redacted_unauthorised
       relation = create(:relation, :with_history, :version => 2)
-      relation_v1 = relation.old_relations.find_by(:version => 1)
-      relation_v1.redact!(create(:redaction))
+      relation.old_relations.find_by(:version => 1).redact!(create(:redaction))
+
+      get api_relation_version_path(relation, 1)
 
-      get api_relation_version_path(relation_v1.relation_id, relation_v1.version)
       assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
+    end
+
+    def test_show_redacted_normal_user
+      relation = create(:relation, :with_history, :version => 2)
+      relation.old_relations.find_by(:version => 1).redact!(create(:redaction))
+
+      get api_relation_version_path(relation, 1), :headers => bearer_authorization_header
 
-      # not even to a logged-in user
-      auth_header = bearer_authorization_header
-      get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
       assert_response :forbidden, "Redacted relation shouldn't be visible via the version API, even when logged in."
     end