Issue-1794: Allow to hide proposals created by admin (#3884)

This commit is contained in:
Srinandan Pai
2020-03-26 19:37:55 +05:30
committed by GitHub
parent a8fe6b8627
commit 14106ce800
3 changed files with 4 additions and 6 deletions

View File

@@ -30,13 +30,11 @@ module Abilities
cannot :moderate, Debate, author_id: user.id cannot :moderate, Debate, author_id: user.id
can :hide, Proposal, hidden_at: nil can :hide, Proposal, hidden_at: nil
cannot :hide, Proposal, author_id: user.id
can :ignore_flag, Proposal, ignored_flag_at: nil, hidden_at: nil can :ignore_flag, Proposal, ignored_flag_at: nil, hidden_at: nil
cannot :ignore_flag, Proposal, author_id: user.id cannot :ignore_flag, Proposal, author_id: user.id
can :moderate, Proposal can :moderate, Proposal
cannot :moderate, Proposal, author_id: user.id
can :hide, Legislation::Proposal, hidden_at: nil can :hide, Legislation::Proposal, hidden_at: nil
cannot :hide, Legislation::Proposal, author_id: user.id cannot :hide, Legislation::Proposal, author_id: user.id

View File

@@ -29,7 +29,7 @@ describe "Moderate proposals" do
expect(page).to have_css(".proposal", count: 0) expect(page).to have_css(".proposal", count: 0)
end end
scenario "Can not hide own proposal" do scenario "Can hide own proposal" do
moderator = create(:moderator) moderator = create(:moderator)
proposal = create(:proposal, author: moderator.user) proposal = create(:proposal, author: moderator.user)
@@ -37,7 +37,7 @@ describe "Moderate proposals" do
visit proposal_path(proposal) visit proposal_path(proposal)
within("#proposal_#{proposal.id}") do 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") expect(page).not_to have_link("Block author")
end end
end end

View File

@@ -66,8 +66,8 @@ describe Abilities::Moderator do
it { should be_able_to(:hide, proposal) } it { should be_able_to(:hide, proposal) }
it { should be_able_to(:hide_in_moderation_screen, 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, hidden_proposal) }
it { should_not be_able_to(:hide, own_proposal) }
it { should be_able_to(:ignore_flag, comment) } it { should be_able_to(:ignore_flag, comment) }
it { should_not be_able_to(:ignore_flag, hidden_comment) } it { should_not be_able_to(:ignore_flag, hidden_comment) }
@@ -88,7 +88,7 @@ describe Abilities::Moderator do
it { should_not be_able_to(:ignore_flag, own_proposal) } it { should_not be_able_to(:ignore_flag, own_proposal) }
it { should be_able_to(:moderate, 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_not be_able_to(:hide, user) }
it { should be_able_to(:hide, other_user) } it { should be_able_to(:hide, other_user) }