bscf-core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/models/bscf/core/address.rb +7 -0
  4. data/app/models/bscf/core/business.rb +15 -0
  5. data/app/models/bscf/core/category.rb +11 -0
  6. data/app/models/bscf/core/order.rb +24 -0
  7. data/app/models/bscf/core/order_item.rb +15 -0
  8. data/app/models/bscf/core/product.rb +29 -0
  9. data/app/models/bscf/core/quotation.rb +29 -0
  10. data/app/models/bscf/core/quotation_item.rb +23 -0
  11. data/app/models/bscf/core/request_for_quotation.rb +13 -0
  12. data/app/models/bscf/core/rfq_item.rb +9 -0
  13. data/app/models/bscf/core/role.rb +10 -0
  14. data/app/models/bscf/core/user.rb +21 -0
  15. data/app/models/bscf/core/user_profile.rb +26 -0
  16. data/app/models/bscf/core/user_role.rb +8 -0
  17. data/app/models/bscf/core/virtual_account.rb +53 -0
  18. data/app/models/bscf/core/virtual_account_transaction.rb +158 -0
  19. data/db/migrate/20250326065606_create_bscf_core_users.rb +18 -0
  20. data/db/migrate/20250326075111_create_bscf_core_roles.rb +9 -0
  21. data/db/migrate/20250326080646_create_bscf_core_user_profiles.rb +19 -0
  22. data/db/migrate/20250326081052_create_bscf_core_addresses.rb +14 -0
  23. data/db/migrate/20250326084233_create_bscf_core_user_roles.rb +10 -0
  24. data/db/migrate/20250326085741_create_bscf_core_virtual_accounts.rb +24 -0
  25. data/db/migrate/20250326103305_create_bscf_core_categories.rb +11 -0
  26. data/db/migrate/20250326105652_create_bscf_core_products.rb +14 -0
  27. data/db/migrate/20250326112449_create_bscf_core_businesses.rb +14 -0
  28. data/db/migrate/20250326115203_create_bscf_core_request_for_quotations.rb +11 -0
  29. data/db/migrate/20250326120613_create_bscf_core_rfq_items.rb +12 -0
  30. data/db/migrate/20250326121246_create_bscf_core_bscf_core_virtual_account_transactions.rb +19 -0
  31. data/db/migrate/20250327041651_create_bscf_core_quotations.rb +15 -0
  32. data/db/migrate/20250327044020_create_bscf_core_quotation_items.rb +15 -0
  33. data/db/migrate/20250327102217_create_bscf_core_orders.rb +14 -0
  34. data/db/migrate/20250327112412_create_bscf_core_order_items.rb +14 -0
  35. data/lib/bscf/core/engine.rb +18 -0
  36. data/lib/bscf/core/version.rb +1 -1
  37. data/lib/tasks/release.rake +42 -0
  38. data/spec/dummy/db/schema.rb +246 -0
  39. data/spec/dummy/log/development.log +2060 -0
  40. data/spec/dummy/log/test.log +69259 -0
  41. data/spec/examples.txt +167 -3
  42. data/spec/factories/bscf/core/addresses.rb +10 -0
  43. data/spec/factories/bscf/core/businesses.rb +24 -0
  44. data/spec/factories/bscf/core/categories.rb +16 -0
  45. data/spec/factories/bscf/core/order_items.rb +10 -0
  46. data/spec/factories/bscf/core/orders.rb +10 -0
  47. data/spec/factories/bscf/core/products.rb +8 -0
  48. data/spec/factories/bscf/core/quotation_items.rb +11 -0
  49. data/spec/factories/bscf/core/quotations.rb +28 -0
  50. data/spec/factories/bscf/core/request_for_quotations.rb +7 -0
  51. data/spec/factories/bscf/core/rfq_items.rb +8 -0
  52. data/spec/factories/bscf/core/roles.rb +5 -0
  53. data/spec/factories/bscf/core/user_profiles.rb +15 -0
  54. data/spec/factories/bscf/core/user_roles.rb +6 -0
  55. data/spec/factories/bscf/core/users.rb +10 -0
  56. data/spec/factories/bscf/core/virtual_account_transactions.rb +34 -0
  57. data/spec/factories/bscf/core/virtual_accounts.rb +38 -0
  58. data/spec/models/bscf/core/address_spec.rb +12 -0
  59. data/spec/models/bscf/core/business_spec.rb +64 -0
  60. data/spec/models/bscf/core/category_spec.rb +43 -0
  61. data/spec/models/bscf/core/order_item_spec.rb +26 -0
  62. data/spec/models/bscf/core/order_spec.rb +16 -0
  63. data/spec/models/bscf/core/product_spec.rb +47 -0
  64. data/spec/models/bscf/core/quotation_item_spec.rb +44 -0
  65. data/spec/models/bscf/core/quotation_spec.rb +41 -0
  66. data/spec/models/bscf/core/request_for_quotation_spec.rb +13 -0
  67. data/spec/models/bscf/core/rfq_item_spec.rb +14 -0
  68. data/spec/models/bscf/core/role_spec.rb +14 -0
  69. data/spec/models/bscf/core/user_profile_spec.rb +20 -0
  70. data/spec/models/bscf/core/user_role_spec.rb +13 -0
  71. data/spec/models/bscf/core/user_spec.rb +22 -0
  72. data/spec/models/bscf/core/virtual_account_spec.rb +111 -0
  73. data/spec/models/bscf/core/virtual_account_transaction_spec.rb +133 -0
  74. data/spec/spec_helper.rb +4 -1
  75. data/spec/support/requests/shared_requests.rb +4 -4
  76. metadata +69 -2
