This never worked right anyway

Stephen Paul Weber created

Change summary

forms/registration/activate.rb |   3 
forms/registration/allow.rb    |   3 
lib/registration.rb            |  26 ++------
test/test_registration.rb      | 105 +----------------------------------
4 files changed, 13 insertions(+), 124 deletions(-)

Detailed changes

forms/registration/activate.rb 🔗

@@ -1,9 +1,8 @@
 form!
 title "Activate JMP"
 
-center = " (#{@rate_center})" if @rate_center
 instructions <<~I
-	You've selected #{@tel}#{center} as your JMP number.
+	You've selected #{@tel} as your JMP number.
 	To activate your account, you can either deposit $#{CONFIG[:activation_amount]} to your balance or enter your referral code if you have one.
 	(If you'd like to pay in a cryptocurrency other than Bitcoin, currently we recommend using a service like simpleswap.io, morphtoken.com, changenow.io, or godex.io. Manual payment via Bitcoin Cash is also available if you contact support.)
 I

forms/registration/allow.rb 🔗

@@ -1,9 +1,8 @@
 form!
 title "Activate JMP"
 
-center = " (#{@rate_center})" if @rate_center
 instructions <<~I
-	You've selected #{@tel}#{center} as your JMP number.
+	You've selected #{@tel} as your JMP number.
 	As a user of #{@domain} you will start out with a free trial for one month, after which you will need to top up your balance to keep the account.
 I
 

lib/registration.rb 🔗

@@ -92,20 +92,14 @@ class Registration
 
 		attr_reader :customer, :tel
 
-		def form(center)
-			FormTemplate.render(
-				"registration/activate",
-				tel: tel,
-				rate_center: center
-			)
+		def form
+			FormTemplate.render("registration/activate", tel: tel)
 		end
 
 		def write
-			rate_center.then { |center|
-				Command.reply do |reply|
-					reply.allowed_actions = [:next]
-					reply.command << form(center)
-				end
+			Command.reply { |reply|
+				reply.allowed_actions = [:next]
+				reply.command << form
 			}.then(&method(:next_step))
 		end
 
@@ -136,13 +130,6 @@ class Registration
 			@customer.save_plan!
 		end
 
-		def rate_center
-			EM.promise_fiber {
-				center = BandwidthIris::Tn.get(tel).get_rate_center
-				"#{center[:rate_center]}, #{center[:state]}"
-			}.catch { nil }
-		end
-
 		class GooglePlay
 			def initialize(customer, google_play_userid, tel)
 				@customer = customer
@@ -207,11 +194,10 @@ class Registration
 				@credit_to = credit_to
 			end
 
-			def form(center)
+			def form
 				FormTemplate.render(
 					"registration/allow",
 					tel: tel,
-					rate_center: center,
 					domain: customer.jid.domain
 				)
 			end

test/test_registration.rb 🔗

@@ -115,25 +115,6 @@ class RegistrationTest < Minitest::Test
 		end
 
 		def test_write
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumber>5555550000</TelephoneNumber>
-				</TelephoneNumberResponse>
-			RESPONSE
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumberDetails>
-						<State>KE</State>
-						<RateCenter>FA</RateCenter>
-					</TelephoneNumberDetails>
-				</TelephoneNumberResponse>
-			RESPONSE
 			Command::COMMAND_MANAGER.expect(
 				:write,
 				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
@@ -142,7 +123,7 @@ class RegistrationTest < Minitest::Test
 				[Matching.new do |iq|
 					assert_equal :form, iq.form.type
 					assert_equal(
-						"You've selected +15555550000 (FA, KE) as your JMP number.",
+						"You've selected +15555550000 as your JMP number.",
 						iq.form.instructions.lines.first.chomp
 					)
 				end]
@@ -165,25 +146,6 @@ class RegistrationTest < Minitest::Test
 		em :test_write
 
 		def test_write_with_code
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumber>5555550000</TelephoneNumber>
-				</TelephoneNumberResponse>
-			RESPONSE
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumberDetails>
-						<State>KE</State>
-						<RateCenter>FA</RateCenter>
-					</TelephoneNumberDetails>
-				</TelephoneNumberResponse>
-			RESPONSE
 			Command::COMMAND_MANAGER.expect(
 				:write,
 				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
@@ -195,7 +157,7 @@ class RegistrationTest < Minitest::Test
 				[Matching.new do |iq|
 					assert_equal :form, iq.form.type
 					assert_equal(
-						"You've selected +15555550000 (FA, KE) as your JMP number.",
+						"You've selected +15555550000 as your JMP number.",
 						iq.form.instructions.lines.first.chomp
 					)
 				end]
@@ -226,25 +188,6 @@ class RegistrationTest < Minitest::Test
 		em :test_write_with_code
 
 		def test_write_with_group_code
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumber>5555550000</TelephoneNumber>
-				</TelephoneNumberResponse>
-			RESPONSE
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumberDetails>
-						<State>KE</State>
-						<RateCenter>FA</RateCenter>
-					</TelephoneNumberDetails>
-				</TelephoneNumberResponse>
-			RESPONSE
 			Command::COMMAND_MANAGER.expect(
 				:write,
 				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
@@ -256,7 +199,7 @@ class RegistrationTest < Minitest::Test
 				[Matching.new do |iq|
 					assert_equal :form, iq.form.type
 					assert_equal(
-						"You've selected +15555550000 (FA, KE) as your JMP number.",
+						"You've selected +15555550000 as your JMP number.",
 						iq.form.instructions.lines.first.chomp
 					)
 				end]
@@ -300,25 +243,6 @@ class RegistrationTest < Minitest::Test
 			cust = Minitest::Mock.new(customer("test"))
 			allow = Registration::Activation::Allow.new(cust, "+15555550000", nil)
 
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumber>5555550000</TelephoneNumber>
-				</TelephoneNumberResponse>
-			RESPONSE
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumberDetails>
-						<State>KE</State>
-						<RateCenter>FA</RateCenter>
-					</TelephoneNumberDetails>
-				</TelephoneNumberResponse>
-			RESPONSE
 			Command::COMMAND_MANAGER.expect(
 				:write,
 				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
@@ -327,7 +251,7 @@ class RegistrationTest < Minitest::Test
 				[Matching.new do |iq|
 					assert_equal :form, iq.form.type
 					assert_equal(
-						"You've selected +15555550000 (FA, KE) as your JMP number.",
+						"You've selected +15555550000 as your JMP number.",
 						iq.form.instructions.lines.first.chomp
 					)
 					assert_equal 1, iq.form.fields.length
@@ -356,25 +280,6 @@ class RegistrationTest < Minitest::Test
 				cust, "+15555550000", "refercust"
 			)
 
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumber>5555550000</TelephoneNumber>
-				</TelephoneNumberResponse>
-			RESPONSE
-			stub_request(
-				:get,
-				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
-			).to_return(status: 201, body: <<~RESPONSE)
-				<TelephoneNumberResponse>
-					<TelephoneNumberDetails>
-						<State>KE</State>
-						<RateCenter>FA</RateCenter>
-					</TelephoneNumberDetails>
-				</TelephoneNumberResponse>
-			RESPONSE
 			Command::COMMAND_MANAGER.expect(
 				:write,
 				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
@@ -383,7 +288,7 @@ class RegistrationTest < Minitest::Test
 				[Matching.new do |iq|
 					assert_equal :form, iq.form.type
 					assert_equal(
-						"You've selected +15555550000 (FA, KE) as your JMP number.",
+						"You've selected +15555550000 as your JMP number.",
 						iq.form.instructions.lines.first.chomp
 					)
 					assert_equal 1, iq.form.fields.length