From 41d67556f438a1856001808293c72a4c7b5758fe Mon Sep 17 00:00:00 2001 From: benji Date: Thu, 29 Oct 2015 14:27:06 +0100 Subject: [PATCH] Fix ability test --- app/models/ability.rb | 4 ++-- spec/models/ability_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 4434f9b..047deee 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -6,7 +6,7 @@ class Ability initialize_admin if user.admin? initialize_koelkast if user.koelkast? - initialize_user + initialize_user(user) can :read, Barcode end @@ -22,7 +22,7 @@ class Ability can :quickpay, User end - def initialize_user + def initialize_user(user) can :read, :all can :manage, User, id: user.id can :create, Order do |order| diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index c480786..77813ff 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -21,13 +21,13 @@ describe User do let(:user) { create :user } it{ should be_able_to(:create, Order.new(user: user)) } - it{ should be_able_to(:delete, Order.new(user: user, created_at: (Rails.application.config.call_api_after - 1.minutes).ago)) } - it{ should_not be_able_to(:delete, Order.new(user: user, created_at: 10.minutes.ago)) } + it{ should be_able_to(:destroy, Order.new(user: user, created_at: (Rails.application.config.call_api_after - 1.minutes).ago)) } + it{ should_not be_able_to(:destroy, Order.new(user: user, created_at: 10.minutes.ago)) } it{ should_not be_able_to(:create, Order.new) } it{ should_not be_able_to(:update, Order.new) } it{ should be_able_to(:read, Product.new) } - it{ should_not be_able_to(:delete, Product.new) } + it{ should_not be_able_to(:destroy, Product.new) } it{ should_not be_able_to(:update, Product.new) } it{ should_not be_able_to(:create, Stock.new) }