Skip to content

Commit

Permalink
Don't crash when host isn't set
Browse files Browse the repository at this point in the history
Since #11 the template
crashes when `host` isn't specified in config/tech-docs.yml.

This makes sure that we don't crash.
  • Loading branch information
tijmenb committed Apr 18, 2018
1 parent a8cb35e commit 76320ca
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 76320ca

Please sign in to comment.