Skip to content

Commit

Permalink
Added title_or_label to presenter. Refactored the test to remove dupl…
Browse files Browse the repository at this point in the history
…icate code and loop through an array instead when testing delegated properties to SolrDocument
  • Loading branch information
hectorcorrea committed Dec 2, 2015
1 parent d5fd03a commit 1279e59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/presenters/curation_concerns/file_set_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize(solr_document, current_ability)
delegate :title, :description, :creator, :contributor, :subject, :publisher,
:language, :date_uploaded, :rights,
:embargo_release_date, :lease_expiration_date,
:depositor, :tags, to: :solr_document
:depositor, :tags, :title_or_label, to: :solr_document

def page_title
Array(solr_document['label_tesim']).first
Expand Down
25 changes: 9 additions & 16 deletions spec/presenters/curation_concerns/file_set_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,17 @@
it { is_expected.to eq 'File Set' }
end

describe "date_uploaded" do
it "delegates to the solr_document" do
expect(solr_document).to receive(:date_uploaded)
presenter.date_uploaded
describe "properties delegated to solr_document" do
let(:solr_properties) do
["date_uploaded", "depositor", "tags", "title_or_label",
"contributor", "creator", "title", "description", "publisher",
"subject", "language", "rights"]
end
end

describe "depositor" do
it "delegates to the solr_document" do
expect(solr_document).to receive(:depositor)
presenter.depositor
end
end

describe "tags" do
it "delegates to the solr_document" do
expect(solr_document).to receive(:tags)
presenter.tags
solr_properties.each do |property|
expect(solr_document).to receive(property.to_sym)
presenter.send(property)
end
end
end

Expand Down

0 comments on commit 1279e59

Please sign in to comment.