refactors highlights
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user