From 4f6d1c1d70d744ff599ae9c51e1cbc3a3c23e13e Mon Sep 17 00:00:00 2001
From: Douglas Barbosa Alexandre <dbalexandre@gmail.com>
Date: Wed, 19 Oct 2016 11:53:31 -0200
Subject: [PATCH] Rename Labels::CreateService to Labels::FindOrCreateService

---
 app/models/project.rb                                           | 2 +-
 app/services/boards/lists/generate_service.rb                   | 2 +-
 app/services/issuable_base_service.rb                           | 2 +-
 .../labels/{create_service.rb => find_or_create_service.rb}     | 2 +-
 app/services/labels/transfer_service.rb                         | 2 +-
 lib/gitlab/fogbugz_import/importer.rb                           | 2 +-
 lib/gitlab/github_import/label_formatter.rb                     | 2 +-
 lib/gitlab/google_code_import/importer.rb                       | 2 +-
 lib/gitlab/issues_labels.rb                                     | 2 +-
 .../{create_service_spec.rb => find_or_create_service_spec.rb}  | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)
 rename app/services/labels/{create_service.rb => find_or_create_service.rb} (96%)
 rename spec/services/labels/{create_service_spec.rb => find_or_create_service_spec.rb} (96%)

diff --git a/app/models/project.rb b/app/models/project.rb
index bc15ca3fc2..a6039bb8cc 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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
 
diff --git a/app/services/boards/lists/generate_service.rb b/app/services/boards/lists/generate_service.rb
index 1d3c7f2071..939f9bfd06 100644
--- a/app/services/boards/lists/generate_service.rb
+++ b/app/services/boards/lists/generate_service.rb
@@ -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
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index 4554963370..bb92cd80cc 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -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
diff --git a/app/services/labels/create_service.rb b/app/services/labels/find_or_create_service.rb
similarity index 96%
rename from app/services/labels/create_service.rb
rename to app/services/labels/find_or_create_service.rb
index bb475ce741..74291312c4 100644
--- a/app/services/labels/create_service.rb
+++ b/app/services/labels/find_or_create_service.rb
@@ -1,5 +1,5 @@
 module Labels
-  class CreateService
+  class FindOrCreateService
     def initialize(current_user, project, params = {})
       @current_user = current_user
       @group = project.group
diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb
index 65b4bdbaff..f91b3724ae 100644
--- a/app/services/labels/transfer_service.rb
+++ b/app/services/labels/transfer_service.rb
@@ -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
diff --git a/lib/gitlab/fogbugz_import/importer.rb b/lib/gitlab/fogbugz_import/importer.rb
index f154ee689c..ce4d87a074 100644
--- a/lib/gitlab/fogbugz_import/importer.rb
+++ b/lib/gitlab/fogbugz_import/importer.rb
@@ -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)
diff --git a/lib/gitlab/github_import/label_formatter.rb b/lib/gitlab/github_import/label_formatter.rb
index 8ed1574c4f..942dfb3312 100644
--- a/lib/gitlab/github_import/label_formatter.rb
+++ b/lib/gitlab/github_import/label_formatter.rb
@@ -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?
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index 904a228aee..b16a565409 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -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)
diff --git a/lib/gitlab/issues_labels.rb b/lib/gitlab/issues_labels.rb
index 6788eca714..01a2c19ab2 100644
--- a/lib/gitlab/issues_labels.rb
+++ b/lib/gitlab/issues_labels.rb
@@ -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
diff --git a/spec/services/labels/create_service_spec.rb b/spec/services/labels/find_or_create_service_spec.rb
similarity index 96%
rename from spec/services/labels/create_service_spec.rb
rename to spec/services/labels/find_or_create_service_spec.rb
index 1e4bc294b4..cbfc63de81 100644
--- a/spec/services/labels/create_service_spec.rb
+++ b/spec/services/labels/find_or_create_service_spec.rb
@@ -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) }
-- 
2.30.9