summaryrefslogtreecommitdiff
path: root/spec/helpers/issues_helper_spec.rb
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/helpers/issues_helper_spec.rb
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/helpers/issues_helper_spec.rb')
-rw-r--r--spec/helpers/issues_helper_spec.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index aeef5352333..95da9a6f3d4 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -96,13 +96,32 @@ describe IssuesHelper do
describe '#award_state_class' do
let!(:upvote) { create(:award_emoji) }
+ let(:awardable) { upvote.awardable }
+ let(:user) { upvote.user }
+
+ before do
+ allow(helper).to receive(:can?) do |*args|
+ Ability.allowed?(*args)
+ end
+ end
it "returns disabled string for unauthenticated user" do
- expect(award_state_class(AwardEmoji.all, nil)).to eq("disabled")
+ expect(helper.award_state_class(awardable, AwardEmoji.all, nil)).to eq("disabled")
+ end
+
+ it "returns disabled for a user that does not have access to the awardable" do
+ expect(helper.award_state_class(awardable, AwardEmoji.all, build(:user))).to eq("disabled")
end
it "returns active string for author" do
- expect(award_state_class(AwardEmoji.all, upvote.user)).to eq("active")
+ expect(helper.award_state_class(awardable, AwardEmoji.all, upvote.user)).to eq("active")
+ end
+
+ it "is blank for a user that has access to the awardable" do
+ user = build(:user)
+ expect(helper).to receive(:can?).with(user, :award_emoji, awardable).and_return(true)
+
+ expect(helper.award_state_class(awardable, AwardEmoji.all, user)).to be_blank
end
end