Skip to content
Snippets Groups Projects
Commit 25b99a5b authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Update tests and application

parent d03e6878
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 18 deletions
Loading
@@ -80,10 +80,6 @@ class Projects::ApplicationController < ApplicationController
Loading
@@ -80,10 +80,6 @@ class Projects::ApplicationController < ApplicationController
cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present? cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present?
end end
   
def builds_enabled
return render_404 unless @project.feature_available?(:builds, current_user)
end
def require_pages_enabled! def require_pages_enabled!
not_found unless Gitlab.config.pages.enabled not_found unless Gitlab.config.pages.enabled
end end
Loading
Loading
Loading
@@ -101,9 +101,10 @@ class GitPushService < BaseService
Loading
@@ -101,9 +101,10 @@ class GitPushService < BaseService
UpdateMergeRequestsWorker UpdateMergeRequestsWorker
.perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref]) .perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref])
   
SystemHookPushWorker.perform_async(build_push_data.dup, :push_hooks)
Ci::CreatePipelineService.new(@project, current_user, build_push_data).execute(:push)
EventCreateService.new.push(@project, current_user, build_push_data) EventCreateService.new.push(@project, current_user, build_push_data)
Ci::CreatePipelineService.new(@project, current_user, build_push_data).execute(:push)
SystemHookPushWorker.perform_async(build_push_data.dup, :push_hooks)
@project.execute_hooks(build_push_data.dup, :push_hooks) @project.execute_hooks(build_push_data.dup, :push_hooks)
@project.execute_services(build_push_data.dup, :push_hooks) @project.execute_services(build_push_data.dup, :push_hooks)
   
Loading
Loading
Loading
@@ -9,9 +9,11 @@ class GitTagPushService < BaseService
Loading
@@ -9,9 +9,11 @@ class GitTagPushService < BaseService
   
EventCreateService.new.push(project, current_user, @push_data) EventCreateService.new.push(project, current_user, @push_data)
Ci::CreatePipelineService.new(project, current_user, @push_data).execute(:push) Ci::CreatePipelineService.new(project, current_user, @push_data).execute(:push)
SystemHooksService.new.execute_hooks(build_system_push_data.dup, :tag_push_hooks) SystemHooksService.new.execute_hooks(build_system_push_data.dup, :tag_push_hooks)
project.execute_hooks(@push_data.dup, :tag_push_hooks) project.execute_hooks(@push_data.dup, :tag_push_hooks)
project.execute_services(@push_data.dup, :tag_push_hooks) project.execute_services(@push_data.dup, :tag_push_hooks)
ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size]) ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size])
   
true true
Loading
Loading
---
title: Fix support for external CI services
merge_request: 11176
author:
Loading
@@ -4,7 +4,7 @@ module Gitlab
Loading
@@ -4,7 +4,7 @@ module Gitlab
module External module External
module Common module Common
def label def label
subject.description || super subject.description
end end
   
def has_details? def has_details?
Loading
Loading
Loading
@@ -5,9 +5,12 @@ describe Projects::PipelinesController do
Loading
@@ -5,9 +5,12 @@ describe Projects::PipelinesController do
   
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:empty_project, :public) } let(:project) { create(:empty_project, :public) }
let(:feature) { ProjectFeature::DISABLED }
   
before do before do
project.add_developer(user) project.add_developer(user)
project.project_feature.update(
builds_access_level: feature)
   
sign_in(user) sign_in(user)
end end
Loading
@@ -153,16 +156,26 @@ describe Projects::PipelinesController do
Loading
@@ -153,16 +156,26 @@ describe Projects::PipelinesController do
format: :json format: :json
end end
   
it 'retries a pipeline without returning any content' do context 'when builds are enabled' do
expect(response).to have_http_status(:no_content) let(:feature) { ProjectFeature::ENABLED }
expect(build.reload).to be_retried
it 'retries a pipeline without returning any content' do
expect(response).to have_http_status(:no_content)
expect(build.reload).to be_retried
end
end
context 'when builds are disabled' do
it 'fails to retry pipeline' do
expect(response).to have_http_status(:not_found)
end
end end
end end
   
describe 'POST cancel.json' do describe 'POST cancel.json' do
let!(:pipeline) { create(:ci_pipeline, project: project) } let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :running, pipeline: pipeline) } let!(:build) { create(:ci_build, :running, pipeline: pipeline) }
before do before do
post :cancel, namespace_id: project.namespace, post :cancel, namespace_id: project.namespace,
project_id: project, project_id: project,
Loading
@@ -170,9 +183,19 @@ describe Projects::PipelinesController do
Loading
@@ -170,9 +183,19 @@ describe Projects::PipelinesController do
format: :json format: :json
end end
   
it 'cancels a pipeline without returning any content' do context 'when builds are enabled' do
expect(response).to have_http_status(:no_content) let(:feature) { ProjectFeature::ENABLED }
expect(pipeline.reload).to be_canceled
it 'cancels a pipeline without returning any content' do
expect(response).to have_http_status(:no_content)
expect(pipeline.reload).to be_canceled
end
end
context 'when builds are disabled' do
it 'fails to retry pipeline' do
expect(response).to have_http_status(:not_found)
end
end end
end end
end end
Loading
@@ -68,9 +68,12 @@ describe 'Edit Project Settings', feature: true do
Loading
@@ -68,9 +68,12 @@ describe 'Edit Project Settings', feature: true do
end end
   
