Skip to content

Commit

Permalink
Issue-1794: Allow to hide proposals created by admin (consuldemocracy…
Browse files Browse the repository at this point in the history
  • Loading branch information
SrinandanPai committed Mar 26, 2020
1 parent 40e5f44 commit 41fbf04
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
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

0 comments on commit 41fbf04

Please sign in to comment.