Skip to content

Commit

Permalink
Merge pull request #17 from alphagov/dont-crash-for-host
Browse files Browse the repository at this point in the history
Don't crash when `host` isn't set
  • Loading branch information
tijmenb authored Apr 18, 2018
2 parents d02b4df + 8e78293 commit 492e621
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/govuk_tech_docs/meta_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def page_title
end

def host
config[:tech_docs][:host]
config[:tech_docs][:host].to_s
end

def locals
Expand Down
13 changes: 13 additions & 0 deletions spec/govuk_tech_docs/meta_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ def generate_title(site_name:, page_title:)

expect(tags["og:title"]).to eql("The local variable title.")
end

it 'works even when no config is set' do
current_page = double("current_page",
data: double("page_frontmatter", description: "The description.", title: "The Title"),
url: "/foo.html",
metadata: { locals: { title: "The local variable title." } })

config = { tech_docs: {} }

tags = GovukTechDocs::MetaTags.new(config, current_page).tags

expect(tags).to be_a(Hash)
end
end

def generate_config(config = {})
Expand Down

0 comments on commit 492e621

Please sign in to comment.