Sha256: 02a3ff07e7454463000d13b16a78e7c4f1747637541b5fdf4ef8a8e657ff38ac

Contents?: true

Size: 1.94 KB

Versions: 4

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'

describe Hydra::Datastream::RightsMetadata do
  before :all do
    class RightsTest < ActiveFedora::Base
      include Hydra::AccessControls::Permissions
    end
  end

  after :all do
    Object.send(:remove_const,:RightsTest)
  end

  describe "rightsMetadata" do
    let!(:thing) {RightsTest.new}

    [:discover,:read,:edit].each do |mode|
      describe "##{mode}_users" do
        let(:get_method) {"#{mode}_users".to_sym}
        let(:set_method) {"#{mode}_users=".to_sym}

        before :each do
          thing.send(set_method, ['locutus@borg.collective.mil'])
          thing.save
        end

        it "should persist initial setting" do
          thing.reload.send(get_method).should == ['locutus@borg.collective.mil']
        end

        it "should persist changes" do
          thing.send(set_method, ['locutus@borg.collective.mil','sevenofnine@borg.collective.mil'])
          thing.save
          thing.reload.send(get_method).should =~ ['locutus@borg.collective.mil','sevenofnine@borg.collective.mil']
        end

        it "should persist emptiness" do
          thing.send(set_method, [])
          thing.save
          thing.reload.send(get_method).should == []
        end
      end

      describe "##{mode}_groups" do
        let(:get_method) {"#{mode}_groups".to_sym}
        let(:set_method) {"#{mode}_groups=".to_sym}

        before :each do
          thing.send(set_method, ['borg'])
          thing.save
        end

        it "should persist initial setting" do
          thing.reload.send(get_method).should == ['borg']
        end

        it "should persist changes" do
          thing.send(set_method, ['borg','federation'])
          thing.save
          thing.reload.send(get_method).should =~ ['borg','federation']
        end

        it "should persist emptiness" do
          thing.send(set_method, [])
          thing.save
          thing.reload.send(get_method).should == []
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hydra-access-controls-6.5.2 spec/unit/hydra_rights_metadata_persistence_spec.rb
hydra-access-controls-6.5.1 spec/unit/hydra_rights_metadata_persistence_spec.rb
hydra-access-controls-6.5.0 spec/unit/hydra_rights_metadata_persistence_spec.rb
hydra-access-controls-6.5.0.rc2 spec/unit/hydra_rights_metadata_persistence_spec.rb