bscf-core 0.2.0 → 0.2.1

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bscf/core/version.rb +1 -1
  3. metadata +2 -55
  4. data/spec/dummy/Rakefile +0 -6
  5. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  6. data/spec/dummy/app/controllers/application_controller.rb +0 -2
  7. data/spec/dummy/app/jobs/application_job.rb +0 -7
  8. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  9. data/spec/dummy/app/models/application_record.rb +0 -3
  10. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  11. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  12. data/spec/dummy/bin/dev +0 -2
  13. data/spec/dummy/bin/rails +0 -4
  14. data/spec/dummy/bin/rake +0 -4
  15. data/spec/dummy/bin/setup +0 -34
  16. data/spec/dummy/config/application.rb +0 -43
  17. data/spec/dummy/config/boot.rb +0 -5
  18. data/spec/dummy/config/cable.yml +0 -10
  19. data/spec/dummy/config/database.yml +0 -17
  20. data/spec/dummy/config/environment.rb +0 -5
  21. data/spec/dummy/config/environments/development.rb +0 -67
  22. data/spec/dummy/config/environments/production.rb +0 -86
  23. data/spec/dummy/config/environments/test.rb +0 -53
  24. data/spec/dummy/config/initializers/cors.rb +0 -16
  25. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -8
  26. data/spec/dummy/config/initializers/inflections.rb +0 -16
  27. data/spec/dummy/config/locales/en.yml +0 -31
  28. data/spec/dummy/config/puma.rb +0 -38
  29. data/spec/dummy/config/routes.rb +0 -3
  30. data/spec/dummy/config/storage.yml +0 -34
  31. data/spec/dummy/config.ru +0 -6
  32. data/spec/dummy/db/schema.rb +0 -246
  33. data/spec/dummy/log/development.log +0 -2077
  34. data/spec/dummy/log/test.log +0 -69259
  35. data/spec/dummy/tmp/local_secret.txt +0 -1
  36. data/spec/examples.txt +0 -167
  37. data/spec/models/bscf/core/address_spec.rb +0 -12
  38. data/spec/models/bscf/core/business_spec.rb +0 -64
  39. data/spec/models/bscf/core/category_spec.rb +0 -43
  40. data/spec/models/bscf/core/order_item_spec.rb +0 -26
  41. data/spec/models/bscf/core/order_spec.rb +0 -16
  42. data/spec/models/bscf/core/product_spec.rb +0 -47
  43. data/spec/models/bscf/core/quotation_item_spec.rb +0 -44
  44. data/spec/models/bscf/core/quotation_spec.rb +0 -41
  45. data/spec/models/bscf/core/request_for_quotation_spec.rb +0 -13
  46. data/spec/models/bscf/core/rfq_item_spec.rb +0 -14
  47. data/spec/models/bscf/core/role_spec.rb +0 -14
  48. data/spec/models/bscf/core/user_profile_spec.rb +0 -20
  49. data/spec/models/bscf/core/user_role_spec.rb +0 -13
  50. data/spec/models/bscf/core/user_spec.rb +0 -22
  51. data/spec/models/bscf/core/virtual_account_spec.rb +0 -111
  52. data/spec/models/bscf/core/virtual_account_transaction_spec.rb +0 -133
  53. data/spec/rails_helper.rb +0 -46
  54. data/spec/spec_helper.rb +0 -37
  55. data/spec/support/models/shared_examples.rb +0 -49
  56. data/spec/support/requests/shared_requests.rb +0 -126
@@ -1 +0,0 @@
1
- 3a22c82420f040930f412554d7919569ed231f0c16026a0795faffcbd126ec78eccdd546cacca4a594cfb3770ba0380c4da0352d5af1c3b7483f2f35bdff4ed0
data/spec/examples.txt DELETED
@@ -1,167 +0,0 @@
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 |
@@ -1,12 +0,0 @@
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
@@ -1,64 +0,0 @@
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
@@ -1,43 +0,0 @@
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
@@ -1,26 +0,0 @@
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
@@ -1,16 +0,0 @@
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
@@ -1,47 +0,0 @@
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
@@ -1,44 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe QuotationItem, type: :model do
6
- attributes = [
7
- { quantity: [ :presence, :numericality ] },
8
- { unit_price: [ :presence, :numericality ] },
9
- { unit: :presence },
10
- { quotation: :belong_to },
11
- { rfq_item: :belong_to },
12
- { product: :belong_to }
13
- ]
14
-
15
- include_examples("model_shared_spec", :quotation_item, attributes)
16
-
17
- describe 'validations' do
18
- it { should validate_numericality_of(:quantity).is_greater_than(0) }
19
- it { should validate_numericality_of(:unit_price).is_greater_than_or_equal_to(0) }
20
- end
21
-
22
- describe '#calculate_subtotal' do
23
- let(:quotation_item) { build(:quotation_item, quantity: 5, unit_price: 10.0) }
24
-
25
- it 'calculates subtotal before validation' do
26
- quotation_item.valid?
27
- expect(quotation_item.subtotal).to eq(50.0)
28
- end
29
-
30
- it 'does not calculate subtotal if quantity is missing' do
31
- quotation_item.quantity = nil
32
- quotation_item.valid?
33
- expect(quotation_item.subtotal).to eq(50.0)
34
- end
35
-
36
- it 'does not calculate subtotal if unit_price is missing' do
37
- quotation_item.unit_price = nil
38
- quotation_item.valid?
39
- expect(quotation_item.subtotal).to eq(50.0)
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,41 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe Quotation, type: :model do
6
- attributes = [
7
- { price: [ :presence, :numericality ] },
8
- { delivery_date: :presence },
9
- { valid_until: :presence },
10
- { status: :presence },
11
- { request_for_quotation: :belong_to },
12
- { business: :belong_to },
13
- { quotation_items: :have_many },
14
- { orders: :have_many },
15
- { products: :have_many }
16
- ]
17
-
18
- include_examples("model_shared_spec", :quotation, attributes)
19
-
20
- describe 'validations' do
21
- it { should validate_numericality_of(:price).is_greater_than_or_equal_to(0) }
22
- end
23
-
24
- describe 'enums' do
25
- it { should define_enum_for(:status).with_values(draft: 0, submitted: 1, accepted: 2, rejected: 3, expired: 4) }
26
- end
27
-
28
- describe 'scopes' do
29
- let!(:draft_quotation) { create(:quotation) }
30
- let!(:submitted_quotation) { create(:quotation, :submitted) }
31
- let!(:rejected_quotation) { create(:quotation, :rejected) }
32
- let!(:expired_quotation) { create(:quotation, :expired) }
33
-
34
- it 'filters active quotations' do
35
- expect(described_class.active).to include(draft_quotation, submitted_quotation)
36
- expect(described_class.active).not_to include(rejected_quotation, expired_quotation)
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,13 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe RequestForQuotation, type: :model do
6
- attributes = [
7
- { user: :belong_to },
8
- { status: :presence }
9
- ]
10
- include_examples("model_shared_spec", :request_for_quotation, attributes)
11
- end
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe RfqItem, type: :model do
6
- attributes = [
7
- { request_for_quotation: :belong_to },
8
- { product: :belong_to },
9
- { quantity: :presence }
10
- ]
11
- include_examples("model_shared_spec", :rfq_item, attributes)
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe Role, type: :model do
6
- attributes = [
7
- { name: :presence },
8
- { user_roles: :have_many },
9
- { users: :have_many }
10
- ]
11
- include_examples("model_shared_spec", :role, attributes)
12
- end
13
- end
14
- end
@@ -1,20 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe UserProfile, type: :model do
6
- attributes = [
7
- { date_of_birth: :presence },
8
- { nationality: :presence },
9
- { occupation: :presence },
10
- { source_of_funds: :presence },
11
- { gender: :presence },
12
- { user: :belong_to },
13
- { address: :belong_to }
14
- ]
15
- include_examples("model_shared_spec", :user_profile, attributes)
16
-
17
- it { is_expected.to belong_to(:verified_by).class_name('User').optional }
18
- end
19
- end
20
- end
@@ -1,13 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe UserRole, type: :model do
6
- attributes = [
7
- { user: :belong_to },
8
- { role: :belong_to }
9
- ]
10
- include_examples("model_shared_spec", :user_role, attributes)
11
- end
12
- end
13
- end
@@ -1,22 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Bscf
4
- module Core
5
- RSpec.describe User, type: :model do
6
- attributes = [
7
- { first_name: :presence },
8
- { middle_name: :presence },
9
- { last_name: :presence },
10
- { password: :presence },
11
- { phone_number: %i[presence uniqueness] },
12
- { email: %i[presence uniqueness] },
13
- { user_profile: :have_one },
14
- { user_roles: :have_many },
15
- { roles: :have_many },
16
- { orders_placed: :have_many },
17
- { orders_received: :have_many }
18
- ]
19
- include_examples("model_shared_spec", :user, attributes)
20
- end
21
- end
22
- end