Skip to content

Commit

Permalink
Merge pull request #931 from alphagov/use-organisation-logo-component…
Browse files Browse the repository at this point in the history
…-from-gem

Use organisation logo component from gem
  • Loading branch information
andysellick authored Jun 8, 2018
2 parents 16a0247 + cb10480 commit 9496ce1
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gem 'gds-api-adapters', '~> 52.5'
gem 'govuk_ab_testing', '~> 2.4'
gem 'govuk_app_config', '~> 1.5'
gem 'govuk_frontend_toolkit', '~> 7.4'
gem 'govuk_publishing_components', '~> 9.1.0'
gem 'govuk_publishing_components', '~> 9.2.0'
gem 'plek', '~> 2.1'
gem 'slimmer', '~> 12.1'

Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ GEM
i18n (>= 0.7)
faraday (0.15.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.23)
ffi (1.9.25)
gds-api-adapters (52.5.1)
addressable
link_header
Expand Down Expand Up @@ -127,7 +127,7 @@ GEM
govuk_frontend_toolkit (7.5.0)
railties (>= 3.1.0)
sass (>= 3.2.0)
govuk_publishing_components (9.1.0)
govuk_publishing_components (9.2.0)
govspeak (>= 5.0.3)
govuk_app_config
govuk_frontend_toolkit
Expand Down Expand Up @@ -368,7 +368,7 @@ DEPENDENCIES
govuk_ab_testing (~> 2.4)
govuk_app_config (~> 1.5)
govuk_frontend_toolkit (~> 7.4)
govuk_publishing_components (~> 9.1.0)
govuk_publishing_components (~> 9.2.0)
govuk_schemas (~> 3.1)
htmlentities (~> 4.3)
jasmine-rails
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/content_item/organisation_branding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def organisation_logo(organisation = default_organisation)
logo = organisation["details"]["logo"]
logo_component_params = {
organisation: {
name: logo["formatted_title"],
name: logo["formatted_title"].html_safe,
url: organisation["base_path"],
brand: organisation_brand(organisation),
crest: logo["crest"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="<%= @content_item.organisation_brand_class %>">
<div class="grid-row">
<div class="column-two-thirds">
<%= render 'govuk_component/organisation_logo', @content_item.organisation_logo %>
<%= render 'govuk_publishing_components/components/organisation_logo', @content_item.organisation_logo %>
</div>
</div>
<div class="grid-row">
Expand Down
20 changes: 11 additions & 9 deletions app/views/content_items/html_publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
content_for :simple_header, true
%>

<div class="publication-external">
<ol class="organisation-logos">
<% @content_item.organisations.each do |organisation| %>
<li class="organisation-logo">
<%= render 'govuk_component/organisation_logo', @content_item.organisation_logo(organisation) %>
</li>
<% end %>
</ol>
</div>
<% if @content_item.organisations %>
<div class="publication-external">
<ol class="organisation-logos">
<% @content_item.organisations.each do |organisation| %>
<li class="organisation-logo">
<%= render 'govuk_publishing_components/components/organisation_logo', @content_item.organisation_logo(organisation) %>
</li>
<% end %>
</ol>
</div>
<% end %>

<%= render 'govuk_publishing_components/components/inverse_header', {} do %>
<%= render 'govuk_publishing_components/components/title',
Expand Down
22 changes: 2 additions & 20 deletions test/integration/corporate_information_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,12 @@ class CorporateInformationPageTest < ActionDispatch::IntegrationTest

test "renders an organisation logo" do
setup_and_visit_content_item('corporate_information_page')
assert_has_component_organisation_logo(
organisation: {
name: 'Department<br/>of Health',
url: '/government/organisations/department-of-health',
brand: 'department-of-health',
crest: 'single-identity'
}
)
assert_has_component_organisation_logo
end

test "renders a custom organisation logo" do
setup_and_visit_content_item('corporate_information_page_translated_custom_logo')
assert_has_component_organisation_logo(
organisation: {
name: 'Land Registry',
url: '/government/organisations/land-registry',
brand: 'department-for-business-innovation-skills',
crest: nil,
image: {
url: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/organisation/logo/69/LR_logo_265.png',
alt_text: 'Land Registry'
}
}
)
assert_has_component_organisation_logo
end

test 'renders a withdrawal notice on withdrawn page' do
Expand Down
8 changes: 2 additions & 6 deletions test/integration/html_publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest
assert page.has_css?('.gem-c-contents-list')
end

within ".organisation-logos" do
assert page.has_text?(@content_item["links"]["organisations"][0]["title"])
end

assert page.has_text?("The Environment Agency will normally put any responses it receives on the public register. This includes your name and contact details. Tell us if you don’t want your response to be public.")
end

Expand Down Expand Up @@ -78,8 +74,8 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest
end

def assert_has_component_organisation_logo_with_brand(brand, index = 1)
within("li.organisation-logo:nth-of-type(#{index}) #{shared_component_selector('organisation_logo')}") do
assert_equal brand, JSON.parse(page.text).fetch("organisation").fetch("brand")
within("li.organisation-logo:nth-of-type(#{index})") do
assert page.has_css?(".gem-c-organisation-logo.brand--#{brand}")
end
end

Expand Down
6 changes: 2 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ def assert_has_component_title(title)
assert page.has_css?('h1', text: title)
end

def assert_has_component_organisation_logo(logo, index = 1)
within(shared_component_selector("organisation_logo") + ":nth-of-type(#{index})") do
assert_equal logo, JSON.parse(page.text).deep_symbolize_keys
end
def assert_has_component_organisation_logo
assert page.has_css?(".gem-c-organisation-logo")
end

def assert_has_component_government_navigation_active(active)
Expand Down

0 comments on commit 9496ce1

Please sign in to comment.