preserve params when redirecting for login on repository (#5671)

[ci skip]
pull/5703/head
ulferts 7 years ago committed by Oliver Günther
parent 5165906e11
commit 520815956d
  1. 4
      app/controllers/repositories_controller.rb
  2. 3
      config/routes.rb
  3. 25
      spec/controllers/repositories_controller_spec.rb

@ -489,6 +489,10 @@ class RepositoriesController < ApplicationController
)
graph.burn
end
def login_back_url_params
params.permit(:path)
end
end
class Date

@ -348,7 +348,8 @@ OpenProject::Application.routes.draw do
get '(/revisions/:rev)(/*path)', action: :show,
format: false,
rev: /[a-z0-9\.\-_]+/
rev: /[a-z0-9\.\-_]+/,
as: 'show_revisions_path'
end
end

@ -35,10 +35,11 @@ describe RepositoriesController, type: :controller do
allow(Project).to receive(:find).and_return(project)
project
end
let(:user) {
let(:user) do
FactoryGirl.create(:user, member_in_project: project,
member_through_role: role)
}
end
let(:role) { FactoryGirl.create(:role, permissions: []) }
let (:url) { 'file:///tmp/something/does/not/exist.svn' }
let(:repository) do
@ -167,7 +168,7 @@ describe RepositoriesController, type: :controller do
end
end
describe 'with filesystem repository' do
describe 'with subversion repository' do
with_subversion_repository do |repo_dir|
let(:root_url) { repo_dir }
let(:url) { "file://#{root_url}" }
@ -332,4 +333,22 @@ describe RepositoriesController, type: :controller do
end
end
end
describe 'when not being logged in' do
let(:anonymous) { FactoryGirl.build_stubbed(:anonymous) }
before do
login_as(anonymous)
end
describe '#show' do
it 'redirects to login while preserving the path' do
params = { path: 'aDir/within/aDir', rev: '42', project_id: project.id }
get :show, params: params
expect(response)
.to redirect_to signin_path(back_url: show_revisions_path_project_repository_url(params))
end
end
end
end

Loading…
Cancel
Save