Ahmed Ejaz
e6b9373570
Refactor line items search to improve security and maintainability
...
Moves search field configuration from frontend to backend to prevent potential security issues with exposing internal field names. The change also improves maintainability by centralizing search logic in the controller.
Adds conditional logic to use name_alias for non-admin users when searching distributor names, enhancing data access control.
2025-07-13 18:07:14 +05:00
cyrillefr
8aba6e9782
Style Metrics/ModuleLength in spec file
2025-06-17 15:41:51 +02:00
Ahmed Ejaz
ccfd0edbf1
fix lint issues
2025-04-13 21:35:55 +05:00
Ahmed Ejaz
bf6934db94
add specs
2025-04-13 21:35:55 +05:00
Ahmed Ejaz
20146a8e11
update respective specs
2025-04-13 21:35:55 +05:00
Maikel Linke
54f83b45c8
Replace has_spree_role? with simpler admin?
...
We have only one role, so let's get rid of the unneeded method.
Now we are in a better place to get rid of Spree::Role and replace it
with a simple boolean.
2024-12-19 09:19:01 +11:00
Gaetan Craig-Riou
3d82309c5f
Fix order permission and specs
2024-07-03 10:17:49 +10:00
Maikel Linke
6317fe1b71
Disable RSpec monkey patching
2024-05-09 12:24:41 +10:00
Maikel Linke
bd6b0ddbf3
Enforce RSpec expect(..).not_to over to_not
2024-03-07 16:57:54 +11:00
Neal Chambers
70e218d2e9
Fix Style/HashSyntax
2023-09-25 13:15:38 +09:00
Neal Chambers
f47f6efcd0
Safely autocorrect Rails/DurationArithmetic
...
Inspecting 1481 files
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.C.................................................................................................................................................................................................................................................................................C..............C..........................................................C...............................C....C..........CC................................................................
Offenses:
app/services/create_order_cycle.rb:41:24: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
orders_close_at: Time.zone.now + 1.month
^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_closing_job_spec.rb:7:74: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
create(:order_cycle, automatic_notifications: true, orders_close_at: Time.zone.now - 1.minute)
^^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_closing_job_spec.rb:10:74: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
create(:order_cycle, automatic_notifications: true, orders_close_at: Time.zone.now + 1.minute)
^^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_closing_job_spec.rb:13:75: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
create(:order_cycle, automatic_notifications: false, orders_close_at: Time.zone.now - 1.minute)
^^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_opened_job_spec.rb:7:42: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
create(:order_cycle, orders_open_at: Time.zone.now - 1.hour)
^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_opened_job_spec.rb:13:42: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
create(:order_cycle, orders_open_at: Time.zone.now + 1.minute)
^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/permissions/order_spec.rb:26:58: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
completed_at: Time.zone.now - 1.year)
^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:21:71: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
allow(customer).to receive(:terms_and_conditions_accepted_at) { Time.zone.now - 1.week }
^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:22:59: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
allow(TermsOfServiceFile).to receive(:updated_at) { Time.zone.now - 2.weeks }
^^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:36:71: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
allow(customer).to receive(:terms_and_conditions_accepted_at) { Time.zone.now - 1.week }
^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:38:45: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
ActiveStorage::Blob.new(created_at: Time.zone.now - 2.weeks)
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:647:57: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
completed_at: Time.zone.now + 1.week,
^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:652:57: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
completed_at: Time.zone.now + 2.weeks,
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:661:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
oc3.update!(orders_close_at: Time.zone.now + 2.weeks)
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:662:39: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
oc3.update!(orders_open_at: Time.zone.now + 1.week)
^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:128:18: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
oc_open_at = Time.zone.now - 2.weeks
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:129:19: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
oc_close_at = Time.zone.now + 2.weeks
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:289:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
order2.update!(completed_at: Time.zone.now - 2.weeks)
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:290:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
order3.update!(completed_at: Time.zone.now - 3.weeks)
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:291:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
order4.update!(completed_at: Time.zone.now - 4.weeks)
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:292:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
order5.update!(completed_at: Time.zone.now - 5.weeks)
^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:113:31: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
let(:completed_at1) { Time.zone.now - 1500.hours } # 1500 hours in the past
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:114:31: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
let(:completed_at2) { Time.zone.now - 1700.hours } # 1700 hours in the past
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:115:33: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
let(:datetime_start1) { Time.zone.now - 1600.hours } # 1600 hours in the past
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:116:33: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
let(:datetime_start2) { Time.zone.now - 1800.hours } # 1600 hours in the past
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:117:30: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
let(:datetime_end) { Time.zone.now - 1400.hours } # 1400 hours in the past
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/packing_report_spec.rb:13:26: C: [Corrected] Style/RedundantParentheses: Don't use parentheses around a method call.
let!(:open_datetime) { (1.month.ago).strftime("%Y-%m-%d 00:00") }
^^^^^^^^^^^^^
spec/system/admin/reports/packing_report_spec.rb:13:27: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
let!(:open_datetime) { (Time.zone.now - 1.month).strftime("%Y-%m-%d 00:00") }
^^^^^^^^^^^^^^^^^^^^^^^
1481 files inspected, 28 offenses detected, 28 offenses corrected
2023-08-01 22:50:21 +09:00
Neal Chambers
728926cc9a
Fix Layout/LineLength
2023-07-19 08:39:26 +09:00
Luis Ramos
23627c5453
Run rubocop -a (safe corrections) removing all exceptions so all possible fixes are applied
...
9290 issues fixed
2021-06-17 22:19:26 +01:00
Luis Ramos
2b8f0abe49
Try some mass auto-correct adding frozen-string-literal to all specs
2020-12-03 06:38:24 -08:00
Luis Ramos
8a9dae0ee2
Run rubocop autocorrect
...
This is the result of bundle exec rubocop --auto-correct
2020-06-22 12:23:10 +01:00
Luis Ramos
55b3f4d54f
Move search params test case to a different context so that we dont have to set the producer of the products in the order
...
This is working in master by chance of the factories but breaks in rails 4 because the orders in this test dont have products supplied by the producer which is a necessary condition in the context where it was
2020-04-03 19:47:33 +01:00
Matt-Yorkley
dd0e135a4d
Add test coverage for Permissions::Order with search_params
2020-03-22 11:45:40 +01:00
luisramos0
8d16f496f4
Move Permissions::Order specs to its specific spec file
2019-11-29 10:49:59 +00:00