Files
grecia/spec/controllers/officing/voters_controller_spec.rb
Javi Martín 07202fea10 Add and apply Style/RedundantBegin rubocop rule
We're about to add code which might fall into the `RedundantBegin`
category, so we're adding the rule in order to prevent that.
2024-10-30 15:57:44 +01:00

26 lines
649 B
Ruby

require "rails_helper"
describe Officing::VotersController do
describe "POST create" do
it "does not create two records with two simultaneous requests", :race_condition do
officer = create(:poll_officer)
poll = create(:poll, officers: [officer])
user = create(:user, :level_two)
sign_in(officer.user)
2.times.map do
Thread.new do
post :create, params: {
voter: { poll_id: poll.id, user_id: user.id },
format: :js
}
rescue ActionDispatch::IllegalStateError
end
end.each(&:join)
expect(Poll::Voter.count).to eq 1
end
end
end