Sha256: c7fda708f78c2d159424f79eeca40a4a18aa7577092da1601b86b98d27e1f499

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

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

  describe "#public?" do
    it "returns true for public items" do
      subject.read_groups = ["public", "othergroup"]
      expect(subject).to be_public
    end
    it "returns fale for non-public items" do
      subject.read_groups = ["notpublic", "othergroup"]
      expect(subject).to_not be_public
    end
  end

  describe "#registered?" do
    it "returns true for registered items" do
      subject.read_groups = ["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

6 entries across 6 versions & 1 rubygems

Version Path
sufia-6.7.0 spec/lib/sufia/readable_permissions_spec.rb
sufia-6.6.1 spec/lib/sufia/readable_permissions_spec.rb
sufia-6.6.0 spec/lib/sufia/readable_permissions_spec.rb
sufia-6.5.0 spec/lib/sufia/readable_permissions_spec.rb
sufia-6.4.0 spec/lib/sufia/readable_permissions_spec.rb
sufia-6.3.0 spec/lib/sufia/readable_permissions_spec.rb