Skip to content

Commit

Permalink
Merge pull request #1949 from alphagov/add-support-for-briefing
Browse files Browse the repository at this point in the history
Add support for briefing
  • Loading branch information
theseanything authored Dec 23, 2020
2 parents 83328e9 + ce26ae9 commit a06abf8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ def format_banner_links(links, type)
end

def content_item_template
return "briefing" if is_briefing?

@content_item.schema_name
end

def is_briefing?
@content_item.content_id == "3d66e959-72d2-417d-89c1-00cd72eea30f"
end

def render_template
if @content_item.requesting_a_part? && !@content_item.has_valid_part?
redirect_to @content_item.base_path
Expand Down
28 changes: 28 additions & 0 deletions app/views/content_items/briefing.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title', title: @content_item.title %>
</div>
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds content-bottom-margin">
<div class="responsive-bottom-margin">
<%= render "govuk_publishing_components/components/govspeak", {
direction: page_text_direction,
} do %>
<%= raw(@content_item.body) %>
<% end %>
</div>

<div class="dont-print responsive-bottom-margin">
<%= render 'govuk_publishing_components/components/share_links',
links: @content_item.share_links,
track_as_sharing: true,
title: t('components.share_links.share_this_page')
%>
</div>
</div>
</div>
19 changes: 19 additions & 0 deletions test/controllers/content_items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,25 @@ class ContentItemsControllerTest < ActionController::TestCase
assert_equal response.headers["Access-Control-Allow-Origin"], "*"
end

test "renders briefing view correctly" do
content_item = content_store_has_schema_example("news_article", "news_article")
content_item["content_id"] = "3d66e959-72d2-417d-89c1-00cd72eea30f"
stub_content_store_has_item(content_item["base_path"], content_item)

get :show, params: { path: path_for(content_item) }
assert_response :success
assert_select ".gem-c-title", content_item["title"]
assert_select ".gem-c-lead-paragraph", content_item["description"]
assert_select ".gem-c-govspeak"
assert_select ".gem-c-share-links"
assert_select ".gem-c-title .gem-c-title__context", false
assert_select ".metadata-logo-wrapper", false
assert_select ".app-c-figure", false
assert_select ".gem-c-contextual-sidebar", false
assert_select ".app-c-published-dates", false
assert_select ".gem-c-contextual-footer", false
end

def path_for(content_item, locale = nil)
base_path = content_item["base_path"].sub(/^\//, "")
base_path.gsub!(/\.#{locale}$/, "") if locale
Expand Down

0 comments on commit a06abf8

Please sign in to comment.