]> cat aescling's git repositories - mastodon.git/commitdiff
Redirect from Web tag timeline to public tag timeline if not signed in (#6633)
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Mon, 5 Mar 2018 18:29:36 +0000 (03:29 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 5 Mar 2018 18:29:36 +0000 (19:29 +0100)
This is also implemented in Pawoo:
https://github.com/pixiv/mastodon/commit/ceafdbd1bbf30fe20a2a814df0f8cae429a4e9db

app/controllers/home_controller.rb
spec/controllers/home_controller_spec.rb

index 21dde20ce40379f37b75746c25e17f8c47e9d73c..b1f8f1ad9022343b354b1d7eaa502e31c09ab478 100644 (file)
@@ -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
index 1077a7288b68331da4e5284a8f7c0ee4450e02a3..f43cf0c27ec510ab3d06d736f819430815ee73ef 100644 (file)
@@ -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