snf_core 0.3.7 → 0.3.8

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/snf_core/auth_controller.rb +3 -2
  3. data/app/models/snf_core/quotation.rb +1 -0
  4. data/db/migrate/20250317135148_add_user_to_quotation.rb +5 -0
  5. data/lib/snf_core/version.rb +1 -1
  6. data/spec/dummy/db/schema.rb +4 -1
  7. data/spec/dummy/log/development.log +793 -0
  8. data/spec/dummy/log/test.log +16055 -0
  9. data/spec/dummy/tmp/storage/4b/jj/4bjj0gif47zey9wtfgchqycn1yvf +0 -0
  10. data/spec/dummy/tmp/storage/4p/en/4peng35m86rx8tqpyj6ekabtkby8 +0 -0
  11. data/spec/dummy/tmp/storage/5m/ym/5mymeg6xe9jzbmzzlgeuc9cpfc7p +0 -0
  12. data/spec/dummy/tmp/storage/74/qy/74qyz5a03ozsho4l4fb1qmcd1iyl +0 -0
  13. data/spec/dummy/tmp/storage/7f/1u/7f1u3qgbmbvx18taa0zeyeau19tv +0 -0
  14. data/spec/dummy/tmp/storage/cf/cn/cfcnhpfk26n7siiezv2v1ooo7m2w +0 -0
  15. data/spec/dummy/tmp/storage/cz/gv/czgv4l1kemyizmlq3975u364pppi +0 -0
  16. data/spec/dummy/tmp/storage/f3/33/f333obc6vddqvdsbesykcpxm41y5 +0 -0
  17. data/spec/dummy/tmp/storage/gt/9z/gt9zc94cxlddgqpgomo30vjjihky +0 -0
  18. data/spec/dummy/tmp/storage/iq/z5/iqz5993sf7hx44dprnqqpc2b7n52 +0 -0
  19. data/spec/dummy/tmp/storage/iy/3r/iy3rwasm8e6s4z3wmhnwwmo7w9sz +0 -0
  20. data/spec/dummy/tmp/storage/ny/o3/nyo3lmyjvneit4ame6w4f3ruhnkp +0 -0
  21. data/spec/dummy/tmp/storage/od/wq/odwqixsz0iqwah8tm7eggdxyvsob +0 -0
  22. data/spec/dummy/tmp/storage/pu/t5/put5ap86ooxqmifj7mi0niu507l8 +0 -0
  23. data/spec/dummy/tmp/storage/qd/5o/qd5oes7453z8e5mizm5e2f3zxuiz +0 -0
  24. data/spec/examples.txt +202 -201
  25. data/spec/factories/snf_core/quotations.rb +1 -0
  26. data/spec/models/snf_core/quotation_spec.rb +1 -0
  27. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a35328a0021c1e91dd51f13689b198090fa04a2118d333f42bc4e856652bce46
4
- data.tar.gz: 7df51380a96c5f9ad7abc4778438756b9b0af94cfc2c17ee6aa2b2ad07e7344e
3
+ metadata.gz: a6089c70b25e81c76d4256e296c173865d35a1719516a5b31f6df20f6da7d603
4
+ data.tar.gz: 6df324619449910eaea298462ed5c5cf85bf54531681c974b73c8ab126508392
5
5
  SHA512:
6
- metadata.gz: bb3c7dc5d5cf944cb52bdecb170fe9aa3f40e3e037ea8d7c4be6e316279d2191e464c74bcdd701973c5cd6359befaaa9aef070d5f1adc15a8b2e2dbfafadb7f0
7
- data.tar.gz: 5803f1fa54fe16ed11370fb0494490cc1ee820b8a27b430b9ad05ae408b24c70778163e61d75b3a4a10b91ef124b1fc8515b7326dbf68cea0516486bb30e387e
6
+ metadata.gz: 075272f56cad453bd1267d0ed084adf61eb1e04460ecb09051841c0bbed5cbc58c5908d0113faba2eee7b874c08234ac1d18cff5f5490c4f40c5c510400241af
7
+ data.tar.gz: e6e6c53d4acaa86abd536c056d5ba5909a1332197d690a686fef60b0f857c4c4c9cae00022527bed54372ef4192d2370dd63623e321c70f067c7d3dd51627e61
@@ -75,9 +75,10 @@ module SnfCore
75
75
  return render json: { success: false, error: "Invalid email or password" }, status: :unauthorized unless user.authenticate(auth_params[:password])
76
76
  user_role = UserRole.find_by(user: user)
77
77
  return render json: { success: false, error: "No role was assigned to your user" }, status: :unauthorized unless user_role
78
-
78
+ address = SnfCore::User.find_by(address_id: user.address_id)
79
+ return render json: { success: false, error: "No address was assigned to your user" }, status: :unauthorized unless address
79
80
  role = Role.find(user_role.role_id)
80
- token = @token_service.encode({ user: user.as_json.except("password_digest", "created_at", "updated_at"), role: role.name })
81
+ token = @token_service.encode({ user: user.as_json.except("password_digest", "created_at", "updated_at"), role: role.name, address: address.as_json(except: [ :created_at, :updated_at ]) })
81
82
  render json: { success: true, token: token, user: user.as_json(except: [ :password_digest ]), role: role.name }
82
83
  end
83
84
 
@@ -1,6 +1,7 @@
1
1
  module SnfCore
2
2
  class Quotation < ApplicationRecord
3
3
  belongs_to :item_request
4
+ belongs_to :user
4
5
 
5
6
  validates :price, presence: true, numericality: { greater_than: 0 }
6
7
  validates :valid_until, presence: true
@@ -0,0 +1,5 @@
1
+ class AddUserToQuotation < ActiveRecord::Migration[8.0]
2
+ def change
3
+ add_reference :snf_core_quotations, :user, null: false, foreign_key: { to_table: :snf_core_users }
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module SnfCore
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema[8.0].define(version: 2025_03_13_103149) do
13
+ ActiveRecord::Schema[8.0].define(version: 2025_03_17_135148) do
14
14
  # These are extensions that must be enabled in order to support this database
15
15
  enable_extension "pg_catalog.plpgsql"
16
16
 
@@ -202,7 +202,9 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_13_103149) do
202
202
  t.text "notes"
203
203
  t.datetime "created_at", null: false
204
204
  t.datetime "updated_at", null: false
205
+ t.bigint "user_id", null: false
205
206
  t.index ["item_request_id"], name: "index_snf_core_quotations_on_item_request_id"
207
+ t.index ["user_id"], name: "index_snf_core_quotations_on_user_id"
206
208
  end
207
209
 
208
210
  create_table "snf_core_roles", force: :cascade do |t|
@@ -333,6 +335,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_13_103149) do
333
335
  add_foreign_key "snf_core_orders", "snf_core_users", column: "user_id"
334
336
  add_foreign_key "snf_core_products", "snf_core_categories", column: "category_id"
335
337
  add_foreign_key "snf_core_quotations", "snf_core_item_requests", column: "item_request_id"
338
+ add_foreign_key "snf_core_quotations", "snf_core_users", column: "user_id"
336
339
  add_foreign_key "snf_core_store_inventories", "snf_core_products", column: "product_id"
337
340
  add_foreign_key "snf_core_store_inventories", "snf_core_stores", column: "store_id"
338
341
  add_foreign_key "snf_core_stores", "snf_core_addresses", column: "address_id"