Sha256: 3d2739f11aa34fa950b216ed83b8015f9f5cf683907c3c7b8bc402cd6ef032ab

Contents?: true

Size: 1.94 KB

Versions: 65

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'
require 'cancan/matchers'

describe 'User' do
  describe 'Abilities' do
    subject { Ability.new(current_user) }

    let(:generic_work) { FactoryGirl.create(:private_generic_work, user: creating_user) }
    let(:user) { FactoryGirl.create(:user) }

    describe 'without embargo' do
      describe 'creator of object' do
        let(:creating_user) { user }
        let(:current_user) { user }
        it do
          should be_able_to(:create, GenericWork.new)
          should be_able_to(:read, generic_work)
          should be_able_to(:update, generic_work)
          should be_able_to(:destroy, generic_work)
        end
      end

      describe 'as a repository manager' do
        let(:manager_user) { FactoryGirl.create(:admin) }
        let(:creating_user) { user }
        let(:current_user) { manager_user }
        it do
          should be_able_to(:create, GenericWork.new)
          should be_able_to(:read, generic_work)
          should be_able_to(:update, generic_work)
          should be_able_to(:destroy, generic_work)
        end
      end

      describe 'another authenticated user' do
        let(:creating_user) { FactoryGirl.create(:user) }
        let(:current_user) { user }
        it do
          should be_able_to(:create, GenericWork.new)
          should_not be_able_to(:read, generic_work)
          should_not be_able_to(:update, generic_work)
          should_not be_able_to(:destroy, generic_work)
          should be_able_to(:collect, generic_work)
        end
      end

      describe 'a nil user' do
        let(:creating_user) { FactoryGirl.create(:user) }
        let(:current_user) { nil }
        it do
          should_not be_able_to(:create, GenericWork.new)
          should_not be_able_to(:read, generic_work)
          should_not be_able_to(:update, generic_work)
          should_not be_able_to(:destroy, generic_work)
          should_not be_able_to(:collect, generic_work)
        end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
curation_concerns-1.3.2 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.3.1 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.3.0 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.2.0 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.1.2 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.1.1 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.1.0 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta10 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta9 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta8 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta7 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta6 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta5 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta4 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta3 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta2 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-1.0.0.beta1 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-0.14.0 spec/abilities/generic_work_abilities_spec.rb
curation_concerns-0.14.0.pre4 spec/abilities/generic_work_abilities_spec.rb