diff --git a/forms/registration/activate.rb b/forms/registration/activate.rb index 0cf8a0acc73bb935d1c5f8e1ac5f647ed4bbfe9f..7c630ff556c1ecf009968d28bd9a62785a1a7afb 100644 --- a/forms/registration/activate.rb +++ b/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 diff --git a/forms/registration/allow.rb b/forms/registration/allow.rb index ef4ece6c54f01374de2781a87c31bf5a5b2cddb4..d11e8455cb57747ca3587e5c25db1ecfe27afde1 100644 --- a/forms/registration/allow.rb +++ b/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 diff --git a/lib/registration.rb b/lib/registration.rb index 22d078f333ce2a5a36ca3a442893182c15adf14c..e8492e9739187877727c6fb9a7af0aaeb527d04b 100644 --- a/lib/registration.rb +++ b/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 diff --git a/test/test_registration.rb b/test/test_registration.rb index 1bf384d0c81cfce31bdfb3405c4978f792bdd965..b3bb2c31c8b648227d5761c3aea4abd8d8191392 100644 --- a/test/test_registration.rb +++ b/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) - - 5555550000 - - RESPONSE - stub_request( - :get, - "https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter" - ).to_return(status: 201, body: <<~RESPONSE) - - - KE - FA - - - 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) - - 5555550000 - - RESPONSE - stub_request( - :get, - "https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter" - ).to_return(status: 201, body: <<~RESPONSE) - - - KE - FA - - - 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) - - 5555550000 - - RESPONSE - stub_request( - :get, - "https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter" - ).to_return(status: 201, body: <<~RESPONSE) - - - KE - FA - - - 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) - - 5555550000 - - RESPONSE - stub_request( - :get, - "https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter" - ).to_return(status: 201, body: <<~RESPONSE) - - - KE - FA - - - 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) - - 5555550000 - - RESPONSE - stub_request( - :get, - "https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter" - ).to_return(status: 201, body: <<~RESPONSE) - - - KE - FA - - - 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