Sha256: c4c840abccecb1789b2610aa839456a6f85a857fc105137536ae59c0c95a2f2b

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe ActiveFedora::SparqlInsert do
  let(:change_set) { ActiveFedora::ChangeSet.new(base, base.resource, base.changed_attributes.keys) }
  subject(:sparql_insert) { described_class.new(change_set.changes) }

  context "with a changed object" do
    before do
      class Library < ActiveFedora::Base
      end

      class Book < ActiveFedora::Base
        belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
        property :title, predicate: ::RDF::Vocab::DC.title
      end

      base.library_id = 'foo'
      base.title = ['bar']
    end
    after do
      Object.send(:remove_const, :Library)
      Object.send(:remove_const, :Book)
    end

    let(:base) { Book.create }

    it "returns the string" do
      expect(sparql_insert.build).to eq "DELETE { <> <info:fedora/fedora-system:def/relations-external#hasConstituent> ?change . }\n  WHERE { <> <info:fedora/fedora-system:def/relations-external#hasConstituent> ?change . } ;\nDELETE { <> <http://purl.org/dc/terms/title> ?change . }\n  WHERE { <> <http://purl.org/dc/terms/title> ?change . } ;\nINSERT { \n<> <info:fedora/fedora-system:def/relations-external#hasConstituent> <#{ActiveFedora.fedora.host}/test/foo> .\n<> <http://purl.org/dc/terms/title> \"bar\" .\n}\n WHERE { }"
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active-fedora-11.1.4 spec/unit/sparql_insert_spec.rb
active-fedora-11.1.3 spec/unit/sparql_insert_spec.rb
active-fedora-11.1.2 spec/unit/sparql_insert_spec.rb
active-fedora-11.1.1 spec/unit/sparql_insert_spec.rb
active-fedora-11.1.0 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.1 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0.rc7 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0.rc6 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0.rc5 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0.rc4 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0.rc3 spec/unit/sparql_insert_spec.rb
active-fedora-11.0.0.rc2 spec/unit/sparql_insert_spec.rb