2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe IssuablePolicy, models: true do
|
2018-03-27 19:54:05 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let(:policies) { described_class.new(user, issue) }
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe '#rules' do
|
|
|
|
context 'when discussion is locked for the issuable' 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)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user is a project member' do
|
|
|
|
before do
|
|
|
|
project.add_guest(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can create a note' do
|
|
|
|
expect(policies).to be_allowed(:create_note)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|