Reload customer after tel selection

Stephen Paul Weber created

Change summary

lib/registration.rb       |  8 +++++---
test/test_registration.rb | 22 ++++++++++++----------
2 files changed, 17 insertions(+), 13 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -116,9 +116,11 @@ class Registration
 				)
 			end
 
-			Registration::FinishOrStartActivation.for(
-				customer, google_play_userid, product
-			)
+			reload_customer(customer).then do |reloaded|
+				Registration::FinishOrStartActivation.for(
+					reloaded, google_play_userid, product
+				)
+			end
 		end
 	end
 

test/test_registration.rb 🔗

@@ -56,17 +56,15 @@ class RegistrationTest < Minitest::Test
 			"test@example.net",
 			TelSelections::ChooseTel::Tn.for_pending_value("+15555550000")
 		)
-		result = execute_command do
+		result = execute_command do |exe|
 			sgx = OpenStruct.new(registered?: false)
-			Registration.for(
-				customer(
-					plan_name: "test_usd",
-					expires_at: Time.now + 999,
-					sgx: sgx
-				),
-				nil,
-				web_manager
+			cust = customer(
+				plan_name: "test_usd",
+				expires_at: Time.now + 999,
+				sgx: sgx
 			)
+			exe.customer_repo.expect(:find, cust, [cust.customer_id])
+			Registration.for(cust, nil, web_manager)
 		end
 		assert_kind_of Registration::Finish, result
 		assert_requested reservation_req
@@ -2268,9 +2266,13 @@ class RegistrationTest < Minitest::Test
 		def test_for_with_telephone_number
 			cust = customer(plan_name: "test_usd", expires_at: Time.now + 999)
 			tel = TelSelections::ChooseTel::Tn.for_pending_value("+15555550000")
-			result = Registration::RegistrationType.for(cust, nil, tel)
+			result = execute_command do |exe|
+				exe.customer_repo.expect(:find, cust, [cust.customer_id])
+				Registration::RegistrationType.for(cust, nil, tel).sync
+			end
 			assert_kind_of Registration::Finish, result
 		end
+		em :test_for_with_telephone_number
 	end
 
 	class DataOnlyTest < Minitest::Test