Sha256: fcb5f5b0a13c0ca1b12822ea406f9bb621deab6f52ed5b130e10727a11836e3e

Contents?: true

Size: 1.93 KB

Versions: 11

Compression:

Stored size: 1.93 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 {
          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

      describe 'as a proxy for the creator of object' do
        let(:proxy_user) { FactoryGirl.create(:user) }
        before do
          creating_user.can_receive_deposits_from << proxy_user
        end
        let(:creating_user) { user }
        let(:current_user) { proxy_user }
        it {
          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

      describe 'another authenticated user' do
        let(:creating_user) { FactoryGirl.create(:user) }
        let(:current_user) { user }
        it {
          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)
        }
      end

      describe 'a nil user' do
        let(:creating_user) { FactoryGirl.create(:user) }
        let(:current_user) { nil }
        it {
          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)
        }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
curate-0.6.4 spec/abilities/generic_work_abilities_spec.rb
curate-0.6.3 spec/abilities/generic_work_abilities_spec.rb
curate-0.6.1 spec/abilities/generic_work_abilities_spec.rb
curate-0.6.0 spec/abilities/generic_work_abilities_spec.rb
curate-0.5.6 spec/abilities/generic_work_abilities_spec.rb
curate-0.5.5 spec/abilities/generic_work_abilities_spec.rb
curate-0.5.4 spec/abilities/generic_work_abilities_spec.rb
curate-0.5.2 spec/abilities/generic_work_abilities_spec.rb
curate-0.5.1 spec/abilities/generic_work_abilities_spec.rb
curate-0.5.0 spec/abilities/generic_work_abilities_spec.rb
curate-0.4.2 spec/abilities/generic_work_abilities_spec.rb