Commit f4c5f900 authored by Mario de la Ossa's avatar Mario de la Ossa

Lock award emojis when issuable is locked

We should not allow award emojis to be toggled when an issuable is
locked
parent c7d3515e
......@@ -24,5 +24,6 @@ class IssuablePolicy < BasePolicy
prevent :create_note
prevent :admin_note
prevent :resolve_note
prevent :award_emoji
end
end
---
title: Disallow awarding emojis to locked Issuables for users that are not member
of the project
merge_request: 40150
author:
type: changed
......@@ -184,6 +184,31 @@ RSpec.describe 'User interacts with awards' do
wait_for_requests
end
context 'when the issue is locked' do
before do
create(:award_emoji, awardable: issue, name: '100')
issue.update!(discussion_locked: true)
visit project_issue_path(project, issue)
wait_for_requests
end
it 'hides the add award button' do
page.within('.awards') do
expect(page).not_to have_css('.js-add-award')
end
end
it 'does not allow toggling existing emoji' do
page.within('.awards') do
find('gl-emoji[data-name="100"]').click
end
wait_for_requests
expect(issue.reload.award_emoji.size).to eq(1)
end
end
it 'adds award to issue' do
first('.js-emoji-btn').click
......
......@@ -40,8 +40,8 @@ RSpec.describe IssuablePolicy, models: true do
let(:issue) { create(:issue, project: project, discussion_locked: true) }
context 'when the user is not a project member' do
it 'can not create a note' do
expect(policies).to be_disallowed(:create_note)
it 'can not create a note nor award emojis' do
expect(policies).to be_disallowed(:create_note, :award_emoji)
end
end
......@@ -50,8 +50,8 @@ RSpec.describe IssuablePolicy, models: true do
project.add_guest(user)
end
it 'can create a note' do
expect(policies).to be_allowed(:create_note)
it 'can create a note and award emojis' do
expect(policies).to be_allowed(:create_note, :award_emoji)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment