gitlab-org--gitlab-foss/spec/services/projects/group_links/create_service_spec.rb
Thong Kuah 85b29c1c2f Add frozen_string_literal to spec/services
Probably useful as we often move these files to "new" files.
2019-04-12 10:14:54 +12:00

32 lines
863 B
Ruby

# frozen_string_literal: true
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) }
before do
group.add_developer(user)
end
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
it 'returns error if user is not allowed to share with a group' do
expect { subject.execute(create :group) }.not_to change { project.project_group_links.count }
end
end