data/spec/examples.txt CHANGED
@@ -1,3 +1,167 @@
1
- example_id | status | run_time |
2
- -------------------------- | ------ | --------------- |
3
- ./spec/sample_spec.rb[1:1] | passed | 0.00068 seconds |
1
+ example_id | status | run_time |
2
+ --------------------------------------------------------------------- | ------ | --------------- |
3
+ ./spec/models/bscf/core/address_spec.rb[1:1] | passed | 0.00229 seconds |
4
+ ./spec/models/bscf/core/address_spec.rb[1:2] | passed | 0.00248 seconds |
5
+ ./spec/models/bscf/core/business_spec.rb[1:1] | passed | 0.00607 seconds |
6
+ ./spec/models/bscf/core/business_spec.rb[1:2] | passed | 0.00721 seconds |
7
+ ./spec/models/bscf/core/business_spec.rb[1:3] | passed | 0.00634 seconds |
8
+ ./spec/models/bscf/core/business_spec.rb[1:4] | passed | 0.00686 seconds |
9
+ ./spec/models/bscf/core/business_spec.rb[1:5] | passed | 0.00676 seconds |
10
+ ./spec/models/bscf/core/business_spec.rb[1:6] | passed | 0.00536 seconds |
11
+ ./spec/models/bscf/core/business_spec.rb[1:7:1:1] | passed | 0.00732 seconds |
12
+ ./spec/models/bscf/core/business_spec.rb[1:8:1] | passed | 0.00601 seconds |
13
+ ./spec/models/bscf/core/business_spec.rb[1:8:2] | passed | 0.00568 seconds |
14
+ ./spec/models/bscf/core/business_spec.rb[1:9:1] | passed | 0.00623 seconds |
15
+ ./spec/models/bscf/core/business_spec.rb[1:10:1] | passed | 0.00206 seconds |
16
+ ./spec/models/bscf/core/business_spec.rb[1:10:2] | passed | 0.00206 seconds |
17
+ ./spec/models/bscf/core/business_spec.rb[1:11:1] | passed | 0.00577 seconds |
18
+ ./spec/models/bscf/core/business_spec.rb[1:11:2] | passed | 0.0054 seconds |
19
+ ./spec/models/bscf/core/business_spec.rb[1:11:3] | passed | 0.00553 seconds |
20
+ ./spec/models/bscf/core/category_spec.rb[1:1] | passed | 0.00201 seconds |
21
+ ./spec/models/bscf/core/category_spec.rb[1:2] | passed | 0.00285 seconds |
22
+ ./spec/models/bscf/core/category_spec.rb[1:3] | passed | 0.0031 seconds |
23
+ ./spec/models/bscf/core/category_spec.rb[1:4:1] | passed | 0.00262 seconds |
24
+ ./spec/models/bscf/core/category_spec.rb[1:4:2] | passed | 0.00354 seconds |
25
+ ./spec/models/bscf/core/category_spec.rb[1:4:3] | passed | 0.00181 seconds |
26
+ ./spec/models/bscf/core/category_spec.rb[1:5:1] | passed | 0.00857 seconds |
27
+ ./spec/models/bscf/core/order_item_spec.rb[1:1] | passed | 0.04477 seconds |
28
+ ./spec/models/bscf/core/order_item_spec.rb[1:2] | passed | 0.04414 seconds |
29
+ ./spec/models/bscf/core/order_item_spec.rb[1:3] | passed | 0.04489 seconds |
30
+ ./spec/models/bscf/core/order_item_spec.rb[1:4] | passed | 0.04439 seconds |
31
+ ./spec/models/bscf/core/order_item_spec.rb[1:5] | passed | 0.04574 seconds |
32
+ ./spec/models/bscf/core/order_item_spec.rb[1:6] | passed | 0.06206 seconds |
33
+ ./spec/models/bscf/core/order_item_spec.rb[1:7] | passed | 0.04486 seconds |
34
+ ./spec/models/bscf/core/order_item_spec.rb[1:8:1] | passed | 0.04475 seconds |
35
+ ./spec/models/bscf/core/order_spec.rb[1:1] | passed | 0.01806 seconds |
36
+ ./spec/models/bscf/core/order_spec.rb[1:2] | passed | 0.02019 seconds |
37
+ ./spec/models/bscf/core/order_spec.rb[1:3] | passed | 0.01823 seconds |
38
+ ./spec/models/bscf/core/order_spec.rb[1:4] | passed | 0.01783 seconds |
39
+ ./spec/models/bscf/core/order_spec.rb[1:5] | passed | 0.0186 seconds |
40
+ ./spec/models/bscf/core/order_spec.rb[1:6] | passed | 0.01875 seconds |
41
+ ./spec/models/bscf/core/product_spec.rb[1:1] | passed | 0.00691 seconds |
42
+ ./spec/models/bscf/core/product_spec.rb[1:2] | passed | 0.00576 seconds |
43
+ ./spec/models/bscf/core/product_spec.rb[1:3] | passed | 0.00676 seconds |
44
+ ./spec/models/bscf/core/product_spec.rb[1:4] | passed | 0.00498 seconds |
45
+ ./spec/models/bscf/core/product_spec.rb[1:5] | passed | 0.00514 seconds |
46
+ ./spec/models/bscf/core/product_spec.rb[1:6] | passed | 0.00503 seconds |
47
+ ./spec/models/bscf/core/product_spec.rb[1:7] | passed | 0.00444 seconds |
48
+ ./spec/models/bscf/core/product_spec.rb[1:8:1] | passed | 0.00375 seconds |
49
+ ./spec/models/bscf/core/product_spec.rb[1:8:2] | passed | 0.00532 seconds |
50
+ ./spec/models/bscf/core/product_spec.rb[1:8:3] | passed | 0.00416 seconds |
51
+ ./spec/models/bscf/core/product_spec.rb[1:8:4] | passed | 0.00778 seconds |
52
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:1] | passed | 0.02403 seconds |
53
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:2] | passed | 0.0251 seconds |
54
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:3] | passed | 0.02261 seconds |
55
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:4] | passed | 0.02414 seconds |
56
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:5] | passed | 0.02304 seconds |
57
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:6] | passed | 0.03561 seconds |
58
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:7] | passed | 0.02265 seconds |
59
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:8] | passed | 0.0246 seconds |
60
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:9] | passed | 0.92674 seconds |
61
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:10:1] | passed | 0.02368 seconds |
62
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:10:2] | passed | 0.02331 seconds |
63
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:11:1] | passed | 0.00618 seconds |
64
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:11:2] | passed | 0.00599 seconds |
65
+ ./spec/models/bscf/core/quotation_item_spec.rb[1:11:3] | passed | 0.00676 seconds |
66
+ ./spec/models/bscf/core/quotation_spec.rb[1:1] | passed | 0.01102 seconds |
67
+ ./spec/models/bscf/core/quotation_spec.rb[1:2] | passed | 0.01175 seconds |
68
+ ./spec/models/bscf/core/quotation_spec.rb[1:3] | passed | 0.0107 seconds |
69
+ ./spec/models/bscf/core/quotation_spec.rb[1:4] | passed | 0.01228 seconds |
70
+ ./spec/models/bscf/core/quotation_spec.rb[1:5] | passed | 0.01113 seconds |
71
+ ./spec/models/bscf/core/quotation_spec.rb[1:6] | passed | 0.0122 seconds |
72
+ ./spec/models/bscf/core/quotation_spec.rb[1:7] | passed | 0.01183 seconds |
73
+ ./spec/models/bscf/core/quotation_spec.rb[1:8] | passed | 0.01091 seconds |
74
+ ./spec/models/bscf/core/quotation_spec.rb[1:9] | passed | 0.01085 seconds |
75
+ ./spec/models/bscf/core/quotation_spec.rb[1:10] | passed | 0.0138 seconds |
76
+ ./spec/models/bscf/core/quotation_spec.rb[1:11] | passed | 0.01079 seconds |
77
+ ./spec/models/bscf/core/quotation_spec.rb[1:12:1] | passed | 0.01096 seconds |
78
+ ./spec/models/bscf/core/quotation_spec.rb[1:13:1] | passed | 0.01152 seconds |
79
+ ./spec/models/bscf/core/quotation_spec.rb[1:14:1] | passed | 0.04296 seconds |
80
+ ./spec/models/bscf/core/request_for_quotation_spec.rb[1:1] | passed | 0.00548 seconds |
81
+ ./spec/models/bscf/core/request_for_quotation_spec.rb[1:2] | passed | 0.0053 seconds |
82
+ ./spec/models/bscf/core/request_for_quotation_spec.rb[1:3] | passed | 0.00581 seconds |
83
+ ./spec/models/bscf/core/rfq_item_spec.rb[1:1] | passed | 0.00904 seconds |
84
+ ./spec/models/bscf/core/rfq_item_spec.rb[1:2] | passed | 0.00932 seconds |
85
+ ./spec/models/bscf/core/rfq_item_spec.rb[1:3] | passed | 0.01761 seconds |
86
+ ./spec/models/bscf/core/rfq_item_spec.rb[1:4] | passed | 0.01062 seconds |
87
+ ./spec/models/bscf/core/role_spec.rb[1:1] | passed | 0.00162 seconds |
88
+ ./spec/models/bscf/core/role_spec.rb[1:2] | passed | 0.00281 seconds |
89
+ ./spec/models/bscf/core/role_spec.rb[1:3] | passed | 0.00188 seconds |
90
+ ./spec/models/bscf/core/role_spec.rb[1:4] | passed | 0.00174 seconds |
91
+ ./spec/models/bscf/core/user_profile_spec.rb[1:1] | passed | 0.00879 seconds |
92
+ ./spec/models/bscf/core/user_profile_spec.rb[1:2] | passed | 0.00834 seconds |
93
+ ./spec/models/bscf/core/user_profile_spec.rb[1:3] | passed | 0.01078 seconds |
94
+ ./spec/models/bscf/core/user_profile_spec.rb[1:4] | passed | 0.03396 seconds |
95
+ ./spec/models/bscf/core/user_profile_spec.rb[1:5] | passed | 0.00857 seconds |
96
+ ./spec/models/bscf/core/user_profile_spec.rb[1:6] | passed | 0.01016 seconds |
97
+ ./spec/models/bscf/core/user_profile_spec.rb[1:7] | passed | 0.00742 seconds |
98
+ ./spec/models/bscf/core/user_profile_spec.rb[1:8] | passed | 0.00769 seconds |
99
+ ./spec/models/bscf/core/user_profile_spec.rb[1:9] | passed | 0.00876 seconds |
100
+ ./spec/models/bscf/core/user_role_spec.rb[1:1] | passed | 0.00626 seconds |
101
+ ./spec/models/bscf/core/user_role_spec.rb[1:2] | passed | 0.00634 seconds |
102
+ ./spec/models/bscf/core/user_role_spec.rb[1:3] | passed | 0.01868 seconds |
103
+ ./spec/models/bscf/core/user_spec.rb[1:1] | passed | 0.00423 seconds |
104
+ ./spec/models/bscf/core/user_spec.rb[1:2] | passed | 0.00736 seconds |
105
+ ./spec/models/bscf/core/user_spec.rb[1:3] | passed | 0.005 seconds |
106
+ ./spec/models/bscf/core/user_spec.rb[1:4] | passed | 0.00528 seconds |
107
+ ./spec/models/bscf/core/user_spec.rb[1:5] | passed | 0.00722 seconds |
108
+ ./spec/models/bscf/core/user_spec.rb[1:6] | passed | 0.00759 seconds |
109
+ ./spec/models/bscf/core/user_spec.rb[1:7] | passed | 0.0069 seconds |
110
+ ./spec/models/bscf/core/user_spec.rb[1:8] | passed | 0.00594 seconds |
111
+ ./spec/models/bscf/core/user_spec.rb[1:9] | passed | 0.00781 seconds |
112
+ ./spec/models/bscf/core/user_spec.rb[1:10] | passed | 0.00872 seconds |
113
+ ./spec/models/bscf/core/user_spec.rb[1:11] | passed | 0.00406 seconds |
114
+ ./spec/models/bscf/core/user_spec.rb[1:12] | passed | 0.00499 seconds |
115
+ ./spec/models/bscf/core/user_spec.rb[1:13] | passed | 0.00426 seconds |
116
+ ./spec/models/bscf/core/user_spec.rb[1:14] | passed | 0.00427 seconds |
117
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:1] | passed | 0.00645 seconds |
118
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:2] | passed | 0.00881 seconds |
119
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:3] | passed | 0.01212 seconds |
120
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:4] | passed | 0.00827 seconds |
121
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:5] | passed | 0.00938 seconds |
122
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:6] | passed | 0.0071 seconds |
123
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:7] | passed | 0.00679 seconds |
124
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:8] | passed | 0.00719 seconds |
125
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:9] | passed | 0.00663 seconds |
126
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:10] | passed | 0.00726 seconds |
127
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:11] | passed | 0.0072 seconds |
128
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:12] | passed | 0.02598 seconds |
129
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:13] | passed | 0.0082 seconds |
130
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:14] | passed | 0.00725 seconds |
131
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:15] | passed | 0.00668 seconds |
132
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:16] | passed | 0.00722 seconds |
133
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:17] | passed | 0.00763 seconds |
134
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:18] | passed | 0.00697 seconds |
135
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:19] | passed | 0.0071 seconds |
136
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:20:1] | passed | 0.02741 seconds |
137
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:20:2] | passed | 0.02691 seconds |
138
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:20:3] | passed | 0.02815 seconds |
139
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:21:1] | passed | 0.00696 seconds |
140
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:21:2] | passed | 0.00566 seconds |
141
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:21:3] | passed | 0.01104 seconds |
142
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:22:1] | passed | 0.00208 seconds |
143
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:22:2] | passed | 0.00194 seconds |
144
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:23:1] | passed | 0.00632 seconds |
145
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:23:2] | passed | 0.00601 seconds |
146
+ ./spec/models/bscf/core/virtual_account_spec.rb[1:23:3] | passed | 0.00668 seconds |
147
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:1] | passed | 0.017 seconds |
148
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:2] | passed | 0.01402 seconds |
149
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:3] | passed | 0.01373 seconds |
150
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:4] | passed | 0.01428 seconds |
151
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:5] | passed | 0.01428 seconds |
152
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:6] | passed | 0.01534 seconds |
153
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:7] | passed | 0.02723 seconds |
154
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:8:1] | passed | 0.01381 seconds |
155
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:9:1] | passed | 0.01358 seconds |
156
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:9:2] | passed | 0.0141 seconds |
157
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:10:1] | passed | 0.00505 seconds |
158
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:10:2] | passed | 0.0051 seconds |
159
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:1:1] | passed | 0.0173 seconds |
160
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:1:2] | passed | 0.01245 seconds |
161
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:1:3] | passed | 0.0133 seconds |
162
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:2:1] | passed | 0.01535 seconds |
163
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:2:2] | passed | 0.00954 seconds |
164
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:3:1] | passed | 0.01964 seconds |
165
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:11:3:2] | passed | 0.00994 seconds |
166
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:12:1] | passed | 0.01374 seconds |
167
+ ./spec/models/bscf/core/virtual_account_transaction_spec.rb[1:12:2] | passed | 0.01276 seconds |
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :address, class: "Bscf::Core::Address" do
3
+ city { Faker::Address.city }
4
+ sub_city { Faker::Name.name }
5
+ woreda { Faker::Name.name }
6
+ latitude { Faker::Address.latitude }
7
+ longitude { Faker::Address.longitude }
8
+ house_number { Faker::Address.building_number }
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ FactoryBot.define do
2
+ factory :business, class: 'Bscf::Core::Business' do
3
+ user
4
+ business_name { Faker::Company.name }
5
+ tin_number { Faker::Number.unique.number(digits: 10).to_s }
6
+ business_type { :retailer }
7
+ verification_status { :pending }
8
+ verified_at { nil }
9
+
10
+ trait :wholesaler do
11
+ business_type { :wholesaler }
12
+ end
13
+
14
+ trait :approved do
15
+ verification_status { :approved }
16
+ verified_at { Time.current }
17
+ end
18
+
19
+ trait :rejected do
20
+ verification_status { :rejected }
21
+ verified_at { Time.current }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ FactoryBot.define do
2
+ factory :category, class: 'Bscf::Core::Category' do
3
+ name { Faker::Commerce.department }
4
+ description { Faker::Lorem.sentence }
5
+
6
+ trait :with_parent do
7
+ association :parent, factory: :category
8
+ end
9
+
10
+ trait :with_children do
11
+ after(:create) do |category|
12
+ create_list(:category, 2, parent: category)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :order_item, class: "Bscf::Core::OrderItem" do
3
+ order
4
+ product
5
+ quotation_item
6
+ quantity { Faker::Number.between(from: 1, to: 15) }
7
+ unit_price { Faker::Number.between(from: 10, to: 100) }
8
+ subtotal { Faker::Number.between(from: 200, to: 15000) }
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :order, class: "Bscf::Core::Order" do
3
+ ordered_by { create(:user) }
4
+ ordered_to { create(:user) }
5
+ quotation { create(:quotation) }
6
+ order_type { :order_from_quote }
7
+ status { :draft }
8
+ total_amount { Faker::Number.between(from: 100, to: 1000) }
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :product, class: 'Bscf::Core::Product' do
3
+ name { Faker::Commerce.product_name }
4
+ description { Faker::Lorem.paragraph }
5
+ association :category, factory: :category
6
+ base_price { Faker::Commerce.price(range: 0..1000.0) }
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :quotation_item, class: 'Bscf::Core::QuotationItem' do
3
+ association :quotation
4
+ association :rfq_item
5
+ association :product
6
+ quantity { rand(1..10) }
7
+ unit_price { rand(10.0..100.0).round(2) }
8
+ unit { 1 }
9
+ subtotal { quantity * unit_price }
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ FactoryBot.define do
2
+ factory :quotation, class: 'Bscf::Core::Quotation' do
3
+ association :request_for_quotation
4
+ association :business
5
+ price { Faker::Commerce.price }
6
+ delivery_date { Faker::Date.forward(days: 30) }
7
+ valid_until { Faker::Time.forward(days: 30) }
8
+ status { :draft }
9
+ notes { Faker::Lorem.paragraph }
10
+
11
+ trait :submitted do
12
+ status { :submitted }
13
+ end
14
+
15
+ trait :accepted do
16
+ status { :accepted }
17
+ end
18
+
19
+ trait :rejected do
20
+ status { :rejected }
21
+ end
22
+
23
+ trait :expired do
24
+ status { :expired }
25
+ valid_until { 1.day.ago }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :request_for_quotation, class: "Bscf::Core::RequestForQuotation" do
3
+ user
4
+ status { 0 }
5
+ notes { Faker::Lorem.sentence }
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :rfq_item, class: "Bscf::Core::RfqItem" do
3
+ request_for_quotation
4
+ product
5
+ quantity { Faker::Number.between(from: 1, to: 20) }
6
+ notes { Faker::Lorem.sentence }
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :role, class: "Bscf::Core::Role" do
3
+ name { Faker::Name.name }
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ FactoryBot.define do
2
+ factory :user_profile, class: "Bscf::Core::UserProfile" do
3
+ user
4
+ date_of_birth { Date.today }
5
+ nationality { Faker::Address.country }
6
+ occupation { Faker::Job.title }
7
+ source_of_funds { Faker::Lorem.word }
8
+ kyc_status { 1 }
9
+ gender { 1 }
10
+ verified_at { DateTime.now }
11
+ verified_by { nil }
12
+ address
13
+ fayda_id { Faker::Alphanumeric.alpha(number: 10) }
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :user_role, class: "Bscf::Core::UserRole" do
3
+ user
4
+ role
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :user, class: "Bscf::Core::User" do
3
+ first_name { Faker::Name.first_name }
4
+ middle_name { Faker::Name.middle_name }
5
+ last_name { Faker::Name.last_name }
6
+ password { Faker::Internet.password }
7
+ email { Faker::Internet.email }
8
+ phone_number { Faker::Alphanumeric.alpha(number: 10) }
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ FactoryBot.define do
2
+ factory :virtual_account_transaction, class: 'Bscf::Core::VirtualAccountTransaction' do
3
+ association :from_account, factory: :virtual_account, status: :active, balance: 10000
4
+ association :to_account, factory: :virtual_account, status: :active, balance: 5000
5
+ amount { 100.0 }
6
+ transaction_type { :transfer }
7
+ status { :pending }
8
+ description { Faker::Lorem.sentence }
9
+
10
+ trait :completed do
11
+ status { :completed }
12
+ end
13
+
14
+ trait :failed do
15
+ status { :failed }
16
+ end
17
+
18
+ trait :cancelled do
19
+ status { :cancelled }
20
+ end
21
+
22
+ trait :deposit do
23
+ transaction_type { :deposit }
24
+ end
25
+
26
+ trait :withdrawal do
27
+ transaction_type { :withdrawal }
28
+ end
29
+
30
+ trait :with_large_amount do
31
+ amount { 5000.0 }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ FactoryBot.define do
2
+ factory :virtual_account, class: 'Bscf::Core::VirtualAccount' do
3
+ association :user, factory: :user
4
+
5
+ sequence(:cbs_account_number) { |n| "CBS#{n.to_s.rjust(8, '0')}" }
6
+ branch_code { "BR001" }
7
+ product_scheme { "SAVINGS" }
8
+ voucher_type { "REGULAR" }
9
+ balance { 0.0 }
10
+ interest_rate { 2.5 }
11
+ interest_type { :simple }
12
+ active { true }
13
+ status { :pending }
14
+
15
+ trait :active_status do
16
+ status { :active }
17
+ end
18
+
19
+ trait :with_balance do
20
+ balance { Faker::Number.decimal(l_digits: 4, r_digits: 2) }
21
+ end
22
+
23
+ trait :compound_interest do
24
+ interest_type { :compound }
25
+ interest_rate { 5.0 }
26
+ end
27
+
28
+ trait :current_account do
29
+ product_scheme { "CURRENT" }
30
+ interest_rate { 0.0 }
31
+ end
32
+
33
+ trait :loan_account do
34
+ product_scheme { "LOAN" }
35
+ interest_rate { 12.5 }
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,12 @@
1
+ require 'rails_helper'
2
+
3
+ module Bscf
4
+ module Core
5
+ RSpec.describe Address, type: :model do
6
+ attributes = [
7
+ { user_profiles: :have_many }
8
+ ]
9
+ include_examples("model_shared_spec", :address, attributes)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,64 @@
1
+ require 'rails_helper'
2
+
3
+ module Bscf
4
+ module Core
5
+ RSpec.describe Business, type: :model do
6
+ attributes = [
7
+ { business_name: [ :presence ] },
8
+ { tin_number: [ :presence ] },
9
+ { business_type: [ :presence ] },
10
+ { verification_status: [ :presence ] },
11
+ { user: :belong_to }
12
+ ]
13
+
14
+ include_examples("model_shared_spec", :business, attributes)
15
+
16
+ describe 'validations' do
17
+ describe 'tin_number uniqueness' do
18
+ subject { build(:business) }
19
+ it { should validate_uniqueness_of(:tin_number).case_insensitive }
20
+ end
21
+ end
22
+
23
+ describe 'enums' do
24
+ it { should define_enum_for(:business_type).with_values(retailer: 0, wholesaler: 1) }
25
+ it { should define_enum_for(:verification_status).with_values(pending: 0, approved: 1, rejected: 2) }
26
+ end
27
+
28
+ describe 'associations' do
29
+ it { should belong_to(:user).class_name('Bscf::Core::User') }
30
+ end
31
+
32
+ describe 'defaults' do
33
+ let(:business) { build(:business) }
34
+
35
+ it 'sets default business_type to retailer' do
36
+ expect(business.business_type).to eq('retailer')
37
+ end
38
+
39
+ it 'sets default verification_status to pending' do
40
+ expect(business.verification_status).to eq('pending')
41
+ end
42
+ end
43
+
44
+ describe 'factory traits' do
45
+ it 'creates wholesaler business' do
46
+ business = create(:business, :wholesaler)
47
+ expect(business).to be_wholesaler
48
+ end
49
+
50
+ it 'creates approved business' do
51
+ business = create(:business, :approved)
52
+ expect(business).to be_approved
53
+ expect(business.verified_at).to be_present
54
+ end
55
+
56
+ it 'creates rejected business' do
57
+ business = create(:business, :rejected)
58
+ expect(business).to be_rejected
59
+ expect(business.verified_at).to be_present
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,43 @@
1
+ require 'rails_helper'
2
+
3
+ module Bscf
4
+ module Core
5
+ RSpec.describe Category, type: :model do
6
+ attributes = [
7
+ { name: [ :presence ] },
8
+ { description: [ :presence ] }
9
+ ]
10
+
11
+ include_examples("model_shared_spec", :category, attributes)
12
+
13
+ describe 'associations' do
14
+ let(:parent_category) { create(:category) }
15
+ let(:child_category) { create(:category, parent: parent_category) }
16
+
17
+ it 'can have a parent category' do
18
+ expect(child_category.parent).to eq(parent_category)
19
+ end
20
+
21
+ it 'can have child categories' do
22
+ child_category
23
+ expect(parent_category.children).to include(child_category)
24
+ end
25
+
26
+ it 'allows parent to be optional' do
27
+ category = create(:category)
28
+ expect(category.parent).to be_nil
29
+ end
30
+ end
31
+
32
+ describe 'hierarchical structure' do
33
+ let(:parent) { create(:category) }
34
+ let!(:children) { create_list(:category, 3, parent: parent) }
35
+
36
+ it 'maintains proper parent-child relationships' do
37
+ expect(parent.children.count).to eq(3)
38
+ expect(children.map(&:parent)).to all(eq(parent))
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ require 'rails_helper'
2
+
3
+ module Bscf
4
+ module Core
5
+ RSpec.describe OrderItem, type: :model do
6
+ attributes = [
7
+ { order: :belong_to },
8
+ { product: :belong_to },
9
+ { quotation_item: [ { belong_to: [ [ :optional, nil ] ] } ] },
10
+ { quantity: :presence },
11
+ { unit_price: :presence },
12
+ { subtotal: :presence }
13
+ ]
14
+ include_examples("model_shared_spec", :order_item, attributes)
15
+
16
+
17
+ describe "#calculate_subtotal" do
18
+ it "calculates subtotal" do
19
+ order_item = create(:order_item, quantity: 2, unit_price: 25)
20
+ order_item.calculate_subtotal
21
+ expect(order_item.calculate_subtotal).to eq 50.0
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ module Bscf
4
+ module Core
5
+ RSpec.describe Order, type: :model do
6
+ attributes = [
7
+ { quotation: [ { belong_to: [ [ :optional, nil ] ] } ] },
8
+ { ordered_by: [ { belong_to: [ [ :optional, nil ] ] } ] },
9
+ { ordered_to: [ { belong_to: [ [ :optional, nil ] ] } ] },
10
+ { order_type: :presence },
11
+ { status: :presence }
12
+ ]
13
+ include_examples("model_shared_spec", :order, attributes)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,47 @@
1
+ require 'rails_helper'
2
+
3
+ module Bscf::Core
4
+ RSpec.describe Product, type: :model do
5
+ attributes = [
6
+ { sku: [ :presence, :uniqueness ] },
7
+ { name: [ :presence ] },
8
+ { description: [ :presence ] },
9
+ { base_price: [ :presence ] },
10
+ { category: :belong_to }
11
+ ]
12
+
13
+ include_examples("model_shared_spec", :product, attributes)
14
+
15
+ describe 'SKU generation' do
16
+ let(:category) { create(:category) }
17
+
18
+ it 'generates SKU automatically' do
19
+ product = create(:product, category: category)
20
+ expect(product.sku).to match(/\ABSC\d{7}\z/)
21
+ end
22
+
23
+ it 'generates sequential SKUs for same category' do
24
+ first_product = create(:product, category: category)
25
+ second_product = create(:product, category: category)
26
+
27
+ first_sequence = first_product.sku[-4..-1].to_i
28
+ second_sequence = second_product.sku[-4..-1].to_i
29
+
30
+ expect(second_sequence).to eq(first_sequence + 1)
31
+ end
32
+
33
+ it 'maintains category code in SKU' do
34
+ product = create(:product, category: category)
35
+ category_code = category.id.to_s.rjust(3, '0')
36
+ expect(product.sku[3..5]).to eq(category_code)
37
+ end
38
+
39
+ it 'does not modify existing SKU' do
40
+ product = create(:product, category: category)
41
+ original_sku = product.sku
42
+ product.update(name: 'Updated Name')
43
+ expect(product.reload.sku).to eq(original_sku)
44
+ end
45
+ end
46
+ end
47
+ end