Merge branch 'ce-6021-extract-ee-services' into 'master'

Backport changes in some EE service objects

See merge request gitlab-org/gitlab-ce!19119
This commit is contained in:
Rémy Coutable 2018-06-05 15:30:46 +00:00
commit 17e30a3212
4 changed files with 14 additions and 5 deletions

View file

@ -1,5 +1,7 @@
module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService
attr_reader :params, :application_setting
def execute
update_terms(@params.delete(:terms))

View file

@ -2,8 +2,7 @@ module Applications
class CreateService
def initialize(current_user, params)
@current_user = current_user
@params = params
@ip_address = @params.delete(:ip_address)
@params = params.except(:ip_address)
end
def execute(request = nil)

View file

@ -1,11 +1,13 @@
module TestHooks
class ProjectService < TestHooks::BaseService
private
attr_writer :project
def project
@project ||= hook.project
end
private
def push_events_data
throw(:validation_error, 'Ensure the project has at least one commit.') if project.empty_repo?

View file

@ -6,13 +6,19 @@ describe TestHooks::ProjectService do
describe '#execute' do
let(:project) { create(:project, :repository) }
let(:hook) { create(:project_hook, project: project) }
let(:trigger) { 'not_implemented_events' }
let(:service) { described_class.new(hook, current_user, trigger) }
let(:sample_data) { { data: 'sample' } }
let(:success_result) { { status: :success, http_status: 200, message: 'ok' } }
context 'hook with not implemented test' do
let(:trigger) { 'not_implemented_events' }
it 'allows to set a custom project' do
project = double
service.project = project
expect(service.project).to eq(project)
end
context 'hook with not implemented test' do
it 'returns error message' do
expect(hook).not_to receive(:execute)
expect(service.execute).to include({ status: :error, message: 'Testing not available for this hook' })