2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::GroupLinks::CreateService, '#execute' do
|
|
|
|
let(:user) { create :user }
|
|
|
|
let(:group) { create :group }
|
|
|
|
let(:project) { create :project }
|
|
|
|
let(:opts) do
|
|
|
|
{
|
|
|
|
link_group_access: '30',
|
|
|
|
expires_at: nil
|
|
|
|
}
|
|
|
|
end
|
|
|
|
let(:subject) { described_class.new(project, user, opts) }
|
|
|
|
|
2019-03-13 22:55:13 +05:30
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'adds group to project' do
|
|
|
|
expect { subject.execute(group) }.to change { project.project_group_links.count }.from(0).to(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false if group is blank' do
|
|
|
|
expect { subject.execute(nil) }.not_to change { project.project_group_links.count }
|
|
|
|
end
|
2019-03-13 22:55:13 +05:30
|
|
|
|
|
|
|
it 'returns error if user is not allowed to share with a group' do
|
2020-04-22 19:07:51 +05:30
|
|
|
expect { subject.execute(create(:group)) }.not_to change { project.project_group_links.count }
|
2019-03-13 22:55:13 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|