Commit 4d5f7aa0 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix more places where we should rename ci_commit to pipeline

parent bcd009e6
......@@ -8,7 +8,7 @@ module Ci
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id
has_many :builds, class_name: 'Ci::Build', foreign_key: :commit_id
has_many :trigger_requests, dependent: :destroy, class_name: 'Ci::TriggerRequest'
has_many :trigger_requests, dependent: :destroy, class_name: 'Ci::TriggerRequest', foreign_key: :commit_id
validates_presence_of :sha
validates_presence_of :status
......
......@@ -3,7 +3,7 @@ module Ci
extend Ci::Model
belongs_to :trigger, class_name: 'Ci::Trigger'
belongs_to :commit, class_name: 'Ci::Pipeline'
belongs_to :commit, class_name: 'Ci::Pipeline', foreign_key: :commit_id
has_many :builds, class_name: 'Ci::Build'
serialize :variables
......
......@@ -219,7 +219,7 @@ describe Ci::Build, models: true do
context 'and trigger variables' do
let(:trigger) { create(:ci_trigger, project: project) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: commit, trigger: trigger) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, commit: commit, trigger: trigger) }
let(:trigger_variables) do
[
{ key: :TRIGGER_KEY, value: 'TRIGGER_VALUE', public: false }
......
......@@ -334,7 +334,7 @@ describe Ci::Pipeline, models: true do
describe '#stages' do
let(:commit2) { FactoryGirl.create :ci_commit, project: project }
subject { CommitStatus.where(commit: [commit, commit2]).stages }
subject { CommitStatus.where(pipeline: [commit, commit2]).stages }
before do
FactoryGirl.create :ci_build, pipeline: commit2, stage: 'test', stage_idx: 1
......
......@@ -4,15 +4,15 @@ describe CommitStatus, models: true do
let(:commit) { FactoryGirl.create :ci_commit }
let(:commit_status) { FactoryGirl.create :commit_status, pipeline: commit }
it { is_expected.to belong_to(:commit) }
it { is_expected.to belong_to(:pipeline) }
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:project) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_inclusion_of(:status).in_array(%w(pending running failed success canceled)) }
it { is_expected.to delegate_method(:sha).to(:commit) }
it { is_expected.to delegate_method(:short_sha).to(:commit) }
it { is_expected.to delegate_method(:sha).to(:pipeline) }
it { is_expected.to delegate_method(:short_sha).to(:pipeline) }
it { is_expected.to respond_to :success? }
it { is_expected.to respond_to :failed? }
......@@ -179,7 +179,7 @@ describe CommitStatus, models: true do
end
context 'stages list' do
subject { CommitStatus.where(commit: commit).stages }
subject { CommitStatus.where(pipeline: commit).stages }
it 'return ordered list of stages' do
is_expected.to eq(%w(build test deploy))
......@@ -187,7 +187,7 @@ describe CommitStatus, models: true do
end
context 'stages with statuses' do
subject { CommitStatus.where(commit: commit).stages_status }
subject { CommitStatus.where(pipeline: commit).stages_status }
it 'return list of stages with statuses' do
is_expected.to eq({
......
......@@ -390,19 +390,19 @@ describe MergeRequest, models: true do
subject { create :merge_request, :simple }
end
describe '#ci_commit' do
describe '#pipeline' do
describe 'when the source project exists' do
it 'returns the latest commit' do
commit = double(:commit, id: '123abc')
ci_commit = double(:ci_commit, ref: 'master')
pipeline = double(:ci_commit, ref: 'master')
allow(subject).to receive(:last_commit).and_return(commit)
expect(subject.source_project).to receive(:ci_commit).
expect(subject.source_project).to receive(:pipeline).
with('123abc', 'master').
and_return(ci_commit)
and_return(pipeline)
expect(subject.pipeline).to eq(ci_commit)
expect(subject.pipeline).to eq(pipeline)
end
end
......
......@@ -22,7 +22,7 @@ describe Project, models: true do
it { is_expected.to have_one(:pushover_service).dependent(:destroy) }
it { is_expected.to have_one(:asana_service).dependent(:destroy) }
it { is_expected.to have_many(:commit_statuses) }
it { is_expected.to have_many(:ci_commits) }
it { is_expected.to have_many(:pipelines) }
it { is_expected.to have_many(:builds) }
it { is_expected.to have_many(:runner_projects) }
it { is_expected.to have_many(:runners) }
......
......@@ -110,8 +110,8 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
context 'properly handles multiple stages' do
let(:ref) { mr_merge_if_green_enabled.source_branch }
let(:build) { create(:ci_build, commit: ci_commit, ref: ref, name: 'build', stage: 'build') }
let(:test) { create(:ci_build, commit: ci_commit, ref: ref, name: 'test', stage: 'test') }
let(:build) { create(:ci_build, pipeline: ci_commit, ref: ref, name: 'build', stage: 'build') }
let(:test) { create(:ci_build, pipeline: ci_commit, ref: ref, name: 'test', stage: 'test') }
before do
# This behavior of MergeRequest: we instantiate a new object
......
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