We're continuing to replace links with buttons, for the reasons
explained in commit 5311daadf.
Since we're using the admin action component, we can also simplify the
logic handling the confirmation message.
In order to avoid duplicate IDs when generating buttons to block the
same author more than once in a page, we're including the record dom_id
in the ID of the button to block an author.
69 lines
2.0 KiB
Ruby
69 lines
2.0 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Shared::ModerationActionsComponent do
|
|
include Rails.application.routes.url_helpers
|
|
before { sign_in(create(:administrator).user) }
|
|
|
|
describe "Hide button" do
|
|
it "is shown for debates" do
|
|
debate = create(:debate)
|
|
|
|
render_inline Shared::ModerationActionsComponent.new(debate)
|
|
|
|
page.find("form[action='#{hide_moderation_debate_path(debate)}']") do
|
|
expect(page).to have_button "Hide"
|
|
end
|
|
end
|
|
|
|
it "is shown for proposals" do
|
|
proposal = create(:proposal)
|
|
|
|
render_inline Shared::ModerationActionsComponent.new(proposal)
|
|
|
|
page.find("form[action='#{hide_moderation_proposal_path(proposal)}']") do
|
|
expect(page).to have_button "Hide"
|
|
end
|
|
end
|
|
|
|
it "is shown for proposal notifications" do
|
|
notification = create(:proposal_notification)
|
|
|
|
render_inline Shared::ModerationActionsComponent.new(notification)
|
|
|
|
page.find("form[action='#{hide_moderation_proposal_notification_path(notification)}']") do
|
|
expect(page).to have_button "Hide"
|
|
end
|
|
end
|
|
|
|
it "is shown for comments" do
|
|
comment = create(:comment)
|
|
|
|
render_inline Shared::ModerationActionsComponent.new(comment)
|
|
|
|
page.find("form[action='#{hide_moderation_comment_path(comment)}']") do
|
|
expect(page).to have_button "Hide"
|
|
end
|
|
end
|
|
|
|
it "is shown for budget investments" do
|
|
investment = create(:budget_investment)
|
|
|
|
render_inline Shared::ModerationActionsComponent.new(investment)
|
|
|
|
page.find("form[action='#{hide_moderation_budget_investment_path(investment)}']") do
|
|
expect(page).to have_button "Hide"
|
|
end
|
|
end
|
|
|
|
it "is shown for legislation proposals" do
|
|
proposal = create(:legislation_proposal)
|
|
|
|
render_inline Shared::ModerationActionsComponent.new(proposal)
|
|
|
|
page.find("form[action='#{hide_moderation_legislation_proposal_path(proposal)}']") do
|
|
expect(page).to have_button "Hide"
|
|
end
|
|
end
|
|
end
|
|
end
|