summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-04-06 20:19:37 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-04-11 10:51:43 +0200
commit04c7d0d55500e6f118bd17153f3af11e83fce826 (patch)
tree7976d051ad4138dd020e78e2fd616f0791bd7123 /spec/models/concerns
parent71ccfde322b633e9245bee6acba1e64cb7640f19 (diff)
downloadgitlab-ce-04c7d0d55500e6f118bd17153f3af11e83fce826.tar.gz
Prevent awarding emoji when a project is archived
This prevents performing the requests, and disables all emoji reaction buttons
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/awardable_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/concerns/awardable_spec.rb b/spec/models/concerns/awardable_spec.rb
index 34f923d3f0c..a980cff28fb 100644
--- a/spec/models/concerns/awardable_spec.rb
+++ b/spec/models/concerns/awardable_spec.rb
@@ -46,6 +46,31 @@ describe Awardable do
end
end
+ describe '#user_can_award?' do
+ let(:user) { create(:user) }
+
+ before do
+ issue.project.add_guest(user)
+ end
+
+ it 'does not allow upvoting or downvoting your own issue' do
+ issue.update!(author: user)
+
+ expect(issue.user_can_award?(user, AwardEmoji::DOWNVOTE_NAME)).to be_falsy
+ expect(issue.user_can_award?(user, AwardEmoji::UPVOTE_NAME)).to be_falsy
+ end
+
+ it 'is truthy when the user is allowed to award emoji' do
+ expect(issue.user_can_award?(user, AwardEmoji::UPVOTE_NAME)).to be_truthy
+ end
+
+ it 'is falsy when the project is archived' do
+ issue.project.update!(archived: true)
+
+ expect(issue.user_can_award?(user, AwardEmoji::UPVOTE_NAME)).to be_falsy
+ end
+ end
+
describe "#toggle_award_emoji" do
it "adds an emoji if it isn't awarded yet" do
expect { issue.toggle_award_emoji("thumbsup", award_emoji.user) }.to change { AwardEmoji.count }.by(1)