Skip to content
Snippets Groups Projects
Commit a38dbd9c authored by Akihiko Odaki's avatar Akihiko Odaki Committed by Eugen Rochko
Browse files

Redirect from Web tag timeline to public tag timeline if not signed in (#6633)

parent f6a8d835
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,8 @@ class HomeController < ApplicationController
end
end
redirect_to(default_redirect_path)
matches = request.path.match(%r{\A/web/timelines/tag/(?<tag>.+)\z})
redirect_to(matches ? tag_path(CGI.unescape(matches[:tag])) : default_redirect_path)
end
def set_initial_state_json
......
......@@ -4,21 +4,24 @@ RSpec.describe HomeController, type: :controller do
render_views
describe 'GET #index' do
subject { get :index }
context 'when not signed in' do
context 'when requested path is tag timeline' do
before { @request.path = '/web/timelines/tag/name' }
it { is_expected.to redirect_to '/tags/name' }
end
it 'redirects to about page' do
@request.path = '/'
get :index
expect(response).to redirect_to(about_path)
is_expected.to redirect_to(about_path)
end
end
context 'when signed in' do
let(:user) { Fabricate(:user) }
subject do
sign_in(user)
get :index
end
before { sign_in(user) }
it 'assigns @body_classes' do
subject
......
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