Rename latest_success* to latest_successful:
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_13164642
This commit is contained in:
parent
0538e1e934
commit
85ceb8b72f
|
|
@ -60,7 +60,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
|
|||
|
||||
def build_from_ref
|
||||
if params[:ref_name]
|
||||
builds = project.latest_success_builds_for(params[:ref_name])
|
||||
builds = project.latest_successful_builds_for(params[:ref_name])
|
||||
|
||||
builds.find_by(name: params[:job])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module Ci
|
|||
scope :with_artifacts, ->() { where.not(artifacts_file: nil) }
|
||||
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) }
|
||||
scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
|
||||
scope :latest_success_with_artifacts, ->() do
|
||||
scope :latest_successful_with_artifacts, ->() do
|
||||
with_artifacts.success.order(id: :desc)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# ref can't be HEAD, can only be branch/tag name or SHA
|
||||
def latest_success_pipeline_for(ref = 'master')
|
||||
def latest_successful_pipeline_for(ref = 'master')
|
||||
table = Ci::Pipeline.quoted_table_name
|
||||
# TODO: Use `where(ref: ref).or(sha: ref)` in Rails 5
|
||||
pipelines.where("#{table}.ref = ? OR #{table}.sha = ?", ref, ref).
|
||||
|
|
@ -438,10 +438,10 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# ref can't be HEAD, can only be branch/tag name or SHA
|
||||
def latest_success_builds_for(ref = 'master')
|
||||
def latest_successful_builds_for(ref = 'master')
|
||||
Ci::Build.joins(:pipeline).
|
||||
merge(latest_success_pipeline_for(ref)).
|
||||
latest_success_with_artifacts
|
||||
merge(latest_successful_pipeline_for(ref)).
|
||||
latest_successful_with_artifacts
|
||||
end
|
||||
|
||||
def merge_base_commit(first_commit_id, second_commit_id)
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@
|
|||
= link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: branch.name), class: 'btn btn-default', method: :post, title: "Compare" do
|
||||
Compare
|
||||
|
||||
- pipeline = @project.latest_success_pipeline_for(branch.name).first
|
||||
- pipeline = @project.latest_successful_pipeline_for(branch.name).first
|
||||
- if pipeline
|
||||
- artifacts = pipeline.builds.latest_success_with_artifacts
|
||||
- artifacts = pipeline.builds.latest_successful_with_artifacts
|
||||
- if artifacts.any?
|
||||
.dropdown.inline.artifacts-btn
|
||||
%a.btn.dropdown-toggle{ 'data-toggle' => 'dropdown' }
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
%li
|
||||
= link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: @ref, format: 'tar.gz'), rel: 'nofollow' do
|
||||
%span Download tar.gz
|
||||
- pipeline = @project.latest_success_pipeline_for(@ref).first
|
||||
- pipeline = @project.latest_successful_pipeline_for(@ref).first
|
||||
- if pipeline
|
||||
- artifacts = pipeline.builds.latest_success_with_artifacts
|
||||
- artifacts = pipeline.builds.latest_successful_with_artifacts
|
||||
- if artifacts.any?
|
||||
%li.dropdown-header Artifacts
|
||||
- unless pipeline.latest?
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
= link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: ref, format: 'tar'), rel: 'nofollow' do
|
||||
%i.fa.fa-download
|
||||
%span Download tar
|
||||
- pipeline = @project.latest_success_pipeline_for(ref).first
|
||||
- pipeline = @project.latest_successful_pipeline_for(ref).first
|
||||
- if pipeline
|
||||
- artifacts = pipeline.builds.latest_success_with_artifacts
|
||||
- artifacts = pipeline.builds.latest_successful_with_artifacts
|
||||
- if artifacts.any?
|
||||
%li.dropdown-header Artifacts
|
||||
- unless pipeline.latest?
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
%li
|
||||
= link_to archive_namespace_project_repository_path(project.namespace, project, ref: ref, format: 'tar.gz'), rel: 'nofollow' do
|
||||
%span Download tar.gz
|
||||
- pipeline = project.latest_success_pipeline_for(ref).first
|
||||
- pipeline = project.latest_successful_pipeline_for(ref).first
|
||||
- if pipeline
|
||||
- artifacts = pipeline.builds.latest_success_with_artifacts
|
||||
- artifacts = pipeline.builds.latest_successful_with_artifacts
|
||||
- if artifacts.any?
|
||||
%li.dropdown-header Artifacts
|
||||
- unless pipeline.latest?
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ module API
|
|||
# GET /projects/:id/artifacts/:ref_name/download?job=name
|
||||
get ':id/builds/artifacts/:ref_name/download',
|
||||
requirements: { ref_name: /.+/ } do
|
||||
builds = user_project.latest_success_builds_for(params[:ref_name])
|
||||
builds = user_project.latest_successful_builds_for(params[:ref_name])
|
||||
latest_build = builds.find_by!(name: params[:job])
|
||||
|
||||
present_artifact!(latest_build.artifacts_file)
|
||||
|
|
|
|||
|
|
@ -678,7 +678,7 @@ describe Ci::Build, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Project#latest_success_builds_for' do
|
||||
describe 'Project#latest_successful_builds_for' do
|
||||
let(:build) do
|
||||
create(:ci_build, :artifacts, :success, pipeline: pipeline)
|
||||
end
|
||||
|
|
@ -689,13 +689,13 @@ describe Ci::Build, models: true do
|
|||
|
||||
context 'with succeed pipeline' do
|
||||
it 'returns builds from ref' do
|
||||
builds = project.latest_success_builds_for('fix')
|
||||
builds = project.latest_successful_builds_for('fix')
|
||||
|
||||
expect(builds).to contain_exactly(build)
|
||||
end
|
||||
|
||||
it 'returns empty relation if the build cannot be found' do
|
||||
builds = project.latest_success_builds_for('TAIL').all
|
||||
builds = project.latest_successful_builds_for('TAIL').all
|
||||
|
||||
expect(builds).to be_empty
|
||||
end
|
||||
|
|
@ -707,7 +707,7 @@ describe Ci::Build, models: true do
|
|||
end
|
||||
|
||||
it 'returns empty relation' do
|
||||
builds = project.latest_success_builds_for('fix').all
|
||||
builds = project.latest_successful_builds_for('fix').all
|
||||
|
||||
expect(builds).to be_empty
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue