Change summary
forms/registration/btc.rb | 19 +++++++++++++++++++
lib/registration.rb | 16 ++++++++--------
test/test_registration.rb | 10 ++--------
3 files changed, 29 insertions(+), 16 deletions(-)
Detailed changes
@@ -0,0 +1,19 @@
+result!
+title "Activate using Bitcoin"
+
+field(
+ label: "Minimum initial Bitcoin deposit for activation",
+ var: "amount",
+ value: "%.6f" % @amount
+)
+
+field(
+ label: "Bitcoin address",
+ var: "btc_addresses",
+ value: @addr
+)
+
+instructions(
+ "You will received a notification when your payment is complete." \
+ "#{@final_message}"
+)
@@ -187,14 +187,15 @@ class Registration
REDIS.setex("pending_tel_for-#{@customer.jid}", THIRTY_DAYS, tel)
end
- def note_text(rate, addr)
+ def form(rate, addr)
amount = CONFIG[:activation_amount] / rate
- <<~NOTE
- Activate your account by sending at least #{'%.6f' % amount} BTC to
- #{addr}
- You will receive a notification when your payment is complete.
- NOTE
+ FormTemplate.render(
+ "registration/btc",
+ amount: amount,
+ addr: addr,
+ final_message: @final_message
+ )
end
def write
@@ -202,8 +203,7 @@ class Registration
Command.reply { |reply|
reply.allowed_actions = [:prev]
reply.status = :canceled
- reply.note_type = :info
- reply.note_text = note_text(rate, addr) + @final_message.to_s
+ reply.command << form(rate, addr)
}.then(&method(:handle_possible_prev))
end
end
@@ -340,20 +340,14 @@ class RegistrationTest < Minitest::Test
EMPromise.resolve([]),
["jmp_customer_btc_addresses-test"]
)
- reply_text = <<~NOTE
- Activate your account by sending at least 1.000000 BTC to
- testaddr
-
- You will receive a notification when your payment is complete.
- NOTE
blather = Minitest::Mock.new
Command::COMMAND_MANAGER.expect(
:write,
EMPromise.reject(SessionManager::Timeout.new),
[Matching.new do |reply|
assert_equal :canceled, reply.status
- assert_equal :info, reply.note_type
- assert_equal reply_text, reply.note.content
+ assert_equal "1.000000", reply.form.field("amount").value
+ assert_equal "testaddr", reply.form.field("btc_addresses").value
true
end]
)