Sha256: 3768265646eef32e5784b3db22ac47a073cb0e38bc0308e14c0a0d2adbb46200

Contents?: true

Size: 1.71 KB

Versions: 10

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

RSpec.describe Hyrax::GraphExporter do
  let(:work) { create(:work_with_one_file, visibility: 'open') }
  let(:document) { double(id: work.id) }
  let(:request) { double(host: 'localhost') }
  let(:service) { described_class.new(document, request) }

  describe "fetch" do
    subject { service.fetch }
    let(:ttl) { subject.dump(:ntriples) }
    it "transforms suburis to hashcodes" do
      expect(ttl).to match %r{<http://localhost/concern/generic_works/#{work.id}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://projecthydra.org/works/models#Work>}
      expect(ttl).to match %r{<http://purl\.org/dc/terms/title> "Test title"}
      expect(ttl).to match %r{<http://www\.w3\.org/ns/auth/acl#accessControl> <http://localhost/catalog/}

      query = subject.query([RDF::URI("http://localhost/concern/generic_works/#{work.id}"),
                             RDF::URI("http://www.iana.org/assignments/relation/first"),
                             nil])
      proxy = query.to_a.first.object

      expect(proxy.to_s).to match %r{http://localhost/concern/generic_works/#{work.id}/list_source#g\d+}

      # It includes the list nodes on the graph
      expect(subject.query([proxy, nil, nil]).count).to eq 2
    end

    context "when a Ldp::NotFound is raised" do
      let(:mock_service) { instance_double(Hydra::ContentNegotiation::CleanGraphRepository) }
      before do
        allow(service).to receive(:clean_graph_repository).and_return(mock_service)
        allow(mock_service).to receive(:find).and_raise(Ldp::NotFound)
      end
      it "raises a error that the controller catches and handles" do
        expect { subject }.to raise_error ActiveFedora::ObjectNotFoundError
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.1.0 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.5 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.4 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.3 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.2 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.1 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.0.rc2 spec/services/hyrax/graph_exporter_spec.rb
hyrax-1.0.0.rc1 spec/services/hyrax/graph_exporter_spec.rb
test_hyrax-0.0.1.alpha spec/services/hyrax/graph_exporter_spec.rb