snf_core 0.2.98 → 0.3.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/snf_core/auth_controller.rb +40 -14
  3. data/app/models/snf_core/quotation.rb +2 -2
  4. data/db/migrate/20250226110217_create_snf_core_addresses.rb +2 -2
  5. data/db/migrate/20250312043359_create_snf_core_quotations.rb +2 -2
  6. data/lib/snf_core/version.rb +1 -1
  7. data/spec/dummy/log/development.log +397 -0
  8. data/spec/dummy/log/test.log +26838 -0
  9. data/spec/dummy/tmp/pids/server.pid +1 -0
  10. data/spec/dummy/tmp/storage/3y/fu/3yfusxgm9k67dmwa3oo0pp8yzh1u +0 -0
  11. data/spec/dummy/tmp/storage/4t/g2/4tg25888ee5rj0ce7tkqbcayu3o6 +0 -0
  12. data/spec/dummy/tmp/storage/4w/8g/4w8gm78byspbg9u3knleahn6yep0 +0 -0
  13. data/spec/dummy/tmp/storage/5m/r3/5mr3d70rwav44966cmlzafropl6p +0 -0
  14. data/spec/dummy/tmp/storage/5z/u2/5zu2fkv6tm01qppyyuik90qr4bug +0 -0
  15. data/spec/dummy/tmp/storage/7w/hv/7whvwq4ot5uwt3k1h5ipc4xtvk36 +0 -0
  16. data/spec/dummy/tmp/storage/a7/00/a700gfeervmzu9mw05rhvbnjx8da +0 -0
  17. data/spec/dummy/tmp/storage/c0/mt/c0mtlkx0368uvpzfgmd38syzoy2v +0 -0
  18. data/spec/dummy/tmp/storage/cr/ny/crnyduu73jm6jtqt2cbq1dz3x8gr +0 -0
  19. data/spec/dummy/tmp/storage/dm/xj/dmxjedfmoojuhgwpb9gjveuqyki7 +0 -0
  20. data/spec/dummy/tmp/storage/dn/m1/dnm1qr855gwf7ppy7sft1dxgsnfd +0 -0
  21. data/spec/dummy/tmp/storage/fx/08/fx08ebmlikk1qd57t92stc1hdbda +0 -0
  22. data/spec/dummy/tmp/storage/gm/ar/gmarwjxd7y7bzebx8atz41yffhjx +0 -0
  23. data/spec/dummy/tmp/storage/h6/un/h6undns4303m8l8ft0pkffjiren6 +0 -0
  24. data/spec/dummy/tmp/storage/mx/lo/mxloqbggy6drma5ov1998tgrkman +0 -0
  25. data/spec/dummy/tmp/storage/qc/vv/qcvvq3ncfl03yp4pc18jyreg8boz +0 -0
  26. data/spec/dummy/tmp/storage/t3/tj/t3tj5uirsnvxchyl1hho04dmh49t +0 -0
  27. data/spec/dummy/tmp/storage/td/9t/td9t86soc5nypxfis5tqyp5pcx9x +0 -0
  28. data/spec/dummy/tmp/storage/tj/e8/tje84os9t9sr081jgbxri4qvi13j +0 -0
  29. data/spec/dummy/tmp/storage/u4/cv/u4cvbf3g5ev4vi4ce3j9lsmrpipj +0 -0
  30. data/spec/dummy/tmp/storage/uw/cb/uwcbklmtksvymz23ijjgkiup5o2e +0 -0
  31. data/spec/dummy/tmp/storage/w9/u9/w9u9utltwus816bm8iznc1e3pprl +0 -0
  32. data/spec/dummy/tmp/storage/wg/o9/wgo9a559sc4bub8phdnkxtupnozr +0 -0
  33. data/spec/dummy/tmp/storage/wv/61/wv61b1fuar05sjp9q0cnx58xplnh +0 -0
  34. data/spec/dummy/tmp/storage/y5/xu/y5xuawt4vxn5vmwzruc3juv1bqk4 +0 -0
  35. data/spec/examples.txt +197 -197
  36. data/spec/models/snf_core/quotation_spec.rb +0 -2
  37. data/spec/requests/snf_core/auth_spec.rb +18 -9
  38. metadata +27 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd314fc21e427da9d504f8db415fff1d4d66e3b3ad00e675778180b596ca9b1d
4
- data.tar.gz: 8f6c6e6c7d54ca74bb588461dda607b973a6ac07c6b3b609918681d6af753ea6
3
+ metadata.gz: f22dd66f3a5b0d74ae9e2861c4e700fbe07526eec275c51943eb701451d92e1f
4
+ data.tar.gz: 33c322e0e4c72983d9ce4ff027861b74299a9cd13a8b6e2ac80a2cb034441bde
5
5
  SHA512:
6
- metadata.gz: 4397affa157cbadfccad676c739dca187953acb090b1e3d77c93dfe3c729cdf2631c700565b4f6bd38691c1e36a4387261a1dace0786245d6250a8bb6ce36789
7
- data.tar.gz: 470a2d192ebabec579dd38bbe92daf77935b4761d7968a6247339b24c18cf8c4f96511fbc12910e86d930eec256c1c2402f48f5a18fb01740aa5b47c0216686a
6
+ metadata.gz: b4c0d27b9b9f687699e1ae64e6fbf469ca351b75d632399ad3ea9cdc316ba8cf7b07206bde77d997a1e800320cd018a928a7768b4bf3adb817836ba2baa16bd3
7
+ data.tar.gz: 4e45106323c448eb148cb21affb9f81f7bd88d2909bfb2c38a035f092c490842515d510486806c4458090c3d100f570ee258571278e954adf8960cc2ba5daf60
@@ -4,24 +4,39 @@ module SnfCore
4
4
 
