Sha256: 29ecc6cfed4e869aec9de0d14faa98d20117b465b68f317c7e6f371c0ad0bee0

Contents?: true

Size: 1.78 KB

Versions: 7

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'
require "cancan/matchers"

describe "User" do
  describe "Abilities" do
    subject { ability }
    let(:ability) { Ability.new(current_user) }
    let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
    let(:mock_curation_concern) {
      FactoryGirl.create_curation_concern(:mock_curation_concern, creating_user, { visibility: visibility })
    }
    let(:generic_file) {
      FactoryGirl.create_generic_file(mock_curation_concern, creating_user) { |gf|
        gf.visibility = visibility
      }
    }
    let(:creating_user) { nil }
    let(:current_user) { nil }
    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, GenericFile.new)
          should be_able_to(:read, generic_file)
          should be_able_to(:update, generic_file)
          should_not be_able_to(:delete, generic_file)
        }
      end

      describe 'another authenticated user' do
        let(:creating_user) { FactoryGirl.create(:user) }
        let(:current_user) { user }
        it {
          should be_able_to(:create, GenericFile.new)
          should_not be_able_to(:read, generic_file)
          should_not be_able_to(:update, generic_file)
          should_not be_able_to(:delete, generic_file)
        }
      end

      describe 'a nil user' do
        let(:creating_user) { FactoryGirl.create(:user) }
        let(:current_user) { nil }
        it {
          should_not be_able_to(:create, GenericFile.new)
          should_not be_able_to(:read, generic_file)
          should_not be_able_to(:update, generic_file)
          should_not be_able_to(:delete, generic_file)
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curate-0.3.2 spec/abilities/generic_file_abilities_spec.rb
curate-0.3.1 spec/abilities/generic_file_abilities_spec.rb
curate-0.2.0 spec/abilities/generic_file_abilities_spec.rb
curate-0.1.3 spec/abilities/generic_file_abilities_spec.rb
curate-0.1.2 spec/abilities/generic_file_abilities_spec.rb
curate-0.1.1 spec/abilities/generic_file_abilities_spec.rb
curate-0.1.0 spec/abilities/generic_file_abilities_spec.rb