Fix ability test
This commit is contained in:
parent
b7ac8c32f7
commit
41d67556f4
2 changed files with 5 additions and 5 deletions
|
@ -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|
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in a new issue