Sha256: b285068b81a64106d45de66caffb7b5d08630390909264034d13043198b2012a

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

shared_examples 'with_access_rights' do

  def prepare_subject_for_access_rights_visibility_test!
    # I am doing this because the actual persistence of the objects requires
    # so much more and I don't know for certain if it has happened.
    allow(subject).to receive(:persisted?).and_return(true)
  end

  it "has an under_embargo?" do
    expect {
      subject.under_embargo?
    }.to_not raise_error
  end

  it "has a visibility attribute" do
    expect(subject).to respond_to(:visibility)
    expect(subject).to respond_to(:visibility=)
  end

  describe 'open access' do
    it "has an open_access?" do
      expect {
        subject.open_access?
      }.to_not raise_error
    end

    it 'sets visibility' do
      prepare_subject_for_access_rights_visibility_test!
      subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
      expect(subject).to be_open_access
    end
  end

  describe 'authenticated access' do
    it 'sets visibility' do
      prepare_subject_for_access_rights_visibility_test!
      subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
      expect(subject).to be_authenticated_only_access
    end

    it "has an authenticated_only_access?" do
      expect {
        subject.authenticated_only_access?
      }.to_not raise_error
    end
  end

  describe 'private access' do
    it 'sets visibility' do
      prepare_subject_for_access_rights_visibility_test!
      subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
      expect(subject).to be_private_access
    end


    it "has an private_access?" do
      expect {
        subject.private_access?
      }.to_not raise_error
    end
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
curation_concerns-0.1.0 spec/support/shared/shared_examples_with_access_rights.rb
worthwhile-0.1.2 spec/support/shared/shared_examples_with_access_rights.rb
worthwhile-0.1.1 spec/support/shared/shared_examples_with_access_rights.rb
worthwhile-0.1.0 spec/support/shared/shared_examples_with_access_rights.rb
worthwhile-0.0.3 spec/support/shared/shared_examples_with_access_rights.rb
worthwhile-0.0.2 spec/support/shared/shared_examples_with_access_rights.rb
worthwhile-0.0.1 spec/support/shared/shared_examples_with_access_rights.rb