Files
nairobi/spec/components/shared/moderation_actions_component_spec.rb
Javi Martín cac24b0159 Extract component to show moderation actions
Note that in proposal notifications we're writing the call to
render the component in the same line as the <div class="reply">
definition in order to be able to use the `:empty` selector when the
component renders nothing. No browser matches whitespace with the
`:empty` selector, so we can't add newline characters inside the tag. A
more elegant solution would be extracting the proposal notification
actions to a component and only rendering it if the moderation actions
component is rendered.
2021-12-30 15:50:03 +01:00

57 lines
1.7 KiB
Ruby

require "rails_helper"
describe Shared::ModerationActionsComponent do
include Rails.application.routes.url_helpers
before { sign_in(create(:administrator).user) }
describe "Hide link" do
it "is shown for debates" do
debate = create(:debate)
render_inline Shared::ModerationActionsComponent.new(debate)
expect(page).to have_link "Hide", href: hide_moderation_debate_path(debate)
end
it "is shown for proposals" do
proposal = create(:proposal)
render_inline Shared::ModerationActionsComponent.new(proposal)
expect(page).to have_link "Hide", href: hide_moderation_proposal_path(proposal)
end
it "is shown for proposal notifications" do
notification = create(:proposal_notification)
render_inline Shared::ModerationActionsComponent.new(notification)
expect(page).to have_link "Hide", href: hide_moderation_proposal_notification_path(notification)
end
it "is shown for comments" do
comment = create(:comment)
render_inline Shared::ModerationActionsComponent.new(comment)
expect(page).to have_link "Hide", href: hide_moderation_comment_path(comment)
end
it "is shown for budget investments" do
investment = create(:budget_investment)
render_inline Shared::ModerationActionsComponent.new(investment)
expect(page).to have_link "Hide", href: hide_moderation_budget_investment_path(investment)
end
it "is shown for legislation proposals" do
proposal = create(:legislation_proposal)
render_inline Shared::ModerationActionsComponent.new(proposal)
expect(page).to have_link "Hide", href: hide_moderation_legislation_proposal_path(proposal)
end
end
end