+
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d552ec75e..d5bf38506 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -9,7 +9,7 @@ en:
menu: Menu
open_city: We are opening Madrid
open_city_slogan: So the citizens can decide what kind of city they want.
- create_debate: Create a debate
+ see_all_debates: See all debates
my_account_link: My account
language: Site language
footer:
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 46c426310..f11259370 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -9,7 +9,7 @@ es:
menu: Menú
open_city: Estamos abriendo Madrid
open_city_slogan: Para que todos los madrileños decidamos que ciudad queremos tener.
- create_debate: Crea un debate
+ see_all_debates: Ver todos los debates
my_account_link: Mi cuenta
language: Idioma de la página
footer:
diff --git a/config/routes.rb b/config/routes.rb
index 74179ba2a..fc7c040b2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -5,7 +5,7 @@ Rails.application.routes.draw do
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
- root 'debates#index'
+ root 'welcome#index'
resources :debates do
member do
diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb
index d164f113b..6265b17d7 100644
--- a/spec/features/debates_spec.rb
+++ b/spec/features/debates_spec.rb
@@ -4,18 +4,9 @@ feature 'Debates' do
scenario 'Index' do
debates = [create(:debate), create(:debate), create(:debate)]
- featured_debates = [create(:debate), create(:debate), create(:debate)]
visit debates_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
-
expect(page).to have_selector('#debates .debate', count: 3)
debates.each do |debate|
within('#debates') do
diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb
index 2efa307cc..fcad1ca24 100644
--- a/spec/features/home_spec.rb
+++ b/spec/features/home_spec.rb
@@ -2,4 +2,19 @@ require 'rails_helper'
feature "Home" do
+ scenario 'featured debates' do
+ featured_debates = [create(:debate), create(:debate), create(:debate)]
+
+ 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
+
end
diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb
index ecb8a8b8f..8deb20c20 100644
--- a/spec/features/votes_spec.rb
+++ b/spec/features/votes_spec.rb
@@ -13,7 +13,55 @@ feature 'Votes' do
visit debate_path(@debate)
end
- scenario "Index show user votes on debates" do
+ scenario "Home shows user votes on featured debates" do
+ debate1 = create(:debate)
+ debate2 = create(:debate)
+ debate3 = create(:debate)
+ vote = create(:vote, voter: @manuela, votable: debate1, vote_flag: true)
+ vote = create(:vote, voter: @manuela, votable: debate3, vote_flag: false)
+
+ visit root_path
+
+ within("#featured-debates") do
+ 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
+ end
+
+ scenario "Index shows user votes on debates" do
debate1 = create(:debate)
debate2 = create(:debate)
debate3 = create(:debate)
@@ -22,42 +70,43 @@ feature 'Votes' do
visit debates_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")
+ within("#debates") do
+ 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(".against") do
- expect(page).to have_css("a.no-voted")
- expect(page).to_not have_css("a.voted")
+ 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
-
- 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 'Show no votes' do
@@ -114,7 +163,7 @@ feature 'Votes' do
end
scenario 'Create from debate featured', :js do
- visit debates_path
+ visit root_path
within("#featured-debates") do
find('.in-favor a').click
@@ -131,15 +180,13 @@ feature 'Votes' do
expect(page).to have_content "1 vote"
end
- expect(URI.parse(current_url).path).to eq(debates_path)
+ expect(URI.parse(current_url).path).to eq(root_path)
end
scenario 'Create from debate index', :js do
- 3.times { create(:debate) }
visit debates_path
within("#debates") do
- expect(page).to have_css(".debate", count: 1)
find('.in-favor a').click