summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb27
-rw-r--r--spec/controllers/application_controller_spec.rb39
-rw-r--r--spec/controllers/concerns/send_file_upload_spec.rb1
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb1
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb6
5 files changed, 39 insertions, 35 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb
index d62e0a97609..4eb0545eb6c 100644
--- a/spec/controllers/admin/application_settings_controller_spec.rb
+++ b/spec/controllers/admin/application_settings_controller_spec.rb
@@ -118,7 +118,32 @@ describe Admin::ApplicationSettingsController do
end
describe 'verify panel actions' do
- (Admin::ApplicationSettingsController::VALID_SETTING_PANELS - %w(templates geo)).each do |valid_action|
+ shared_examples 'renders correct panels' do
+ it 'renders correct action on error' do
+ expect_next_instance_of(ApplicationSettings::UpdateService) do |service|
+ allow(service).to receive(:execute).and_return(false)
+ end
+
+ patch action, params: { application_setting: { unused_param: true } }
+
+ expect(subject).to render_template(action)
+ end
+
+ it 'redirects to same panel on success' do
+ expect_next_instance_of(ApplicationSettings::UpdateService) do |service|
+ allow(service).to receive(:execute).and_return(true)
+ end
+
+ referer_path = public_send("#{action}_admin_application_settings_path")
+ request.env["HTTP_REFERER"] = referer_path
+
+ patch action, params: { application_setting: { unused_param: true } }
+
+ expect(subject).to redirect_to(referer_path)
+ end
+ end
+
+ (Admin::ApplicationSettingsController::VALID_SETTING_PANELS - %w(show templates geo)).each do |valid_action|
it_behaves_like 'renders correct panels' do
let(:action) { valid_action }
end
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index d7134d3d25a..0b3833e6515 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
@@ -170,40 +171,16 @@ 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
- sign_in(user)
-
- get :index
-
- expect(response).to have_gitlab_http_status(404)
- end
-
- it 'redirects to login page via authenticate_user! if not authenticated' do
- get :index
-
- expect(response).to redirect_to new_user_session_path
+ allow(controller).to receive(:current_user).and_return(user)
+ expect(controller).to receive(:not_found)
+ controller.send(:route_not_found)
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
+ 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)
end
end
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb
index 4110be721ad..3bf0ec799c7 100644
--- a/spec/controllers/concerns/send_file_upload_spec.rb
+++ b/spec/controllers/concerns/send_file_upload_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index 53d32665b0c..b455b55bd11 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index eda8c282341..e1f67054d0a 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -1289,7 +1289,7 @@ describe Projects::MergeRequestsController do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = commit_diff_note.note_diff_file
- expect(collection).to receive(:load_highlight).and_call_original
+ expect(collection).to receive(:load_highlight).with([note_diff_file.id]).and_call_original
expect(collection).to receive(:find_by_id).with(note_diff_file.id).and_call_original
end
@@ -1306,7 +1306,7 @@ describe Projects::MergeRequestsController do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = diff_note.note_diff_file
- expect(collection).to receive(:load_highlight).and_call_original
+ expect(collection).to receive(:load_highlight).with([note_diff_file.id]).and_call_original
expect(collection).to receive(:find_by_id).with(note_diff_file.id).and_call_original
end
@@ -1319,7 +1319,7 @@ describe Projects::MergeRequestsController do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = diff_note.note_diff_file
- expect(collection).to receive(:load_highlight).and_call_original
+ expect(collection).to receive(:load_highlight).with([]).and_call_original
expect(collection).to receive(:find_by_id).with(note_diff_file.id).and_call_original
end