describe 'project features visibility pages' do describe 'project features visibility pages' do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, pipeline: pipeline) }
let(:tools) do let(:tools) do
{ {
builds: namespace_project_pipelines_path(project.namespace, project), builds: namespace_project_job_path(project.namespace, project, job),
issues: namespace_project_issues_path(project.namespace, project), issues: namespace_project_issues_path(project.namespace, project),
wiki: namespace_project_wiki_path(project.namespace, project, :home), wiki: namespace_project_wiki_path(project.namespace, project, :home),
snippets: namespace_project_snippets_path(project.namespace, project), snippets: namespace_project_snippets_path(project.namespace, project),
Loading
Loading
Loading
@@ -300,4 +300,37 @@ describe ProjectsHelper do
Loading
@@ -300,4 +300,37 @@ describe ProjectsHelper do
expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Private') expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Private')
end end
end end
describe '#get_project_nav_tabs' do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
before do
allow(helper).to receive(:can?) { true }
end
subject do
helper.send(:get_project_nav_tabs, project, user)
end
context 'when builds feature is enabled' do
before do
allow(project).to receive(:builds_enabled?).and_return(true)
end
it "does include pipelines tab" do
is_expected.to include(:pipelines)
end
end
context 'when builds feature is disabled' do
before do
allow(project).to receive(:builds_enabled?).and_return(false)
end
it "do not include pipelines tab" do
is_expected.not_to include(:pipelines)
end
end
end
end end
Loading
@@ -4,9 +4,10 @@ describe Gitlab::Ci::Status::External::Common do
Loading
@@ -4,9 +4,10 @@ describe Gitlab::Ci::Status::External::Common do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { external_status.project } let(:project) { external_status.project }
let(:external_target_url) { 'http://example.gitlab.com/status' } let(:external_target_url) { 'http://example.gitlab.com/status' }
let(:external_description) { 'my description' }
   
let(:external_status) do let(:external_status) do
create(:generic_commit_status, target_url: external_target_url) create(:generic_commit_status, target_url: external_target_url, description: external_description)
end end
   
subject do subject do
Loading
@@ -15,6 +16,12 @@ describe Gitlab::Ci::Status::External::Common do
Loading
@@ -15,6 +16,12 @@ describe Gitlab::Ci::Status::External::Common do
.extend(described_class) .extend(described_class)
end end
   
describe '#label' do
it 'returns description' do
expect(subject.label).to eq external_description
end
end
describe '#has_action?' do describe '#has_action?' do
it { is_expected.not_to have_action } it { is_expected.not_to have_action }
end end
Loading
Loading
Loading
@@ -139,6 +139,18 @@ describe ProjectPolicy, models: true do
Loading
@@ -139,6 +139,18 @@ describe ProjectPolicy, models: true do
is_expected.not_to include(:read_build, :read_pipeline) is_expected.not_to include(:read_build, :read_pipeline)
end end
end end
context 'when builds are disabled' do
before do
project.project_feature.update(
builds_access_level: ProjectFeature::DISABLED)
end
it do
is_expected.not_to include(:read_build)
is_expected.to include(:read_pipeline)
end
end
end end
   
context 'reporter' do context 'reporter' do
Loading
Loading
Loading
@@ -39,7 +39,7 @@ describe JobEntity do
Loading
@@ -39,7 +39,7 @@ describe JobEntity do
expect(subject[:status]).to include :icon, :favicon, :text, :label expect(subject[:status]).to include :icon, :favicon, :text, :label
end end
   
context 'when build is retryable' do context 'when job is retryable' do
before do before do
job.update(status: :failed) job.update(status: :failed)
end end
Loading
@@ -49,7 +49,7 @@ describe JobEntity do
Loading
@@ -49,7 +49,7 @@ describe JobEntity do
end end
end end
   
context 'when build is cancelable' do context 'when job is cancelable' do
before do before do
job.update(status: :running) job.update(status: :running)
end end
Loading
Loading
Loading
@@ -91,6 +91,20 @@ describe PipelineDetailsEntity do
Loading
@@ -91,6 +91,20 @@ describe PipelineDetailsEntity do
end end
end end
   
context 'when pipeline has commit statuses' do
let(:pipeline) { create(:ci_empty_pipeline) }
before do
create(:generic_commit_status, pipeline: pipeline)
end
it 'contains stages' do
expect(subject).to include(:details)
expect(subject[:details]).to include(:stages)
expect(subject[:details][:stages].first).to include(name: 'external')
end
end
context 'when pipeline has YAML errors' do context 'when pipeline has YAML errors' do
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, config: { rspec: { invalid: :value } }) create(:ci_pipeline, config: { rspec: { invalid: :value } })
Loading
Loading
Loading
@@ -54,6 +54,17 @@ describe StageEntity do
Loading
@@ -54,6 +54,17 @@ describe StageEntity do
it 'exposes the group key' do it 'exposes the group key' do
expect(subject).to include :groups expect(subject).to include :groups
end end
context 'and contains commit status' do
before do
create(:generic_commit_status, pipeline: pipeline, stage: 'test')
end
it 'contains commit status' do
groups = subject[:groups].map { |group| group[:name] }
expect(groups).to include('generic')
end
end
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment