]> git.openstreetmap.org Git - rails.git/blobdiff - test/abilities/api_abilities_test.rb
Merge remote-tracking branch 'upstream/pull/5669'
[rails.git] / test / abilities / api_abilities_test.rb
index 7734ce996f7f095dffc871c2b01d80cfc9aa3ce8..38154174c4f8a8527eb15f67d5a005a70c15107c 100644 (file)
@@ -7,13 +7,14 @@ end
 
 class GuestApiAbilityTest < ApiAbilityTest
   test "note permissions for a guest" do
 
 class GuestApiAbilityTest < ApiAbilityTest
   test "note permissions for a guest" do
-    ability = ApiAbility.new nil
+    scopes = Set.new
+    ability = ApiAbility.new nil, scopes
 
 
-    [:index, :create, :comment, :feed, :show, :search].each do |action|
+    [:index, :create, :feed, :show, :search].each do |action|
       assert ability.can?(action, Note), "should be able to #{action} Notes"
     end
 
       assert ability.can?(action, Note), "should be able to #{action} Notes"
     end
 
-    [:close, :reopen, :destroy].each do |action|
+    [:comment, :close, :reopen, :destroy].each do |action|
       assert ability.cannot?(action, Note), "should not be able to #{action} Notes"
     end
   end
       assert ability.cannot?(action, Note), "should not be able to #{action} Notes"
     end
   end
@@ -21,7 +22,9 @@ end
 
 class UserApiAbilityTest < ApiAbilityTest
   test "Note permissions" do
 
 class UserApiAbilityTest < ApiAbilityTest
   test "Note permissions" do
-    ability = ApiAbility.new create(:user)
+    user = create(:user)
+    scopes = Set.new %w[write_notes]
+    ability = ApiAbility.new user, scopes
 
     [:index, :create, :comment, :feed, :show, :search, :close, :reopen].each do |action|
       assert ability.can?(action, Note), "should be able to #{action} Notes"
 
     [:index, :create, :comment, :feed, :show, :search, :close, :reopen].each do |action|
       assert ability.can?(action, Note), "should be able to #{action} Notes"
@@ -35,7 +38,9 @@ end
 
 class ModeratorApiAbilityTest < ApiAbilityTest
   test "Note permissions" do
 
 class ModeratorApiAbilityTest < ApiAbilityTest
   test "Note permissions" do
-    ability = ApiAbility.new create(:moderator_user)
+    user = create(:moderator_user)
+    scopes = Set.new %w[write_notes]
+    ability = ApiAbility.new user, scopes
 
     [:index, :create, :comment, :feed, :show, :search, :close, :reopen, :destroy].each do |action|
       assert ability.can?(action, Note), "should be able to #{action} Notes"
 
     [:index, :create, :comment, :feed, :show, :search, :close, :reopen, :destroy].each do |action|
       assert ability.can?(action, Note), "should be able to #{action} Notes"