Commit 17e30a32 authored by Rémy Coutable's avatar Rémy Coutable

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

Backport changes in some EE service objects

See merge request gitlab-org/gitlab-ce!19119
parents ffe87460 c75baaa4
module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService
attr_reader :params, :application_setting
def execute
update_terms(@params.delete(:terms))
......
......@@ -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)
......
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?
......
......@@ -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' })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment