mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Refactor routes in order to be compatible with Rails 4
This commit is contained in:
parent
d13166fa17
commit
e39cc464b1
8 changed files with 16 additions and 16 deletions
|
@ -61,7 +61,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
rescue_from Discourse::NotLoggedIn do |e|
|
rescue_from Discourse::NotLoggedIn do |e|
|
||||||
raise e if Rails.env.test?
|
raise e if Rails.env.test?
|
||||||
redirect_to root_path
|
redirect_to "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from Discourse::NotFound do
|
rescue_from Discourse::NotFound do
|
||||||
|
|
|
@ -24,7 +24,7 @@ class InvitesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to root_path
|
redirect_to "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -44,7 +44,7 @@ class StaticController < ApplicationController
|
||||||
|
|
||||||
redirect_to(
|
redirect_to(
|
||||||
if params[:redirect].blank? || params[:redirect].match(login_path)
|
if params[:redirect].blank? || params[:redirect].match(login_path)
|
||||||
root_path
|
"/"
|
||||||
else
|
else
|
||||||
params[:redirect]
|
params[:redirect]
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<% if @needs_approval %>
|
<% if @needs_approval %>
|
||||||
<%= t 'activation.approval_required' %>
|
<%= t 'activation.approval_required' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= raw t('activation.please_continue', link: link_to(SiteSetting.title, root_path)) %></a>.
|
<%= raw t('activation.please_continue', link: link_to(SiteSetting.title, '/')) %></a>.
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<%else%>
|
<%else%>
|
||||||
<h2><%= t 'change_email.confirmed' %></h2>
|
<h2><%= t 'change_email.confirmed' %></h2>
|
||||||
<p>
|
<p>
|
||||||
<%= raw t('change_email.please_continue', link: link_to(SiteSetting.title, root_path)) %>
|
<%= raw t('change_email.please_continue', link: link_to(SiteSetting.title, '/')) %>
|
||||||
</p>
|
</p>
|
||||||
<%end%>
|
<%end%>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<%- if @requires_approval %>
|
<%- if @requires_approval %>
|
||||||
<%= t 'login.not_approved' %>
|
<%= t 'login.not_approved' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to( t('password_reset.continue', site_name: SiteSetting.title), root_path ) %>
|
<%= link_to( t('password_reset.continue', site_name: SiteSetting.title), '/' ) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -10,7 +10,7 @@ USERNAME_ROUTE_FORMAT = /[A-Za-z0-9\_]+/ unless defined? USERNAME_ROUTE_FORMAT
|
||||||
|
|
||||||
Discourse::Application.routes.draw do
|
Discourse::Application.routes.draw do
|
||||||
|
|
||||||
match "/404", to: "exceptions#not_found"
|
match "/404", to: "exceptions#not_found", via: [:get, :post]
|
||||||
|
|
||||||
mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new
|
mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ Discourse::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get 'email_preferences' => 'email#preferences_redirect'
|
get 'email_preferences' => 'email#preferences_redirect', :as => 'email_preferences_redirect'
|
||||||
get 'email/unsubscribe/:key' => 'email#unsubscribe', as: 'email_unsubscribe'
|
get 'email/unsubscribe/:key' => 'email#unsubscribe', as: 'email_unsubscribe'
|
||||||
post 'email/resubscribe/:key' => 'email#resubscribe', as: 'email_resubscribe'
|
post 'email/resubscribe/:key' => 'email#resubscribe', as: 'email_resubscribe'
|
||||||
|
|
||||||
|
@ -148,8 +148,8 @@ Discourse::Application.routes.draw do
|
||||||
resources :notifications
|
resources :notifications
|
||||||
resources :categories
|
resources :categories
|
||||||
|
|
||||||
match "/auth/:provider/callback", to: "users/omniauth_callbacks#complete"
|
match "/auth/:provider/callback", to: "users/omniauth_callbacks#complete", via: [:get, :post]
|
||||||
match "/auth/failure", to: "users/omniauth_callbacks#failure"
|
match "/auth/failure", to: "users/omniauth_callbacks#failure", via: [:get, :post]
|
||||||
|
|
||||||
resources :clicks do
|
resources :clicks do
|
||||||
collection do
|
collection do
|
||||||
|
@ -170,8 +170,8 @@ Discourse::Application.routes.draw do
|
||||||
|
|
||||||
get 'category/:category.rss' => 'list#category_feed', format: :rss, as: 'category_feed'
|
get 'category/:category.rss' => 'list#category_feed', format: :rss, as: 'category_feed'
|
||||||
get 'category/:category' => 'list#category'
|
get 'category/:category' => 'list#category'
|
||||||
get 'category/:category' => 'list#category', as: 'category'
|
get 'category/:category' => 'list#category'
|
||||||
get 'category/:category/more' => 'list#category', as: 'category'
|
get 'category/:category/more' => 'list#category'
|
||||||
get 'categories' => 'categories#index'
|
get 'categories' => 'categories#index'
|
||||||
|
|
||||||
# We've renamed popular to latest. If people access it we want a permanent redirect.
|
# We've renamed popular to latest. If people access it we want a permanent redirect.
|
||||||
|
@ -241,9 +241,9 @@ Discourse::Application.routes.draw do
|
||||||
get 'robots.txt' => 'robots_txt#index'
|
get 'robots.txt' => 'robots_txt#index'
|
||||||
|
|
||||||
[:latest, :hot, :unread, :new, :favorited, :read, :posted].each do |filter|
|
[:latest, :hot, :unread, :new, :favorited, :read, :posted].each do |filter|
|
||||||
root to: "list##{filter}", constraints: HomePageConstraint.new("#{filter}")
|
root to: "list##{filter}", constraints: HomePageConstraint.new("#{filter}"), :as => "list_#{filter}"
|
||||||
end
|
end
|
||||||
# special case for categories
|
# special case for categories
|
||||||
root to: "categories#index", constraints: HomePageConstraint.new("categories")
|
root to: "categories#index", constraints: HomePageConstraint.new("categories"), :as => "categories_index"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ describe StaticController do
|
||||||
context 'without a redirect path' do
|
context 'without a redirect path' do
|
||||||
it 'redirects to the root url' do
|
it 'redirects to the root url' do
|
||||||
xhr :post, :enter
|
xhr :post, :enter
|
||||||
expect(response).to redirect_to root_path
|
expect(response).to redirect_to '/'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ describe StaticController do
|
||||||
context 'when the redirect path is the login page' do
|
context 'when the redirect path is the login page' do
|
||||||
it 'redirects to the root url' do
|
it 'redirects to the root url' do
|
||||||
xhr :post, :enter, redirect: login_path
|
xhr :post, :enter, redirect: login_path
|
||||||
expect(response).to redirect_to root_path
|
expect(response).to redirect_to '/'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue