We're about to add code which might fall into the `RedundantBegin` category, so we're adding the rule in order to prevent that.
26 lines
649 B
Ruby
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
|