Extract methods in poll status component

This way we remove duplication in the HTML.

We're also adding a test checking what happens when users can vote in
order to test the `render?` method we've added.
This commit is contained in:
Javi Martín
2024-04-22 03:28:33 +02:00
parent b2a49cd291
commit 1b9d321c4e
3 changed files with 39 additions and 19 deletions

View File

@@ -37,4 +37,12 @@ describe Polls::AccessStatusComponent do
expect(page).to have_css ".already-answer", count: 1
expect(page).to have_content "You already have participated in this poll"
end
it "is not rendered when users can vote" do
sign_in(create(:user, :level_two))
render_inline Polls::AccessStatusComponent.new(create(:poll))
expect(page).not_to be_rendered
end
end