diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 98c8bf1b9..ed3324488 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -4,7 +4,20 @@ class WelcomeController < ApplicationController layout "devise", only: :welcome def index - current_user ? signed_in_home : public_home + current_user ? (redirect_to :highlights) : public_home + end + + def highlights + debates = Debate.sort_by_hot_score.page(params[:page]).per(10).for_render + set_debate_votes(debates) + + proposals = Proposal.sort_by_hot_score.page(params[:page]).per(10).for_render + set_proposal_votes(proposals) + + @list = (debates.to_a + proposals.to_a).sort{|a, b| b.hot_score <=> a.hot_score} + @paginator = debates.total_pages > proposals.total_pages ? debates : proposals + + render 'signed_in_home' end def welcome @@ -19,16 +32,5 @@ class WelcomeController < ApplicationController set_proposal_votes(@featured_proposals) end - def signed_in_home - debates = Debate.sort_by_hot_score.page(params[:page]).per(10).for_render - set_debate_votes(debates) - proposals = Proposal.sort_by_hot_score.page(params[:page]).per(10).for_render - set_proposal_votes(proposals) - - @list = (debates.to_a + proposals.to_a).sort{|a, b| b.hot_score <=> a.hot_score} - @paginator = debates.total_pages > proposals.total_pages ? debates : proposals - - render 'signed_in_home' - end end diff --git a/config/routes.rb b/config/routes.rb index 656117d0f..dcff99b57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,7 @@ Rails.application.routes.draw do # You can have the root of your site routed with "root" root 'welcome#index' get '/welcome', to: 'welcome#welcome' + get '/highlights', to: 'welcome#highlights', as: :highlights resources :debates do diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index a096b2b83..63f27b7db 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -15,7 +15,8 @@ feature 'Admin' do login_as(user) visit admin_root_path - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(admin_root_path) + expect(current_path).to eq(highlights_path) expect(page).to have_content "not authorized" end @@ -23,7 +24,8 @@ feature 'Admin' do login_as(moderator) visit admin_root_path - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(admin_root_path) + expect(current_path).to eq(highlights_path) expect(page).to have_content "not authorized" end diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 45acc0a6f..928d8e887 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -237,7 +237,8 @@ feature 'Debates' do login_as(create(:user)) visit edit_debate_path(debate) - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(edit_debate_path(debate)) + expect(current_path).to eq(highlights_path) expect(page).to have_content 'not authorized' end @@ -249,7 +250,8 @@ feature 'Debates' do visit edit_debate_path(debate) - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(edit_debate_path(debate)) + expect(current_path).to eq(highlights_path) expect(page).to have_content 'not authorized' end diff --git a/spec/features/moderation_spec.rb b/spec/features/moderation_spec.rb index 78df5e56f..9fe3f1e7a 100644 --- a/spec/features/moderation_spec.rb +++ b/spec/features/moderation_spec.rb @@ -10,7 +10,8 @@ feature 'Admin' do expect(page).to_not have_link("Moderation") visit moderation_root_path - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(moderation_root_path) + expect(current_path).to eq(highlights_path) expect(page).to have_content "not authorized" end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 7d146efaa..1529f5cc6 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -255,7 +255,8 @@ feature 'Proposals' do login_as(create(:user)) visit edit_proposal_path(proposal) - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(edit_proposal_path(proposal)) + expect(current_path).to eq(highlights_path) expect(page).to have_content 'not authorized' end @@ -269,7 +270,8 @@ feature 'Proposals' do login_as(proposal.author) visit edit_proposal_path(proposal) - expect(current_path).to eq(root_path) + expect(current_path).not_to eq(edit_proposal_path(proposal)) + expect(current_path).to eq(highlights_path) expect(page).to have_content 'not authorized' end diff --git a/spec/features/welcome_spec.rb b/spec/features/welcome_spec.rb index 2635ef0df..7ce50b529 100644 --- a/spec/features/welcome_spec.rb +++ b/spec/features/welcome_spec.rb @@ -15,7 +15,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(root_path) + expect(current_path).to eq(highlights_path) end scenario 'is not shown to organizations' do @@ -23,7 +23,7 @@ feature "Welcome screen" do login_through_form_as(organization.user) - expect(current_path).to eq(root_path) + expect(current_path).to eq(highlights_path) end scenario 'it is not shown to level-2 users' do @@ -31,7 +31,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(root_path) + expect(current_path).to eq(highlights_path) end scenario 'it is not shown to level-3 users' do @@ -39,7 +39,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(root_path) + expect(current_path).to eq(highlights_path) end end