mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-16 16:16:43 +10:00
Fix specs
This commit is contained in:
@@ -92,16 +92,11 @@ class CommitStatus < ActiveRecord::Base
|
||||
|
||||
def self.stages
|
||||
# We group by stage name, but order stages by theirs' index
|
||||
unscoped.from(all, :sg).group('stage').order('max(stage_idx)', 'stage').pluck('sg.stage')
|
||||
unscoped.where(id: all).group('stage').order('max(stage_idx)', 'stage').pluck('stage')
|
||||
end
|
||||
|
||||
def self.stages_status
|
||||
# We execute subquery for each stage to calculate a stage status
|
||||
statuses = unscoped.from(all, :sg).group('stage').pluck('sg.stage', all.where('stage=sg.stage').status_sql)
|
||||
statuses.inject({}) do |h, k|
|
||||
h[k.first] = k.last
|
||||
h
|
||||
end
|
||||
def self.status_for_stage(stage)
|
||||
where(stage: stage).status
|
||||
end
|
||||
|
||||
def ignored?
|
||||
|
||||
@@ -354,7 +354,7 @@ class Project < ActiveRecord::Base
|
||||
join_body = "INNER JOIN (
|
||||
SELECT project_id, COUNT(*) AS amount
|
||||
FROM notes
|
||||
WHERE created_at >= #{sanitize(since)}project.ci_commits
|
||||
WHERE created_at >= #{sanitize(since)}
|
||||
GROUP BY project_id
|
||||
) join_note_counts ON projects.id = join_note_counts.project_id"
|
||||
|
||||
|
||||
@@ -31,10 +31,9 @@
|
||||
Cant find HEAD commit for this branch
|
||||
|
||||
|
||||
- stages_status = commit.statuses.stages_status
|
||||
- stages.each do |stage|
|
||||
%td
|
||||
- if status = stages_status[stage]
|
||||
- if status = commit.statuses.status_for_stage(stage)
|
||||
- tooltip = "#{stage.titleize}: #{status}"
|
||||
%span.has-tooltip(title="#{tooltip}"){class: "ci-status-icon-#{status}"}
|
||||
= ci_icon_for_status(status)
|
||||
|
||||
@@ -52,15 +52,15 @@ describe "Pipelines" do
|
||||
before { click_link('Retry') }
|
||||
|
||||
it { expect(page).to_not have_link('Retry') }
|
||||
it { expect(page).to have_selector('.ci-running') }
|
||||
it { expect(page).to have_selector('.ci-pending') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'downloadable pipelines' do
|
||||
before { visit namespace_project_pipelines_path(project.namespace, project) }
|
||||
|
||||
context 'with artifacts' do
|
||||
let!(:with_artifacts) { create(:ci_build, :success, :artifacts, commit: pipeline, name: 'rspec tests', stage: 'test') }
|
||||
let!(:with_artifacts) { create(:ci_build, :artifacts, :success, commit: pipeline, name: 'rspec tests', stage: 'test') }
|
||||
|
||||
before { visit namespace_project_pipelines_path(project.namespace, project) }
|
||||
|
||||
it { expect(page).to have_selector('.build-artifacts') }
|
||||
it { expect(page).to have_link(with_artifacts.name) }
|
||||
@@ -78,10 +78,10 @@ describe "Pipelines" do
|
||||
let(:pipeline) { create(:ci_commit, project: project, ref: 'master') }
|
||||
|
||||
before do
|
||||
@success = create(:ci_build, :success, commit: pipeline, stage: 'build')
|
||||
@failed = create(:ci_build, :failed, commit: pipeline, stage: 'test', commands: 'test')
|
||||
@running = create(:ci_build, :running, commit: pipeline, stage: 'deploy')
|
||||
@external = create(:generic_commit_status, :success, commit: pipeline, stage: 'external')
|
||||
@success = create(:ci_build, :success, commit: pipeline, stage: 'build', name: 'build')
|
||||
@failed = create(:ci_build, :failed, commit: pipeline, stage: 'test', name: 'test', commands: 'test')
|
||||
@running = create(:ci_build, :running, commit: pipeline, stage: 'deploy', name: 'deploy')
|
||||
@external = create(:generic_commit_status, status: 'success', commit: pipeline, name: 'jenkins', stage: 'external')
|
||||
end
|
||||
|
||||
before { visit namespace_project_pipeline_path(project.namespace, project, pipeline) }
|
||||
@@ -126,7 +126,10 @@ describe "Pipelines" do
|
||||
before { visit new_namespace_project_pipeline_path(project.namespace, project) }
|
||||
|
||||
context 'for valid commit' do
|
||||
before { fill_in('Create for', with: 'master') }
|
||||
before do
|
||||
fill_in('Create for', with: 'master')
|
||||
stub_ci_commit_to_return_yaml_file
|
||||
end
|
||||
|
||||
it { expect{ click_on 'Create pipeline' }.to change{ Ci::Commit.count }.by(1) }
|
||||
end
|
||||
|
||||
@@ -219,17 +219,5 @@ describe CommitStatus, models: true do
|
||||
is_expected.to eq(%w(build test deploy))
|
||||
end
|
||||
end
|
||||
|
||||
context 'stages with statuses' do
|
||||
subject { CommitStatus.where(commit: commit).stages_status }
|
||||
|
||||
it 'return list of stages with statuses' do
|
||||
is_expected.to eq({
|
||||
'build' => 'failed',
|
||||
'test' => 'success',
|
||||
'deploy' => 'running'
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user