From 58357dad2c5d0e72f5ad632a97fd3530da427177 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 14 Sep 2015 19:06:16 +0200 Subject: [PATCH] removes featured debates and proposals --- app/controllers/welcome_controller.rb | 19 ++---- spec/features/home_spec.rb | 45 +------------- spec/features/votes_spec.rb | 90 --------------------------- 3 files changed, 9 insertions(+), 145 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index d37804c4f..fa716a520 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -4,7 +4,12 @@ class WelcomeController < ApplicationController layout "devise", only: :welcome def index - current_user ? (redirect_to :highlights) : public_home + if current_user + redirect_to :highlights + end + end + + def welcome end def highlights @@ -20,17 +25,5 @@ class WelcomeController < ApplicationController render 'highlights' end - def welcome - 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 - end diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 5858566e4..62e80b241 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -3,54 +3,15 @@ require 'rails_helper' feature "Home" do feature "For not logged users" do - scenario 'featured debates' do - featured_debates = [create(:debate), create(:debate), create(:debate)] - + scenario 'Welcome message' do visit root_path - expect(page).to have_selector('#featured-debates .debate-featured', count: 3) - featured_debates.each do |debate| - within('#featured-debates') do - expect(page).to have_content debate.title - expect(page).to have_css("a[href='#{debate_path(debate)}']", text: debate.description) - end - end - end - - scenario 'featured proposals' do - featured_proposals = [create(:proposal), create(:proposal), create(:proposal)] - - visit root_path - - expect(page).to have_selector('#featured-proposals .proposal-featured', count: 3) - 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') + expect(page).to have_content "we open this digital Puerta del Sol" end end feature "For signed in users" do - scenario 'debates and proposals order by hot_score' 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) diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index a207a9a2c..f8d6e9594 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -10,53 +10,6 @@ feature 'Votes' do end feature 'Debates' do - xscenario "Home shows user votes on featured debates" do - pending "logged in user cannot see this page" - - debate1 = create(:debate) - debate2 = create(:debate) - debate3 = create(:debate) - create(:vote, voter: @manuela, votable: debate1, vote_flag: true) - create(:vote, voter: @manuela, votable: debate3, vote_flag: false) - - visit root_path - - within("#debate_#{debate1.id}_votes") do - within(".in-favor") do - expect(page).to have_css("a.voted") - expect(page).to_not have_css("a.no-voted") - end - - within(".against") do - expect(page).to have_css("a.no-voted") - expect(page).to_not have_css("a.voted") - end - end - - within("#debate_#{debate2.id}_votes") do - within(".in-favor") do - expect(page).to_not have_css("a.voted") - expect(page).to_not have_css("a.no-voted") - end - - within(".against") do - expect(page).to_not have_css("a.no-voted") - expect(page).to_not have_css("a.voted") - end - end - - within("#debate_#{debate3.id}_votes") do - within(".in-favor") do - expect(page).to have_css("a.no-voted") - expect(page).to_not have_css("a.voted") - end - - within(".against") do - expect(page).to have_css("a.voted") - expect(page).to_not have_css("a.no-voted") - end - end - end scenario "Index shows user votes on debates" do debate1 = create(:debate) @@ -251,11 +204,6 @@ feature 'Votes' do visit "/" click_link "Logout" - within("#debate_#{debate.id}") do - find("div.votes").hover - expect_message_you_need_to_sign_in - end - visit debates_path within("#debate_#{debate.id}") do find("div.votes").hover @@ -293,39 +241,6 @@ feature 'Votes' do end feature 'Proposals' do - xscenario "Home shows user votes on featured proposals" do - pending "logged in user cannot see this page" - proposal1 = create(:proposal) - proposal2 = create(:proposal) - proposal3 = create(:proposal) - create(:vote, voter: @manuela, votable: proposal1, vote_flag: true) - create(:vote, voter: @manuela, votable: proposal3, vote_flag: false) - - visit root_path - - within("#featured-proposals") do - within("#proposal_#{proposal1.id}_votes") do - within(".supports") do - expect(page).to have_css("a.voted") - expect(page).to_not have_css("a.no-voted") - end - end - - within("#proposal_#{proposal2.id}_votes") do - within(".supports") do - expect(page).to_not have_css("a.voted") - expect(page).to_not have_css("a.no-voted") - end - end - - within("#proposal_#{proposal3.id}_votes") do - within(".supports") do - expect(page).to have_css("a.no-voted") - expect(page).to_not have_css("a.voted") - end - end - end - end scenario "Index shows user votes on proposals" do proposal1 = create(:proposal) @@ -437,11 +352,6 @@ feature 'Votes' do click_link "Logout" expect(page).to have_content "Signed out successfully." - within("#proposal_#{proposal.id}") do - find("div.supports").hover - expect_message_you_need_to_sign_in - end - visit proposals_path within("#proposal_#{proposal.id}") do find("div.supports").hover