Commit 984367f9 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Move those builders to their own namespace, feedback:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5620#note_13540099
parent 7506fb92d3de
......@@ -349,7 +349,7 @@ def stuck?
def execute_hooks
return unless project
build_data = Gitlab::BuildDataBuilder.build(self)
build_data = Gitlab::DataBuilder::BuildDataBuilder.build(self)
project.execute_hooks(build_data.dup, :build_hooks)
project.execute_services(build_data.dup, :build_hooks)
project.running_or_pending_build_count(force: true)
......@@ -461,7 +461,7 @@ def predefined_variables
def build_attributes_from_config
return {} unless pipeline.config_processor
pipeline.config_processor.build_attributes(name)
end
end
......
......@@ -52,7 +52,7 @@ def disabled_title
def test_data(project = nil, user = nil)
build = project.builds.last
Gitlab::BuildDataBuilder.build(build)
Gitlab::DataBuilder::BuildDataBuilder.build(build)
end
def fields
......
......@@ -80,7 +80,7 @@ def fields
end
def test_data(project, user)
Gitlab::PushDataBuilder.build_sample(project, user)
Gitlab::DataBuilder::PushDataBuilder.build_sample(project, user)
end
def event_channel_names
......
......@@ -39,7 +39,7 @@ def success(message)
end
def build_push_data(branch)
Gitlab::PushDataBuilder
Gitlab::DataBuilder::PushDataBuilder
.build(project, current_user, branch.target.sha, Gitlab::Git::BLANK_SHA, "#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}", [])
end
end
......@@ -33,7 +33,7 @@ def success(message)
end
def build_push_data(tag)
Gitlab::PushDataBuilder
Gitlab::DataBuilder::PushDataBuilder
.build(project, current_user, tag.target.sha, Gitlab::Git::BLANK_SHA, "#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}", [])
end
end
......@@ -138,12 +138,12 @@ def process_commit_messages
end
def build_push_data
@push_data ||= Gitlab::PushDataBuilder.
@push_data ||= Gitlab::DataBuilder::PushDataBuilder.
build(@project, current_user, params[:oldrev], params[:newrev], params[:ref], push_commits)
end
def build_push_data_system_hook
@push_data_system ||= Gitlab::PushDataBuilder.
@push_data_system ||= Gitlab::DataBuilder::PushDataBuilder.
build(@project, current_user, params[:oldrev], params[:newrev], params[:ref], [])
end
......
......@@ -34,12 +34,12 @@ def build_push_data
end
end
Gitlab::PushDataBuilder.
Gitlab::DataBuilder::PushDataBuilder.
build(project, current_user, params[:oldrev], params[:newrev], params[:ref], commits, message)
end
def build_system_push_data
Gitlab::PushDataBuilder.
Gitlab::DataBuilder::PushDataBuilder.
build(project, current_user, params[:oldrev], params[:newrev], params[:ref], [], '')
end
end
......@@ -16,7 +16,7 @@ def execute
end
def hook_data
Gitlab::NoteDataBuilder.build(@note, @note.author)
Gitlab::DataBuilder::NoteDataBuilder.build(@note, @note.author)
end
def execute_note_hooks
......
class TestHookService
def execute(hook, current_user)
data = Gitlab::PushDataBuilder.build_sample(hook.project, current_user)
data = Gitlab::DataBuilder::PushDataBuilder.
build_sample(hook.project, current_user)
hook.execute(data, 'push_hooks')
end
end
module Gitlab
class BuildDataBuilder
class << self
module DataBuilder
module BuildDataBuilder
module_function
def build(build)
project = build.project
commit = build.pipeline
......
module Gitlab
class NoteDataBuilder
class << self
module DataBuilder
module NoteDataBuilder
module_function
# Produce a hash of post-receive data
#
# For all notes:
......
module Gitlab
class PushDataBuilder
class << self
module DataBuilder
module PushDataBuilder
module_function
# Produce a hash of post-receive data
#
# data = {
......
require 'spec_helper'
describe 'Gitlab::BuildDataBuilder' do
describe Gitlab::DataBuilder::BuildDataBuilder do
let(:build) { create(:ci_build) }
describe '.build' do
let(:data) do
Gitlab::BuildDataBuilder.build(build)
Gitlab::DataBuilder::BuildDataBuilder.build(build)
end
it { expect(data).to be_a(Hash) }
......
require 'spec_helper'
describe 'Gitlab::NoteDataBuilder', lib: true do
describe Gitlab::DataBuilder::NoteDataBuilder, lib: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:data) { Gitlab::NoteDataBuilder.build(note, user) }
let(:data) { Gitlab::DataBuilder::NoteDataBuilder.build(note, user) }
let(:fixed_time) { Time.at(1425600000) } # Avoid time precision errors
before(:each) do
......
require 'spec_helper'
describe Gitlab::PushDataBuilder, lib: true do
describe Gitlab::DataBuilder::PushDataBuilder, lib: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
......
......@@ -39,7 +39,8 @@
token: 'verySecret',
subdomain: 'project_name'
)
@sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
@sample_data = Gitlab::DataBuilder::PushDataBuilder.
build_sample(project, user)
@api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret'
WebMock.stub_request(:post, @api_url)
end
......
require 'spec_helper'
describe BuildsEmailService do
let(:data) { Gitlab::BuildDataBuilder.build(create(:ci_build)) }
let(:data) do
Gitlab::DataBuilder::BuildDataBuilder.build(create(:ci_build))
end
describe 'Validations' do
context 'when service is active' do
......@@ -39,7 +41,7 @@
describe '#test' do
it 'sends email' do
data = Gitlab::BuildDataBuilder.build(create(:ci_build))
data = Gitlab::DataBuilder::BuildDataBuilder.build(create(:ci_build))
subject.recipients = 'test@gitlab.com'
expect(BuildEmailWorker).to receive(:perform_async)
......@@ -49,7 +51,7 @@
context 'notify only failed builds is true' do
it 'sends email' do
data = Gitlab::BuildDataBuilder.build(create(:ci_build))
data = Gitlab::DataBuilder::BuildDataBuilder.build(create(:ci_build))
data[:build_status] = "success"
subject.recipients = 'test@gitlab.com'
......
......@@ -84,7 +84,9 @@
include_context :drone_ci_service
let(:user) { create(:user, username: 'username') }
let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
let(:push_sample_data) do
Gitlab::DataBuilder::PushDataBuilder.build_sample(project, user)
end
it do
service_hook = double
......
......@@ -52,7 +52,8 @@
service_hook: true,
token: 'verySecret'
)
@sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
@sample_data = Gitlab::DataBuilder::PushDataBuilder.
build_sample(project, user)
@api_url = 'https://api.flowdock.com/v1/messages'
WebMock.stub_request(:post, @api_url)
end
......
......@@ -55,7 +55,8 @@
token: 'verySecret',
api_key: 'GemnasiumUserApiKey'
)
@sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
@sample_data = Gitlab::DataBuilder::PushDataBuilder.
build_sample(project, user)
end
it "should call Gemnasium service" do
expect(Gemnasium::GitlabService).to receive(:execute).with(an_instance_of(Hash)).once
......
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