diff --git a/app/models/ability.rb b/app/models/ability.rb index 9032038a1..a29f09a60 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -66,10 +66,15 @@ class Ability cannot :hide, User, id: user.id end + if user.moderator? + can :comment_as_moderator, [Debate, Comment] + end + if user.administrator? can :restore, Comment can :restore, Debate can :restore, User + can :comment_as_administrator, [Debate, Comment] end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 1ff4933b0..ff3e3800c 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -22,13 +22,15 @@ describe Ability do it { should be_able_to(:show, debate) } it { should be_able_to(:vote, debate) } - it { should be_able_to(:show, user) } it { should be_able_to(:edit, user) } it { should be_able_to(:create, Comment) } it { should be_able_to(:vote, Comment) } + it { should_not be_able_to(:comment_as_administrator, debate) } + it { should_not be_able_to(:comment_as_moderator, debate) } + describe 'flagging content as inappropiate' do it { should be_able_to(:flag_as_inappropiate, debate) } it { should_not be_able_to(:undo_flag_as_inappropiate, debate) } @@ -158,6 +160,9 @@ describe Ability do 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) } + + it { should be_able_to(:comment_as_moderator, debate) } + it { should_not be_able_to(:comment_as_administrator, debate) } end end @@ -173,5 +178,8 @@ 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) } + + it { should be_able_to(:comment_as_administrator, debate) } + it { should_not be_able_to(:comment_as_moderator, debate) } end end