Sha256: 40a7fe93de0f355def47d58fad2aa36c13b8996d4acceb40b07c189f69fa4591

Contents?: true

Size: 1020 Bytes

Versions: 22

Compression:

Stored size: 1020 Bytes

Contents

require 'spec_helper'

describe ActiveFedora::WithMetadata do
  before do
    class Sample < ActiveFedora::Base
      contains :file, class_name: 'SampleFile'
    end

    class SampleFile < ActiveFedora::File
      include ActiveFedora::WithMetadata

      metadata do
        property :title, predicate: ::RDF::DC.title
      end
    end
  end

  after do
    Object.send(:remove_const, :SampleFile)
    Object.send(:remove_const, :Sample)
  end

  let(:base) { Sample.new }
  let(:file) { base.file }

  describe "properties" do
    before do
      file.title = ['one', 'two']
    end
    it "should set and retrieve properties" do
      expect(file.title).to eq ['one', 'two']
    end

    it "should track changes" do
      expect(file.title_changed?).to be true
    end
  end

  describe "#save" do
    before do
      file.content = "Hey"
      file.title = ["foo"]
      base.save
      base.reload
    end

    it "should save the metadata too" do
      expect(base.file.title).to eq ['foo']
    end
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
active-fedora-9.0.8 spec/integration/with_metadata_spec.rb
active-fedora-9.1.1 spec/integration/with_metadata_spec.rb
active-fedora-9.1.0 spec/integration/with_metadata_spec.rb
active-fedora-9.1.0.rc1 spec/integration/with_metadata_spec.rb
active-fedora-9.0.6 spec/integration/with_metadata_spec.rb
active-fedora-9.0.5 spec/integration/with_metadata_spec.rb
active-fedora-9.0.4 spec/integration/with_metadata_spec.rb
active-fedora-9.0.3 spec/integration/with_metadata_spec.rb
active-fedora-9.0.2 spec/integration/with_metadata_spec.rb
active-fedora-9.0.1 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.rc3 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.rc2 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.rc1 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.beta8 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.beta7 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.beta6 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.beta5 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.beta4 spec/integration/with_metadata_spec.rb
active-fedora-9.0.0.beta3 spec/integration/with_metadata_spec.rb