Skip to content

Commit

Permalink
Resolve with_content_areas view_component deprecation warning
Browse files Browse the repository at this point in the history
`with_content_areas` is deprecated and will be removed in ViewComponent v3.0.0 so slots should be used instead.
  • Loading branch information
despo committed Apr 28, 2021
1 parent 3400130 commit 4938a4f
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 4938a4f

Please sign in to comment.