diff --git a/app/models/ability.rb b/app/models/ability.rb index 9cce129a2..10a136e22 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -28,11 +28,13 @@ class Ability can :hide, Comment can :hide, Debate + can :hide, User end if user.administrator? can :restore, Comment can :restore, Debate + can :restore, User end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 20a3456d4..b484e9e7c 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -64,6 +64,7 @@ describe Ability do describe "Moderator" do let(:user) { create(:user) } before { create(:moderator, user: user) } + let(:other_user) { create(:user) } it { should be_able_to(:index, Debate) } it { should be_able_to(:show, debate) } @@ -88,14 +89,17 @@ describe Ability do it { should be_able_to(:hide, comment) } it { should be_able_to(:hide, debate) } + it { should be_able_to(:hide, other_user) } it { should_not be_able_to(:restore, comment) } it { should_not be_able_to(:restore, debate) } + it { should_not be_able_to(:restore, other_user) } end describe "Administrator" do let(:user) { create(:user) } before { create(:administrator, user: user) } + let(:other_user) { create(:user) } it { should be_able_to(:index, Debate) } it { should be_able_to(:show, debate) } @@ -103,5 +107,6 @@ describe Ability do it { should be_able_to(:restore, comment) } it { should be_able_to(:restore, debate) } + it { should be_able_to(:restore, other_user) } end end