Sha256: c12ef7316e358cda820b52d67d534b42e7e09d2096ba32b47634e1689928a9bd

Contents?: true

Size: 1.52 KB

Versions: 66

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe CurationConcerns::Permissions::Readable do
  class SubjectClass
    include CurationConcerns::Permissions::Readable
    attr_accessor :read_groups
  end
  let(:subject) { SubjectClass.new }

  describe '#public?' do
    it 'returns true for public items' do
      subject.read_groups = %w(public othergroup)
      expect(subject).to be_public
    end
    it 'returns fale for non-public items' do
      subject.read_groups = %w(notpublic othergroup)
      expect(subject).to_not be_public
    end
  end

  describe '#registered?' do
    it 'returns true for registered items' do
      subject.read_groups = %w(registered othergroup)
      expect(subject).to be_registered
    end
    it 'returns fale for non-registered items' do
      subject.read_groups = ['othergroup']
      expect(subject).to_not be_registered
    end
  end

  describe '#private?' do
    context 'is true' do
      specify 'when there are no groups defined' do
        subject.read_groups = []
        expect(subject).to be_private
      end
      specify "when groups do not include 'public' or 'registered'" do
        subject.read_groups = ['othergroup']
        expect(subject).to be_private
      end
    end
    context 'is false' do
      specify "when 'registered' group is present" do
        subject.read_groups = ['registered']
        expect(subject).to_not be_private
      end
      specify "when 'public' group is present" do
        subject.read_groups = ['public']
        expect(subject).to_not be_private
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.7 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-2.0.0 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-2.0.0.rc2 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.6 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.5 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.4 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.3 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.2 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-2.0.0.rc1 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.1 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.0 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.7.0.beta1 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.6.3 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.6.2 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.6.1 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.6.0 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.5.0 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.4.0 spec/lib/curation_concerns/readable_permissions_spec.rb
curation_concerns-1.3.3 spec/lib/curation_concerns/readable_permissions_spec.rb