Skip to content

Commit

Permalink
Merge pull request #147 from despo/resolve-with-content-areas-depreca…
Browse files Browse the repository at this point in the history
…tion-warning

Resolve `with_content_areas` view_component deprecation warning
  • Loading branch information
peteryates authored Apr 28, 2021
2 parents 3400130 + 4938a4f commit fb264dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/components/govuk_component/cookie_banner.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class GovukComponent::CookieBanner < GovukComponent::Base
with_content_areas :body, :actions
renders_one :body
renders_one :actions

attr_accessor :title, :aria_label

Expand Down
24 changes: 14 additions & 10 deletions spec/components/govuk_component/cookie_banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@

subject! do
render_inline(described_class.new(**kwargs)) do |component|
component.with(:body) { body }
component.with(:actions) { actions }
component.body { body }
component.actions { actions }
end
end

specify "contains a cookies banner with the correct title, body text and actions" do
expect(page).to have_css("div", class: %w(govuk-cookie-banner)) do |banner|
expect(banner).to have_css("h2", class: %w(govuk-cookie-banner__heading), text: title)
within "div.govuk-cookie-banner__content" do
expect(banner).to have_content(body)
end
within "div.govuk-button-group" do
expect(banner).to have_content(actions)
end
expect(page).to have_css("h2", class: %w(govuk-cookie-banner__heading), text: title)

expect(page).to have_css('.govuk-cookie-banner__content') do |body|
expect(body).to have_content('An introductory paragraph.')
expect(body).to have_content('A second paragraph.')
end

expect(page).to have_css('.govuk-button-group') do |actions|
expect(actions).to have_button(value: 'Accept')
expect(actions).to have_button(value: 'Reject')

expect(actions).to have_link(text: 'View', href: '/view-path')
end
end

Expand Down

0 comments on commit fb264dd

Please sign in to comment.