Commit 9614c522 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix tests offenses: use `pipeline` of Ci::Build and rename views

parent bf2bd237
...@@ -316,7 +316,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -316,7 +316,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff = @merge_request.merge_request_diff @merge_request_diff = @merge_request.merge_request_diff
@pipeline = @merge_request.pipeline @pipeline = @merge_request.pipeline
@statuses = @ci_commit.statuses if @pipeline @statuses = @pipeline.statuses if @pipeline
if @merge_request.locked_long_ago? if @merge_request.locked_long_ago?
@merge_request.unlock_mr @merge_request.unlock_mr
......
...@@ -99,8 +99,8 @@ ...@@ -99,8 +99,8 @@
%td.build-link %td.build-link
- if project - if project
= link_to ci_status_path(build.commit) do = link_to ci_status_path(build.pipeline) do
%strong #{build.commit.short_sha} %strong #{build.pipeline.short_sha}
%td.timestamp %td.timestamp
- if build.finished_at - if build.finished_at
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%p %p
Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.project.namespace, @build.project, @build.sha)} Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.project.namespace, @build.project, @build.sha)}
%p %p
Author: #{@build.commit.git_author_name} Author: #{@build.pipeline.git_author_name}
%p %p
Branch: #{@build.ref} Branch: #{@build.ref}
%p %p
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
%p %p
Job: #{@build.name} Job: #{@build.name}
%p %p
Message: #{@build.commit.git_commit_message} Message: #{@build.pipeline.git_commit_message}
%p %p
Build details: #{link_to "Build #{@build.id}", namespace_project_build_url(@build.project.namespace, @build.project, @build)} Build details: #{link_to "Build #{@build.id}", namespace_project_build_url(@build.project.namespace, @build.project, @build)}
Build failed for <%= @project.name %> Build failed for <%= @project.name %>
Status: <%= @build.status %> Status: <%= @build.status %>
Commit: <%= @build.commit.short_sha %> Commit: <%= @build.pipeline.short_sha %>
Author: <%= @build.commit.git_author_name %> Author: <%= @build.pipeline.git_author_name %>
Branch: <%= @build.ref %> Branch: <%= @build.ref %>
Stage: <%= @build.stage %> Stage: <%= @build.stage %>
Job: <%= @build.name %> Job: <%= @build.name %>
Message: <%= @build.commit.git_commit_message %> Message: <%= @build.pipeline.git_commit_message %>
Url: <%= namespace_project_build_url(@build.project.namespace, @build.project, @build) %> Url: <%= namespace_project_build_url(@build.project.namespace, @build.project, @build) %>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%p %p
Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.project.namespace, @build.project, @build.sha)} Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.project.namespace, @build.project, @build.sha)}
%p %p
Author: #{@build.commit.git_author_name} Author: #{@build.pipeline.git_author_name}
%p %p
Branch: #{@build.ref} Branch: #{@build.ref}
%p %p
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
%p %p
Job: #{@build.name} Job: #{@build.name}
%p %p
Message: #{@build.commit.git_commit_message} Message: #{@build.pipeline.git_commit_message}
%p %p
Build details: #{link_to "Build #{@build.id}", namespace_project_build_url(@build.project.namespace, @build.project, @build)} Build details: #{link_to "Build #{@build.id}", namespace_project_build_url(@build.project.namespace, @build.project, @build)}
Build successful for <%= @project.name %> Build successful for <%= @project.name %>
Status: <%= @build.status %> Status: <%= @build.status %>
Commit: <%= @build.commit.short_sha %> Commit: <%= @build.pipeline.short_sha %>
Author: <%= @build.commit.git_author_name %> Author: <%= @build.pipeline.git_author_name %>
Branch: <%= @build.ref %> Branch: <%= @build.ref %>
Stage: <%= @build.stage %> Stage: <%= @build.stage %>
Job: <%= @build.name %> Job: <%= @build.name %>
Message: <%= @build.commit.git_commit_message %> Message: <%= @build.pipeline.git_commit_message %>
Url: <%= namespace_project_build_url(@build.project.namespace, @build.project, @build) %> Url: <%= namespace_project_build_url(@build.project.namespace, @build.project, @build) %>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.build-page .build-page
.row-content-block.top-block .row-content-block.top-block
Build ##{@build.id} for commit Build ##{@build.id} for commit
%strong.monospace= link_to @build.commit.short_sha, ci_status_path(@build.commit) %strong.monospace= link_to @build.pipeline.short_sha, ci_status_path(@build.pipeline)
from from
= link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref) = link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref)
- merge_request = @build.merge_request - merge_request = @build.merge_request
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= link_to "merge request #{merge_request.to_reference}", merge_request_path(merge_request) = link_to "merge request #{merge_request.to_reference}", merge_request_path(merge_request)
#up-build-trace #up-build-trace
- builds = @build.commit.builds.latest.to_a - builds = @build.pipeline.builds.latest.to_a
- if builds.size > 1 - if builds.size > 1
%ul.nav-links.no-top.no-bottom %ul.nav-links.no-top.no-bottom
- builds.each do |build| - builds.each do |build|
...@@ -178,16 +178,16 @@ ...@@ -178,16 +178,16 @@
Commit Commit
.pull-right .pull-right
%small %small
= link_to @build.commit.short_sha, ci_status_path(@build.commit), class: "monospace" = link_to @build.pipeline.short_sha, ci_status_path(@build.pipeline), class: "monospace"
%p %p
%span.attr-name Branch: %span.attr-name Branch:
= link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref) = link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref)
%p %p
%span.attr-name Author: %span.attr-name Author:
#{@build.commit.git_author_name} #{@build.pipeline.git_author_name}
%p %p
%span.attr-name Message: %span.attr-name Message:
#{@build.commit.git_commit_message} #{@build.pipeline.git_commit_message}
- if @build.tags.any? - if @build.tags.any?
.build-widget .build-widget
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
.build-widget .build-widget
%h4.title #{pluralize(@builds.count(:id), "other build")} for %h4.title #{pluralize(@builds.count(:id), "other build")} for
= succeed ":" do = succeed ":" do
= link_to @build.commit.short_sha, ci_status_path(@build.commit), class: "monospace" = link_to @build.pipeline.short_sha, ci_status_path(@build.pipeline), class: "monospace"
%table.table.builds %table.table.builds
- @builds.each_with_index do |build, i| - @builds.each_with_index do |build, i|
%tr.build %tr.build
......
- status = commit.status - status = pipeline.status
%tr.commit %tr.commit
%td.commit-link %td.commit-link
= link_to namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: "ci-status ci-#{status}" do = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: "ci-status ci-#{status}" do
= ci_icon_for_status(status) = ci_icon_for_status(status)
%strong ##{commit.id} %strong ##{pipeline.id}
%td %td
%div.branch-commit %div.branch-commit
- if commit.ref - if pipeline.ref
= link_to commit.ref, namespace_project_commits_path(@project.namespace, @project, commit.ref), class: "monospace" = link_to pipeline.ref, namespace_project_commits_path(@project.namespace, @project, pipeline.ref), class: "monospace"
&middot; &middot;
= link_to commit.short_sha, namespace_project_commit_path(@project.namespace, @project, commit.sha), class: "commit-id monospace" = link_to pipeline.short_sha, namespace_project_commit_path(@project.namespace, @project, pipeline.sha), class: "commit-id monospace"
&nbsp; &nbsp;
- if commit.tag? - if pipeline.tag?
%span.label.label-primary tag %span.label.label-primary tag
- elsif commit.latest? - elsif pipeline.latest?
%span.label.label-success.has-tooltip{ title: 'Latest build for this branch' } latest %span.label.label-success.has-tooltip{ title: 'Latest build for this branch' } latest
- if commit.triggered? - if pipeline.triggered?
%span.label.label-primary triggered %span.label.label-primary triggered
- if commit.yaml_errors.present? - if pipeline.yaml_errors.present?
%span.label.label-danger.has-tooltip{ title: "#{commit.yaml_errors}" } yaml invalid %span.label.label-danger.has-tooltip{ title: "#{pipeline.yaml_errors}" } yaml invalid
- if commit.builds.any?(&:stuck?) - if pipeline.builds.any?(&:stuck?)
%span.label.label-warning stuck %span.label.label-warning stuck
%p.commit-title %p.commit-title
- if commit_data = commit.commit_data - if commit_data = pipeline.commit_data
= link_to_gfm truncate(commit_data.title, length: 60), namespace_project_commit_path(@project.namespace, @project, commit_data.id), class: "commit-row-message" = link_to_gfm truncate(commit_data.title, length: 60), namespace_project_commit_path(@project.namespace, @project, commit_data.id), class: "commit-row-message"
- else - else
Cant find HEAD commit for this branch Cant find HEAD commit for this branch
- stages_status = commit.statuses.stages_status - stages_status = pipeline.statuses.stages_status
- stages.each do |stage| - stages.each do |stage|
%td %td
- status = stages_status[stage] - status = stages_status[stage]
- tooltip = "#{stage.titleize}: #{status || 'not found'}" - tooltip = "#{stage.titleize}: #{status || 'not found'}"
- if status - if status
= link_to namespace_project_pipeline_path(@project.namespace, @project, commit.id, anchor: stage), class: "has-tooltip ci-status-icon-#{status}", title: tooltip do = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id, anchor: stage), class: "has-tooltip ci-status-icon-#{status}", title: tooltip do
= ci_icon_for_status(status) = ci_icon_for_status(status)
- else - else
.light.has-tooltip{ title: tooltip } .light.has-tooltip{ title: tooltip }
\- \-
%td %td
- if commit.started_at && commit.finished_at - if pipeline.started_at && pipeline.finished_at
%p.duration %p.duration
#{duration_in_words(commit.finished_at, commit.started_at)} #{duration_in_words(pipeline.finished_at, pipeline.started_at)}
%td %td
.controls.hidden-xs.pull-right .controls.hidden-xs.pull-right
- artifacts = commit.builds.latest.select { |b| b.artifacts? } - artifacts = pipeline.builds.latest.select { |b| b.artifacts? }
- if artifacts.present? - if artifacts.present?
.dropdown.inline.build-artifacts .dropdown.inline.build-artifacts
%button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'} %button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'}
...@@ -63,9 +63,9 @@ ...@@ -63,9 +63,9 @@
%span #{build.name} %span #{build.name}
- if can?(current_user, :update_pipeline, @project) - if can?(current_user, :update_pipeline, @project)
- if commit.retryable? - if pipeline.retryable?
= link_to retry_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn has-tooltip', title: "Retry", method: :post do = link_to retry_namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: 'btn has-tooltip', title: "Retry", method: :post do
= icon("repeat") = icon("repeat")
- if commit.cancelable? - if pipeline.cancelable?
= link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do = link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do
= icon("remove") = icon("remove")
...@@ -11,7 +11,7 @@ module SharedBuilds ...@@ -11,7 +11,7 @@ module SharedBuilds
step 'project has a recent build' do step 'project has a recent build' do
@ci_commit = create(:ci_commit, project: @project, sha: @project.commit.sha, ref: 'master') @ci_commit = create(:ci_commit, project: @project, sha: @project.commit.sha, ref: 'master')
@build = create(:ci_build_with_coverage, commit: @ci_commit) @build = create(:ci_build_with_coverage, pipeline: @ci_commit)
end end
step 'recent build is successful' do step 'recent build is successful' do
......
...@@ -443,7 +443,7 @@ describe API::API, api: true do ...@@ -443,7 +443,7 @@ describe API::API, api: true do
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(:pipeline).and_return(pipeline) allow_any_instance_of(MergeRequest).to receive(:pipeline).and_return(pipeline)
allow(ci_commit).to receive(:active?).and_return(true) allow(pipeline).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
......
...@@ -85,7 +85,7 @@ describe Ci::API::API do ...@@ -85,7 +85,7 @@ describe Ci::API::API do
trigger = FactoryGirl.create(:ci_trigger, project: project) trigger = FactoryGirl.create(:ci_trigger, project: project)
commit = FactoryGirl.create(:ci_commit, project: project, ref: 'master') commit = FactoryGirl.create(:ci_commit, project: project, ref: 'master')
trigger_request = FactoryGirl.create(:ci_trigger_request_with_variables, pipeline: commit, trigger: trigger) trigger_request = FactoryGirl.create(:ci_trigger_request_with_variables, commit: commit, trigger: trigger)
commit.create_builds(nil, trigger_request) commit.create_builds(nil, trigger_request)
project.variables << Ci::Variable.new(key: "SECRET_KEY", value: "secret_value") project.variables << Ci::Variable.new(key: "SECRET_KEY", value: "secret_value")
......
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