Skip to content
Snippets Groups Projects
Commit 25b99a5b authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
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
Loading
@@ -80,10 +80,6 @@ class Projects::ApplicationController < ApplicationController
cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present?
end
 
def builds_enabled
return render_404 unless @project.feature_available?(:builds, current_user)
end
def require_pages_enabled!
not_found unless Gitlab.config.pages.enabled
end
Loading
Loading
Loading
Loading
@@ -101,9 +101,10 @@ class GitPushService < BaseService
UpdateMergeRequestsWorker
.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)
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_services(build_push_data.dup, :push_hooks)
 
Loading
Loading
Loading
Loading
@@ -9,9 +9,11 @@ class GitTagPushService < BaseService
 
EventCreateService.new.push(project, current_user, @push_data)
Ci::CreatePipelineService.new(project, current_user, @push_data).execute(:push)
SystemHooksService.new.execute_hooks(build_system_push_data.dup, :tag_push_hooks)
project.execute_hooks(@push_data.dup, :tag_push_hooks)
project.execute_services(@push_data.dup, :tag_push_hooks)
ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size])
 
true
Loading
Loading
---
title: Fix support for external CI services
merge_request: 11176
author:
Loading
Loading
@@ -4,7 +4,7 @@ module Gitlab
module External
module Common
def label
subject.description || super
subject.description
end
 
def has_details?
Loading
Loading
Loading
Loading
@@ -5,9 +5,12 @@ describe Projects::PipelinesController do
 
let(:user) { create(:user) }
let(:project) { create(:empty_project, :public) }
let(:feature) { ProjectFeature::DISABLED }
 
before do
project.add_developer(user)
project.project_feature.update(
builds_access_level: feature)
 
sign_in(user)
end
Loading
Loading
@@ -153,16 +156,26 @@ describe Projects::PipelinesController do
format: :json
end
 
it 'retries a pipeline without returning any content' do
expect(response).to have_http_status(:no_content)
expect(build.reload).to be_retried
context 'when builds are enabled' do
let(:feature) { ProjectFeature::ENABLED }
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
 
describe 'POST cancel.json' do
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :running, pipeline: pipeline) }
before do
post :cancel, namespace_id: project.namespace,
project_id: project,
Loading
Loading
@@ -170,9 +183,19 @@ describe Projects::PipelinesController do
format: :json
end
 
it 'cancels a pipeline without returning any content' do
expect(response).to have_http_status(:no_content)
expect(pipeline.reload).to be_canceled
context 'when builds are enabled' do
let(:feature) { ProjectFeature::ENABLED }
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
Loading
Loading
@@ -68,9 +68,12 @@ describe 'Edit Project Settings', feature: true do
end
 
describe 'project features visibility pages' do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, pipeline: pipeline) }
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),
wiki: namespace_project_wiki_path(project.namespace, project, :home),
snippets: namespace_project_snippets_path(project.namespace, project),
Loading
Loading
Loading
Loading
@@ -300,4 +300,37 @@ describe ProjectsHelper do
expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Private')
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
Loading
Loading
@@ -4,9 +4,10 @@ describe Gitlab::Ci::Status::External::Common do
let(:user) { create(:user) }
let(:project) { external_status.project }
let(:external_target_url) { 'http://example.gitlab.com/status' }
let(:external_description) { 'my description' }
 
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
 
subject do
Loading
Loading
@@ -15,6 +16,12 @@ describe Gitlab::Ci::Status::External::Common do
.extend(described_class)
end
 
describe '#label' do
it 'returns description' do
expect(subject.label).to eq external_description
end
end
describe '#has_action?' do
it { is_expected.not_to have_action }
end
Loading
Loading
Loading
Loading
@@ -139,6 +139,18 @@ describe ProjectPolicy, models: true do
is_expected.not_to include(:read_build, :read_pipeline)
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
 
context 'reporter' do
Loading
Loading
Loading
Loading
@@ -39,7 +39,7 @@ describe JobEntity do
expect(subject[:status]).to include :icon, :favicon, :text, :label
end
 
context 'when build is retryable' do
context 'when job is retryable' do
before do
job.update(status: :failed)
end
Loading
Loading
@@ -49,7 +49,7 @@ describe JobEntity do
end
end
 
context 'when build is cancelable' do
context 'when job is cancelable' do
before do
job.update(status: :running)
end
Loading
Loading
Loading
Loading
@@ -91,6 +91,20 @@ describe PipelineDetailsEntity do
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
let(:pipeline) do
create(:ci_pipeline, config: { rspec: { invalid: :value } })
Loading
Loading
Loading
Loading
@@ -54,6 +54,17 @@ describe StageEntity do
it 'exposes the group key' do
expect(subject).to include :groups
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
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