Hide legislation proposals when blocking a user
We're also updating the notice messages to specify all contents have been hidden (not just debates).
This commit is contained in:
@@ -758,6 +758,21 @@ describe User do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#block" do
|
||||
it "hides legislation proposals created by the user" do
|
||||
user = create(:user)
|
||||
other_user = create(:user)
|
||||
|
||||
proposal = create(:legislation_proposal, author: user)
|
||||
other_proposal = create(:legislation_proposal, author: other_user)
|
||||
|
||||
user.block
|
||||
|
||||
expect(Legislation::Proposal.all).to eq [other_proposal]
|
||||
expect(Legislation::Proposal.with_hidden).to match_array [proposal, other_proposal]
|
||||
end
|
||||
end
|
||||
|
||||
describe "#full_restore" do
|
||||
it "restore all previous hidden user content" do
|
||||
user = create(:user, :hidden)
|
||||
@@ -768,18 +783,21 @@ describe User do
|
||||
investment = create(:budget_investment, :hidden, author: user)
|
||||
proposal = create(:proposal, :hidden, author: user)
|
||||
proposal_notification = create(:proposal_notification, :hidden, proposal: proposal)
|
||||
legislation_proposal = create(:legislation_proposal, :hidden, author: user)
|
||||
|
||||
old_hidden_comment = create(:comment, hidden_at: 3.days.ago, author: user)
|
||||
old_hidden_debate = create(:debate, hidden_at: 3.days.ago, author: user)
|
||||
old_hidden_investment = create(:budget_investment, hidden_at: 3.days.ago, author: user)
|
||||
old_hidden_proposal = create(:proposal, hidden_at: 3.days.ago, author: user)
|
||||
old_hidden_proposal_notification = create(:proposal_notification, hidden_at: 3.days.ago, proposal: proposal)
|
||||
old_hidden_legislation_proposal = create(:legislation_proposal, hidden_at: 3.days.ago, author: user)
|
||||
|
||||
other_user_comment = create(:comment, :hidden, author: other_user)
|
||||
other_user_debate = create(:debate, :hidden, author: other_user)
|
||||
other_user_proposal = create(:proposal, :hidden, author: other_user)
|
||||
other_user_investment = create(:budget_investment, :hidden, author: other_user)
|
||||
other_user_proposal_notification = create(:proposal_notification, :hidden, proposal: other_user_proposal)
|
||||
other_user_legislation_proposal = create(:legislation_proposal, :hidden, author: other_user)
|
||||
|
||||
user.full_restore
|
||||
|
||||
@@ -788,18 +806,21 @@ describe User do
|
||||
expect(investment.reload).not_to be_hidden
|
||||
expect(proposal.reload).not_to be_hidden
|
||||
expect(proposal_notification.reload).not_to be_hidden
|
||||
expect(legislation_proposal.reload).not_to be_hidden
|
||||
|
||||
expect(old_hidden_comment.reload).to be_hidden
|
||||
expect(old_hidden_debate.reload).to be_hidden
|
||||
expect(old_hidden_investment.reload).to be_hidden
|
||||
expect(old_hidden_proposal.reload).to be_hidden
|
||||
expect(old_hidden_proposal_notification.reload).to be_hidden
|
||||
expect(old_hidden_legislation_proposal.reload).to be_hidden
|
||||
|
||||
expect(other_user_comment.reload).to be_hidden
|
||||
expect(other_user_debate.reload).to be_hidden
|
||||
expect(other_user_investment.reload).to be_hidden
|
||||
expect(other_user_proposal.reload).to be_hidden
|
||||
expect(other_user_proposal_notification.reload).to be_hidden
|
||||
expect(other_user_legislation_proposal.reload).to be_hidden
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user