diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb index bc69d6200..9915b0b50 100644 --- a/app/controllers/spending_proposals_controller.rb +++ b/app/controllers/spending_proposals_controller.rb @@ -12,6 +12,7 @@ class SpendingProposalsController < ApplicationController def index @spending_proposals = apply_filters_and_search(SpendingProposal).page(params[:page]).for_render + set_spending_proposal_votes(@spending_proposals) end def new diff --git a/app/views/spending_proposals/_spending_proposal.html.erb b/app/views/spending_proposals/_spending_proposal.html.erb index 4437fba0b..7dff660fc 100644 --- a/app/views/spending_proposals/_spending_proposal.html.erb +++ b/app/views/spending_proposals/_spending_proposal.html.erb @@ -37,6 +37,9 @@ <%= t("shared.collective") %> <% end %> + +  •  + <%= geozone_name(spending_proposal) %>

<%= link_to spending_proposal.description, spending_proposal_path(spending_proposal) %>

@@ -46,7 +49,10 @@
- +
+ <%= render 'spending_proposals/votes', + { spending_proposal: spending_proposal, vote_url: vote_spending_proposal_path(spending_proposal, value: 'yes') } %> +
diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index caadf2637..632162c3c 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -365,25 +365,39 @@ feature 'Votes' do feature 'Spending Proposals' do background { login_as(@manuela) } - xscenario "Index shows user votes on proposals" do - proposal1 = create(:proposal) - proposal2 = create(:proposal) - proposal3 = create(:proposal) - create(:vote, voter: @manuela, votable: proposal1, vote_flag: true) + feature 'Index' do + scenario "Index shows user votes on proposals" do + spending_proposal1 = create(:spending_proposal) + spending_proposal2 = create(:spending_proposal) + spending_proposal3 = create(:spending_proposal) + create(:vote, voter: @manuela, votable: spending_proposal1, vote_flag: true) - visit proposals_path + visit spending_proposals_path - within("#proposals") do - within("#proposal_#{proposal1.id}_votes") do - expect(page).to have_content "You have already supported this proposal. Share it!" + within("#investment-projects") do + within("#spending_proposal_#{spending_proposal1.id}_votes") do + expect(page).to have_content "You have already supported this. Share it!" + end + + within("#spending_proposal_#{spending_proposal2.id}_votes") do + expect(page).to_not have_content "You have already supported this. Share it!" + end + + within("#spending_proposal_#{spending_proposal3.id}_votes") do + expect(page).to_not have_content "You have already supported this. Share it!" + end end + end - within("#proposal_#{proposal2.id}_votes") do - expect(page).to_not have_content "You have already supported this proposal. Share it!" - end + scenario 'Create from spending proposal index', :js do + spending_proposal = create(:spending_proposal) + visit spending_proposals_path - within("#proposal_#{proposal3.id}_votes") do - expect(page).to_not have_content "You have already supported this proposal. Share it!" + within('.supports') do + find('.in-favor a').click + + expect(page).to have_content "1 support" + expect(page).to have_content "You have already supported this. Share it!" end end end