Allow users to remove their support on investments

Note we don't cast negative votes when users remove their support. That
way we provide compatibility for institutions who have implemented real
negative votes (in case there are / will be any), and we also keep the
database meaningful: it's not that users downvoted something; they
simply removed their upvote.

Co-Authored-By: Javi Martín <javim@elretirao.net>
Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
This commit is contained in:
decabeza
2020-06-25 17:58:52 +02:00
committed by Javi Martín
parent 368023986a
commit a851048d56
17 changed files with 209 additions and 22 deletions

View File

@@ -23,8 +23,21 @@ describe Budgets::Investments::VotesComponent, type: :component do
render_inline component
expect(page).to have_button count: 1, disabled: :all
expect(page).to have_button "Support", disabled: true
end
it "shows the button to remove support when users have supported the investment" do
user = create(:user)
user.up_votes(investment)
allow(controller).to receive(:current_user).and_return(user)
render_inline component
expect(page).to have_button count: 1, disabled: :all
expect(page).to have_button "Remove your support"
expect(page).to have_button "Remove your support to Renovate sidewalks in Main Street"
end
end
end
end