Skip to content
Snippets Groups Projects
Commit 17e30a32 authored by Rémy Coutable's avatar Rémy Coutable
Browse files

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
No related branches found
No related tags found
No related merge requests found
module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService
attr_reader :params, :application_setting
def execute
update_terms(@params.delete(:terms))
 
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
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?
 
Loading
Loading
Loading
Loading
@@ -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' })
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment