Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow admins to hide proposals created by themselves #3884

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/models/abilities/moderation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ def initialize(user)
cannot :moderate, Debate, author_id: user.id

can :hide, Proposal, hidden_at: nil
cannot :hide, Proposal, author_id: user.id

can :ignore_flag, Proposal, ignored_flag_at: nil, hidden_at: nil
cannot :ignore_flag, Proposal, author_id: user.id

can :moderate, Proposal
cannot :moderate, Proposal, author_id: user.id

can :hide, Legislation::Proposal, hidden_at: nil
cannot :hide, Legislation::Proposal, author_id: user.id
Expand Down
4 changes: 2 additions & 2 deletions spec/features/moderation/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
expect(page).to have_css(".proposal", count: 0)
end

scenario "Can not hide own proposal" do
scenario "Can hide own proposal" do
moderator = create(:moderator)
proposal = create(:proposal, author: moderator.user)

login_as(moderator.user)
visit proposal_path(proposal)

within("#proposal_#{proposal.id}") do
expect(page).not_to have_link("Hide")
expect(page).to have_link("Hide")
expect(page).not_to have_link("Block author")
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/abilities/moderator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@

it { should be_able_to(:hide, proposal) }
it { should be_able_to(:hide_in_moderation_screen, proposal) }
it { should be_able_to(:hide, own_proposal) }
it { should_not be_able_to(:hide, hidden_proposal) }
it { should_not be_able_to(:hide, own_proposal) }

it { should be_able_to(:ignore_flag, comment) }
it { should_not be_able_to(:ignore_flag, hidden_comment) }
Expand All @@ -88,7 +88,7 @@
it { should_not be_able_to(:ignore_flag, own_proposal) }

it { should be_able_to(:moderate, proposal) }
it { should_not be_able_to(:moderate, own_proposal) }
it { should be_able_to(:moderate, own_proposal) }

it { should_not be_able_to(:hide, user) }
it { should be_able_to(:hide, other_user) }
Expand Down