spec/auth/ability_spec.rb in ddr-models-2.4.9 vs spec/auth/ability_spec.rb in ddr-models-2.4.10

- old
+ new

@@ -1,10 +1,10 @@ module Ddr::Auth RSpec.describe Ability, type: :model, abilities: true do subject { described_class.new(auth_context) } - + let(:auth_context) { FactoryGirl.build(:auth_context) } describe "aliases" do it "should have :replace aliases" do expect(subject.aliased_actions[:replace]).to contain_exactly(:upload) @@ -139,9 +139,28 @@ end end describe "when the attachment is not attached" do it { should_not be_able_to(:create, attachment) } + end + end + + describe "locks" do + let(:obj) { Ddr::Models::Base.new } + + describe "effects of locks on abilities" do + before do + allow(obj).to receive(:effective_permissions) { Permissions::ALL } + allow(obj).to receive(:locked?) { true } + end + it { should be_able_to(:read, obj) } + it { should be_able_to(:download, obj) } + it { should_not be_able_to(:add_children, obj) } + it { should_not be_able_to(:update, obj) } + it { should_not be_able_to(:replace, obj) } + it { should_not be_able_to(:arrange, obj) } + it { should be_able_to(:audit, obj) } + it { should_not be_able_to(:grant, obj) } end end describe "role based abilities" do shared_examples "it has role based abilities" do