5
5
  def signup
6
6
  ActiveRecord::Base.transaction do
7
- @user = User.new(user_params)
7
+ @address = Address.new(address_params)
8
8
 
9
- if @user.save
10
- @business = Business.new(
11
- user: @user,
12
- business_name: signup_params[:business_name],
13
- tin_number: signup_params[:tin_number],
14
- business_type: signup_params[:business_type],
15
- )
9
+ if @address.save
10
+ @user = User.new(user_params)
11
+ @user.address = @address
16
12
 
17
- if @business.save
18
- render json: { success: true }, status: :created
13
+ if @user.save
14
+ @business = Business.new(
15
+ user: @user,
16
+ business_name: signup_params[:business_name],
17
+ tin_number: signup_params[:tin_number],
18
+ business_type: signup_params[:business_type]
19
+ )
20
+
21
+ if @business.save
22
+ render json: {
23
+ success: true,
24
+ user: @user.as_json(except: [ :password_digest ]),
25
+ business: @business,
26
+ address: @address
27
+ }, status: :created
28
+ return
29
+ else
30
+ render json: { errors: @business.errors.full_messages }, status: :unprocessable_entity
31
+ raise ActiveRecord::Rollback
32
+ end
19
33
  else
34
+ render json: { errors: @user.errors.full_messages }, status: :unprocessable_entity
20
35
  raise ActiveRecord::Rollback
21
- render json: { errors: @business.errors.full_messages }, status: :unprocessable_entity
22
36
  end
23
37
  else
24
- render json: { errors: @user.errors.full_messages }, status: :unprocessable_entity
38
+ render json: { errors: @address.errors.full_messages }, status: :unprocessable_entity
39
+ raise ActiveRecord::Rollback
25
40
  end
26
41
  end
27
42
  end
@@ -55,7 +70,7 @@ module SnfCore
55
70
  :first_name, :middle_name, :last_name, :password,
56
71
  :phone_number, :business_name, :tin_number, :business_type,
57
72
  :date_of_birth, :nationality, :occupation, :source_of_funds, :kyc_status,
58
- :gender, :verified_at, :verified_by_id, :address_id
73
+ :gender, :verified_at, :verified_by_id, :email
59
74
  )
60
75
  end
61
76
 
@@ -64,8 +79,19 @@ module SnfCore
64
79
  :first_name, :middle_name, :last_name, :password,
65
80
  :phone_number, :date_of_birth, :nationality,
66
81
  :occupation, :source_of_funds, :kyc_status,
67
- :gender, :verified_at, :verified_by_id, :address_id
82
+ :gender, :verified_at, :verified_by_id, :email
68
83
  )
69
84
  end
85
+
86
+ def address_params
87
+ params.require(:address).permit(
88
+ :address_type,
89
+ :city,
90
+ :sub_city,
91
+ :woreda,
92
+ :latitude,
93
+ :longitude
94
+ )
95
+ end
70
96
  end
71
97
  end
@@ -8,7 +8,7 @@ module SnfCore
8
8
  validates :status, presence: true
9
9
  validate :valid_until_cannot_be_in_past
10
10
  validate :delivery_date_cannot_be_in_past
11
-
11
+
12
12
  before_validation :check_expiration
13
13
 
14
14
  enum :status, {
@@ -19,7 +19,7 @@ module SnfCore
19
19
  }
20
20
 
21
21
  private
22
-
22
+
23
23
  def check_expiration
24
24
  if valid_until.present? && valid_until < DateTime.current && !expired?
25
25
  self.status = :expired
@@ -5,8 +5,8 @@ class CreateSnfCoreAddresses < ActiveRecord::Migration[8.0]
5
5
  t.string :city, null: false
6
6
  t.string :sub_city, null: false
7
7
  t.string :woreda
8
- t.decimal :latitude, null: false
9
- t.decimal :longitude, null: false
8
+ t.decimal :latitude
9
+ t.decimal :longitude
10
10
 
11
11
  t.timestamps
12
12
  end
@@ -1,8 +1,8 @@
1
1
  class CreateSnfCoreQuotations < ActiveRecord::Migration[8.0]
2
2
  def change
3
3
  create_table :snf_core_quotations do |t|
4
- t.references :item_request, null: false, foreign_key: {to_table: :snf_core_item_requests}
5
- t.decimal :price , null: false
4
+ t.references :item_request, null: false, foreign_key: { to_table: :snf_core_item_requests }
5
+ t.decimal :price, null: false
6
6
  t.date :delivery_date, null: false
7
7
  t.datetime :valid_until, null: false
8
8
  t.integer :status, null: false, default: 0
@@ -1,3 +1,3 @@
1
1
  module SnfCore
2
- VERSION = "0.2.98"
2
+ VERSION = "0.3.0"
3
3
  end