Files
grecia/spec/components/polls/poll_header_component_spec.rb
Javi Martín eef9f58410 Extract component to render poll geozones
This way we remove a bit of duplication.

These changes also affect the way geozones are rendered in a couple of
minor ways, making them more consistent:

* No empty list of geozones is rendered when there are no geozones
  (before these changes, an empty list was rendered in the index action
  but not in the show action)
* The text clarifying the geozone restriction is always shown (before
  these changes, it was shown in the index action but not in the show
  action)

We've added tests for these cases.
2024-06-10 17:11:30 +02:00

18 lines
613 B
Ruby

require "rails_helper"
describe Polls::PollHeaderComponent do
describe "geozones" do
it "shows a text when the poll is geozone-restricted" do
render_inline Polls::PollHeaderComponent.new(create(:poll, geozone_restricted_to: [create(:geozone)]))
expect(page).to have_content "Only residents in the following areas can participate"
end
it "does not show the text when the poll isn't geozone-restricted" do
render_inline Polls::PollHeaderComponent.new(create(:poll))
expect(page).not_to have_content "Only residents in the following areas can participate"
end
end
end