Backport changes in app/services/test_hooks/project_service.rb
This commit is contained in:
parent
fe0ebf76c4
commit
caadfcdee3
|
|
@ -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?
|
||||
|
||||
|
|
|
|||
|
|
@ -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…
Reference in New Issue