adds basic activity page as signed_in_home
This commit is contained in:
@@ -4,11 +4,31 @@ class WelcomeController < ApplicationController
|
|||||||
layout "devise", only: :welcome
|
layout "devise", only: :welcome
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@featured_debates = Debate.sort_by_confidence_score.limit(3).for_render
|
current_user ? signed_in_home : public_home
|
||||||
set_debate_votes(@featured_debates)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def welcome
|
def welcome
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def public_home
|
||||||
|
@featured_debates = Debate.sort_by_confidence_score.limit(3).for_render
|
||||||
|
set_debate_votes(@featured_debates)
|
||||||
|
|
||||||
|
@featured_proposals = Proposal.sort_by_confidence_score.limit(3).for_render
|
||||||
|
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
|
end
|
||||||
|
|||||||
19
app/views/welcome/signed_in_home.html.erb
Normal file
19
app/views/welcome/signed_in_home.html.erb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<section role="main">
|
||||||
|
<div class="wrap row">
|
||||||
|
<div id="activities" class="debates-list small-12 medium-9 column">
|
||||||
|
|
||||||
|
<div class="filters">
|
||||||
|
|
||||||
|
<div class="small-12 medium-7 left">
|
||||||
|
<h2 class="margin-top">
|
||||||
|
<%= t('welcome.signed_in_home_title') %>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render @list %>
|
||||||
|
<%= paginate @paginator %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -289,6 +289,7 @@ en:
|
|||||||
welcome:
|
welcome:
|
||||||
last_debates: Last debates
|
last_debates: Last debates
|
||||||
last_proposals: Last proposals
|
last_proposals: Last proposals
|
||||||
|
signed_in_home_title: Recent activity
|
||||||
welcome:
|
welcome:
|
||||||
title: Account verification
|
title: Account verification
|
||||||
instructions_1_html: "Welcome to the public participation website."
|
instructions_1_html: "Welcome to the public participation website."
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ es:
|
|||||||
welcome:
|
welcome:
|
||||||
last_debates: Últimos debates
|
last_debates: Últimos debates
|
||||||
last_proposals: Últimas propuestas
|
last_proposals: Últimas propuestas
|
||||||
|
signed_in_home_title: Actividad reciente
|
||||||
welcome:
|
welcome:
|
||||||
title: Verificación de cuenta
|
title: Verificación de cuenta
|
||||||
instructions_1_html: "Bienvenido a la página de participación ciudadana"
|
instructions_1_html: "Bienvenido a la página de participación ciudadana"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ require 'rails_helper'
|
|||||||
|
|
||||||
feature "Home" do
|
feature "Home" do
|
||||||
|
|
||||||
|
feature "For not logged users" do
|
||||||
scenario 'featured debates' do
|
scenario 'featured debates' do
|
||||||
featured_debates = [create(:debate), create(:debate), create(:debate)]
|
featured_debates = [create(:debate), create(:debate), create(:debate)]
|
||||||
|
|
||||||
@@ -14,18 +15,60 @@ feature "Home" do
|
|||||||
expect(page).to have_css("a[href='#{debate_path(debate)}']", text: debate.description)
|
expect(page).to have_css("a[href='#{debate_path(debate)}']", text: debate.description)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Order by confidence score" do
|
scenario 'featured proposals' do
|
||||||
create(:debate, confidence_score: 100, title: 'best')
|
featured_proposals = [create(:proposal), create(:proposal), create(:proposal)]
|
||||||
create(:debate, confidence_score: -20, title: 'worst')
|
|
||||||
create(:debate, confidence_score: 50, title: 'medium')
|
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
expect('best').to appear_before('medium')
|
expect(page).to have_selector('#featured-proposals .proposal-featured', count: 3)
|
||||||
expect('medium').to appear_before('worst')
|
featured_proposals.each do |proposal|
|
||||||
|
within('#featured-proposals') do
|
||||||
|
expect(page).to have_content proposal.title
|
||||||
|
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Order by confidence score" do
|
||||||
|
create(:debate, confidence_score: 100, title: 'best debate')
|
||||||
|
create(:debate, confidence_score: -20, title: 'worst debate')
|
||||||
|
create(:debate, confidence_score: 50, title: 'medium debate')
|
||||||
|
|
||||||
|
create(:proposal, confidence_score: 100, title: 'best proposal')
|
||||||
|
create(:proposal, confidence_score: -20, title: 'worst proposal')
|
||||||
|
create(:proposal, confidence_score: 50, title: 'medium proposal')
|
||||||
|
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
expect('best debate').to appear_before('medium debate')
|
||||||
|
expect('medium debate').to appear_before('worst debate')
|
||||||
|
expect('best proposal').to appear_before('medium proposal')
|
||||||
|
expect('medium proposal').to appear_before('worst proposal')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature "For signed in users" do
|
||||||
|
scenario 'debates and proposals order by hot_score' do
|
||||||
|
create(:debate, title: 'best debate 100').update_column(:hot_score, 100)
|
||||||
|
create(:debate, title: 'worst debate 50').update_column(:hot_score, 50)
|
||||||
|
create(:debate, title: 'medium debate 70').update_column(:hot_score, 70)
|
||||||
|
|
||||||
|
create(:proposal, title: 'best proposal 90').update_column(:hot_score, 90)
|
||||||
|
create(:proposal, title: 'worst proposal 60').update_column(:hot_score, 60)
|
||||||
|
create(:proposal, title: 'medium proposal 80').update_column(:hot_score, 80)
|
||||||
|
|
||||||
|
login_as(create(:user))
|
||||||
|
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
expect('best debate 100').to appear_before('best proposal 90')
|
||||||
|
expect('best proposal 90').to appear_before('medium proposal 80')
|
||||||
|
expect('medium proposal 80').to appear_before('medium debate 70')
|
||||||
|
expect('medium debate 70').to appear_before('worst proposal 60')
|
||||||
|
expect('worst proposal 60').to appear_before('worst debate 50')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user