Rename Labels::CreateService to Labels::FindOrCreateService

This commit is contained in:
Douglas Barbosa Alexandre 2016-10-19 11:53:31 -02:00
parent fc2c64fcdf
commit 4f6d1c1d70
10 changed files with 10 additions and 10 deletions

View file

@ -734,7 +734,7 @@ class Project < ActiveRecord::Base
def create_labels
Label.templates.each do |label|
params = label.attributes.except('id', 'template', 'created_at', 'updated_at')
Labels::CreateService.new(owner, self, params).execute
Labels::FindOrCreateService.new(owner, self, params).execute
end
end

View file

@ -19,7 +19,7 @@ module Boards
end
def find_or_create_label(params)
::Labels::CreateService.new(current_user, project, params).execute
::Labels::FindOrCreateService.new(current_user, project, params).execute
end
def label_params

View file

@ -88,7 +88,7 @@ class IssuableBaseService < BaseService
return unless labels
params[:label_ids] = labels.split(',').map do |label_name|
service = Labels::CreateService.new(current_user, project, title: label_name.strip)
service = Labels::FindOrCreateService.new(current_user, project, title: label_name.strip)
label = service.execute
label.id

View file

@ -1,5 +1,5 @@
module Labels
class CreateService
class FindOrCreateService
def initialize(current_user, project, params = {})
@current_user = current_user
@group = project.group

View file

@ -43,7 +43,7 @@ module Labels
def find_or_create_label!(label)
params = label.attributes.slice('title', 'description', 'color')
new_label = CreateService.new(current_user, project, params).execute
new_label = FindOrCreateService.new(current_user, project, params).execute
new_label.id
end

View file

@ -75,7 +75,7 @@ module Gitlab
def create_label(name)
params = { title: name, color: nice_label_color(name) }
::Labels::CreateService.new(project.owner, project, params).execute
::Labels::FindOrCreateService.new(project.owner, project, params).execute
end
def user_info(person_id)

View file

@ -15,7 +15,7 @@ module Gitlab
def create!
params = attributes.except(:project)
service = ::Labels::CreateService.new(project.owner, project, params)
service = ::Labels::FindOrCreateService.new(project.owner, project, params)
label = service.execute
raise ActiveRecord::RecordInvalid.new(label) unless label.persisted?

View file

@ -234,7 +234,7 @@ module Gitlab
def create_label(name)
params = { name: name, color: nice_label_color(name) }
::Labels::CreateService.new(project.owner, project, params).execute
::Labels::FindOrCreateService.new(project.owner, project, params).execute
end
def format_content(raw_content)

View file

@ -19,7 +19,7 @@ module Gitlab
]
labels.each do |params|
::Labels::CreateService.new(project.owner, project).execute(params)
::Labels::FindOrCreateService.new(project.owner, project).execute(params)
end
end
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe Labels::CreateService, services: true do
describe Labels::FindOrCreateService, services: true do
describe '#execute' do
let(:user) { create(:user) }
let(:group) { create(:group) }