Skip to content

Commit

Permalink
Fix bootstrapping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD committed Jan 15, 2025
1 parent 5d9ad05 commit 256b302
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/commands/user/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def call
private
def link_bootcamp_user!
ubd = User::BootcampData.find_by(access_code: bootcamp_access_code) if bootcamp_access_code.present?
ubd ||= User::BootcampData.paid.find_by(email: user.email)
ubd ||= User::BootcampData.find_by(email: user.email)
return unless ubd

Expand Down
15 changes: 15 additions & 0 deletions test/commands/user/bootstrap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,19 @@ class User::BootstrapTest < ActiveSupport::TestCase
refute user.reload.bootcamp_attendee?
assert_equal user.id, ubd.reload.user_id
end

test "finds paid bootcamp data first" do
email = "[email protected]"
create(:user_bootcamp_data, email:)
ubd = create :user_bootcamp_data, email:, paid_at: Time.current
create(:user_bootcamp_data, email:)
user = create(:user, email:)

# Always does this once by default anyway
User::Bootcamp::SubscribeToOnboardingEmails.expects(:defer).with(ubd).twice

User::Bootstrap.(user, bootcamp_access_code: ubd.access_code)
assert user.reload.bootcamp_attendee?
assert_equal user.id, ubd.reload.user_id
end
end

0 comments on commit 256b302

Please sign in to comment.