Skip to content

Commit

Permalink
Track who performed the unvote
Browse files Browse the repository at this point in the history
  • Loading branch information
sauloperez committed Oct 30, 2020
1 parent c9615f6 commit be2e4cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def destroy

user = delegation.blank? ? current_user : delegation.granter

PaperTrail.request(enabled: delegation.present?) do
PaperTrail.request(enabled: delegation.present?, whodunnit: current_user.id) do
Decidim::Consultations::UnvoteQuestion.call(current_question, user) do
on(:ok) do
current_question.reload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Consultations
context "when a delegation is specified", versioning: true do
let(:delegation) { create(:delegation, setting: setting, grantee: user) }

before { create(:vote, author: delegation.granter, question: question) }
let!(:vote) { create(:vote, author: delegation.granter, question: question) }

it "destroys the vote" do
delete :destroy, params: { question_slug: question.slug, decidim_consultations_delegation_id: delegation.id }, format: :js
Expand All @@ -35,6 +35,12 @@ module Consultations
delete :destroy, params: { question_slug: question.slug, decidim_consultations_delegation_id: delegation.id }, format: :js
end.to change(PaperTrail::Version, :count)
end

it "tracks who performed the unvote" do
delete :destroy, params: { question_slug: question.slug, decidim_consultations_delegation_id: delegation.id }, format: :js
version = vote.versions.last
expect(version.whodunnit).to eq(user.id.to_s)
end
end

context "when no delegation is specified", versioning: true do
Expand Down

0 comments on commit be2e4cb

Please sign in to comment.