-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add case studies model, view, controller, route and tests as well as content_item_model_presenter and related concerns Commit audit trail: - https://github.com/alphagov/government-frontend/blob/0aee348d51cebacd5344115f2ca02bdb17095249/app/presenters/case_study_presenter.rb - https://github.com/alphagov/government-frontend/blob/0aee348d51cebacd5344115f2ca02bdb17095249/app/views/content_items/case_study.html.erb - https://github.com/alphagov/government-frontend/blob/0aee348d51cebacd5344115f2ca02bdb17095249/test/integration/case_study_test.rb - https://github.com/alphagov/government-frontend/blob/0aee348d51cebacd5344115f2ca02bdb17095249/test/presenters/case_study_presenter_test.rb - https://github.com/alphagov/government-frontend/blob/0aee348d51cebacd5344115f2ca02bdb17095249/config/routes.rb Update app/views/components/_published_dates.html.erb to render dates correctly
- Loading branch information
1 parent
acdb67a
commit ca267f5
Showing
7 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class CaseStudyController < ContentItemsController | ||
def show | ||
@case_study_presenter = ContentItemModelPresenter.new(content_item) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CaseStudy < ContentItem | ||
include Updatable | ||
include WorldwideOrganisations | ||
|
||
def related_entities | ||
(linkable_organisations + worldwide_organisations).uniq | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<% content_for :title, "#{@case_study_presenter.page_title} - #{I18n.t("formats.#{content_item.document_type}", count: 1)} - GOV.UK" %> | ||
|
||
<% content_for :extra_headers do %> | ||
<%= render "govuk_publishing_components/components/machine_readable_metadata", { content_item: content_item.to_h, schema: :article } %> | ||
<% end %> | ||
|
||
<main role="main" id="content" class="case-study" <%= lang_attribute(content_item.locale) %>> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds responsive-top-margin"> | ||
<%= render 'govuk_publishing_components/components/title', { | ||
title: content_item.title, | ||
context: I18n.t("formats.#{content_item.document_type}", count: 1), | ||
context_locale: t_locale_fallback("formats.#{content_item.document_type}", count: 1), | ||
average_title_length: "long", | ||
} %> | ||
</div> | ||
<%= render 'shared/translations' %> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= render 'govuk_publishing_components/components/lead_paragraph', text: content_item.description %> | ||
</div> | ||
</div> | ||
|
||
<%= render 'shared/publisher_metadata', locals: { | ||
from: govuk_styled_links_list(content_item.related_entities), | ||
first_published: display_date(content_item.first_public_at || content_item.first_published_at), | ||
last_updated: display_date(content_item.updated), | ||
see_updates_link: true, | ||
} | ||
%> | ||
|
||
<% if content_item.withdrawn? %> | ||
<% withdrawn_time_tag = tag.time(display_date(content_item.withdrawn_at), datetime: content_item.withdrawn_at) %> | ||
|
||
<%= render 'govuk_publishing_components/components/notice', { | ||
title: I18n.t("formats.case_study.withdrawn_notice.title", schema_name: I18n.t("formats.#{content_item.schema_name}", count: 1, locale: :en).downcase, withdrawn_time: withdrawn_time_tag).html_safe, | ||
description_govspeak: content_item.withdrawn_explanation&.html_safe, | ||
time: withdrawn_time_tag, | ||
lang: "en", | ||
} %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<div class="content-bottom-margin"> | ||
<div class="responsive-bottom-margin"> | ||
<%= render 'components/figure', | ||
src: content_item.image["url"], | ||
alt: content_item.image["alt_text"], | ||
credit: content_item.image["credit"], | ||
caption: content_item.image["caption"] if content_item.image %> | ||
|
||
<%= render 'govuk_publishing_components/components/govspeak', { | ||
direction: page_text_direction, | ||
} do %> | ||
<%= raw(content_item.body) %> | ||
<% end %> | ||
</div> | ||
|
||
<%= render 'components/published_dates', { | ||
published: display_date(content_item.first_public_at), | ||
last_updated: display_date(content_item.updated), | ||
history: content_item.history | ||
} %> | ||
</div> | ||
</div> | ||
|
||
<%= render 'shared/sidebar_navigation' %> | ||
</div> | ||
</main> | ||
|
||
<%= render 'shared/footer_navigation' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RSpec.describe CaseStudy do | ||
it_behaves_like "it can be updated", "case_study" | ||
it_behaves_like "it can have worldwide organisations", "case_study" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
RSpec.describe "Case Study" do | ||
before do | ||
content_store_has_example_item("/government/case-studies/get-britain-building-carlisle-park", schema: :case_study) | ||
end | ||
|
||
context "when visiting the index route" do | ||
it "returns 200" do | ||
get "/government/case-studies/get-britain-building-carlisle-park" | ||
|
||
expect(response).to have_http_status(:ok) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
RSpec.describe "CaseStudy" do | ||
before do | ||
content_store_has_example_item("/government/case-studies/get-britain-building-carlisle-park", schema: :case_study) | ||
content_store_has_example_item("/government/case-studies/doing-business-in-spain", schema: :case_study, example: "doing-business-in-spain") | ||
end | ||
|
||
it_behaves_like "it has meta tags", "case_study", "/government/case-studies/doing-business-in-spain" | ||
it_behaves_like "it has meta tags for images", "case_study", "/government/case-studies/doing-business-in-spain" | ||
|
||
context "when visiting a Case Study page" do | ||
it "displays the case_study page" do | ||
visit "/government/case-studies/get-britain-building-carlisle-park" | ||
|
||
expect(page).to have_title("Get Britain Building: Carlisle Park - Case study - GOV.UK") | ||
|
||
expect(page).to have_css("h1", text: "Get Britain Building: Carlisle Park") | ||
expect(page).to have_text("Nearly 400 homes are set to be built on the site of a former tar distillery thanks to Gleeson Homes and HCA investment.") | ||
|
||
expect(page).to have_css(".gem-c-translation-nav") | ||
end | ||
|
||
context "when visiting a Withdrawn Case Study page which is also translatable" do | ||
it "displays the case_study page" do | ||
visit "/government/case-studies/doing-business-in-spain" | ||
|
||
expect(page).to have_title("[Withdrawn] Doing business in Spain - Case study - GOV.UK") | ||
|
||
expect(page).to have_css("h1", text: "Doing business in Spain") | ||
expect(page).to have_text("This case study was withdrawn on") | ||
|
||
expect(page).to have_css(".gem-c-translation-nav") | ||
end | ||
end | ||
|
||
it "does not display a single page notification button" do | ||
visit "/government/case-studies/get-britain-building-carlisle-park" | ||
|
||
expect(page).not_to have_css(".gem-c-single-page-notification-button") | ||
end | ||
end | ||
end |