]> git.openstreetmap.org Git - rails.git/blobdiff - test/abilities/api_capability_test.rb
Rename browse controller to feature queries controller
[rails.git] / test / abilities / api_capability_test.rb
index 0f69ddba9583a86eb33e5b2a19d448736b857862..0945b6290045a444b6c35e163a968819fd6a88cc 100644 (file)
@@ -8,23 +8,19 @@ class ChangesetCommentApiCapabilityTest < ActiveSupport::TestCase
     scopes = Set.new
     ability = ApiAbility.new user, scopes
 
-    [:create, :destroy, :restore].each do |action|
-      assert ability.cannot? action, ChangesetComment
-    end
+    assert ability.cannot? :create, ChangesetComment
+    assert ability.cannot? :create, :changeset_comment_visibility
+    assert ability.cannot? :destroy, :changeset_comment_visibility
   end
 
-  test "as a normal user with write_api scope" do
+  test "as a normal user with write_changeset_comments scope" do
     user = create(:user)
-    scopes = Set.new %w[write_api]
+    scopes = Set.new %w[write_changeset_comments]
     ability = ApiAbility.new user, scopes
 
-    [:destroy, :restore].each do |action|
-      assert ability.cannot? action, ChangesetComment
-    end
-
-    [:create].each do |action|
-      assert ability.can? action, ChangesetComment
-    end
+    assert ability.can? :create, ChangesetComment
+    assert ability.cannot? :create, :changeset_comment_visibility
+    assert ability.cannot? :destroy, :changeset_comment_visibility
   end
 
   test "as a moderator without scopes" do
@@ -32,19 +28,19 @@ class ChangesetCommentApiCapabilityTest < ActiveSupport::TestCase
     scopes = Set.new
     ability = ApiAbility.new user, scopes
 
-    [:create, :destroy, :restore].each do |action|
-      assert ability.cannot? action, ChangesetComment
-    end
+    assert ability.cannot? :create, ChangesetComment
+    assert ability.cannot? :create, :changeset_comment_visibility
+    assert ability.cannot? :destroy, :changeset_comment_visibility
   end
 
-  test "as a moderator with write_api scope" do
+  test "as a moderator with write_changeset_comments scope" do
     user = create(:moderator_user)
-    scopes = Set.new %w[write_api]
+    scopes = Set.new %w[write_changeset_comments]
     ability = ApiAbility.new user, scopes
 
-    [:create, :destroy, :restore].each do |action|
-      assert ability.can? action, ChangesetComment
-    end
+    assert ability.can? :create, ChangesetComment
+    assert ability.can? :create, :changeset_comment_visibility
+    assert ability.can? :destroy, :changeset_comment_visibility
   end
 end