Files
nairobi/spec/components/debates/mark_featured_action_component_spec.rb
Javi Martín 251968ae72 Fix mark as featured button being rendered to everyone
We introduced this issue in commit f8faabf7d.

Since this component didn't have any tests (there are system tests for
it, though), we're also adding tests that check that only the right
buttons are rendered when accessing as administrator.
2025-10-31 16:01:33 +01:00

32 lines
863 B
Ruby

require "rails_helper"
describe Debates::MarkFeaturedActionComponent do
let(:debate) { create(:debate) }
it "is not rendered for regular users" do
sign_in(create(:user, :verified))
render_inline Debates::MarkFeaturedActionComponent.new(debate)
expect(page).not_to be_rendered
end
context "administradors", :admin do
it "renders a button to mark debates as featured" do
render_inline Debates::MarkFeaturedActionComponent.new(debate)
expect(page).to have_button "Featured"
expect(page).to have_button count: 1
end
it "renders a button to unmark featured debates" do
debate = create(:debate, featured_at: Time.current)
render_inline Debates::MarkFeaturedActionComponent.new(debate)
expect(page).to have_button "Unmark featured"
expect(page).to have_button count: 1
end
end
end