Skip to content

Commit

Permalink
Move brand_helper and add test file
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed May 10, 2018
1 parent bbb8aee commit 2b86d3e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

* Add an optional `canonical` meta tag.
* Add an optional `canonical` meta tag (PR #302)
* Iterate branding model (PR #300)

# 7.2.0

Expand Down
2 changes: 1 addition & 1 deletion lib/govuk_publishing_components.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "govuk_publishing_components/config"
require "govuk_publishing_components/engine"
require "govuk_publishing_components/presenters/brand_helper"
require "govuk_publishing_components/presenters/contextual_navigation"
require "govuk_publishing_components/presenters/related_navigation_helper"
require "govuk_publishing_components/presenters/step_by_step_nav_helper"
Expand All @@ -15,6 +14,7 @@
require "govuk_publishing_components/presenters/content_item"

require "govuk_publishing_components/app_helpers/taxon_breadcrumbs"
require "govuk_publishing_components/app_helpers/brand_helper"

module GovukPublishingComponents
end
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module GovukPublishingComponents
module Presenters
module AppHelpers
class BrandHelper
def initialize(brand)
@brand = brand if brand
end

# Apply government organisation branding to individual components, specifically
# link colour and border colour
# see https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_branding.md

def brand_class
"brand--#{@brand}" if @brand
end
Expand Down
21 changes: 21 additions & 0 deletions spec/lib/app_helpers/brand_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

RSpec.describe GovukPublishingComponents::AppHelpers::BrandHelper do
describe "Brand helper" do
it "returns nothing if no brand is specified" do
brand = GovukPublishingComponents::AppHelpers::BrandHelper.new(nil)

expect(brand.brand_class).to eql(nil)
expect(brand.border_color_class).to eql(nil)
expect(brand.color_class).to eql(nil)
end

it "returns the expected brand" do
brand = GovukPublishingComponents::AppHelpers::BrandHelper.new('attorney-generals-office')

expect(brand.brand_class).to eql('brand--attorney-generals-office')
expect(brand.border_color_class).to eql('brand__border-color')
expect(brand.color_class).to eql('brand__color')
end
end
end

0 comments on commit 2b86d3e

Please sign in to comment.