Merge pull request #5761 from consuldemocracy/officing_voters_lock
Include voter initialization in officing voters lock
This commit is contained in:
@@ -13,16 +13,19 @@ class Officing::VotersController < Officing::BaseController
|
|||||||
def create
|
def create
|
||||||
@poll = Poll.find(voter_params[:poll_id])
|
@poll = Poll.find(voter_params[:poll_id])
|
||||||
@user = User.find(voter_params[:user_id])
|
@user = User.find(voter_params[:user_id])
|
||||||
@voter = Poll::Voter.new(document_type: @user.document_type,
|
|
||||||
document_number: @user.document_number,
|
|
||||||
user: @user,
|
|
||||||
poll: @poll,
|
|
||||||
origin: "booth",
|
|
||||||
officer: current_user.poll_officer,
|
|
||||||
booth_assignment: current_booth.booth_assignments.find_by(poll: @poll),
|
|
||||||
officer_assignment: officer_assignment(@poll))
|
|
||||||
|
|
||||||
@user.with_lock { @voter.save! }
|
@user.with_lock do
|
||||||
|
@voter = Poll::Voter.new(document_type: @user.document_type,
|
||||||
|
document_number: @user.document_number,
|
||||||
|
user: @user,
|
||||||
|
poll: @poll,
|
||||||
|
origin: "booth",
|
||||||
|
officer: current_user.poll_officer,
|
||||||
|
booth_assignment: current_booth.booth_assignments.find_by(poll: @poll),
|
||||||
|
officer_assignment: officer_assignment(@poll))
|
||||||
|
|
||||||
|
@voter.save!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ describe Officing::VotersController do
|
|||||||
voter: { poll_id: poll.id, user_id: user.id },
|
voter: { poll_id: poll.id, user_id: user.id },
|
||||||
format: :js
|
format: :js
|
||||||
}
|
}
|
||||||
rescue ActionDispatch::IllegalStateError
|
rescue ActionDispatch::IllegalStateError, ActiveRecord::RecordInvalid
|
||||||
end
|
end
|
||||||
end.each(&:join)
|
end.each(&:join)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user