summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-16 12:06:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-16 12:06:26 +0000
commitd2798d607e11e0ebae83ae909404834388733428 (patch)
tree096b7f4d4bdb315d28cdcd4d6db4e80911112e9c /spec
parentd8211a0ed119eada7d292e974a8fc7b0cd982d3c (diff)
downloadgitlab-ce-d2798d607e11e0ebae83ae909404834388733428.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/application_controller_spec.rb38
-rw-r--r--spec/javascripts/boards/boards_store_spec.js4
-rw-r--r--spec/lib/gitlab/popen_spec.rb8
-rw-r--r--spec/lib/gitlab_danger_spec.rb2
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb5
-rw-r--r--spec/services/service_response_spec.rb14
6 files changed, 60 insertions, 11 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 0b3833e6515..52a68e987f0 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -171,16 +171,40 @@ describe ApplicationController do
end
describe '#route_not_found' do
+ controller(described_class) do
+ def index
+ route_not_found
+ end
+ end
+
it 'renders 404 if authenticated' do
- allow(controller).to receive(:current_user).and_return(user)
- expect(controller).to receive(:not_found)
- controller.send(:route_not_found)
+ sign_in(user)
+
+ get :index
+
+ expect(response).to have_gitlab_http_status(404)
end
- it 'does redirect to login page via authenticate_user! if not authenticated' do
- allow(controller).to receive(:current_user).and_return(nil)
- expect(controller).to receive(:authenticate_user!)
- controller.send(:route_not_found)
+ it 'redirects to login page via authenticate_user! if not authenticated' do
+ get :index
+
+ expect(response).to redirect_to new_user_session_path
+ end
+
+ context 'request format is unknown' do
+ it 'redirects if unauthenticated' do
+ get :index, format: 'unknown'
+
+ expect(response).to redirect_to new_user_session_path
+ end
+
+ it 'returns a 401 if the feature flag is disabled' do
+ stub_feature_flags(devise_redirect_unknown_formats: false)
+
+ get :index, format: 'unknown'
+
+ expect(response).to have_gitlab_http_status(401)
+ end
end
end
diff --git a/spec/javascripts/boards/boards_store_spec.js b/spec/javascripts/boards/boards_store_spec.js
index 36bd7ada4f0..11352140ba4 100644
--- a/spec/javascripts/boards/boards_store_spec.js
+++ b/spec/javascripts/boards/boards_store_spec.js
@@ -1,7 +1,5 @@
-/* eslint-disable no-unused-vars */
/* global ListIssue */
-import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import Cookies from 'js-cookie';
@@ -190,7 +188,7 @@ describe('Store', () => {
it('moves the position of lists', () => {
const listOne = boardsStore.addList(listObj);
- const listTwo = boardsStore.addList(listObjDuplicate);
+ boardsStore.addList(listObjDuplicate);
expect(boardsStore.state.lists.length).toBe(2);
diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb
index 29afd9df74e..b398381a7e0 100644
--- a/spec/lib/gitlab/popen_spec.rb
+++ b/spec/lib/gitlab/popen_spec.rb
@@ -87,4 +87,12 @@ describe Gitlab::Popen do
it { expect(@status).to be_zero }
it { expect(@output).to eq('hello') }
end
+
+ context 'when binary is absent' do
+ it 'raises error' do
+ expect do
+ @klass.new.popen(%w[foobar])
+ end.to raise_error
+ end
+ end
end
diff --git a/spec/lib/gitlab_danger_spec.rb b/spec/lib/gitlab_danger_spec.rb
index 623ac20fa7c..26bf5d76756 100644
--- a/spec/lib/gitlab_danger_spec.rb
+++ b/spec/lib/gitlab_danger_spec.rb
@@ -9,7 +9,7 @@ describe GitlabDanger do
describe '.local_warning_message' do
it 'returns an informational message with rules that can run' do
- expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, gemfile, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, database')
+ expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, gemfile, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, database, commit_messages')
end
end
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index fe86982af91..19cc2ddf7db 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -317,9 +317,14 @@ describe Ci::CreatePipelineService do
context 'interruptible builds' do
before do
+ Feature.enable(:ci_support_interruptible_pipelines)
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
+ after do
+ Feature.disable(:ci_support_interruptible_pipelines)
+ end
+
let(:config) do
{
stages: %w[stage1 stage2 stage3 stage4],
diff --git a/spec/services/service_response_spec.rb b/spec/services/service_response_spec.rb
index e790d272e61..a6567f52c6f 100644
--- a/spec/services/service_response_spec.rb
+++ b/spec/services/service_response_spec.rb
@@ -23,6 +23,20 @@ describe ServiceResponse do
expect(response).to be_success
expect(response.payload).to eq(good: 'orange')
end
+
+ it 'creates a successful response with default HTTP status' do
+ response = described_class.success
+
+ expect(response).to be_success
+ expect(response.http_status).to eq(:ok)
+ end
+
+ it 'creates a successful response with custom HTTP status' do
+ response = described_class.success(http_status: 204)
+
+ expect(response).to be_success
+ expect(response.http_status).to eq(204)
+ end
end
describe '.error' do