Sha256: a8f8b860f3cca0f2c5ccd1a5355c0f036f498f3cd65fb0ac020a8cace3fc64a9
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
require 'spec_helper' describe ActiveFedora::WithMetadata do before do 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) end let(:file) { SampleFile.new } describe "properties" do before do file.title = ['one', 'two'] end it "sets and retrieve properties" do expect(file.title).to eq ['one', 'two'] end it "tracks changes" do expect(file.title_changed?).to be true end end describe "#save" do before do file.title = ["foo"] end context "if the object saves (because it has content)" do before do file.content = "Hey" file.save end let(:reloaded) { SampleFile.new(file.uri) } it "saves the metadata too" do expect(reloaded.title).to eq ['foo'] end end context "if the object is a new_record (didn't save)" do it "doesn't save the metadata" do expect(file.metadata_node).not_to receive(:save) file.save end end end context "when RDF.type is set" do let(:book) { RDF::URI.new("http://example.com/ns/Book") } before do class SampleBook < ActiveFedora::File include ActiveFedora::WithMetadata metadata do configure type: RDF::URI.new("http://example.com/ns/Book") end end file.content = 'foo' file.save end after do Object.send(:remove_const, :SampleBook) end let(:file) { SampleBook.new } let(:reloaded_file) { SampleBook.new(file.uri) } it "persists the configured type" do expect(reloaded_file.metadata_node.query(predicate: ::RDF.type).map(&:object)).to include book end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active-fedora-9.6.2 | spec/integration/with_metadata_spec.rb |
active-fedora-9.6.1 | spec/integration/with_metadata_spec.rb |