/
_relationships.html.erb_spec.rb
31 lines (28 loc) · 1.13 KB
/
_relationships.html.erb_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'spec_helper'
describe 'curation_concerns/base/relationships' do
let(:ability) { double }
let(:solr_doc) { double(id: '123', human_readable_type: 'Work') }
let(:presenter) { Sufia::WorkShowPresenter.new(solr_doc, ability) }
context "when collections are not present" do
before do
render 'curation_concerns/base/relationships', presenter: presenter
end
it "shows the message" do
expect(rendered).to match %r{This Work is not currently in any collections\.}
end
end
context "when collections are present" do
let(:collection_presenters) { [double(id: '456', title: ['Containing collection', 'foobar'], to_s: 'Containing collection')] }
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
render 'curation_concerns/base/relationships', presenter: presenter
end
it "links to collections" do
expect(page).to have_link 'Containing collection'
end
it "labels the link using the presenter's #to_s method" do
expect(page).not_to have_content 'foobar'
end
end
end