liquidvotingio / api

Enable liquid democracy in your decision making platform
GNU Affero General Public License v3.0
17 stars 3 forks source link

Bugfix: Preload voting_method when create vote for delegator. #241

Closed jinjagit closed 3 years ago

jinjagit commented 3 years ago

This fixes case where a voter is already the delegator in a delegation for the same proposal (proposal_url + voting_method).

Prior to this fix, the process of searching for, and deleting the related delegation, in create_vote/1 in voting.ex, returned a vote without the associated voting_method being preloaded, which would cause a createVote mutation to fail due to the associated voting_method being unavailable.

Adds a preload of voting_method when the vote is returned in this case.

Also adds a test of the case that highlighted this bug + a similar test of creating a vote for the delegate, following a proposal-delegation creation.