Skip to content

Commit

Permalink
Use the passed in capability_list_url in ResourceListWriter
Browse files Browse the repository at this point in the history
Fixes #2701
  • Loading branch information
jcoyne committed Sep 16, 2016
1 parent ee24ce3 commit b9e8c24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/sufia/resource_sync/resource_list_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def write

private

def builder(capability_list_url: 'http://example.com/dataset1/capabilitylist.xml')
def builder
Nokogiri::XML::Builder.new do |xml|
xml.urlset('xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
'xmlns:rs' => 'http://www.openarchives.org/rs/terms/') do
Expand Down
17 changes: 10 additions & 7 deletions spec/lib/sufia/resource_sync/resource_list_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
subject { described_class.new(resource_host: 'example.com', capability_list_url: capability_list).write }
let(:xml) { Nokogiri::XML.parse(subject) }

it "has two urls" do
first_url = xml.xpath('//x:url[1]/x:loc', 'x' => sitemap).text
second_url = xml.xpath('//x:url[2]/x:loc', 'x' => sitemap).text
third_url = xml.xpath('//x:url[3]/x:loc', 'x' => sitemap).text
expect(first_url).to eq "http://example.com/collections/#{public_collection.id}"
expect(second_url).to eq "http://example.com/concern/generic_works/#{public_work.id}"
expect(third_url).to eq "http://example.com/concern/file_sets/#{file_set.id}"
it "has a list of resources" do
capability = xml.xpath('//rs:ln/@href', 'rs' => "http://www.openarchives.org/rs/terms/").text
expect(capability).to eq capability_list
expect(query(1)).to eq "http://example.com/collections/#{public_collection.id}"
expect(query(2)).to eq "http://example.com/concern/generic_works/#{public_work.id}"
expect(query(3)).to eq "http://example.com/concern/file_sets/#{file_set.id}"
expect(xml.xpath('//x:url', 'x' => sitemap).count).to eq 3
end

def query(n)
xml.xpath("//x:url[#{n}]/x:loc", 'x' => sitemap).text
end
end

0 comments on commit b9e8c24

Please sign in to comment.