moves featured debates to home page

This commit is contained in:
rgarcia
2015-08-10 21:25:04 +02:00
parent 2c88c6e07d
commit 4dd7e14ac4
14 changed files with 129 additions and 58 deletions

View File

@@ -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