Commit 021d3810 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline

parent 5accd87a
...@@ -26,9 +26,9 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -26,9 +26,9 @@ class Projects::BuildsController < Projects::ApplicationController
end end
def show def show
@builds = @project.ci_commits.find_by_sha(@build.sha).builds.order('id DESC') @builds = @project.pipelines.find_by_sha(@build.sha).builds.order('id DESC')
@builds = @builds.where("id not in (?)", @build.id) @builds = @builds.where("id not in (?)", @build.id)
@commit = @build.commit @pipeline = @build.pipeline
respond_to do |format| respond_to do |format|
format.html format.html
......
...@@ -100,7 +100,7 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -100,7 +100,7 @@ class Projects::CommitController < Projects::ApplicationController
end end
def ci_commits def ci_commits
@ci_commits ||= project.ci_commits.where(sha: commit.sha) @ci_commits ||= project.pipelines.where(sha: commit.sha)
end end
def ci_builds def ci_builds
......
...@@ -119,8 +119,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -119,8 +119,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diffs = @merge_request.compare.diffs(diff_options) if @merge_request.compare @diffs = @merge_request.compare.diffs(diff_options) if @merge_request.compare
@diff_notes_disabled = true @diff_notes_disabled = true
@ci_commit = @merge_request.ci_commit @pipeline = @merge_request.pipeline
@statuses = @ci_commit.statuses if @ci_commit @statuses = @pipeline.statuses if @pipeline
@note_counts = Note.where(commit_id: @commits.map(&:id)). @note_counts = Note.where(commit_id: @commits.map(&:id)).
group(:commit_id).count group(:commit_id).count
...@@ -194,7 +194,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -194,7 +194,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.update(merge_error: nil) @merge_request.update(merge_error: nil)
if params[:merge_when_build_succeeds].present? && @merge_request.ci_commit && @merge_request.ci_commit.active? if params[:merge_when_build_succeeds].present? && @merge_request.pipeline && @merge_request.pipeline.active?
MergeRequests::MergeWhenBuildSucceedsService.new(@project, current_user, merge_params) MergeRequests::MergeWhenBuildSucceedsService.new(@project, current_user, merge_params)
.execute(@merge_request) .execute(@merge_request)
@status = :merge_when_build_succeeds @status = :merge_when_build_succeeds
...@@ -225,10 +225,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -225,10 +225,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def ci_status def ci_status
ci_commit = @merge_request.ci_commit pipeline = @merge_request.pipeline
if ci_commit if pipeline
status = ci_commit.status status = pipeline.status
coverage = ci_commit.try(:coverage) coverage = pipeline.try(:coverage)
status ||= "preparing" status ||= "preparing"
else else
...@@ -310,8 +310,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -310,8 +310,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff = @merge_request.merge_request_diff @merge_request_diff = @merge_request.merge_request_diff
@ci_commit = @merge_request.ci_commit @pipeline = @merge_request.pipeline
@statuses = @ci_commit.statuses if @ci_commit @statuses = @ci_commit.statuses if @pipeline
if @merge_request.locked_long_ago? if @merge_request.locked_long_ago?
@merge_request.unlock_mr @merge_request.unlock_mr
...@@ -320,8 +320,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -320,8 +320,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def define_widget_vars def define_widget_vars
@ci_commit = @merge_request.ci_commit @pipeline = @merge_request.pipeline
@ci_commits = [@ci_commit].compact @pipelines = [@pipeline].compact
closes_issues closes_issues
end end
......
...@@ -7,7 +7,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -7,7 +7,7 @@ class Projects::PipelinesController < Projects::ApplicationController
def index def index
@scope = params[:scope] @scope = params[:scope]
all_pipelines = project.ci_commits all_pipelines = project.pipelines
@pipelines_count = all_pipelines.count @pipelines_count = all_pipelines.count
@running_or_pending_count = all_pipelines.running_or_pending.count @running_or_pending_count = all_pipelines.running_or_pending.count
@pipelines = PipelinesFinder.new(project).execute(all_pipelines, @scope) @pipelines = PipelinesFinder.new(project).execute(all_pipelines, @scope)
...@@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
def new def new
@pipeline = project.ci_commits.new(ref: @project.default_branch) @pipeline = project.pipelines.new(ref: @project.default_branch)
end end
def create def create
...@@ -50,7 +50,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -50,7 +50,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
def pipeline def pipeline
@pipeline ||= project.ci_commits.find_by!(id: params[:id]) @pipeline ||= project.pipelines.find_by!(id: params[:id])
end end
def commit def commit
......
...@@ -45,8 +45,8 @@ module Ci ...@@ -45,8 +45,8 @@ module Ci
new_build.options = build.options new_build.options = build.options
new_build.commands = build.commands new_build.commands = build.commands
new_build.tag_list = build.tag_list new_build.tag_list = build.tag_list
new_build.gl_project_id = build.gl_project_id new_build.project = build.project
new_build.commit_id = build.commit_id new_build.pipeline = build.pipeline
new_build.name = build.name new_build.name = build.name
new_build.allow_failure = build.allow_failure new_build.allow_failure = build.allow_failure
new_build.stage = build.stage new_build.stage = build.stage
...@@ -66,7 +66,7 @@ module Ci ...@@ -66,7 +66,7 @@ module Ci
# We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed # We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed
around_transition any => [:success, :failed, :canceled] do |build, block| around_transition any => [:success, :failed, :canceled] do |build, block|
block.call block.call
build.commit.create_next_builds(build) if build.commit build.pipeline.create_next_builds(build) if build.pipeline
end end
after_transition any => [:success, :failed, :canceled] do |build| after_transition any => [:success, :failed, :canceled] do |build|
...@@ -80,7 +80,7 @@ module Ci ...@@ -80,7 +80,7 @@ module Ci
end end
def retried? def retried?
!self.commit.statuses.latest.include?(self) !self.pipeline.statuses.latest.include?(self)
end end
def retry def retry
...@@ -89,7 +89,7 @@ module Ci ...@@ -89,7 +89,7 @@ module Ci
def depends_on_builds def depends_on_builds
# Get builds of the same type # Get builds of the same type
latest_builds = self.commit.builds.latest latest_builds = self.pipeline.builds.latest
# Return builds from previous stages # Return builds from previous stages
latest_builds.where('stage_idx < ?', stage_idx) latest_builds.where('stage_idx < ?', stage_idx)
...@@ -114,7 +114,7 @@ module Ci ...@@ -114,7 +114,7 @@ module Ci
def merge_request def merge_request
merge_requests = MergeRequest.includes(:merge_request_diff) merge_requests = MergeRequest.includes(:merge_request_diff)
.where(source_branch: ref, source_project_id: commit.gl_project_id) .where(source_branch: ref, source_project_id: pipeline.gl_project_id)
.reorder(iid: :asc) .reorder(iid: :asc)
merge_requests.find do |merge_request| merge_requests.find do |merge_request|
......
module Ci module Ci
class Commit < ActiveRecord::Base class Pipeline < ActiveRecord::Base
extend Ci::Model extend Ci::Model
include Statuseable include Statuseable
...@@ -47,7 +47,7 @@ module Ci ...@@ -47,7 +47,7 @@ module Ci
end end
def short_sha def short_sha
Ci::Commit.truncate_sha(sha) Ci::Pipeline.truncate_sha(sha)
end end
def commit_data def commit_data
......
...@@ -3,7 +3,7 @@ module Ci ...@@ -3,7 +3,7 @@ module Ci
extend Ci::Model extend Ci::Model
belongs_to :trigger, class_name: 'Ci::Trigger' belongs_to :trigger, class_name: 'Ci::Trigger'
belongs_to :commit, class_name: 'Ci::Commit' belongs_to :commit, class_name: 'Ci::Pipeline'
has_many :builds, class_name: 'Ci::Build' has_many :builds, class_name: 'Ci::Build'
serialize :variables serialize :variables
......
...@@ -214,13 +214,13 @@ class Commit ...@@ -214,13 +214,13 @@ class Commit
@raw.short_id(7) @raw.short_id(7)
end end
def ci_commits def pipelines
@ci_commits ||= project.ci_commits.where(sha: sha) @pipeline ||= project.pipelines.where(sha: sha)
end end
def status def status
return @status if defined?(@status) return @status if defined?(@status)
@status ||= ci_commits.status @status ||= pipelines.status
end end
def revert_branch_name def revert_branch_name
......
...@@ -4,10 +4,10 @@ class CommitStatus < ActiveRecord::Base ...@@ -4,10 +4,10 @@ class CommitStatus < ActiveRecord::Base
self.table_name = 'ci_builds' self.table_name = 'ci_builds'
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
belongs_to :commit, class_name: 'Ci::Commit', touch: true belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :commit_id, touch: true
belongs_to :user belongs_to :user
validates :commit, presence: true validates :pipeline, presence: true
validates_presence_of :name validates_presence_of :name
...@@ -44,11 +44,11 @@ class CommitStatus < ActiveRecord::Base ...@@ -44,11 +44,11 @@ class CommitStatus < ActiveRecord::Base
end end
after_transition [:pending, :running] => :success do |commit_status| after_transition [:pending, :running] => :success do |commit_status|
MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.commit.project, nil).trigger(commit_status) MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status)
end end
after_transition any => :failed do |commit_status| after_transition any => :failed do |commit_status|
MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.commit.project, nil).execute(commit_status) MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.pipeline.project, nil).execute(commit_status)
end end
end end
......
...@@ -579,8 +579,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -579,8 +579,8 @@ class MergeRequest < ActiveRecord::Base
diverged_commits_count > 0 diverged_commits_count > 0
end end
def ci_commit def pipeline
@ci_commit ||= source_project.ci_commit(last_commit.id, source_branch) if last_commit && source_project @pipeline ||= source_project.pipeline(last_commit.id, source_branch) if last_commit && source_project
end end
def diff_refs def diff_refs
......
...@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base ...@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base
has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" has_one :import_data, dependent: :destroy, class_name: "ProjectImportData"
has_many :commit_statuses, dependent: :destroy, class_name: 'CommitStatus', foreign_key: :gl_project_id has_many :commit_statuses, dependent: :destroy, class_name: 'CommitStatus', foreign_key: :gl_project_id
has_many :ci_commits, dependent: :destroy, class_name: 'Ci::Commit', foreign_key: :gl_project_id has_many :pipelines, dependent: :destroy, class_name: 'Ci::Pipeline', foreign_key: :gl_project_id
has_many :builds, class_name: 'Ci::Build', foreign_key: :gl_project_id # the builds are created from the commit_statuses has_many :builds, class_name: 'Ci::Build', foreign_key: :gl_project_id # the builds are created from the commit_statuses
has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject', foreign_key: :gl_project_id has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject', foreign_key: :gl_project_id
has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
...@@ -930,12 +930,12 @@ class Project < ActiveRecord::Base ...@@ -930,12 +930,12 @@ class Project < ActiveRecord::Base
!namespace.share_with_group_lock !namespace.share_with_group_lock
end end
def ci_commit(sha, ref) def pipeline(sha, ref)
ci_commits.order(id: :desc).find_by(sha: sha, ref: ref) pipelines.order(id: :desc).find_by(sha: sha, ref: ref)
end end
def ensure_ci_commit(sha, ref) def ensure_pipeline(sha, ref)
ci_commit(sha, ref) || ci_commits.create(sha: sha, ref: ref) pipeline(sha, ref) || pipelines.create(sha: sha, ref: ref)
end end
def enable_ci def enable_ci
......
module Ci module Ci
class CreatePipelineService < BaseService class CreatePipelineService < BaseService
def execute def execute
pipeline = project.ci_commits.new(params) pipeline = project.pipelines.new(params)
unless ref_names.include?(params[:ref]) unless ref_names.include?(params[:ref])
pipeline.errors.add(:base, 'Reference not found') pipeline.errors.add(:base, 'Reference not found')
...@@ -19,7 +19,7 @@ module Ci ...@@ -19,7 +19,7 @@ module Ci
end end
begin begin
Ci::Commit.transaction do Ci::Pipeline.transaction do
pipeline.sha = commit.id pipeline.sha = commit.id
unless pipeline.config_processor unless pipeline.config_processor
......
...@@ -7,7 +7,7 @@ module Ci ...@@ -7,7 +7,7 @@ module Ci
# check if ref is tag # check if ref is tag
tag = project.repository.find_tag(ref).present? tag = project.repository.find_tag(ref).present?
ci_commit = project.ci_commits.create(sha: commit.sha, ref: ref, tag: tag) ci_commit = project.pipelines.create(sha: commit.sha, ref: ref, tag: tag)
trigger_request = trigger.trigger_requests.create!( trigger_request = trigger.trigger_requests.create!(
variables: variables, variables: variables,
......
...@@ -3,7 +3,7 @@ module Ci ...@@ -3,7 +3,7 @@ module Ci
def execute(project, opts) def execute(project, opts)
sha = opts[:sha] || ref_sha(project, opts[:ref]) sha = opts[:sha] || ref_sha(project, opts[:ref])
ci_commits = project.ci_commits.where(sha: sha) ci_commits = project.pipelines.where(sha: sha)
ci_commits = ci_commits.where(ref: opts[:ref]) if opts[:ref] ci_commits = ci_commits.where(ref: opts[:ref]) if opts[:ref]
image_name = image_for_status(ci_commits.status) image_name = image_for_status(ci_commits.status)
......
...@@ -18,7 +18,7 @@ class CreateCommitBuildsService ...@@ -18,7 +18,7 @@ class CreateCommitBuildsService
return false return false
end end
commit = Ci::Commit.new(project: project, sha: sha, ref: ref, before_sha: before_sha, tag: tag) commit = Ci::Pipeline.new(project: project, sha: sha, ref: ref, before_sha: before_sha, tag: tag)
# Skip creating ci_commit when no gitlab-ci.yml is found # Skip creating ci_commit when no gitlab-ci.yml is found
unless commit.ci_yaml_file unless commit.ci_yaml_file
......
...@@ -55,12 +55,12 @@ module MergeRequests ...@@ -55,12 +55,12 @@ module MergeRequests
def each_merge_request(commit_status) def each_merge_request(commit_status)
merge_request_from(commit_status).each do |merge_request| merge_request_from(commit_status).each do |merge_request|
ci_commit = merge_request.ci_commit pipeline = merge_request.pipeline
next unless ci_commit next unless pipeline
next unless ci_commit.sha == commit_status.sha next unless pipeline.sha == commit_status.sha
yield merge_request, ci_commit yield merge_request, pipeline
end end
end end
end end
......
...@@ -169,7 +169,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps ...@@ -169,7 +169,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end end
step 'repository contains ".gitlab-ci.yml" file' do step 'repository contains ".gitlab-ci.yml" file' do
allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file).and_return(String.new) allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(String.new)
end end
step 'I see commit ci info' do step 'I see commit ci info' do
......
...@@ -50,7 +50,7 @@ module API ...@@ -50,7 +50,7 @@ module API
commit = @project.commit(params[:sha]) commit = @project.commit(params[:sha])
not_found! 'Commit' unless commit not_found! 'Commit' unless commit
# Since the CommitStatus is attached to Ci::Commit (in the future Pipeline) # Since the CommitStatus is attached to Ci::Pipeline (in the future Pipeline)
# We need to always have the pipeline object # We need to always have the pipeline object
# To have a valid pipeline object that can be attached to specific MR # To have a valid pipeline object that can be attached to specific MR
# Other CI service needs to send `ref` # Other CI service needs to send `ref`
......
...@@ -238,7 +238,7 @@ module API ...@@ -238,7 +238,7 @@ module API
should_remove_source_branch: params[:should_remove_source_branch] should_remove_source_branch: params[:should_remove_source_branch]
} }
if parse_boolean(params[:merge_when_build_succeeds]) && merge_request.ci_commit && merge_request.ci_commit.active? if parse_boolean(params[:merge_when_build_succeeds]) && merge_request.pipeline && merge_request.pipeline.active?
::MergeRequests::MergeWhenBuildSucceedsService.new(merge_request.target_project, current_user, merge_params). ::MergeRequests::MergeWhenBuildSucceedsService.new(merge_request.target_project, current_user, merge_params).
execute(merge_request) execute(merge_request)
else else
......
...@@ -60,7 +60,7 @@ module Ci ...@@ -60,7 +60,7 @@ module Ci
class BuildTime < Chart class BuildTime < Chart
def collect def collect
commits = project.ci_commits.last(30) commits = project.pipelines.last(30)
commits.each do |commit| commits.each do |commit|
@labels << commit.short_sha @labels << commit.short_sha
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# #
FactoryGirl.define do FactoryGirl.define do
factory :ci_empty_commit, class: Ci::Commit do factory :ci_empty_commit, class: Ci::Pipeline do
sha '97de212e80737a608d939f648d959671fb0a0142' sha '97de212e80737a608d939f648d959671fb0a0142'
project factory: :empty_project project factory: :empty_project
......
...@@ -167,7 +167,7 @@ describe "Pipelines" do ...@@ -167,7 +167,7 @@ describe "Pipelines" do
context 'with gitlab-ci.yml' do context 'with gitlab-ci.yml' do
before { stub_ci_commit_to_return_yaml_file } before { stub_ci_commit_to_return_yaml_file }
it { expect{ click_on 'Create pipeline' }.to change{ Ci::Commit.count }.by(1) } it { expect{ click_on 'Create pipeline' }.to change{ Ci::Pipeline.count }.by(1) }
end end
context 'without gitlab-ci.yml' do context 'without gitlab-ci.yml' do
......
...@@ -3,8 +3,8 @@ require 'spec_helper' ...@@ -3,8 +3,8 @@ require 'spec_helper'
describe CiStatusHelper do describe CiStatusHelper do
include IconsHelper include IconsHelper
let(:success_commit) { double("Ci::Commit", status: 'success') } let(:success_commit) { double("Ci::Pipeline", status: 'success') }
let(:failed_commit) { double("Ci::Commit", status: 'failed') } let(:failed_commit) { double("Ci::Pipeline", status: 'failed') }
describe 'ci_icon_for_status' do describe 'ci_icon_for_status' do
it { expect(helper.ci_icon_for_status(success_commit.status)).to include('fa-check') } it { expect(helper.ci_icon_for_status(success_commit.status)).to include('fa-check') }
......
...@@ -5,7 +5,7 @@ describe MergeRequestsHelper do ...@@ -5,7 +5,7 @@ describe MergeRequestsHelper do
let(:project) { create :project } let(:project) { create :project }
let(:merge_request) { MergeRequest.new } let(:merge_request) { MergeRequest.new }
let(:ci_service) { CiService.new } let(:ci_service) { CiService.new }
let(:last_commit) { Ci::Commit.new({}) } let(:last_commit) { Ci::Pipeline.new({}) }
before do before do
allow(merge_request).to receive(:source_project).and_return(project) allow(merge_request).to receive(:source_project).and_return(project)
......
require 'spec_helper' require 'spec_helper'
describe Ci::Commit, models: true do describe Ci::Pipeline, models: true do
let(:project) { FactoryGirl.create :empty_project } let(:project) { FactoryGirl.create :empty_project }
let(:commit) { FactoryGirl.create :ci_commit, project: project } let(:commit) { FactoryGirl.create :ci_commit, project: project }
......
...@@ -402,7 +402,7 @@ describe MergeRequest, models: true do ...@@ -402,7 +402,7 @@ describe MergeRequest, models: true do
with('123abc', 'master'). with('123abc', 'master').
and_return(ci_commit) and_return(ci_commit)
expect(subject.ci_commit).to eq(ci_commit) expect(subject.pipeline).to eq(ci_commit)
end end
end end
...@@ -410,7 +410,7 @@ describe MergeRequest, models: true do ...@@ -410,7 +410,7 @@ describe MergeRequest, models: true do
it 'returns nil' do it 'returns nil' do
allow(subject).to receive(:source_project).and_return(nil) allow(subject).to receive(:source_project).and_return(nil)
expect(subject.ci_commit).to be_nil expect(subject.pipeline).to be_nil
end end
end end
end end
......
...@@ -403,7 +403,7 @@ describe Project, models: true do ...@@ -403,7 +403,7 @@ describe Project, models: true do
let(:project) { create :project } let(:project) { create :project }
let(:commit) { create :ci_commit, project: project, ref: 'master' } let(:commit) { create :ci_commit, project: project, ref: 'master' }
subject { project.ci_commit(commit.sha, 'master') } subject { project.pipeline(commit.sha, 'master') }
it { is_expected.to eq(commit) } it { is_expected.to eq(commit) }
......
...@@ -16,8 +16,8 @@ describe API::CommitStatuses, api: true do ...@@ -16,8 +16,8 @@ describe API::CommitStatuses, api: true do
let(:get_url) { "/projects/#{project.id}/repository/commits/#{sha}/statuses" } let(:get_url) { "/projects/#{project.id}/repository/commits/#{sha}/statuses" }
context 'ci commit exists' do context 'ci commit exists' do
let!(:master) { project.ci_commits.create(sha: commit.id, ref: 'master') } let!(:master) { project.pipelines.create(sha: commit.id, ref: 'master') }
let!(:develop) { project.ci_commits.create(sha: commit.id, ref: 'develop') } let!(:develop) { project.pipelines.create(sha: commit.id, ref: 'develop') }
it_behaves_like 'a paginated resources' do it_behaves_like 'a paginated resources' do
let(:request) { get api(get_url, reporter) } let(:request) { get api(get_url, reporter) }
......
...@@ -388,7 +388,7 @@ describe API::API, api: true do ...@@ -388,7 +388,7 @@ describe API::API, api: true do
end end
describe "PUT /projects/:id/merge_requests/:merge_request_id/merge" do describe "PUT /projects/:id/merge_requests/:merge_request_id/merge" do
let(:ci_commit) { create(:ci_commit_without_jobs) } let(:pipeline) { create(:ci_commit_without_jobs) }
it "should return merge_request in case of success" do it "should return merge_request in case of success" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
...@@ -429,7 +429,7 @@ describe API::API, api: true do ...@@ -429,7 +429,7 @@ describe API::API, api: true do
end end
it "enables merge when build succeeds if the ci is active" do it "enables merge when build succeeds if the ci is active" do
allow_any_instance_of(MergeRequest).to receive(:ci_commit).and_return(ci_commit) allow_any_instance_of(MergeRequest).to receive(:pipeline).and_return(pipeline)
allow(ci_commit).to receive(:active?).and_return(true) allow(ci_commit).to receive(:active?).and_return(true)
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), merge_when_build_succeeds: true put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), merge_when_build_succeeds: true
......
...@@ -44,7 +44,7 @@ describe API::API do ...@@ -44,7 +44,7 @@ describe API::API do
end end
context 'Have a commit' do context 'Have a commit' do
let(:commit) { project.ci_commits.last } let(:commit) { project.pipelines.last }
it 'should create builds' do it 'should create builds' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'master') post api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'master')
......
...@@ -36,7 +36,7 @@ describe Ci::API::API do ...@@ -36,7 +36,7 @@ describe Ci::API::API do
end end
context 'Have a commit' do context 'Have a commit' do
let(:commit) { project.ci_commits.last } let(:commit) { project.pipelines.last }
it 'should create builds' do it 'should create builds' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options
......
...@@ -20,10 +20,10 @@ describe CreateCommitBuildsService, services: true do ...@@ -20,10 +20,10 @@ describe CreateCommitBuildsService, services: true do
) )
end end
it { expect(commit).to be_kind_of(Ci::Commit) } it { expect(commit).to be_kind_of(Ci::Pipeline) }
it { expect(commit).to be_valid } it { expect(commit).to be_valid }
it { expect(commit).to be_persisted } it { expect(commit).to be_persisted }
it { expect(commit).to eq(project.ci_commits.last) } it { expect(commit).to eq(project.pipelines.last) }
it { expect(commit.builds.first).to be_kind_of(Ci::Build) } it { expect(commit.builds.first).to be_kind_of(Ci::Build) }
end end
...@@ -61,12 +61,12 @@ describe CreateCommitBuildsService, services: true do ...@@ -61,12 +61,12 @@ describe CreateCommitBuildsService, services: true do
commits: [{ message: 'Message' }] commits: [{ message: 'Message' }]
) )
expect(result).to be_falsey expect(result).to be_falsey
expect(Ci::Commit.count).to eq(0) expect(Ci::Pipeline.count).to eq(0)
end end
it 'fails commits if yaml is invalid' do it 'fails commits if yaml is invalid' do
message = 'message' message = 'message'
allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { message } allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { message }
stub_ci_commit_yaml_file('invalid: file: file') stub_ci_commit_yaml_file('invalid: file: file')
commits = [{ message: message }] commits = [{ message: message }]
commit = service.execute(project, user, commit = service.execute(project, user,
...@@ -85,7 +85,7 @@ describe CreateCommitBuildsService, services: true do ...@@ -85,7 +85,7 @@ describe CreateCommitBuildsService, services: true do
let(:message) { "some message[ci skip]" } let(:message) { "some message[ci skip]" }
before do before do
allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { message } allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { message }
end end
it "skips builds creation if there is [ci skip] tag in commit message" do it "skips builds creation if there is [ci skip] tag in commit message" do
...@@ -102,7 +102,7 @@ describe CreateCommitBuildsService, services: true do ...@@ -102,7 +102,7 @@ describe CreateCommitBuildsService, services: true do
end end
it "does not skips builds creation if there is no [ci skip] tag in commit message" do it "does not skips builds creation if there is no [ci skip] tag in commit message" do
allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { "some message" } allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { "some message" }
commits = [{ message: "some message" }] commits = [{ message: "some message" }]
commit = service.execute(project, user, commit = service.execute(project, user,
...@@ -133,7 +133,7 @@ describe CreateCommitBuildsService, services: true do ...@@ -133,7 +133,7 @@ describe CreateCommitBuildsService, services: true do
end end
it "skips build creation if there are already builds" do it "skips build creation if there are already builds" do
allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file) { gitlab_ci_yaml } allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file) { gitlab_ci_yaml }
commits = [{ message: "message" }] commits = [{ message: "message" }]
commit = service.execute(project, user, commit = service.execute(project, user,
......
...@@ -116,7 +116,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do ...@@ -116,7 +116,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
before do before do
# This behavior of MergeRequest: we instantiate a new object # This behavior of MergeRequest: we instantiate a new object
allow_any_instance_of(MergeRequest).to receive(:ci_commit).and_wrap_original do allow_any_instance_of(MergeRequest).to receive(:ci_commit).and_wrap_original do
Ci::Commit.find(ci_commit.id) Ci::Pipeline.find(ci_commit.id)
end end
# We create test after the build # We create test after the build
......
...@@ -18,7 +18,7 @@ module StubGitlabCalls ...@@ -18,7 +18,7 @@ module StubGitlabCalls
end end
def stub_ci_commit_yaml_file(ci_yaml) def stub_ci_commit_yaml_file(ci_yaml)
allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file) { ci_yaml } allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file) { ci_yaml }
end end
def stub_ci_builds_disabled def stub_ci_builds_disabled
......
...@@ -52,16 +52,16 @@ describe PostReceive do ...@@ -52,16 +52,16 @@ describe PostReceive do
context "gitlab-ci.yml" do context "gitlab-ci.yml" do
subject { PostReceive.new.perform(pwd(project), key_id, base64_changes) } subject { PostReceive.new.perform(pwd(project), key_id, base64_changes) }
context "creates a Ci::Commit for every change" do context "creates a Ci::Pipeline for every change" do
before { stub_ci_commit_to_return_yaml_file } before { stub_ci_commit_to_return_yaml_file }
it { expect{ subject }.to change{ Ci::Commit.count }.by(2) } it { expect{ subject }.to change{ Ci::Pipeline.count }.by(2) }
end end
context "does not create a Ci::Commit" do context "does not create a Ci::Pipeline" do
before { stub_ci_commit_yaml_file(nil) } before { stub_ci_commit_yaml_file(nil) }
it { expect{ subject }.not_to change{ Ci::Commit.count } } it { expect{ subject }.not_to change{ Ci::Pipeline.count } }
end end
end end
end end
......
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