summaryrefslogtreecommitdiff
path: root/spec/controllers/concerns
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-21 18:06:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-21 18:06:29 +0000
commitf1bb2a307e9b125a8ee0be3728cb0d1baa21a3d4 (patch)
tree154817af5e3f1b134be08ef22d1926edf87ab74f /spec/controllers/concerns
parentad1e4b8fb8104b642fa79ed34fd144bc2bed8a19 (diff)
downloadgitlab-ce-f1bb2a307e9b125a8ee0be3728cb0d1baa21a3d4.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r--spec/controllers/concerns/redirects_for_missing_path_on_tree_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/concerns/redirects_for_missing_path_on_tree_spec.rb b/spec/controllers/concerns/redirects_for_missing_path_on_tree_spec.rb
new file mode 100644
index 00000000000..903100ba93f
--- /dev/null
+++ b/spec/controllers/concerns/redirects_for_missing_path_on_tree_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe RedirectsForMissingPathOnTree, type: :controller do
+ controller(ActionController::Base) do
+ include Gitlab::Routing.url_helpers
+ include RedirectsForMissingPathOnTree
+
+ def fake
+ redirect_to_tree_root_for_missing_path(Project.find(params[:project_id]), params[:ref], params[:file_path])
+ end
+ end
+
+ let(:project) { create(:project) }
+
+ before do
+ routes.draw { get 'fake' => 'anonymous#fake' }
+ end
+
+ describe '#redirect_to_root_path' do
+ it 'redirects to the tree path with a notice' do
+ long_file_path = ('a/b/' * 30) + 'foo.txt'
+ truncated_file_path = '...b/' + ('a/b/' * 12) + 'foo.txt'
+ expected_message = "\"#{truncated_file_path}\" did not exist on \"theref\""
+
+ get :fake, params: { project_id: project.id, ref: 'theref', file_path: long_file_path }
+
+ expect(response).to redirect_to project_tree_path(project, 'theref')
+ expect(response.flash[:notice]).to eq(expected_message)
+ end
+ end
+end