Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the breadcrumb helper and add extra tests #484

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/govuk_link_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def govuk_button_link_to(name, href = nil, new_tab: false, disabled: false, inve
end

def govuk_breadcrumb_link_to(name, href = nil, **kwargs, &block)
link_args = { class: "#{brand}-breadcrumbs--link" }.deep_merge_html_attributes(kwargs)
link_args = { class: "#{brand}-breadcrumbs__link" }.deep_merge_html_attributes(kwargs)

link_to(name, href, **link_args, &block)
end
Expand Down
17 changes: 17 additions & 0 deletions spec/helpers/govuk_link_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,21 @@ def url_for(path)
end
end
end

describe "govuk_breadcrumb_link_to" do
let(:kwargs) { {} }
subject { govuk_breadcrumb_link_to("hello", "/world", **kwargs) }

specify "creates a breadcrumb link with the correct class" do
expect(subject).to have_tag("a", with: { class: "govuk-breadcrumbs__link", href: "/world" }, text: "hello")
end

context "when extra classes and attributes are provided" do
let(:kwargs) { { class: "bright-pink", lang: "fr" } }

specify "creates a breadcrumb link with the additional attributes and classes" do
expect(subject).to have_tag("a", with: { class: %w(govuk-breadcrumbs__link bright-pink), href: "/world", lang: "fr" }, text: "hello")
end
end
end
end