Commit 80abdad6 authored by Rémy Coutable's avatar Rémy Coutable

Allow TestHooks::ProjectService to take a project

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 98a3a762
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