forms/sim_details.rb 🔗
@@ -1,4 +1,9 @@
result!
title "(e)SIM Details"
-table(@sims, iccid: "ICCID", remaining_usage_mb: "MB Remaining")
+table(
+ @sims,
+ iccid: "ICCID",
+ remaining_usage_mb: "MB Remaining",
+ nickname: "Nickname"
+)
root21 created
Added columns to the eSIMs command to now display the nickname of a SIM,
if set.
Added test for the new columns in sim_repo.
Added nicknames column to sims form, and modified to a multiline form.
forms/sim_details.rb | 7 ++++++-
lib/sim.rb | 1 +
lib/sim_repo.rb | 6 ++++--
schemas | 2 +-
test/test_sim_repo.rb | 3 ++-
5 files changed, 14 insertions(+), 5 deletions(-)
@@ -1,4 +1,9 @@
result!
title "(e)SIM Details"
-table(@sims, iccid: "ICCID", remaining_usage_mb: "MB Remaining")
+table(
+ @sims,
+ iccid: "ICCID",
+ remaining_usage_mb: "MB Remaining",
+ nickname: "Nickname"
+)
@@ -9,6 +9,7 @@ class SIM
remaining_usage_kb Integer
remaining_days Integer
notes String
+ nickname Either(String, nil), default: nil
end
def self.extract(kwargs)
@@ -26,10 +26,12 @@ class SIMRepo
def owned_by(customer)
customer = customer.customer_id if customer.respond_to?(:customer_id)
promise = db.query_defer(<<~SQL, [customer])
- SELECT iccid FROM sims WHERE customer_id=$1
+ SELECT iccid, nickname FROM sims WHERE customer_id=$1
SQL
promise.then { |result|
- EMPromise.all(result.map { |row| find(row["iccid"]) })
+ EMPromise.all(result.map { |row|
+ find(row["iccid"]).then { |sim| sim.with(nickname: row["nickname"]) }
+ })
}
end
end
@@ -1 +1 @@
-Subproject commit a449672f5cad37e63e6339e4577ed27ff8289df9
+Subproject commit a9f8b83487140f91fc8da3a3de99f5f28aa060b9
@@ -7,7 +7,7 @@ class SIMRepoTest < Minitest::Test
def setup
@repo = SIMRepo.new(
db: FakeDB.new(
- ["test"] => [{ "iccid" => "1234" }]
+ ["test"] => [{ "iccid" => "1234", "nickname" => "My Cool SIM" }]
)
)
end
@@ -33,6 +33,7 @@ class SIMRepoTest < Minitest::Test
sims = @repo.owned_by("test").sync
assert_equal 1, sims.length
assert_equal "1234", sims[0].iccid
+ assert_equal "My Cool SIM", sims[0].nickname
assert_requested req
end
em :test_owned_by