Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch speeches to metadata module
  • Loading branch information
fofr committed Jan 5, 2017
1 parent a6e6d36 commit 4ca1e83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
18 changes: 14 additions & 4 deletions app/presenters/speech_presenter.rb
Expand Up @@ -3,6 +3,7 @@ class SpeechPresenter < ContentItemPresenter
include Political
include Updatable
include TitleAndContext
include Metadata

def body
content_item["details"]["body"]
Expand All @@ -24,18 +25,27 @@ def delivered_on_metadata
"#{delivered_on}#{speech_type_explanation}"
end

def location
content_item["details"]["location"]
end

def from
super.tap do |f|
f.push(speaker_without_profile) if speaker_without_profile
end
end

def metadata
super.tap do |m|
m[:other] = {
"Location" => location,
delivery_type => delivered_on_metadata
}
end
end

private

def location
content_item["details"]["location"]
end

def delivered_on
delivered_on_date = content_item["details"]["delivered_on"]
content_tag(:time, display_date(delivered_on_date), datetime: delivered_on_date)
Expand Down
27 changes: 2 additions & 25 deletions app/views/content_items/speech.html.erb
Expand Up @@ -4,31 +4,8 @@
<%= render 'shared/title_and_translations', content_item: @content_item %>
<%= render 'shared/withdrawal_notice', content_item: @content_item %>

<div class="grid-row">
<div class="column-two-thirds">
<%= render 'govuk_component/metadata',
from: @content_item.from,
first_published: @content_item.published,
last_updated: @content_item.updated,
part_of: @content_item.part_of,
see_updates_link: true,
other: {
@content_item.delivery_type => @content_item.delivered_on_metadata,
"Location" => @content_item.location
}
%>
</div>
</div>

<%= render 'shared/metadata', content_item: @content_item %>
<%= render 'shared/history_notice', content_item: @content_item %>
<%= render 'shared/description', description: @content_item.description %>
<%= render 'shared/sidebar_with_body', content_item: @content_item %>
<%= render 'govuk_component/document_footer',
from: @content_item.from,
published: @content_item.published,
updated: @content_item.updated,
history: @content_item.history,
part_of: @content_item.part_of
%>
<%= render 'govuk_component/document_footer', @content_item.document_footer %>
2 changes: 1 addition & 1 deletion test/presenters/speech_presenter_test.rb
Expand Up @@ -21,7 +21,7 @@ class PresentedSpeech < SpeechTestCase
end

test 'presents a speech location' do
assert_equal schema_item['details']['location'], presented_item.location
assert_equal schema_item['details']['location'], presented_item.metadata[:other]["Location"]
end

test 'presents how speech was delivered' do
Expand Down

0 comments on commit 4ca1e83

Please sign in to comment.