diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-18 00:11:33 -0200 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:27 -0200 |
commit | 6c189dcc8e76d5ddb348832500b003bf0d1b49a6 (patch) | |
tree | 598cb637e1cddfa1ea74894ca78c610630adca94 /spec/services/labels | |
parent | 49ec98d1b2ca6f57f3f9434a0be0018fa5a53681 (diff) | |
download | gitlab-ce-6c189dcc8e76d5ddb348832500b003bf0d1b49a6.tar.gz |
Add service to create project labels
Diffstat (limited to 'spec/services/labels')
-rw-r--r-- | spec/services/labels/create_service_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/services/labels/create_service_spec.rb b/spec/services/labels/create_service_spec.rb new file mode 100644 index 00000000000..1e4bc294b46 --- /dev/null +++ b/spec/services/labels/create_service_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe Labels::CreateService, services: true do + describe '#execute' do + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:project) { create(:project, namespace: group) } + + let(:params) do + { + title: 'Security', + description: 'Security related stuff.', + color: '#FF0000' + } + end + + subject(:service) { described_class.new(user, project, params) } + + before do + project.team << [user, :developer] + end + + context 'when label does not exist at group level' do + it 'creates a new label at project level' do + expect { service.execute }.to change(project.labels, :count).by(1) + end + end + + context 'when label exists at group level' do + it 'returns the group label' do + group_label = create(:group_label, group: group, title: 'Security') + + expect(service.execute).to eq group_label + end + end + + context 'when label does not exist at group level' do + it 'creates a new label at project leve' do + expect { service.execute }.to change(project.labels, :count).by(1) + end + end + + context 'when label exists at project level' do + it 'returns the project label' do + project_label = create(:label, project: project, title: 'Security') + + expect(service.execute).to eq project_label + end + end + end +end |