Skip to content

Commit dddfb10

Browse files
Lock school while creating domains and syncing with Profile
1 parent 27cc95f commit dddfb10

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/concepts/school_email_domain/operations/create.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def call(school:, domain:, token:)
77
response = OperationResponse.new
88
response[:school_email_domain] = nil
99
response[:school_email_domain] = build_domain(school, domain)
10-
SchoolEmailDomain.transaction do
10+
school.with_lock do
1111
response[:school_email_domain].save!
1212
update_profile(school, token)
1313
end

spec/concepts/school_email_domain/create_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
)
4444
end
4545

46+
it 'locks the school while creating and syncing to Profile' do
47+
allow(school).to receive(:with_lock).and_call_original
48+
49+
described_class.call(school:, domain:, token:)
50+
51+
expect(school).to have_received(:with_lock)
52+
end
53+
4654
context 'when multiple domains already exist' do
4755
before do
4856
create(:school_email_domain, school:, domain: 'first.edu')

0 commit comments

Comments
 (0)