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

Make render? check for content as well as headings #120

Merged
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/components/govuk_component/notification_banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def success?
end

def render?
headings.any?
headings.any? || content.present?
end

def title_tag
Expand Down
17 changes: 16 additions & 1 deletion spec/components/govuk_component/notification_banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let(:kwargs) { { title: title } }

describe "rendering a notification banner" do
describe "rendering a notification banner with headings" do
before do
render_inline(GovukComponent::NotificationBanner.new(**kwargs)) do |nb|
nb.slot(:heading, text: "omg")
Expand Down Expand Up @@ -196,4 +196,19 @@
let(:block) { ->(banner) { banner.add_heading(text: "What a nice heading!") } }
end
end

describe "rendering a notification banner with arbitrary content" do
before do
render_inline(GovukComponent::NotificationBanner.new(**kwargs)) { additional_content }
end

let(:subject) { page }

specify "the extra banner with extra content is rendered" do
expect(subject).to have_css(".govuk-notification-banner > .govuk-notification-banner__content") do |content|
expect(content).to have_css("p", text: "The quick brown fox")
expect(content).to have_css("blockquote", text: "Jumped over the lazy dog")
end
end
end
end