diff --git a/.circleci/config.yml b/.circleci/config.yml index a158820b122..d319f20b2b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ executors: parameters: ¶meters ruby: type: string - default: "3.0" + default: "3.1" working_directory: &workdir ~/solidus environment: &environment DEFAULT_MAX_WAIT_TIME: 10 @@ -159,7 +159,7 @@ commands: ruby -v >> /tmp/.ruby-versions gem --version >> /tmp/.gems-versions bundle --version >> /tmp/.gems-versions - gem search -eq rails -v "~> 7" -v "< 7.2" >> /tmp/.gems-versions # get the latest rails from rubygems + gem search -eq rails -v "~> 7" -v "< 8.0" >> /tmp/.gems-versions # get the latest rails from rubygems gem search -eq solidus >> /tmp/.gems-versions # get the latest solidus from rubygems cat /tmp/.ruby-versions @@ -172,7 +172,7 @@ commands: name: "Prepare the rails application" command: | cd /tmp - test -d my_app || (gem install rails -v "< 7.1" && gem install solidus) + test -d my_app || (gem install rails -v "< 8.0" && gem install solidus) test -d my_app || rails new my_app --skip-git - save_cache: key: solidus-installer-v9-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }} @@ -191,10 +191,10 @@ commands: parameters: app_root: type: string - default: '/tmp/my_app' + default: "/tmp/my_app" path: type: string - default: '/' + default: "/" expected_text: type: string @@ -223,7 +223,7 @@ commands: mkdir -p /tmp/dummy_extension cd /tmp/dummy_extension bundle init - bundle add rails -v "< 7.1" --skip-install + bundle add rails -v "< 8.0" --skip-install bundle add sqlite3 -v "~> 1.3" --skip-install test -n "<>" && bundle add <> --skip-install bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")" @@ -239,7 +239,7 @@ jobs: ESLINT_USE_FLAT_CONFIG: false steps: - checkout - - run: 'bundle install' + - run: "bundle install" - run: name: Check Ruby command: "bin/rake lint:rb" @@ -255,7 +255,7 @@ jobs: solidus_installer: executor: name: sqlite - ruby: "3.0" + ruby: "3.1" steps: - checkout - run: @@ -292,7 +292,7 @@ jobs: default: postgres ruby: type: string - default: '3.2' + default: "3.2" rails: type: string default: "7.1" @@ -328,13 +328,13 @@ jobs: default: postgres ruby: type: string - default: '3.2' + default: "3.2" executor: name: << parameters.database >> ruby: << parameters.ruby >> parallelism: 3 environment: - COVERAGE: 'true' + COVERAGE: "true" COVERAGE_DIR: /tmp/coverage DISABLE_ACTIVE_STORAGE: false steps: @@ -342,14 +342,14 @@ jobs: - run: name: Setup Coverage Env Vars command: | - echo 'export COVERAGE_FILE=/tmp/coverage/coverage.xml' >> $BASH_ENV - source $BASH_ENV + echo 'export COVERAGE_FILE=/tmp/coverage/coverage.xml' >> $BASH_ENV + source $BASH_ENV - run: name: Verify Coverage Env Vars command: | - echo $COVERAGE - echo /tmp/coverage - echo /tmp/coverage/coverage.xml + echo $COVERAGE + echo /tmp/coverage + echo /tmp/coverage/coverage.xml - run: name: Setup Coverage Directory command: mkdir -p /tmp/coverage @@ -371,13 +371,49 @@ workflows: # https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html. - test_solidus: name: &name "test-rails-<>-ruby-<>-<>-<<#matrix.paperclip>>paperclip<><<^matrix.paperclip>>activestorage<>" - matrix: { parameters: { rails: ['7.0', '7.1'], ruby: ['3.0'], database: ['mysql'], paperclip: [true] } } + matrix: + { + parameters: + { + rails: ["7.0", "7.1", "7.2"], + ruby: ["3.1"], + database: ["mysql"], + paperclip: [true], + }, + } - test_solidus: name: *name - matrix: { parameters: { rails: ['7.0', '7.1'], ruby: ['3.1'], database: ['postgres'], paperclip: [false] } } + matrix: + { + parameters: + { + rails: ["7.0", "7.1", "7.2"], + ruby: ["3.1"], + database: ["postgres"], + paperclip: [false], + }, + } - test_solidus: name: *name - matrix: { parameters: { rails: ['7.0'], ruby: ['3.2'], database: ['sqlite'], paperclip: [false] } } + matrix: + { + parameters: + { + rails: ["7.1"], + ruby: ["3.2"], + database: ["sqlite"], + paperclip: [false], + }, + } - test_solidus: name: *name - matrix: { parameters: { rails: ['7.1', 'main'], ruby: ['3.3.2'], database: ['sqlite'], paperclip: [false] } } + matrix: + { + parameters: + { + rails: ["7.2", "main"], + ruby: ["3.3.5"], + database: ["sqlite"], + paperclip: [false], + }, + } diff --git a/.rubocop.yml b/.rubocop.yml index 4dda7c638e7..e01af4f98c8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,8 +8,8 @@ require: AllCops: Exclude: - - '**/{tmp,vendor,spec/dummy,sandbox,templates,pkg}/**/*' - TargetRubyVersion: 3.0 + - "**/{tmp,vendor,spec/dummy,sandbox,templates,pkg}/**/*" + TargetRubyVersion: 3.1 NewCops: disable SuggestExtensions: false @@ -121,7 +121,7 @@ Rails/DynamicFindBy: # It's okay to skip model validations to setup a spec. Rails/SkipsModelValidations: Exclude: - - '*/spec/**/*' + - "*/spec/**/*" # We use a lot of # @@ -132,15 +132,15 @@ Rails/SkipsModelValidations: # syntax in the specs files. Lint/AmbiguousBlockAssociation: Exclude: - - '*/spec/**/*' - - 'spec/**/*' # For the benefit of apps that inherit from this config + - "*/spec/**/*" + - "spec/**/*" # For the benefit of apps that inherit from this config # We use eval to add common_spree_dependencies into the Gemfiles of each of our gems Security/Eval: Exclude: - - 'Gemfile' - - 'common_spree_dependencies.rb' - - '*/Gemfile' + - "Gemfile" + - "common_spree_dependencies.rb" + - "*/Gemfile" Naming/VariableNumber: Enabled: false @@ -306,10 +306,10 @@ Style/FrozenStringLiteralComment: Enabled: true EnforcedStyle: always Exclude: - - '*/lib/generators/**/*' - - '**/bin/**/*' - - '*/db/migrate/**/*' - - '*/config/importmap.rb' + - "*/lib/generators/**/*" + - "**/bin/**/*" + - "*/db/migrate/**/*" + - "*/config/importmap.rb" # json.() is idiomatic in jbuilder files Style/LambdaCall: @@ -333,13 +333,13 @@ Lint/SuppressedException: Lint/MissingSuper: Exclude: - - '*/app/components/**/*' # components need pristine initializer methods - - 'core/lib/spree/deprecated_instance_variable_proxy.rb' # this is a known class that doesn't require super - - 'core/lib/spree/preferences/configuration.rb' # this class has no superclass defining `self.inherited` + - "*/app/components/**/*" # components need pristine initializer methods + - "core/lib/spree/deprecated_instance_variable_proxy.rb" # this is a known class that doesn't require super + - "core/lib/spree/preferences/configuration.rb" # this class has no superclass defining `self.inherited` Rails/FindEach: Exclude: - - 'db/migrate/**/*' + - "db/migrate/**/*" # Since we're writing library code we can't assume that # tasks should load the rails environment loaded. diff --git a/admin/app/components/solidus_admin/base_component.rb b/admin/app/components/solidus_admin/base_component.rb index fd1f74a8020..7bfe1b52852 100644 --- a/admin/app/components/solidus_admin/base_component.rb +++ b/admin/app/components/solidus_admin/base_component.rb @@ -10,7 +10,7 @@ class BaseComponent < ViewComponent::Base include Turbo::FramesHelper def icon_tag(name, **attrs) - render component("ui/icon").new(name: name, **attrs) + render component("ui/icon").new(name:, **attrs) end def missing_translation(key, options) diff --git a/admin/app/components/solidus_admin/layout/navigation/account/component.rb b/admin/app/components/solidus_admin/layout/navigation/account/component.rb index 00bd0d0bcdd..e5a448cde66 100644 --- a/admin/app/components/solidus_admin/layout/navigation/account/component.rb +++ b/admin/app/components/solidus_admin/layout/navigation/account/component.rb @@ -11,7 +11,7 @@ def initialize(user_label:, account_path:, logout_path:, logout_method:) def locale_options_for_select(available_locales) available_locales.map do |locale| [ - t("spree.i18n.this_file_language", locale: locale, default: locale.to_s, fallback: false), + t("spree.i18n.this_file_language", locale:, default: locale.to_s, fallback: false), locale, ] end.sort @@ -27,7 +27,7 @@ def autosubmit_select_tag(name, options, icon:, &block) block_given? ? capture(&block) : nil, tag.label(safe_join([ icon_tag(icon, class: "w-full max-w-[20px] h-5 fill-current shrink"), - tag.select(options, name: name, onchange: "this.form.requestSubmit()", class: "w-full appearance-none grow bg-transparent outline-none"), + tag.select(options, name:, onchange: "this.form.requestSubmit()", class: "w-full appearance-none grow bg-transparent outline-none"), icon_tag("expand-up-down-line", class: "w-full max-w-[20px] h-5 fill-current shrink"), ]), class: "flex gap-2 items-center px-2"), ]) diff --git a/admin/app/components/solidus_admin/layout/navigation/component.rb b/admin/app/components/solidus_admin/layout/navigation/component.rb index 56704ed936d..6cefdff2c8c 100644 --- a/admin/app/components/solidus_admin/layout/navigation/component.rb +++ b/admin/app/components/solidus_admin/layout/navigation/component.rb @@ -9,7 +9,7 @@ def initialize( @logo_path = logo_path @items = items.map do |attrs| children = attrs[:children].to_a.map { SolidusAdmin::MenuItem.new(**_1, top_level: false) } - SolidusAdmin::MenuItem.new(**attrs, children: children, top_level: true) + SolidusAdmin::MenuItem.new(**attrs, children:, top_level: true) end @store = store end diff --git a/admin/app/components/solidus_admin/orders/index/component.rb b/admin/app/components/solidus_admin/orders/index/component.rb index 92e37feadc6..4f1c45d1989 100644 --- a/admin/app/components/solidus_admin/orders/index/component.rb +++ b/admin/app/components/solidus_admin/orders/index/component.rb @@ -117,7 +117,7 @@ def state_column 'canceled' => :blue, 'cart' => :graphite_light, }[order.state] || :yellow - component('ui/badge').new(name: order.state.humanize, color: color) + component('ui/badge').new(name: order.state.humanize, color:) end } end diff --git a/admin/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb b/admin/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb index 341e5f8931e..d6368cf2c49 100644 --- a/admin/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb +++ b/admin/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb @@ -10,7 +10,7 @@ def initialize(adjustment) end def call - render component("ui/thumbnail_with_caption").new(caption: caption, detail: detail) do + render component("ui/thumbnail_with_caption").new(caption:, detail:) do thumbnail end end diff --git a/admin/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb b/admin/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb index 4f1e34781c2..87e477cd66b 100644 --- a/admin/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb +++ b/admin/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb @@ -10,7 +10,7 @@ def initialize(adjustment) end def call - render component("ui/thumbnail_with_caption").new(icon: icon, caption: caption, detail: detail) + render component("ui/thumbnail_with_caption").new(icon:, caption:, detail:) end def caption diff --git a/admin/app/components/solidus_admin/products/index/component.rb b/admin/app/components/solidus_admin/products/index/component.rb index 029b1c2be02..6a015ebcbd2 100644 --- a/admin/app/components/solidus_admin/products/index/component.rb +++ b/admin/app/components/solidus_admin/products/index/component.rb @@ -68,7 +68,7 @@ def filters { label: option_type.presentation, combinator: 'or', - attribute: "variants_option_values", + attribute: "option_values_id", predicate: "in", options: option_type.option_values.pluck(:name, :id), } diff --git a/admin/app/components/solidus_admin/products/status/component.rb b/admin/app/components/solidus_admin/products/status/component.rb index bf10c63e343..01fe489abfe 100644 --- a/admin/app/components/solidus_admin/products/status/component.rb +++ b/admin/app/components/solidus_admin/products/status/component.rb @@ -20,7 +20,7 @@ def self.from_product(product) :unavailable end - new(status: status) + new(status:) end def initialize(status:) diff --git a/admin/app/components/solidus_admin/stock_items/index/component.rb b/admin/app/components/solidus_admin/stock_items/index/component.rb index b9c306f82dc..fc20bb93f71 100644 --- a/admin/app/components/solidus_admin/stock_items/index/component.rb +++ b/admin/app/components/solidus_admin/stock_items/index/component.rb @@ -138,7 +138,7 @@ def stock_movements_column count = stock_movement_counts[_1.id] || 0 link_to( - "#{count} #{Spree::StockMovement.model_name.human(count: count).downcase}", + "#{count} #{Spree::StockMovement.model_name.human(count:).downcase}", spree.admin_stock_location_stock_movements_path( _1.stock_location.id, q: { variant_sku_eq: _1.variant.sku }, diff --git a/admin/app/components/solidus_admin/stock_locations/index/component.rb b/admin/app/components/solidus_admin/stock_locations/index/component.rb index 643c4b4231f..f6324732666 100644 --- a/admin/app/components/solidus_admin/stock_locations/index/component.rb +++ b/admin/app/components/solidus_admin/stock_locations/index/component.rb @@ -57,7 +57,7 @@ def columns color = _1.active? ? :green : :graphite_light text = _1.active? ? t('.active') : t('.inactive') - component('ui/badge').new(name: text, color: color) + component('ui/badge').new(name: text, color:) }, }, { @@ -78,7 +78,7 @@ def columns count = _1.stock_movements.count link_to( - "#{count} #{Spree::StockMovement.model_name.human(count: count).downcase}", + "#{count} #{Spree::StockMovement.model_name.human(count:).downcase}", spree.admin_stock_location_stock_movements_path(_1), class: 'body-link' ) diff --git a/admin/app/components/solidus_admin/ui/forms/field/component.rb b/admin/app/components/solidus_admin/ui/forms/field/component.rb index 9ceb3d8f7d4..352d1d9e58a 100644 --- a/admin/app/components/solidus_admin/ui/forms/field/component.rb +++ b/admin/app/components/solidus_admin/ui/forms/field/component.rb @@ -18,14 +18,14 @@ def self.text_field(form, method, object: nil, hint: nil, tip: nil, size: :m, ** object_name, object, label, errors = extract_form_details(form, object, method) new( - label: label, - hint: hint, - tip: tip, + label:, + hint:, + tip:, error: errors, input_attributes: { name: "#{object_name}[#{method}]", tag: :input, - size: size, + size:, value: object.public_send(method), error: (errors.to_sentence.capitalize if errors), **attributes, @@ -37,15 +37,15 @@ def self.select(form, method, choices, object: nil, hint: nil, tip: nil, size: : object_name, object, label, errors = extract_form_details(form, object, method) new( - label: label, - hint: hint, - tip: tip, + label:, + hint:, + tip:, error: errors, input_attributes: { name: "#{object_name}[#{method}]", tag: :select, - choices: choices, - size: size, + choices:, + size:, value: object.public_send(method), error: (errors.to_sentence.capitalize if errors), **attributes, @@ -57,13 +57,13 @@ def self.text_area(form, method, object: nil, hint: nil, tip: nil, size: :m, **a object_name, object, label, errors = extract_form_details(form, object, method) new( - label: label, - hint: hint, - tip: tip, + label:, + hint:, + tip:, error: errors, input_attributes: { name: "#{object_name}[#{method}]", - size: size, + size:, tag: :textarea, value: object.public_send(method), error: (errors.to_sentence.capitalize if errors), @@ -76,14 +76,14 @@ def self.toggle(form, method, object: nil, hint: nil, tip: nil, size: :m, **attr object_name, object, label, errors = extract_form_details(form, object, method) new( - label: label, - hint: hint, - tip: tip, + label:, + hint:, + tip:, error: errors, ).with_content( component('ui/forms/switch').new( name: "#{object_name}[#{method}]", - size: size, + size:, checked: object.public_send(method), include_hidden: true, **attributes, diff --git a/admin/app/components/solidus_admin/ui/pages/index/component.rb b/admin/app/components/solidus_admin/ui/pages/index/component.rb index 6ee519537bb..ad6cd5b5092 100644 --- a/admin/app/components/solidus_admin/ui/pages/index/component.rb +++ b/admin/app/components/solidus_admin/ui/pages/index/component.rb @@ -61,8 +61,8 @@ def search_options value: search_params, url: search_url, searchbar_key: search_key, - filters: filters, - scopes: scopes, + filters:, + scopes:, } end @@ -80,12 +80,12 @@ def render_table id: stimulus_id, data: { class: model_class, - rows: rows, + rows:, fade: -> { row_fade(_1) }, prev: prev_page_path, next: next_page_path, - columns: columns, - batch_actions: batch_actions, + columns:, + batch_actions:, url: -> { row_url(_1) }, }, search: search_options, diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index c398b521d74..79e08f9d494 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -138,7 +138,7 @@ def render_ransack_filter_dropdown(filter, index) predicate: filter.predicate, options: filter.options, form: search_form_id, - index: index, + index:, ) end diff --git a/admin/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb b/admin/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb index 575a57fc35b..1b6028c1a10 100644 --- a/admin/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb +++ b/admin/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb @@ -10,6 +10,6 @@ def initialize(icon: "question-line", caption: "", detail: nil) end def icon_thumbnail - render component("ui/thumbnail").new(icon: icon) + render component("ui/thumbnail").new(icon:) end end diff --git a/admin/app/components/solidus_admin/users/index/component.rb b/admin/app/components/solidus_admin/users/index/component.rb index 81fb38444ff..7664299a11f 100644 --- a/admin/app/components/solidus_admin/users/index/component.rb +++ b/admin/app/components/solidus_admin/users/index/component.rb @@ -75,7 +75,7 @@ def columns when 'customer' then :green else :graphite_light end - render component('ui/badge').new(name: _1.name, color: color) + render component('ui/badge').new(name: _1.name, color:) }) end, }, diff --git a/admin/app/controllers/solidus_admin/controller_helpers/search.rb b/admin/app/controllers/solidus_admin/controller_helpers/search.rb index 3f40fb20fc5..1bf5d0d79fd 100644 --- a/admin/app/controllers/solidus_admin/controller_helpers/search.rb +++ b/admin/app/controllers/solidus_admin/controller_helpers/search.rb @@ -7,8 +7,8 @@ module ClassMethods def search_scope(name, default: false, &block) search_scopes << SearchScope.new( name: name.to_s, - block: block, - default: default, + block:, + default:, ) end @@ -20,8 +20,8 @@ def search_scopes private def apply_search_to(relation, param:) - relation = apply_scopes_to(relation, param: param) - apply_ransack_search_to(relation, param: param) + relation = apply_scopes_to(relation, param:) + apply_ransack_search_to(relation, param:) end def apply_ransack_search_to(relation, param:) diff --git a/admin/lib/solidus_admin/component_registry.rb b/admin/lib/solidus_admin/component_registry.rb index b86789bbc02..e1320587f21 100644 --- a/admin/lib/solidus_admin/component_registry.rb +++ b/admin/lib/solidus_admin/component_registry.rb @@ -28,7 +28,7 @@ def infer_constant_from(key) prefix = "#{SolidusAdmin::Configuration::ENGINE_ROOT}/app/components/solidus_admin/" suffix = "/component.rb" dictionary = Dir["#{prefix}**#{suffix}"].map { _1.delete_prefix(prefix).delete_suffix(suffix) } - corrections = DidYouMean::SpellChecker.new(dictionary: dictionary).correct(key.to_s) + corrections = DidYouMean::SpellChecker.new(dictionary:).correct(key.to_s) raise ComponentNotFoundError.new( "Unknown component #{key}#{DidYouMean.formatter.message_for(corrections)}", diff --git a/admin/lib/solidus_admin/configuration.rb b/admin/lib/solidus_admin/configuration.rb index edbc1bb0af6..93674be7116 100644 --- a/admin/lib/solidus_admin/configuration.rb +++ b/admin/lib/solidus_admin/configuration.rb @@ -169,10 +169,10 @@ def import_menu_items_from_backend! { position: index, key: item.label, - icon: icon, - route: route, + icon:, + route:, children: item.children.map.with_index(&menu_item_to_hash), - match_path: match_path, + match_path:, } end diff --git a/admin/lib/solidus_admin/testing_support/feature_helpers.rb b/admin/lib/solidus_admin/testing_support/feature_helpers.rb index 1547590eb8f..e8dfa7c54f7 100644 --- a/admin/lib/solidus_admin/testing_support/feature_helpers.rb +++ b/admin/lib/solidus_admin/testing_support/feature_helpers.rb @@ -19,7 +19,7 @@ def stub_authorization!(user) end def find_row(text) - find('table tbody tr', text: text) + find('table tbody tr', text:) end def find_row_checkbox(text) diff --git a/admin/solidus_admin.gemspec b/admin/solidus_admin.gemspec index 41867f53963..f15f2c9ce47 100644 --- a/admin/solidus_admin.gemspec +++ b/admin/solidus_admin.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |s| f.match(%r{^(spec|script)/}) end + ["app/assets/builds/solidus_admin/tailwind.css"] - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' s.add_dependency 'geared_pagination', '~> 1.1' diff --git a/admin/spec/components/previews/solidus_admin/ui/badge/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/badge/component_preview.rb index a45ddf1d442..af118443aa0 100644 --- a/admin/spec/components/previews/solidus_admin/ui/badge/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/badge/component_preview.rb @@ -6,14 +6,14 @@ class SolidusAdmin::UI::Badge::ComponentPreview < ViewComponent::Preview # @param name text def overview(name: "Label") - render_with_template(locals: { name: name }) + render_with_template(locals: { name: }) end # @param name text # @param color select :color_options # @param size select :size_options def playground(name: "Label", color: :green, size: :m) - render current_component.new(name: name, color: color, size: size) + render current_component.new(name:, color:, size:) end private diff --git a/admin/spec/components/previews/solidus_admin/ui/button/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/button/component_preview.rb index e2edd012a46..e2935ac94e2 100644 --- a/admin/spec/components/previews/solidus_admin/ui/button/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/button/component_preview.rb @@ -7,7 +7,7 @@ class SolidusAdmin::UI::Button::ComponentPreview < ViewComponent::Preview # @param text text # @param show_icon toggle def overview(text: "Button", show_icon: true) - render_with_template locals: { text: text, show_icon: show_icon } + render_with_template locals: { text:, show_icon: } end # @param size select { choices: [s, m, l] } @@ -15,7 +15,7 @@ def overview(text: "Button", show_icon: true) # @param icon select "Of all icon names we show only 10, chosen randomly" :icon_options # @param text text def playground(size: :m, scheme: :primary, text: "Button", icon: 'search-line') - render component("ui/button").new(size: size, scheme: scheme, text: text, icon: icon.presence) + render component("ui/button").new(size:, scheme:, text:, icon: icon.presence) end def group diff --git a/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb index 6bdbcf4b900..b9c19e409ed 100644 --- a/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb @@ -14,11 +14,11 @@ def overview # @param open toggle def playground(text: "text", size: :m, direction: :right, open: false) render component("ui/dropdown").new( - text: text, + text:, size: size.to_sym, direction: direction.to_sym, style: "float: #{direction == :left ? 'right' : 'left'}", - open: open, + open:, ).with_content( tag.span("Lorem ipsum dolor sit amet"), ) diff --git a/admin/spec/components/previews/solidus_admin/ui/forms/address/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/address/component_preview.rb index cba6252cd1b..4a9f9b12c1a 100644 --- a/admin/spec/components/previews/solidus_admin/ui/forms/address/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/forms/address/component_preview.rb @@ -13,7 +13,7 @@ def playground(disabled: false) render component("ui/forms/address").new( name: "", address: fake_address, - disabled: disabled + disabled: ) end @@ -21,6 +21,6 @@ def playground(disabled: false) def fake_address country = Spree::Country.find_or_initialize_by(iso: Spree::Config.default_country_iso) - Spree::Address.new(country: country) + Spree::Address.new(country:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/forms/checkbox/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/checkbox/component_preview.rb index f828441d11a..f83458bd7e2 100644 --- a/admin/spec/components/previews/solidus_admin/ui/forms/checkbox/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/forms/checkbox/component_preview.rb @@ -53,6 +53,6 @@ def overview # @param checked toggle # @param disabled toggle def playground(size: :m, checked: false, disabled: false) - render current_component.new(size: size.to_sym, checked: checked, disabled: disabled) + render current_component.new(size: size.to_sym, checked:, disabled:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/forms/field/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/field/component_preview.rb index 38aa05b4e0c..b566d9fb308 100644 --- a/admin/spec/components/previews/solidus_admin/ui/forms/field/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/forms/field/component_preview.rb @@ -12,8 +12,8 @@ def overview # @param tip text # @param error text def playground(label: "My field", hint: "hint", tip: "tip", error: "error") - render component("ui/forms/field").new(label: label, hint: hint, tip: tip, error: error, input_attributes: { - tag: :input, value: "My value", error: error + render component("ui/forms/field").new(label:, hint:, tip:, error:, input_attributes: { + tag: :input, value: "My value", error: }) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/forms/input/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/input/component_preview.rb index fe4025467fc..f8058772831 100644 --- a/admin/spec/components/previews/solidus_admin/ui/forms/input/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/forms/input/component_preview.rb @@ -18,7 +18,7 @@ def input_playground(error: false, size: "m", value: "value", type: "text") type: type.to_sym, error: error ? "There is an error" : nil, size: size.to_sym, - value: value, + value:, ) end @@ -38,7 +38,7 @@ def select_playground(error: false, include_blank: true, options: 3, rows: 1, si "size" => rows > 1 ? rows : nil, error: error ? "There is an error" : nil, size: size.to_sym, - multiple: multiple, + multiple:, ).with_content(options.reduce(:+)) end diff --git a/admin/spec/components/previews/solidus_admin/ui/forms/switch/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/switch/component_preview.rb index c16c7f7887e..7c01a687e5d 100644 --- a/admin/spec/components/previews/solidus_admin/ui/forms/switch/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/forms/switch/component_preview.rb @@ -29,6 +29,6 @@ def overview # @param checked toggle # @param disabled toggle def playground(size: :m, checked: false, disabled: false) - render current_component.new(id: 1, size: size.to_sym, checked: checked, disabled: disabled) + render current_component.new(id: 1, size: size.to_sym, checked:, disabled:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/forms/switch_field/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/switch_field/component_preview.rb index 9bd5e3a0c9e..6afd19eab64 100644 --- a/admin/spec/components/previews/solidus_admin/ui/forms/switch_field/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/forms/switch_field/component_preview.rb @@ -25,14 +25,14 @@ def playground( disabled: false ) render current_component.new( - label: label, + label:, name: nil, error: [error], - hint: hint, - tip: tip, + hint:, + tip:, size: size.to_sym, - checked: checked, - disabled: disabled, + checked:, + disabled:, ) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb index d94b80022f8..d65ef66251d 100644 --- a/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb @@ -10,7 +10,7 @@ def overview # @param name select "Of all icon names we show only 10, chosen randomly" :name_options def playground(name: name_options.first) - render component("ui/icon").new(name: name, class: 'w-10 h-10') + render component("ui/icon").new(name:, class: 'w-10 h-10') end private diff --git a/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb index 4b18c2bdf37..b84349a9a74 100644 --- a/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb @@ -46,6 +46,6 @@ def batch_actions end end - render component_subclcass.new(page: page) + render component_subclcass.new(page:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/resource_item/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/resource_item/component_preview.rb index e8996f5877e..264b8a7e2ec 100644 --- a/admin/spec/components/previews/solidus_admin/ui/resource_item/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/resource_item/component_preview.rb @@ -13,9 +13,9 @@ def overview # @param subtitle text def render_resource_item(title: "Your Title", subtitle: "Your Subtitle", thumbnail: "https://picsum.photos/200/300") render current_component.new( - title: title, - subtitle: subtitle, - thumbnail: thumbnail + title:, + subtitle:, + thumbnail: ) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/tab/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/tab/component_preview.rb index 37ceecc9cf8..e34be48af31 100644 --- a/admin/spec/components/previews/solidus_admin/ui/tab/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/tab/component_preview.rb @@ -6,7 +6,7 @@ class SolidusAdmin::UI::Tab::ComponentPreview < ViewComponent::Preview # @param text text def overview(text: "text") - render_with_template locals: { text: text } + render_with_template locals: { text: } end # @param text text @@ -14,6 +14,6 @@ def overview(text: "text") # @param current toggle # @param disabled toggle def playground(text: "Tab", size: :m, current: false, disabled: false) - render current_component.new(text: text, size: size, current: current, disabled: disabled) + render current_component.new(text:, size:, current:, disabled:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb index c572cf03bae..238959dead0 100644 --- a/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb @@ -45,7 +45,7 @@ def table_data(batch_actions, sortable) { class: Spree::Product, rows: Array.new(10) { |n| Spree::Product.new(id: n, name: "Product #{n}", price: n * 10.0, available_on: n.days.ago) }, - columns: columns, + columns:, prev: nil, next: '#2', }.tap do |data| diff --git a/admin/spec/components/previews/solidus_admin/ui/table/ransack_filter/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/table/ransack_filter/component_preview.rb index 7db9b1a0d76..799fd3b5bb8 100644 --- a/admin/spec/components/previews/solidus_admin/ui/table/ransack_filter/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/table/ransack_filter/component_preview.rb @@ -12,7 +12,7 @@ def overview # @param search_bar select { choices: [[ Yes, 10], [ No, 3]] } def playground(presentation: "Filter", search_bar: 10) render current_component.new( - presentation: presentation, + presentation:, combinator: 'or', attribute: "attribute", predicate: "eq", diff --git a/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview.rb index 5691be19f31..074e3e88d42 100644 --- a/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview.rb @@ -11,6 +11,6 @@ def overview # @param size select { choices: [s, m, l] } # @param src text def playground(size: :m, src: "https://picsum.photos/200/300") - render component("ui/thumbnail").new(size: size.to_sym, src: src) + render component("ui/thumbnail").new(size: size.to_sym, src:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/toast/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/toast/component_preview.rb index 5398cede795..a52e7c8a566 100644 --- a/admin/spec/components/previews/solidus_admin/ui/toast/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/toast/component_preview.rb @@ -12,6 +12,6 @@ def overview # @param text text # @param icon text def playground(text: "Toast", scheme: :default, icon: "checkbox-circle-fill") - render component("ui/toast").new(text: text, scheme: scheme, icon: icon) + render component("ui/toast").new(text:, scheme:, icon:) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/toggletip/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/toggletip/component_preview.rb index 1b2b66ab125..52589cae9de 100644 --- a/admin/spec/components/previews/solidus_admin/ui/toggletip/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/toggletip/component_preview.rb @@ -13,9 +13,9 @@ def overview # @param open toggle def playground(text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", position: :above, open: false) render current_component.new( - text: text, - position: position, - open: open, + text:, + position:, + open:, class: "m-40" ) end diff --git a/admin/spec/features/orders/adjustments_spec.rb b/admin/spec/features/orders/adjustments_spec.rb index 6baeae09933..f88d36ebea8 100644 --- a/admin/spec/features/orders/adjustments_spec.rb +++ b/admin/spec/features/orders/adjustments_spec.rb @@ -13,7 +13,7 @@ it "allows locking and unlocking adjustments" do taxrate = create(:tax_rate) Spree::Adjustment.create( - order: order, + order:, adjustable: order, amount: 10, label: "Test Adjustment", @@ -49,7 +49,7 @@ it "can display an adjustment without a source" do Spree::Adjustment.create( - order: order, + order:, adjustable: order, amount: 10, label: "No Source Adjustment", @@ -87,7 +87,7 @@ before do order.shipments.first.adjustments.create!( - order: order, + order:, label: "Manual shipping discount", amount: -2, source: nil diff --git a/admin/spec/helpers/solidus_admin/permission_sets_helper_spec.rb b/admin/spec/helpers/solidus_admin/permission_sets_helper_spec.rb index 235e0df669f..ddc0865a917 100644 --- a/admin/spec/helpers/solidus_admin/permission_sets_helper_spec.rb +++ b/admin/spec/helpers/solidus_admin/permission_sets_helper_spec.rb @@ -39,9 +39,9 @@ context "when permission_sets are provided" do it "organizes permissions into the correct categories with labels and IDs" do result = helper.organize_permissions( - permission_sets: permission_sets, - view_label: view_label, - edit_label: edit_label + permission_sets:, + view_label:, + edit_label: ) expect(result[:sample_privilege]).to contain_exactly( @@ -56,9 +56,9 @@ it "creates a hash with keys for each privilege and other" do result = helper.organize_permissions( - permission_sets: permission_sets, - view_label: view_label, - edit_label: edit_label + permission_sets:, + view_label:, + edit_label: ) expect(result.keys).to include(:sample_privilege, :other) @@ -70,9 +70,9 @@ it "returns an empty hash" do result = helper.organize_permissions( - permission_sets: permission_sets, - view_label: view_label, - edit_label: edit_label + permission_sets:, + view_label:, + edit_label: ) expect(result).to eq({}) @@ -84,9 +84,9 @@ it "returns an empty hash" do result = helper.organize_permissions( - permission_sets: permission_sets, - view_label: view_label, - edit_label: edit_label + permission_sets:, + view_label:, + edit_label: ) expect(result).to eq({}) diff --git a/api/app/controllers/spree/api/variants_controller.rb b/api/app/controllers/spree/api/variants_controller.rb index d6746245443..39b584ec76f 100644 --- a/api/app/controllers/spree/api/variants_controller.rb +++ b/api/app/controllers/spree/api/variants_controller.rb @@ -28,7 +28,7 @@ def index @variants = if params[:variant_search_term] Spree::Config.variant_search_class.new( - params[:variant_search_term], scope: scope + params[:variant_search_term], scope: ).results.includes(include_list) else scope.includes(include_list).ransack(params[:q]).result diff --git a/api/app/views/spree/api/credit_cards/index.json.jbuilder b/api/app/views/spree/api/credit_cards/index.json.jbuilder index 39efed770a0..374346646ae 100644 --- a/api/app/views/spree/api/credit_cards/index.json.jbuilder +++ b/api/app/views/spree/api/credit_cards/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.credit_cards(@credit_cards) do |credit_card| - json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card) + json.partial!("spree/api/credit_cards/credit_card", credit_card:) end json.partial! 'spree/api/shared/pagination', pagination: @credit_cards diff --git a/api/app/views/spree/api/images/index.json.jbuilder b/api/app/views/spree/api/images/index.json.jbuilder index cba54b723fc..4c26c64a959 100644 --- a/api/app/views/spree/api/images/index.json.jbuilder +++ b/api/app/views/spree/api/images/index.json.jbuilder @@ -1,5 +1,5 @@ # frozen_string_literal: true json.images(@images) do |image| - json.partial!("spree/api/images/image", image: image) + json.partial!("spree/api/images/image", image:) end diff --git a/api/app/views/spree/api/line_items/_line_item.json.jbuilder b/api/app/views/spree/api/line_items/_line_item.json.jbuilder index 506f48cc9fa..3229f371489 100644 --- a/api/app/views/spree/api/line_items/_line_item.json.jbuilder +++ b/api/app/views/spree/api/line_items/_line_item.json.jbuilder @@ -9,10 +9,10 @@ json.cache! [I18n.locale, line_item] do json.partial!("spree/api/variants/small", variant: line_item.variant) json.(line_item.variant, :product_id) json.images(line_item.variant.gallery.images) do |image| - json.partial!("spree/api/images/image", image: image) + json.partial!("spree/api/images/image", image:) end end json.adjustments(line_item.adjustments) do |adjustment| - json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + json.partial!("spree/api/adjustments/adjustment", adjustment:) end end diff --git a/api/app/views/spree/api/option_types/index.json.jbuilder b/api/app/views/spree/api/option_types/index.json.jbuilder index 102817c315f..988199fe336 100644 --- a/api/app/views/spree/api/option_types/index.json.jbuilder +++ b/api/app/views/spree/api/option_types/index.json.jbuilder @@ -1,5 +1,5 @@ # frozen_string_literal: true json.array! @option_types do |option_type| - json.partial!("spree/api/option_types/option_type", option_type: option_type) + json.partial!("spree/api/option_types/option_type", option_type:) end diff --git a/api/app/views/spree/api/option_values/index.json.jbuilder b/api/app/views/spree/api/option_values/index.json.jbuilder index 9e61b650777..564cb704ab2 100644 --- a/api/app/views/spree/api/option_values/index.json.jbuilder +++ b/api/app/views/spree/api/option_values/index.json.jbuilder @@ -1,5 +1,5 @@ # frozen_string_literal: true json.array! @option_values do |option_value| - json.partial!("spree/api/option_values/option_value", option_value: option_value) + json.partial!("spree/api/option_values/option_value", option_value:) end diff --git a/api/app/views/spree/api/orders/_big.json.jbuilder b/api/app/views/spree/api/orders/_big.json.jbuilder index 11140e50c73..35e50f82c3a 100644 --- a/api/app/views/spree/api/orders/_big.json.jbuilder +++ b/api/app/views/spree/api/orders/_big.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true -json.partial!("spree/api/orders/order", order: order) +json.partial!("spree/api/orders/order", order:) json.payment_methods(order.available_payment_methods) do |payment_method| json.(payment_method, :id, :name, :partial_name) json.method_type payment_method.partial_name @@ -20,7 +20,7 @@ json.ship_address do end end json.line_items(order.line_items) do |line_item| - json.partial!("spree/api/line_items/line_item", line_item: line_item) + json.partial!("spree/api/line_items/line_item", line_item:) end json.payments(order.payments) do |payment| json.(payment, *payment_attributes) @@ -36,7 +36,7 @@ json.payments(order.payments) do |payment| if payment_source json.partial!( "spree/api/payments/source_views/#{payment.payment_method.partial_name}", - payment_source: payment_source + payment_source: ) else json.nil! @@ -44,14 +44,14 @@ json.payments(order.payments) do |payment| end end json.shipments(order.shipments) do |shipment| - json.partial!("spree/api/shipments/small", shipment: shipment) + json.partial!("spree/api/shipments/small", shipment:) end json.adjustments(order.adjustments) do |adjustment| - json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + json.partial!("spree/api/adjustments/adjustment", adjustment:) end json.permissions do json.can_update current_ability.can?(:update, order) end json.credit_cards(order.valid_credit_cards) do |credit_card| - json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card) + json.partial!("spree/api/credit_cards/credit_card", credit_card:) end diff --git a/api/app/views/spree/api/orders/index.json.jbuilder b/api/app/views/spree/api/orders/index.json.jbuilder index 0edb2557e9d..5ad9b405d2f 100644 --- a/api/app/views/spree/api/orders/index.json.jbuilder +++ b/api/app/views/spree/api/orders/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.orders(@orders) do |order| - json.partial!("spree/api/orders/order", order: order) + json.partial!("spree/api/orders/order", order:) end json.partial! 'spree/api/shared/pagination', pagination: @orders diff --git a/api/app/views/spree/api/orders/mine.json.jbuilder b/api/app/views/spree/api/orders/mine.json.jbuilder index 915a6766dca..a3e1d075f8f 100644 --- a/api/app/views/spree/api/orders/mine.json.jbuilder +++ b/api/app/views/spree/api/orders/mine.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.orders(@orders) do |order| - json.partial!("spree/api/orders/big", order: order) + json.partial!("spree/api/orders/big", order:) end json.partial! 'spree/api/shared/pagination', pagination: @orders diff --git a/api/app/views/spree/api/products/_product.json.jbuilder b/api/app/views/spree/api/products/_product.json.jbuilder index f6f3725364f..827f1bf3546 100644 --- a/api/app/views/spree/api/products/_product.json.jbuilder +++ b/api/app/views/spree/api/products/_product.json.jbuilder @@ -14,7 +14,7 @@ json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing json.partial!("spree/api/variants/small", variant: product.master) end json.variants(product.variants) do |variant| - json.partial!("spree/api/variants/small", variant: variant) + json.partial!("spree/api/variants/small", variant:) end end unless @exclude_data[:option_types] diff --git a/api/app/views/spree/api/products/index.json.jbuilder b/api/app/views/spree/api/products/index.json.jbuilder index c705ae0dc5a..89b7fa7d905 100644 --- a/api/app/views/spree/api/products/index.json.jbuilder +++ b/api/app/views/spree/api/products/index.json.jbuilder @@ -2,5 +2,5 @@ json.partial! 'spree/api/shared/pagination', pagination: @products json.products(@products) do |product| - json.partial!("spree/api/products/product", product: product) + json.partial!("spree/api/products/product", product:) end diff --git a/api/app/views/spree/api/shipments/_big.json.jbuilder b/api/app/views/spree/api/shipments/_big.json.jbuilder index 6f7495af402..20fa51ed0eb 100644 --- a/api/app/views/spree/api/shipments/_big.json.jbuilder +++ b/api/app/views/spree/api/shipments/_big.json.jbuilder @@ -2,14 +2,14 @@ json.cache! [I18n.locale, shipment] do json.(shipment, *shipment_attributes) - json.partial!("spree/api/shipments/small", shipment: shipment) + json.partial!("spree/api/shipments/small", shipment:) json.inventory_units(shipment.inventory_units) do |inventory_unit| json.(inventory_unit, *inventory_unit_attributes) json.variant do json.partial!("spree/api/variants/small", variant: inventory_unit.variant) json.(inventory_unit.variant, :product_id) json.images(inventory_unit.variant.gallery.images) do |image| - json.partial!("spree/api/images/image", image: image) + json.partial!("spree/api/images/image", image:) end end json.line_item do diff --git a/api/app/views/spree/api/shipments/_small.json.jbuilder b/api/app/views/spree/api/shipments/_small.json.jbuilder index 591affb8d52..549c10c0320 100644 --- a/api/app/views/spree/api/shipments/_small.json.jbuilder +++ b/api/app/views/spree/api/shipments/_small.json.jbuilder @@ -5,7 +5,7 @@ json.cache! [I18n.locale, shipment] do json.order_id(shipment.order.number) json.stock_location_name(shipment.stock_location.name) json.shipping_rates(shipment.shipping_rates) do |shipping_rate| - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate:) end json.selected_shipping_rate do if shipment.selected_shipping_rate @@ -29,6 +29,6 @@ json.cache! [I18n.locale, shipment] do json.states(manifest_item.states) end json.adjustments(shipment.adjustments) do |adjustment| - json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + json.partial!("spree/api/adjustments/adjustment", adjustment:) end end diff --git a/api/app/views/spree/api/shipments/mine.json.jbuilder b/api/app/views/spree/api/shipments/mine.json.jbuilder index a3570814ce0..a93e0111bb7 100644 --- a/api/app/views/spree/api/shipments/mine.json.jbuilder +++ b/api/app/views/spree/api/shipments/mine.json.jbuilder @@ -2,5 +2,5 @@ json.partial! 'spree/api/shared/pagination', pagination: @shipments json.shipments(@shipments) do |shipment| - json.partial!("spree/api/shipments/big", shipment: shipment) + json.partial!("spree/api/shipments/big", shipment:) end diff --git a/api/app/views/spree/api/shipments/show.json.jbuilder b/api/app/views/spree/api/shipments/show.json.jbuilder index a7a328c2228..9e3467e543e 100644 --- a/api/app/views/spree/api/shipments/show.json.jbuilder +++ b/api/app/views/spree/api/shipments/show.json.jbuilder @@ -5,7 +5,7 @@ json.cache! [I18n.locale, @shipment] do json.order_id(@shipment.order.number) json.stock_location_name(@shipment.stock_location.name) json.shipping_rates(@shipment.shipping_rates) do |shipping_rate| - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate:) end json.selected_shipping_rate do if @shipment.selected_shipping_rate diff --git a/api/app/views/spree/api/stock_items/index.json.jbuilder b/api/app/views/spree/api/stock_items/index.json.jbuilder index bc901832b1a..361f9c0ab19 100644 --- a/api/app/views/spree/api/stock_items/index.json.jbuilder +++ b/api/app/views/spree/api/stock_items/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.stock_items(@stock_items) do |stock_item| - json.partial!("spree/api/stock_items/stock_item", stock_item: stock_item) + json.partial!("spree/api/stock_items/stock_item", stock_item:) end json.partial! 'spree/api/shared/pagination', pagination: @stock_items diff --git a/api/app/views/spree/api/stock_locations/index.json.jbuilder b/api/app/views/spree/api/stock_locations/index.json.jbuilder index c7f59c8810b..489c4b7cc49 100644 --- a/api/app/views/spree/api/stock_locations/index.json.jbuilder +++ b/api/app/views/spree/api/stock_locations/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.stock_locations(@stock_locations) do |stock_location| - json.partial!("spree/api/stock_locations/stock_location", stock_location: stock_location) + json.partial!("spree/api/stock_locations/stock_location", stock_location:) end json.partial! 'spree/api/shared/pagination', pagination: @stock_locations diff --git a/api/app/views/spree/api/stock_movements/index.json.jbuilder b/api/app/views/spree/api/stock_movements/index.json.jbuilder index 66259a2ee22..124035c6ac1 100644 --- a/api/app/views/spree/api/stock_movements/index.json.jbuilder +++ b/api/app/views/spree/api/stock_movements/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.stock_movements(@stock_movements) do |stock_movement| - json.partial!("spree/api/stock_movements/stock_movement", stock_movement: stock_movement) + json.partial!("spree/api/stock_movements/stock_movement", stock_movement:) end json.partial! 'spree/api/shared/pagination', pagination: @stock_movements diff --git a/api/app/views/spree/api/taxonomies/_nested.json.jbuilder b/api/app/views/spree/api/taxonomies/_nested.json.jbuilder index 46234cf757f..d3865f76383 100644 --- a/api/app/views/spree/api/taxonomies/_nested.json.jbuilder +++ b/api/app/views/spree/api/taxonomies/_nested.json.jbuilder @@ -5,6 +5,6 @@ json.root do json.(taxonomy.root, *taxon_attributes) json.taxons(taxonomy.root.children) do |taxon| json.(taxon, *taxon_attributes) - json.partial!("spree/api/taxons/taxons", taxon: taxon) + json.partial!("spree/api/taxons/taxons", taxon:) end end diff --git a/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder b/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder index 1e9528636d3..4a2cb4b6179 100644 --- a/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder +++ b/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder @@ -1,7 +1,7 @@ # frozen_string_literal: true if params[:set] == "nested" - json.partial!("spree/api/taxonomies/nested", taxonomy: taxonomy) + json.partial!("spree/api/taxonomies/nested", taxonomy:) else json.(taxonomy, *taxonomy_attributes) json.root do diff --git a/api/app/views/spree/api/taxonomies/index.json.jbuilder b/api/app/views/spree/api/taxonomies/index.json.jbuilder index 656a2d60892..09976f688de 100644 --- a/api/app/views/spree/api/taxonomies/index.json.jbuilder +++ b/api/app/views/spree/api/taxonomies/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.taxonomies(@taxonomies) do |taxonomy| - json.partial!("spree/api/taxonomies/taxonomy", taxonomy: taxonomy) + json.partial!("spree/api/taxonomies/taxonomy", taxonomy:) end json.partial! 'spree/api/shared/pagination', pagination: @taxonomies diff --git a/api/app/views/spree/api/taxons/_taxons.json.jbuilder b/api/app/views/spree/api/taxons/_taxons.json.jbuilder index 88a87713b0f..d24ef637402 100644 --- a/api/app/views/spree/api/taxons/_taxons.json.jbuilder +++ b/api/app/views/spree/api/taxons/_taxons.json.jbuilder @@ -2,5 +2,5 @@ json.taxons(taxon.children) do |taxon| json.(taxon, *taxon_attributes) - json.partial!("spree/api/taxons/taxons", taxon: taxon) + json.partial!("spree/api/taxons/taxons", taxon:) end diff --git a/api/app/views/spree/api/taxons/index.json.jbuilder b/api/app/views/spree/api/taxons/index.json.jbuilder index f9d1ccb97ac..7db246367c9 100644 --- a/api/app/views/spree/api/taxons/index.json.jbuilder +++ b/api/app/views/spree/api/taxons/index.json.jbuilder @@ -4,6 +4,6 @@ json.partial! 'spree/api/shared/pagination', pagination: @taxons json.taxons(@taxons) do |taxon| json.(taxon, *taxon_attributes) unless params[:without_children] - json.partial!("spree/api/taxons/taxons", taxon: taxon) + json.partial!("spree/api/taxons/taxons", taxon:) end end diff --git a/api/app/views/spree/api/users/index.json.jbuilder b/api/app/views/spree/api/users/index.json.jbuilder index a25daef13f3..792316772f9 100644 --- a/api/app/views/spree/api/users/index.json.jbuilder +++ b/api/app/views/spree/api/users/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.users(@users) do |user| - json.partial!("spree/api/users/user", user: user) + json.partial!("spree/api/users/user", user:) end json.partial! 'spree/api/shared/pagination', pagination: @users diff --git a/api/app/views/spree/api/variants/_big.json.jbuilder b/api/app/views/spree/api/variants/_big.json.jbuilder index f875955c029..7bcbd571719 100644 --- a/api/app/views/spree/api/variants/_big.json.jbuilder +++ b/api/app/views/spree/api/variants/_big.json.jbuilder @@ -2,7 +2,7 @@ json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do json.(variant, *variant_attributes) - json.partial!("spree/api/variants/small", variant: variant) + json.partial!("spree/api/variants/small", variant:) json.variant_properties(variant.variant_properties) do |variant_property| json.(variant_property, *variant_property_attributes) end diff --git a/api/app/views/spree/api/variants/_small.json.jbuilder b/api/app/views/spree/api/variants/_small.json.jbuilder index d807e82ec3b..942556afe30 100644 --- a/api/app/views/spree/api/variants/_small.json.jbuilder +++ b/api/app/views/spree/api/variants/_small.json.jbuilder @@ -16,6 +16,6 @@ json.cache! [I18n.locale, current_pricing_options, variant] do json.(option_value, *option_value_attributes) end json.images(variant.gallery.images) do |image| - json.partial!("spree/api/images/image", image: image) + json.partial!("spree/api/images/image", image:) end end diff --git a/api/app/views/spree/api/variants/index.json.jbuilder b/api/app/views/spree/api/variants/index.json.jbuilder index 43126f014ed..d82c68c4f3b 100644 --- a/api/app/views/spree/api/variants/index.json.jbuilder +++ b/api/app/views/spree/api/variants/index.json.jbuilder @@ -2,5 +2,5 @@ json.partial! 'spree/api/shared/pagination', pagination: @variants json.variants(@variants) do |variant| - json.partial!("spree/api/variants/big", variant: variant) + json.partial!("spree/api/variants/big", variant:) end diff --git a/api/app/views/spree/api/zones/index.json.jbuilder b/api/app/views/spree/api/zones/index.json.jbuilder index efc331059ac..99e78bde657 100644 --- a/api/app/views/spree/api/zones/index.json.jbuilder +++ b/api/app/views/spree/api/zones/index.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true json.zones(@zones) do |zone| - json.partial!("spree/api/zones/zone", zone: zone) + json.partial!("spree/api/zones/zone", zone:) end json.partial! 'spree/api/shared/pagination', pagination: @zones diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index b01a91f5d1a..90885c28ebd 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| f.match(%r{^(spec|script)/}) end - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' s.add_dependency 'jbuilder', '~> 2.8' diff --git a/api/spec/features/checkout_spec.rb b/api/spec/features/checkout_spec.rb index 21af915ed69..02f1a6d1b4a 100644 --- a/api/spec/features/checkout_spec.rb +++ b/api/spec/features/checkout_spec.rb @@ -55,7 +55,7 @@ def update_order(order_params: {}) def create_line_item(variant, quantity = 1) expect { post "/api/orders/#{@order.number}/line_items", - params: { line_item: { variant_id: variant.id, quantity: quantity } } + params: { line_item: { variant_id: variant.id, quantity: } } }.to change { @order.line_items.count }.by 1 expect(response).to have_http_status(:created) end diff --git a/api/spec/requests/ransackable_attributes_spec.rb b/api/spec/requests/ransackable_attributes_spec.rb index 315a47935fe..95cbf7fa24c 100644 --- a/api/spec/requests/ransackable_attributes_spec.rb +++ b/api/spec/requests/ransackable_attributes_spec.rb @@ -4,7 +4,7 @@ describe "Ransackable Attributes" do let(:user) { create(:user).tap(&:generate_spree_api_key!) } - let(:order) { create(:order_with_line_items, user: user) } + let(:order) { create(:order_with_line_items, user:) } context "filtering by attributes one association away" do it "does not allow the filtering of variants by order attributes" do 2.times { create(:variant) } @@ -30,7 +30,7 @@ context "it maintains desired association behavior" do it "allows filtering of variants product name" do product = create(:product, name: "Fritos") - variant = create(:variant, product: product) + variant = create(:variant, product:) other_variant = create(:variant) get "/api/variants?q[product_name_or_sku_cont]=fritos", params: { token: user.spree_api_key } diff --git a/api/spec/requests/spree/api/checkouts_spec.rb b/api/spec/requests/spree/api/checkouts_spec.rb index 193db21ad59..c9eafbcf811 100644 --- a/api/spec/requests/spree/api/checkouts_spec.rb +++ b/api/spec/requests/spree/api/checkouts_spec.rb @@ -133,7 +133,7 @@ module Spree::Api it "can update shipping method and transition from delivery to payment" do order.update_column(:state, "delivery") - shipment = create(:shipment, order: order) + shipment = create(:shipment, order:) shipment.refresh_rates shipping_rate = shipment.shipping_rates.where(selected: false).first put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token, order: { shipments_attributes: { "0" => { selected_shipping_rate_id: shipping_rate.id, id: shipment.id } } } } @@ -195,7 +195,7 @@ module Spree::Api end it 'sets the payment amount to the order total' do - put spree.api_checkout_path(order), params: params + put(spree.api_checkout_path(order), params:) expect(response.status).to eq(200) expect(json_response['payments'][0]['amount']).to eq(order.total.to_s) end @@ -221,7 +221,7 @@ module Spree::Api end it 'succeeds' do - put spree.api_checkout_path(order), params: params + put(spree.api_checkout_path(order), params:) expect(response.status).to eq(200) expect(json_response['payments'][0]['payment_method']['name']).to eq(@payment_method.name) expect(json_response['payments'][0]['amount']).to eq(order.total.to_s) @@ -248,7 +248,7 @@ module Spree::Api end it 'returns errors' do - put spree.api_checkout_path(order), params: params + put(spree.api_checkout_path(order), params:) expect(response.status).to eq(422) cc_errors = json_response['errors']['payments.Credit Card'] @@ -296,7 +296,7 @@ module Spree::Api receive(:verification_value=).with('456').and_call_original ) - put spree.api_checkout_path(order), params: params + put(spree.api_checkout_path(order), params:) expect(response.status).to eq 200 expect(order.credit_cards).to match_array [credit_card] @@ -321,7 +321,7 @@ module Spree::Api } } expect do - put spree.api_checkout_path(order), params: params + put spree.api_checkout_path(order), params: end.not_to change { order.reload.ship_address.zipcode } expect(response.status).to eq(200) end @@ -393,7 +393,7 @@ module Spree::Api context "complete" do context "with order in confirm state" do subject do - put spree.complete_api_checkout_path(order), params: params + put spree.complete_api_checkout_path(order), params: end let(:params) { { order_token: order.guest_token } } diff --git a/api/spec/requests/spree/api/customer_returns_spec.rb b/api/spec/requests/spree/api/customer_returns_spec.rb index c9fe4584d4e..2da3f9a4c35 100644 --- a/api/spec/requests/spree/api/customer_returns_spec.rb +++ b/api/spec/requests/spree/api/customer_returns_spec.rb @@ -148,7 +148,7 @@ module Spree::Api let(:inventory_unit) { create(:inventory_unit, state: "shipped") } let(:order) { inventory_unit.order } let(:return_item) do - create(:return_item, inventory_unit: inventory_unit) + create(:return_item, inventory_unit:) end let(:customer_return_params) do diff --git a/api/spec/requests/spree/api/line_items_spec.rb b/api/spec/requests/spree/api/line_items_spec.rb index 9db68f36e7d..b9f6e03bacb 100644 --- a/api/spec/requests/spree/api/line_items_spec.rb +++ b/api/spec/requests/spree/api/line_items_spec.rb @@ -151,7 +151,7 @@ module Spree::Api context "order contents changed after shipments were created" do let!(:store) { create(:store) } - let!(:order) { Spree::Order.create(store: store) } + let!(:order) { Spree::Order.create(store:) } let!(:line_item) { order.contents.add(product.master) } before { order.create_proposed_shipments } diff --git a/api/spec/requests/spree/api/option_values_spec.rb b/api/spec/requests/spree/api/option_values_spec.rb index 23be8b0ca0a..a6f5ef02b1a 100644 --- a/api/spec/requests/spree/api/option_values_spec.rb +++ b/api/spec/requests/spree/api/option_values_spec.rb @@ -28,7 +28,7 @@ module Spree::Api context "filtering by product" do let(:product) { create(:product, option_types: [product_option_value.option_type]) } let(:product_option_value) { create(:option_value, presentation: "BLACK") } - let!(:variant) { create(:variant, product: product, option_values: [product_option_value]) } + let!(:variant) { create(:variant, product:, option_values: [product_option_value]) } it "can filter by product" do get spree.api_option_values_path(q: { variants_product_id_eq: product.id } ) @@ -54,8 +54,8 @@ module Spree::Api end it "can retrieve a list of option types" do - option_value_one = create(:option_value, option_type: option_type) - create(:option_value, option_type: option_type) + option_value_one = create(:option_value, option_type:) + create(:option_value, option_type:) get spree.api_option_values_path, params: { ids: [option_value.id, option_value_one.id] } expect(json_response.count).to eq(2) end diff --git a/api/spec/requests/spree/api/orders_spec.rb b/api/spec/requests/spree/api/orders_spec.rb index 4d3a5410220..1fa53c3dc9b 100644 --- a/api/spec/requests/spree/api/orders_spec.rb +++ b/api/spec/requests/spree/api/orders_spec.rb @@ -226,7 +226,7 @@ module Spree::Api context "the current api user is authenticated" do let(:current_api_user) { order.user } let(:store) { create(:store) } - let(:order) { create(:order, line_items: [line_item], store: store) } + let(:order) { create(:order, line_items: [line_item], store:) } it "can view all of their own orders for the current store" do get spree.api_my_orders_path, headers: { 'SERVER_NAME' => store.url } @@ -257,11 +257,11 @@ module Spree::Api it "returns orders in reverse chronological order by completed_at" do order.update_columns completed_at: Time.current, created_at: 3.days.ago - order_two = Spree::Order.create user: order.user, completed_at: Time.current - 1.day, created_at: 2.days.ago, store: store + order_two = Spree::Order.create(user: order.user, completed_at: Time.current - 1.day, created_at: 2.days.ago, store:) expect(order_two.created_at).to be > order.created_at - order_three = Spree::Order.create user: order.user, completed_at: nil, created_at: 1.day.ago, store: store + order_three = Spree::Order.create(user: order.user, completed_at: nil, created_at: 1.day.ago, store:) expect(order_three.created_at).to be > order_two.created_at - order_four = Spree::Order.create user: order.user, completed_at: nil, created_at: 0.days.ago, store: store + order_four = Spree::Order.create(user: order.user, completed_at: nil, created_at: 0.days.ago, store:) expect(order_four.created_at).to be > order_three.created_at get spree.api_my_orders_path, headers: { 'SERVER_NAME' => store.url } @@ -288,7 +288,7 @@ module Spree::Api let(:current_api_user) { nil } before do - get spree.api_current_order_path(format: 'json'), params: { order_token: order_token } + get spree.api_current_order_path(format: 'json'), params: { order_token: } end context "when the spree guest token is not present" do @@ -319,7 +319,7 @@ module Spree::Api describe 'GET #show' do let(:order) { create :order_with_line_items } - let(:adjustment) { FactoryBot.create(:adjustment, adjustable: order, order: order) } + let(:adjustment) { FactoryBot.create(:adjustment, adjustable: order, order:) } subject { get spree.api_order_path(order) } @@ -372,7 +372,7 @@ module Spree::Api end context 'when credit cards are present' do - let!(:payment) { create(:credit_card_payment, order: order, source: credit_card) } + let!(:payment) { create(:credit_card_payment, order:, source: credit_card) } let(:credit_card) { create(:credit_card, address: create(:address)) } it 'contains the credit cards' do @@ -391,7 +391,7 @@ module Spree::Api end context 'when store credit is present' do - let!(:payment) { create(:store_credit_payment, order: order, source: store_credit) } + let!(:payment) { create(:store_credit_payment, order:, source: store_credit) } let(:store_credit) { create(:store_credit) } it 'renders the payment source view for store credit' do @@ -648,7 +648,7 @@ module Spree::Api let(:line_item) { order.line_items.first } it "can empty an order" do - create(:adjustment, order: order, adjustable: order) + create(:adjustment, order:, adjustable: order) put spree.empty_api_order_path(order) expect(response.status).to eq(200) expect(json_response['id']).to eq(order.id) @@ -683,7 +683,7 @@ module Spree::Api it "lists line item adjustments" do adjustment = create(:adjustment, label: "10% off!", - order: order, + order:, adjustable: order.line_items.first) adjustment.update_column(:amount, 5) get spree.api_order_path(order) diff --git a/api/spec/requests/spree/api/payments_spec.rb b/api/spec/requests/spree/api/payments_spec.rb index 5b323abd51c..4cf4296469a 100644 --- a/api/spec/requests/spree/api/payments_spec.rb +++ b/api/spec/requests/spree/api/payments_spec.rb @@ -5,7 +5,7 @@ module Spree::Api describe 'Payments', type: :request do let!(:order) { create(:order_with_line_items) } - let!(:payment) { create(:payment, order: order, amount: order.amount) } + let!(:payment) { create(:payment, order:, amount: order.amount) } let!(:attributes) { [:id, :source_type, :source_id, :amount, :display_amount, :payment_method_id, :state, :avs_response, @@ -119,7 +119,7 @@ module Spree::Api end context "multiple payments" do - before { @payment = create(:payment, order: order) } + before { @payment = create(:payment, order:) } it "can view all payments on an order" do get spree.api_order_payments_path(order) diff --git a/api/spec/requests/spree/api/products_spec.rb b/api/spec/requests/spree/api/products_spec.rb index 1c4b2f6f365..6554f419f1f 100644 --- a/api/spec/requests/spree/api/products_spec.rb +++ b/api/spec/requests/spree/api/products_spec.rb @@ -372,7 +372,7 @@ module Spree::Api variant_hash = { sku: '123', price: 19.99, options: [{ name: "size", value: "small" }] } - variant_id = product.variants.create!({ product: product }.merge(variant_hash)).id + variant_id = product.variants.create!({ product: }.merge(variant_hash)).id put spree.api_product_path(product), params: { product: { variants: [ diff --git a/api/spec/requests/spree/api/return_authorizations_spec.rb b/api/spec/requests/spree/api/return_authorizations_spec.rb index 695aaab7270..43610d5e2ba 100644 --- a/api/spec/requests/spree/api/return_authorizations_spec.rb +++ b/api/spec/requests/spree/api/return_authorizations_spec.rb @@ -83,7 +83,7 @@ module Spree::Api sign_in_as_admin! it "can show return authorization" do - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) return_authorization = order.return_authorizations.first get spree.api_order_return_authorization_path(order, return_authorization.id) expect(response.status).to eq(200) @@ -92,8 +92,8 @@ module Spree::Api end it "can get a list of return authorizations" do - FactoryBot.create(:return_authorization, order: order) - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) + FactoryBot.create(:return_authorization, order:) get spree.api_order_return_authorizations_path(order), params: { order_id: order.number } expect(response.status).to eq(200) return_authorizations = json_response["return_authorizations"] @@ -102,8 +102,8 @@ module Spree::Api end it 'can control the page size through a parameter' do - FactoryBot.create(:return_authorization, order: order) - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) + FactoryBot.create(:return_authorization, order:) get spree.api_order_return_authorizations_path(order), params: { order_id: order.number, per_page: 1 } expect(json_response['count']).to eq(1) expect(json_response['current_page']).to eq(1) @@ -111,7 +111,7 @@ module Spree::Api end it 'can query the results through a paramter' do - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) expected_result = create(:return_authorization, memo: 'damaged') order.return_authorizations << expected_result get spree.api_order_return_authorizations_path(order), params: { q: { memo_cont: 'damaged' } } @@ -127,7 +127,7 @@ module Spree::Api end it "can update a return authorization on the order" do - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) return_authorization = order.return_authorizations.first put spree.api_order_return_authorization_path(order, return_authorization.id), params: { return_authorization: { memo: "ABC" } } expect(response.status).to eq(200) @@ -135,7 +135,7 @@ module Spree::Api end it "can cancel a return authorization on the order" do - FactoryBot.create(:new_return_authorization, order: order) + FactoryBot.create(:new_return_authorization, order:) return_authorization = order.return_authorizations.first expect(return_authorization.state).to eq("authorized") put spree.cancel_api_order_return_authorization_path(order, return_authorization.id) @@ -144,7 +144,7 @@ module Spree::Api end it "can delete a return authorization on the order" do - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) return_authorization = order.return_authorizations.first delete spree.api_order_return_authorization_path(order, return_authorization.id) expect(response.status).to eq(204) @@ -161,7 +161,7 @@ module Spree::Api end it "cannot update a return authorization on the order" do - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) return_authorization = order.return_authorizations.first put spree.api_order_return_authorization_path(order, return_authorization.id), params: { return_authorization: { memo: "ABC" } } assert_unauthorized! @@ -169,7 +169,7 @@ module Spree::Api end it "cannot delete a return authorization on the order" do - FactoryBot.create(:return_authorization, order: order) + FactoryBot.create(:return_authorization, order:) return_authorization = order.return_authorizations.first delete spree.api_order_return_authorization_path(order, return_authorization.id) assert_unauthorized! diff --git a/api/spec/requests/spree/api/shipments_spec.rb b/api/spec/requests/spree/api/shipments_spec.rb index 7567963e56b..10dbe0840de 100644 --- a/api/spec/requests/spree/api/shipments_spec.rb +++ b/api/spec/requests/spree/api/shipments_spec.rb @@ -58,7 +58,7 @@ module Spree::Api end subject do - post spree.api_shipments_path, params: params + post spree.api_shipments_path, params: end it 'creates a new shipment' do @@ -87,7 +87,7 @@ module Spree::Api } } - put spree.api_shipment_path(shipment), params: params + put(spree.api_shipment_path(shipment), params:) expect(response.status).to eq(200) expect(json_response['stock_location_name']).to eq(stock_location.name) end @@ -136,7 +136,7 @@ module Spree::Api end context 'for ready shipments' do - let(:order) { create :order_ready_to_ship, line_items_attributes: [{ variant: variant, quantity: 1 }] } + let(:order) { create :order_ready_to_ship, line_items_attributes: [{ variant:, quantity: 1 }] } let(:shipment) { order.shipments.first } it 'adds a variant to a shipment' do @@ -171,7 +171,7 @@ module Spree::Api context 'for empty shipments' do let(:order) { create :completed_order_with_totals } - let(:shipment) { order.shipments.create(stock_location: stock_location) } + let(:shipment) { order.shipments.create(stock_location:) } it 'adds a variant to a shipment' do put spree.add_api_shipment_path(shipment), params: { variant_id: variant.to_param, quantity: 2 } @@ -182,7 +182,7 @@ module Spree::Api describe '#mine' do subject do - get spree.mine_api_shipments_path, params: params + get spree.mine_api_shipments_path, params: end let(:params) { {} } @@ -306,7 +306,7 @@ module Spree::Api let(:send_mailer) { nil } subject do - put spree.ship_api_shipment_path(shipment), params: { send_mailer: send_mailer } + put spree.ship_api_shipment_path(shipment), params: { send_mailer: } end context "the user is allowed to ship the shipment" do @@ -396,10 +396,10 @@ module Spree::Api let(:order) do create( :completed_order_with_totals, - user: user, + user:, line_items_attributes: [ { - variant: variant + variant: } ] ) @@ -417,7 +417,7 @@ module Spree::Api post "/api/shipments/transfer_to_location.json", params: { original_shipment_number: source_shipment.number, - stock_location_id: stock_location_id, + stock_location_id:, quantity: 1, variant_id: variant.id, token: user.spree_api_key @@ -498,7 +498,7 @@ module Spree::Api describe "POST /api/shipments/transfer_to_shipment" do let(:stock_location) { create(:stock_location) } let(:source_shipment) { order.shipments.first } - let(:target_shipment) { order.shipments.create(stock_location: stock_location) } + let(:target_shipment) { order.shipments.create(stock_location:) } let(:parsed_response) { JSON.parse(response.body) } let(:source_shipment_number) { source_shipment.number } diff --git a/api/spec/requests/spree/api/stock_items_spec.rb b/api/spec/requests/spree/api/stock_items_spec.rb index 07c31965d68..4d64e2a796d 100644 --- a/api/spec/requests/spree/api/stock_items_spec.rb +++ b/api/spec/requests/spree/api/stock_items_spec.rb @@ -55,7 +55,7 @@ module Spree::Api } } - post spree.api_stock_location_stock_items_path(stock_location), params: params + post(spree.api_stock_location_stock_items_path(stock_location), params:) expect(response.status).to eq(401) end end @@ -122,13 +122,13 @@ module Spree::Api { stock_item: { variant_id: variant.id, - count_on_hand: count_on_hand + count_on_hand: } } end subject do - post spree.api_stock_location_stock_items_path(stock_location), params: params + post spree.api_stock_location_stock_items_path(stock_location), params: end it 'can create a new stock item' do @@ -182,7 +182,7 @@ module Spree::Api end subject do - put spree.api_stock_item_path(stock_item), params: params + put spree.api_stock_item_path(stock_item), params: end context 'adjusting count_on_hand' do @@ -190,7 +190,7 @@ module Spree::Api let(:params) do { stock_item: { - count_on_hand: count_on_hand, + count_on_hand:, backorderable: true } } @@ -248,7 +248,7 @@ module Spree::Api { id: stock_item.to_param, stock_item: { - count_on_hand: count_on_hand, + count_on_hand:, backorderable: true, force: true } diff --git a/api/spec/requests/spree/api/stock_locations_spec.rb b/api/spec/requests/spree/api/stock_locations_spec.rb index ea9915d9716..3794fc77604 100644 --- a/api/spec/requests/spree/api/stock_locations_spec.rb +++ b/api/spec/requests/spree/api/stock_locations_spec.rb @@ -52,7 +52,7 @@ module Spree::Api } } - post spree.api_stock_locations_path, params: params + post(spree.api_stock_locations_path, params:) expect(response.status).to eq(401) end end @@ -138,7 +138,7 @@ module Spree::Api } } - post spree.api_stock_locations_path, params: params + post(spree.api_stock_locations_path, params:) expect(response.status).to eq(201) expect(json_response).to have_attributes(attributes) end @@ -152,7 +152,7 @@ module Spree::Api } } - put spree.api_stock_location_path(stock_location), params: params + put(spree.api_stock_location_path(stock_location), params:) expect(response.status).to eq(200) expect(json_response['name']).to eq 'South Pole' end diff --git a/api/spec/requests/spree/api/stock_movements_spec.rb b/api/spec/requests/spree/api/stock_movements_spec.rb index 68cc77b9556..1cd499002e4 100644 --- a/api/spec/requests/spree/api/stock_movements_spec.rb +++ b/api/spec/requests/spree/api/stock_movements_spec.rb @@ -6,7 +6,7 @@ module Spree::Api describe 'Stock movements', type: :request do let!(:stock_location) { create(:stock_location_with_items) } let!(:stock_item) { stock_location.stock_items.order(:id).first } - let!(:stock_movement) { create(:stock_movement, stock_item: stock_item) } + let!(:stock_movement) { create(:stock_movement, stock_item:) } let!(:attributes) { [:id, :quantity, :stock_item_id] } before do @@ -31,7 +31,7 @@ module Spree::Api } } - post spree.api_stock_location_stock_movements_path(stock_location), params: params + post(spree.api_stock_location_stock_movements_path(stock_location), params:) expect(response.status).to eq(401) end end @@ -46,7 +46,7 @@ module Spree::Api end it 'can control the page size through a parameter' do - create(:stock_movement, stock_item: stock_item) + create(:stock_movement, stock_item:) get spree.api_stock_location_stock_movements_path(stock_location), params: { per_page: 1 } expect(json_response['count']).to eq(1) expect(json_response['current_page']).to eq(1) @@ -54,7 +54,7 @@ module Spree::Api end it 'can query the results through a paramter' do - create(:stock_movement, :received, quantity: 10, stock_item: stock_item) + create(:stock_movement, :received, quantity: 10, stock_item:) get spree.api_stock_location_stock_movements_path(stock_location), params: { q: { quantity_eq: '10' } } expect(json_response['count']).to eq(1) end @@ -72,7 +72,7 @@ module Spree::Api } } - post spree.api_stock_location_stock_movements_path(stock_location), params: params + post(spree.api_stock_location_stock_movements_path(stock_location), params:) expect(response.status).to eq(201) expect(json_response).to have_attributes(attributes) end diff --git a/api/spec/requests/spree/api/taxonomies_spec.rb b/api/spec/requests/spree/api/taxonomies_spec.rb index dc0d1b37ace..ff927b5b215 100644 --- a/api/spec/requests/spree/api/taxonomies_spec.rb +++ b/api/spec/requests/spree/api/taxonomies_spec.rb @@ -5,13 +5,13 @@ module Spree::Api describe 'Taxonomies', type: :request do let(:taxonomy) { create(:taxonomy) } - let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) } - let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) } + let(:taxon) { create(:taxon, name: "Ruby", taxonomy:) } + let(:taxon2) { create(:taxon, name: "Rails", taxonomy:) } let(:attributes) { [:id, :name] } before do stub_authentication! - taxon2.children << create(:taxon, name: "3.2.2", taxonomy: taxonomy) + taxon2.children << create(:taxon, name: "3.2.2", taxonomy:) taxon.children << taxon2 taxonomy.root.children << taxon end diff --git a/api/spec/requests/spree/api/taxons_spec.rb b/api/spec/requests/spree/api/taxons_spec.rb index 022ce0e535a..d93ff52e549 100644 --- a/api/spec/requests/spree/api/taxons_spec.rb +++ b/api/spec/requests/spree/api/taxons_spec.rb @@ -5,9 +5,9 @@ module Spree::Api describe 'Taxons', type: :request do let!(:taxonomy) { create(:taxonomy) } - let!(:taxon) { create(:taxon, name: "Ruby", parent: taxonomy.root, taxonomy: taxonomy) } - let!(:taxon2) { create(:taxon, name: "Rails", parent: taxon, taxonomy: taxonomy) } - let!(:rails_v3_2_2) { create(:taxon, name: "3.2.2", parent: taxon2, taxonomy: taxonomy) } + let!(:taxon) { create(:taxon, name: "Ruby", parent: taxonomy.root, taxonomy:) } + let!(:taxon2) { create(:taxon, name: "Rails", parent: taxon, taxonomy:) } + let!(:rails_v3_2_2) { create(:taxon, name: "3.2.2", parent: taxon2, taxonomy:) } let(:attributes) { ["id", "name", "pretty_name", "permalink", "parent_id", "taxonomy_id"] } before do @@ -34,7 +34,7 @@ module Spree::Api end it "paginates through taxons" do - new_taxon = create(:taxon, name: "Go", taxonomy: taxonomy) + new_taxon = create(:taxon, name: "Go", taxonomy:) taxonomy.root.children << new_taxon expect(taxonomy.root.children.count).to eql(2) get spree.api_taxonomy_taxons_path(taxonomy), params: { page: 1, per_page: 1 } @@ -92,8 +92,8 @@ module Spree::Api it 'returns only requested ids' do # We need a completly new branch to avoid having parent that can be preloaded from the rails ancestors - python = create(:taxon, name: "Python", parent: taxonomy.root, taxonomy: taxonomy) - python_three = create(:taxon, name: "3.0", parent: python, taxonomy: taxonomy) + python = create(:taxon, name: "Python", parent: taxonomy.root, taxonomy:) + python_three = create(:taxon, name: "3.0", parent: python, taxonomy:) get spree.api_taxons_path, params: { ids: [rails_v3_2_2.id, python_three.id] } diff --git a/api/spec/requests/spree/api/users_spec.rb b/api/spec/requests/spree/api/users_spec.rb index 4203515546c..7b0d2d9d7b1 100644 --- a/api/spec/requests/spree/api/users_spec.rb +++ b/api/spec/requests/spree/api/users_spec.rb @@ -193,7 +193,7 @@ module Spree::Api end it "cannot destroy user with orders" do - create(:completed_order_with_totals, user: user) + create(:completed_order_with_totals, user:) delete spree.api_user_path(user) expect(response.status).to eq(422) expect(json_response).to eq({ "error" => "Cannot delete record." }) diff --git a/api/spec/requests/spree/api/zones_spec.rb b/api/spec/requests/spree/api/zones_spec.rb index 6ef5c5ecc52..4a121504def 100644 --- a/api/spec/requests/spree/api/zones_spec.rb +++ b/api/spec/requests/spree/api/zones_spec.rb @@ -54,7 +54,7 @@ module Spree::Api } } - post spree.api_zones_path, params: params + post(spree.api_zones_path, params:) expect(response.status).to eq(201) expect(json_response).to have_attributes(attributes) expect(json_response["zone_members"]).not_to be_empty @@ -73,7 +73,7 @@ module Spree::Api } } - put spree.api_zone_path(zone), params: params + put(spree.api_zone_path(zone), params:) expect(response.status).to eq(200) expect(json_response['name']).to eq 'North Pole' expect(json_response['zone_members']).not_to be_blank diff --git a/api/spec/support/controller_hacks.rb b/api/spec/support/controller_hacks.rb index 19f13777a45..c1765cce24d 100644 --- a/api/spec/support/controller_hacks.rb +++ b/api/spec/support/controller_hacks.rb @@ -29,10 +29,10 @@ def api_process(action, params = {}, session = nil, flash = nil, method = "get") scoping = respond_to?(:resource_scoping) ? resource_scoping : {} process( action, - method: method, + method:, params: params.merge(scoping), - session: session, - flash: flash, + session:, + flash:, format: :json ) end diff --git a/backend/app/controllers/spree/admin/cancellations_controller.rb b/backend/app/controllers/spree/admin/cancellations_controller.rb index 2602cdc5807..8d075c3888f 100644 --- a/backend/app/controllers/spree/admin/cancellations_controller.rb +++ b/backend/app/controllers/spree/admin/cancellations_controller.rb @@ -20,7 +20,7 @@ def short_ship flash[:error] = t('spree.no_inventory_selected') redirect_to admin_order_cancellations_path(@order) else - @order.cancellations.short_ship(inventory_units, created_by: created_by) + @order.cancellations.short_ship(inventory_units, created_by:) flash[:success] = t('spree.inventory_canceled') redirect_to edit_admin_order_url(@order) diff --git a/backend/app/controllers/spree/admin/option_types_controller.rb b/backend/app/controllers/spree/admin/option_types_controller.rb index ce422e8682d..23c52941fec 100644 --- a/backend/app/controllers/spree/admin/option_types_controller.rb +++ b/backend/app/controllers/spree/admin/option_types_controller.rb @@ -7,7 +7,7 @@ class OptionTypesController < ResourceController def update_values_positions params[:positions].each do |id, index| - Spree::OptionValue.where(id: id).update_all(position: index) + Spree::OptionValue.where(id:).update_all(position: index) end respond_to do |format| diff --git a/backend/app/controllers/spree/admin/orders/customer_details_controller.rb b/backend/app/controllers/spree/admin/orders/customer_details_controller.rb index a588a0397d9..5306a6dfe94 100644 --- a/backend/app/controllers/spree/admin/orders/customer_details_controller.rb +++ b/backend/app/controllers/spree/admin/orders/customer_details_controller.rb @@ -15,8 +15,8 @@ def show def edit country_id = default_country_id - @order.build_bill_address(country_id: country_id) if @order.bill_address.nil? - @order.build_ship_address(country_id: country_id) if @order.ship_address.nil? + @order.build_bill_address(country_id:) if @order.bill_address.nil? + @order.build_ship_address(country_id:) if @order.ship_address.nil? @order.bill_address.country_id = country_id if @order.bill_address.country.nil? @order.ship_address.country_id = country_id if @order.ship_address.country.nil? diff --git a/backend/app/controllers/spree/admin/resource_controller.rb b/backend/app/controllers/spree/admin/resource_controller.rb index 4f63edb0e0b..5b0a350d839 100644 --- a/backend/app/controllers/spree/admin/resource_controller.rb +++ b/backend/app/controllers/spree/admin/resource_controller.rb @@ -88,7 +88,7 @@ def update_positions # # TODO : create a global set_list_position on all concerned objects # maybe in the acts_as_list gem - model_class.where(id: id).first&.set_list_position(index) + model_class.where(id:).first&.set_list_position(index) end end diff --git a/backend/app/helpers/spree/admin/base_helper.rb b/backend/app/helpers/spree/admin/base_helper.rb index c77b1dd2c9f..b1e6d33bb9d 100644 --- a/backend/app/helpers/spree/admin/base_helper.rb +++ b/backend/app/helpers/spree/admin/base_helper.rb @@ -25,7 +25,7 @@ def error_message_on(object, method, _options = {}) end def admin_hint(title, text) - content_tag(:span, class: 'hint-tooltip', title: title, data: { content: text }) do + content_tag(:span, class: 'hint-tooltip', title:, data: { content: text }) do content_tag(:i, '', class: 'fa fa-info-circle') end end @@ -39,7 +39,7 @@ def datepicker_field_value(date, with_time: false) t('spree.date_picker.format', default: '%Y/%m/%d') end - l(date, format: format) + l(date, format:) end def spree_dom_id(record) diff --git a/backend/app/helpers/spree/admin/navigation_helper.rb b/backend/app/helpers/spree/admin/navigation_helper.rb index 60f566cadf4..259745214b3 100644 --- a/backend/app/helpers/spree/admin/navigation_helper.rb +++ b/backend/app/helpers/spree/admin/navigation_helper.rb @@ -114,7 +114,7 @@ def link_to_delete(resource, options = {}) name = options[:name] || t('spree.actions.delete') confirm = options[:confirm] || t('spree.are_you_sure') options[:class] = "#{options[:class]} delete-resource".strip - options[:data] = { confirm: confirm, action: 'remove' } + options[:data] = { confirm:, action: 'remove' } link_to_with_icon 'trash', name, url, options end diff --git a/backend/solidus_backend.gemspec b/backend/solidus_backend.gemspec index 02af2dfebd4..7d0fcd2b8cb 100644 --- a/backend/solidus_backend.gemspec +++ b/backend/solidus_backend.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| f.match(%r{^(spec|script)/}) end - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' s.add_dependency 'solidus_api', s.version diff --git a/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb b/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb index 27279f62cf7..4fd763d209d 100644 --- a/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/customer_returns_controller_spec.rb @@ -61,7 +61,7 @@ module Admin let!(:inactive_rma_reason) { create(:return_reason, active: false) } let(:order) { create(:shipped_order, line_items_count: 4) } - let(:rma) { create(:return_authorization, order: order, reason: return_reason_1) } + let(:rma) { create(:return_authorization, order:, reason: return_reason_1) } let!(:rma_return_item) { create(:return_item, return_authorization: rma, inventory_unit: order.inventory_units.first, return_reason: return_reason_2) } let!(:customer_return_return_item) { create(:return_item, return_authorization: nil, inventory_unit: order.inventory_units.last, return_reason: return_reason_3) } @@ -199,13 +199,13 @@ module Admin { order_id: order.to_param, customer_return: { - stock_location_id: stock_location_id, + stock_location_id:, return_items_attributes: { "0" => { returned: "1", amount: "15.99", inventory_unit_id: order.inventory_units.shipped.last.id, - reception_status_event: reception_status_event + reception_status_event: } } } diff --git a/backend/spec/controllers/spree/admin/locale_controller_spec.rb b/backend/spec/controllers/spree/admin/locale_controller_spec.rb index 9cd61bc91d6..02a7c05b562 100644 --- a/backend/spec/controllers/spree/admin/locale_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/locale_controller_spec.rb @@ -16,7 +16,7 @@ let(:json_response) { JSON.parse(response.body, symbolize_names: true) } before do - get :set, params: { switch_to_locale: switch_to_locale, format: :json } + get :set, params: { switch_to_locale:, format: :json } end context 'available locale' do diff --git a/backend/spec/controllers/spree/admin/orders_controller_spec.rb b/backend/spec/controllers/spree/admin/orders_controller_spec.rb index a9b4028198b..0569abbb979 100644 --- a/backend/spec/controllers/spree/admin/orders_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/orders_controller_spec.rb @@ -324,7 +324,7 @@ context "#not_finalized_adjustments" do let(:order) { create(:order) } - let!(:finalized_adjustment) { create(:adjustment, finalized: true, adjustable: order, order: order) } + let!(:finalized_adjustment) { create(:adjustment, finalized: true, adjustable: order, order:) } it "changes all the finalized adjustments to unfinalized" do post :unfinalize_adjustments, params: { id: order.number } @@ -344,7 +344,7 @@ context "#finalize_adjustments" do let(:order) { create(:order) } - let!(:not_finalized_adjustment) { create(:adjustment, finalized: false, adjustable: order, order: order) } + let!(:not_finalized_adjustment) { create(:adjustment, finalized: false, adjustable: order, order:) } it "changes all the unfinalized adjustments to finalized" do post :finalize_adjustments, params: { id: order.number } diff --git a/backend/spec/controllers/spree/admin/payment_methods_controller_spec.rb b/backend/spec/controllers/spree/admin/payment_methods_controller_spec.rb index dece8d5a88a..e815d5f3c7b 100644 --- a/backend/spec/controllers/spree/admin/payment_methods_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/payment_methods_controller_spec.rb @@ -99,7 +99,7 @@ class GatewayWithPassword < PaymentMethod end it 'updates the resource' do - put :update, params: params + put(:update, params:) expect(response).to redirect_to(spree.edit_admin_payment_method_path(payment_method)) response_payment_method = Spree::PaymentMethod.find(payment_method.id) diff --git a/backend/spec/controllers/spree/admin/payments_controller_spec.rb b/backend/spec/controllers/spree/admin/payments_controller_spec.rb index 37bfb1cb24d..da351bcbeb3 100644 --- a/backend/spec/controllers/spree/admin/payments_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/payments_controller_spec.rb @@ -131,7 +131,7 @@ module Admin context "order has payments" do before do - order.payments << create(:payment, amount: order.total, order: order, state: 'completed') + order.payments << create(:payment, amount: order.total, order:, state: 'completed') end it "shows the payments page" do diff --git a/backend/spec/controllers/spree/admin/prices_controller_spec.rb b/backend/spec/controllers/spree/admin/prices_controller_spec.rb index 0e86a0187e2..e2e785b24d2 100644 --- a/backend/spec/controllers/spree/admin/prices_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/prices_controller_spec.rb @@ -31,7 +31,7 @@ let(:variant) { create(:variant) } let(:product) { variant.product } - let!(:deleted_variant_price) { create(:price, variant: variant).tap(&:discard!) } + let!(:deleted_variant_price) { create(:price, variant:).tap(&:discard!) } subject { get :index, params: { product_id: product.slug, variant_id: variant.id } } diff --git a/backend/spec/controllers/spree/admin/product_properties_controller_spec.rb b/backend/spec/controllers/spree/admin/product_properties_controller_spec.rb index b7eab913634..b373b85c9d4 100644 --- a/backend/spec/controllers/spree/admin/product_properties_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/product_properties_controller_spec.rb @@ -33,7 +33,7 @@ module Admin let(:product) { create(:product, option_types: [size]) } let(:size_small) { create(:option_value, name: 'small', option_type: size) } let(:size_large) { create(:option_value, name: 'large', option_type: size) } - let!(:first_rule) { create(:variant_property_rule, product: product, option_value: size_small) } + let!(:first_rule) { create(:variant_property_rule, product:, option_value: size_small) } context "no rules match the option values" do let(:parameters) do diff --git a/backend/spec/controllers/spree/admin/products_controller_spec.rb b/backend/spec/controllers/spree/admin/products_controller_spec.rb index 66849315d0a..867a83378ee 100644 --- a/backend/spec/controllers/spree/admin/products_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/products_controller_spec.rb @@ -25,7 +25,7 @@ let(:params) { { q: {} } } it 'filters out soft-deleted products by default' do - get :index, params: params + get(:index, params:) expect(assigns[:collection]).to_not include(soft_deleted_product) end end @@ -34,7 +34,7 @@ let(:params) { { q: { with_discarded: 'true' } } } it 'includes soft-deleted products' do - get :index, params: params + get(:index, params:) expect(assigns[:collection]).to include(soft_deleted_product) end end @@ -190,7 +190,7 @@ let(:original_option_value) { create(:option_value) } let!(:product) { create(:product, option_types: [option_value.option_type]) } let!(:rule) do - create(:variant_property_rule, product: product, option_value: original_option_value) + create(:variant_property_rule, product:, option_value: original_option_value) end let(:payload) do { @@ -261,7 +261,7 @@ context "destroying a product" do let(:product) do product = create(:product) - create(:variant, product: product) + create(:variant, product:) product end diff --git a/backend/spec/controllers/spree/admin/resource_controller_spec.rb b/backend/spec/controllers/spree/admin/resource_controller_spec.rb index 7fd6927d173..90f392686ba 100644 --- a/backend/spec/controllers/spree/admin/resource_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/resource_controller_spec.rb @@ -101,7 +101,7 @@ def check_destroy_constraints { widget: { name: 'a widget' } } end - subject { post :create, params: params } + subject { post :create, params: } it 'creates the resource' do expect { subject }.to change { Widget.count }.by(1) @@ -141,7 +141,7 @@ def check_destroy_constraints } end - subject { put :update, params: params } + subject { put :update, params: } it 'updates the resource' do expect { subject }.to change { widget.reload.name }.from('a widget').to('widget renamed') @@ -167,7 +167,7 @@ def check_destroy_constraints end it 'returns to edit page with error' do - put :update, params: params + put(:update, params:) expect(flash[:error]).to eq('Record invalid') end end @@ -178,7 +178,7 @@ def check_destroy_constraints let(:params) { { id: widget.id } } subject { - delete :destroy, params: params + delete :destroy, params: } it 'destroys the resource' do @@ -190,7 +190,7 @@ def check_destroy_constraints let(:params) { { id: widget.id } } context 'js format' do - subject { delete :destroy, params: params, format: 'js' } + subject { delete :destroy, params:, format: 'js' } it 'responds with error message' do subject @@ -200,7 +200,7 @@ def check_destroy_constraints end context 'html format' do - subject { delete :destroy, params: params } + subject { delete :destroy, params: } it 'responds with error message' do subject diff --git a/backend/spec/controllers/spree/admin/return_authorizations_controller_spec.rb b/backend/spec/controllers/spree/admin/return_authorizations_controller_spec.rb index 4be7f642ebd..96ed7e65768 100644 --- a/backend/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/return_authorizations_controller_spec.rb @@ -13,7 +13,7 @@ let(:inventory_unit_3) { order.inventory_units.order('id asc')[2] } describe '#fire' do - let(:return_authorization) { create(:return_authorization, order: order) } + let(:return_authorization) { create(:return_authorization, order:) } context 'with the event parameter set' do let(:params) do @@ -28,7 +28,7 @@ let(:event) { 'cancel' } it 'sends method with ! to return authorization and redirect back' do - get :fire, params: params + get(:fire, params:) expect(response).to redirect_to(admin_order_return_authorizations_path(order)) expect(flash[:success]).to eq 'Return merchandise authorization updated' @@ -39,7 +39,7 @@ let(:event) { 'do_something_crazy' } it 'redirects back with an error message' do - get :fire, params: params + get(:fire, params:) expect(response).to redirect_to(admin_order_return_authorizations_path(order)) expect(flash[:error]).to eq 'Cannot perform this action on return merchandise authorization' @@ -52,7 +52,7 @@ it 'redirects back with an error message' do expect(return_authorization).not_to receive :destroy! - get :fire, params: params + get(:fire, params:) expect(response).to redirect_to(admin_order_return_authorizations_path(order)) expect(flash[:error]).to eq 'Cannot perform this action on return merchandise authorization' @@ -107,7 +107,7 @@ shared_context 'with existing return items' do context 'with existing return items' do - let!(:return_item_1) { create(:return_item, inventory_unit: inventory_unit_1, return_authorization: return_authorization) } + let!(:return_item_1) { create(:return_item, inventory_unit: inventory_unit_1, return_authorization:) } it 'has 1 existing return item and 2 new return items' do subject @@ -132,7 +132,7 @@ } end - let(:return_authorization) { create(:return_authorization, order: order) } + let(:return_authorization) { create(:return_authorization, order:) } include_context 'without existing return items' include_context 'with existing return items' @@ -158,7 +158,7 @@ } end - let(:return_authorization) { create(:return_authorization, order: order) } + let(:return_authorization) { create(:return_authorization, order:) } include_context 'without existing return items' include_context 'with existing return items' @@ -199,7 +199,7 @@ context '#create' do let(:stock_location) { create(:stock_location) } - subject { post :create, params: params } + subject { post :create, params: } let(:params) do { @@ -223,7 +223,7 @@ end context '#update' do - let(:return_authorization) { create(:return_authorization, order: order) } + let(:return_authorization) { create(:return_authorization, order:) } let(:params) do { @@ -239,7 +239,7 @@ } end - subject { put :update, params: params } + subject { put :update, params: } context "adding an item" do let(:return_items_params) do @@ -257,7 +257,7 @@ context 'with existing completed items' do let!(:completed_return_item) do create(:return_item, { - return_authorization: return_authorization, + return_authorization:, inventory_unit: inventory_unit_1, reception_status: 'received' }) @@ -272,7 +272,7 @@ context "removing an item" do let!(:return_item) do - create(:return_item, return_authorization: return_authorization, inventory_unit: inventory_unit_1) + create(:return_item, return_authorization:, inventory_unit: inventory_unit_1) end let(:return_items_params) do diff --git a/backend/spec/controllers/spree/admin/return_items_controller_spec.rb b/backend/spec/controllers/spree/admin/return_items_controller_spec.rb index 37580834f70..afa4f0a3253 100644 --- a/backend/spec/controllers/spree/admin/return_items_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/return_items_controller_spec.rb @@ -39,7 +39,7 @@ end subject do - put :update, params: { id: return_item.to_param, return_item: { reception_status_event: reception_status_event } } + put :update, params: { id: return_item.to_param, return_item: { reception_status_event: } } end it 'updates the return item' do diff --git a/backend/spec/controllers/spree/admin/search_controller_spec.rb b/backend/spec/controllers/spree/admin/search_controller_spec.rb index 6be30c95f9d..3f2b0754353 100644 --- a/backend/spec/controllers/spree/admin/search_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/search_controller_spec.rb @@ -15,7 +15,7 @@ end describe 'GET #users' do - subject { get :users, params: params, as: :json } + subject { get :users, params:, as: :json } shared_examples_for 'user found by search' do it "should include users matching query" do @@ -60,7 +60,7 @@ def starting_letters(string) let!(:product_one) { create(:product, name: 'jersey') } let!(:product_two) { create(:product, name: 'better jersey') } - subject { get :products, params: params, as: :json } + subject { get :products, params:, as: :json } shared_examples_for 'product search' do it 'should respond with http success' do diff --git a/backend/spec/controllers/spree/admin/stock_movements_controller_spec.rb b/backend/spec/controllers/spree/admin/stock_movements_controller_spec.rb index fffd98e33a1..4af9d6acc6b 100644 --- a/backend/spec/controllers/spree/admin/stock_movements_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/stock_movements_controller_spec.rb @@ -28,7 +28,7 @@ module Admin end describe '#index' do - subject { get :index, params: params } + subject { get :index, params: } context 'with no params' do let(:params) { { stock_location_id: stock_location.id } } diff --git a/backend/spec/controllers/spree/admin/store_credits_controller_spec.rb b/backend/spec/controllers/spree/admin/store_credits_controller_spec.rb index 8ebce0f9300..8890ce58a34 100644 --- a/backend/spec/controllers/spree/admin/store_credits_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/store_credits_controller_spec.rb @@ -19,8 +19,8 @@ let!(:store_credit_reason) { create(:store_credit_reason) } describe "#show" do - let!(:store_credit) { create(:store_credit, user: user, category: a_credit_category) } - let!(:event) { create(:store_credit_auth_event, store_credit: store_credit, created_at: 5.days.ago) } + let!(:store_credit) { create(:store_credit, user:, category: a_credit_category) } + let!(:event) { create(:store_credit_auth_event, store_credit:, created_at: 5.days.ago) } before { get :show, params: { user_id: user.id, id: store_credit.id } } @@ -95,7 +95,7 @@ end describe "#edit_amount" do - let!(:store_credit) { create(:store_credit, user: user, category: a_credit_category) } + let!(:store_credit) { create(:store_credit, user:, category: a_credit_category) } before { get :edit_amount, params: { user_id: user.id, id: store_credit.id } } @@ -107,7 +107,7 @@ end describe "#edit_validity" do - let!(:store_credit) { create(:store_credit, user: user, category: a_credit_category) } + let!(:store_credit) { create(:store_credit, user:, category: a_credit_category) } before { get :edit_validity, params: { user_id: user.id, id: store_credit.id } } @@ -120,7 +120,7 @@ describe "#update" do let(:memo) { "New memo" } - let!(:store_credit) { create(:store_credit, user: user) } + let!(:store_credit) { create(:store_credit, user:) } subject { put :update, params: parameters.merge(format: :json) } @@ -132,7 +132,7 @@ user_id: user.id, id: store_credit.id, store_credit: { - memo: memo + memo: } } end @@ -172,7 +172,7 @@ describe "#update_amount" do let(:original_amount) { 100.0 } - let!(:store_credit) { create(:store_credit, user: user, amount: original_amount) } + let!(:store_credit) { create(:store_credit, user:, amount: original_amount) } let!(:store_credit_reason) { create(:store_credit_reason) } let(:parameters) do { @@ -265,7 +265,7 @@ end describe "#invalidate" do - let!(:store_credit) { create(:store_credit, user: user, category: b_credit_category) } + let!(:store_credit) { create(:store_credit, user:, category: b_credit_category) } let(:parameters) do { @@ -309,7 +309,7 @@ end end context 'User does not exist' do - let(:store_credit) { create(:store_credit, user: user, category: a_credit_category) } + let(:store_credit) { create(:store_credit, user:, category: a_credit_category) } it "cannot find a store-credit for non-existent user" do get :index, params: { user_id: 'non-existent-user', id: store_credit.id } expect(response).to redirect_to(spree.admin_users_path) diff --git a/backend/spec/controllers/spree/admin/variants_controller_spec.rb b/backend/spec/controllers/spree/admin/variants_controller_spec.rb index 92b217dec9a..10115a22c03 100644 --- a/backend/spec/controllers/spree/admin/variants_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/variants_controller_spec.rb @@ -11,7 +11,7 @@ module Admin let(:product) { create(:product) } let(:params) { { product_id: product.slug } } - subject { get :index, params: params } + subject { get :index, params: } context "the value of @parent" do it "is the product" do @@ -30,8 +30,8 @@ module Admin end context "the value of @collection" do - let!(:variant) { create(:variant, product: product) } - let!(:deleted_variant) { create(:variant, product: product) } + let!(:variant) { create(:variant, product:) } + let!(:deleted_variant) { create(:variant, product:) } context "with soft-deleted variants" do before { deleted_variant.discard } diff --git a/backend/spec/features/admin/configuration/tax_rates_spec.rb b/backend/spec/features/admin/configuration/tax_rates_spec.rb index 465728f4ede..876bd437c6e 100644 --- a/backend/spec/features/admin/configuration/tax_rates_spec.rb +++ b/backend/spec/features/admin/configuration/tax_rates_spec.rb @@ -31,8 +31,8 @@ describe "listing" do let(:calculator) { create(:default_tax_calculator) } - let!(:tax_rate_1) { create(:tax_rate, name: "Tax Rate 1", calculator: calculator) } - let!(:tax_rate_2) { create(:tax_rate, name: "Tax Rate 2", calculator: calculator) } + let!(:tax_rate_1) { create(:tax_rate, name: "Tax Rate 1", calculator:) } + let!(:tax_rate_2) { create(:tax_rate, name: "Tax Rate 2", calculator:) } it "shows all tax rates if no filter is applied" do visit spree.admin_tax_rates_path diff --git a/backend/spec/features/admin/javascript_format_money_spec.rb b/backend/spec/features/admin/javascript_format_money_spec.rb index 0a159c6b0f6..6af6690bd46 100644 --- a/backend/spec/features/admin/javascript_format_money_spec.rb +++ b/backend/spec/features/admin/javascript_format_money_spec.rb @@ -12,7 +12,7 @@ visit '/admin' Money::Currency.all.map(&:id).map(&:to_s).map(&:upcase).uniq.each do |currency| - money = Spree::Money.new(1234, currency: currency) + money = Spree::Money.new(1234, currency:) js_result = page.evaluate_script("Spree.formatMoney(#{money.to_d}, '#{currency}')") diff --git a/backend/spec/features/admin/orders/adjustments_spec.rb b/backend/spec/features/admin/orders/adjustments_spec.rb index 02ef8c740ec..880adaaf1aa 100644 --- a/backend/spec/features/admin/orders/adjustments_spec.rb +++ b/backend/spec/features/admin/orders/adjustments_spec.rb @@ -13,16 +13,16 @@ let!(:order) do create( :completed_order_with_totals, - line_items_attributes: [{ price: 10, variant: variant }] * 5, - ship_address: ship_address, + line_items_attributes: [{ price: 10, variant: }] * 5, + ship_address:, ) end let!(:line_item) { order.line_items[0] } let(:tax_category) { create(:tax_category) } - let(:variant) { create(:variant, tax_category: tax_category) } + let(:variant) { create(:variant, tax_category:) } - let!(:adjustment) { order.adjustments.create!(order: order, label: 'Rebate', amount: 10) } + let!(:adjustment) { order.adjustments.create!(order:, label: 'Rebate', amount: 10) } before(:each) do order.recalculate diff --git a/backend/spec/features/admin/orders/customer_details_spec.rb b/backend/spec/features/admin/orders/customer_details_spec.rb index 264fddafa3c..e3b91f0b2a8 100644 --- a/backend/spec/features/admin/orders/customer_details_spec.rb +++ b/backend/spec/features/admin/orders/customer_details_spec.rb @@ -8,16 +8,16 @@ stub_authorization! let(:country) { create(:country, name: "Kangaland") } - let(:state) { create(:state, name: "Alabama", country: country) } + let(:state) { create(:state, name: "Alabama", country:) } let!(:shipping_method) { create(:shipping_method) } - let!(:order) { create(:order, ship_address: ship_address, bill_address: bill_address, state: 'complete', completed_at: "2011-02-01 12:36:15") } + let!(:order) { create(:order, ship_address:, bill_address:, state: 'complete', completed_at: "2011-02-01 12:36:15") } let!(:product) { create(:product_in_stock) } # We need a unique name that will appear for the customer dropdown - let!(:ship_address) { create(:address, country: country, state: state, name: "Jane Doe") } - let!(:bill_address) { create(:address, country: country, state: state, name: "Jane Doe") } + let!(:ship_address) { create(:address, country:, state:, name: "Jane Doe") } + let!(:bill_address) { create(:address, country:, state:, name: "Jane Doe") } - let!(:user) { create(:user, email: 'foobar@example.com', ship_address: ship_address, bill_address: bill_address) } + let!(:user) { create(:user, email: 'foobar@example.com', ship_address:, bill_address:) } context "brand new order" do let(:quantity) { 1 } @@ -27,7 +27,7 @@ click_link "Orders" click_link "New Order" - add_line_item product.name, quantity: quantity + add_line_item(product.name, quantity:) expect(page).to have_css('.line-item') click_link "Customer" diff --git a/backend/spec/features/admin/orders/listing_spec.rb b/backend/spec/features/admin/orders/listing_spec.rb index 9dfc866a087..3528d5d6b88 100644 --- a/backend/spec/features/admin/orders/listing_spec.rb +++ b/backend/spec/features/admin/orders/listing_spec.rb @@ -65,7 +65,7 @@ before do stores.each do |store| - FactoryBot.create(:completed_order_with_totals, number: "R#{store.id}999", store: store) + FactoryBot.create(:completed_order_with_totals, number: "R#{store.id}999", store:) end end diff --git a/backend/spec/features/admin/orders/new_order_spec.rb b/backend/spec/features/admin/orders/new_order_spec.rb index b89fa4aaa90..b844856f0bf 100644 --- a/backend/spec/features/admin/orders/new_order_spec.rb +++ b/backend/spec/features/admin/orders/new_order_spec.rb @@ -170,11 +170,11 @@ end context "when changing customer", :js do - let!(:other_user) { create :user, bill_address: bill_address } + let!(:other_user) { create :user, bill_address: } context "when one customer address have only textual state" do let(:country) { create :country, iso: "IT" } - let(:bill_address) { create :address, country: country, state: nil, state_name: "Veneto" } + let(:bill_address) { create :address, country:, state: nil, state_name: "Veneto" } it "changes the bill address state accordingly" do click_on "Customer" @@ -219,7 +219,7 @@ # Regression test for https://github.com/spree/spree/issues/5327 context "customer with default credit card", js: true do - let!(:credit_card) { create(:credit_card, user: user) } + let!(:credit_card) { create(:credit_card, user:) } before do user.wallet.add(credit_card) diff --git a/backend/spec/features/admin/orders/order_details_spec.rb b/backend/spec/features/admin/orders/order_details_spec.rb index 17430541eed..70b8760df25 100644 --- a/backend/spec/features/admin/orders/order_details_spec.rb +++ b/backend/spec/features/admin/orders/order_details_spec.rb @@ -32,8 +32,8 @@ let(:count_on_hand) { 100 } before do - product.master.update_columns(track_inventory: track_inventory) - product.master.stock_items.update_all(count_on_hand: count_on_hand, backorderable: backorderable) + product.master.update_columns(track_inventory:) + product.master.stock_items.update_all(count_on_hand:, backorderable:) visit spree.cart_admin_order_path(order) end @@ -70,7 +70,7 @@ context 'when the items cannot be added to the existing shipment' do before do - create :payment, order: order, amount: order.amount + create :payment, order:, amount: order.amount visit spree.admin_order_payments_path(order) find('.fa-capture').click end @@ -375,7 +375,7 @@ context 'A shipment has shipped' do it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do - order = create(:shipped_order, state: 'payment', stock_location: stock_location) + order = create(:shipped_order, state: 'payment', stock_location:) visit spree.cart_admin_order_path(order) diff --git a/backend/spec/features/admin/orders/payments_spec.rb b/backend/spec/features/admin/orders/payments_spec.rb index 39dc4dd6f06..910d16d95e0 100644 --- a/backend/spec/features/admin/orders/payments_spec.rb +++ b/backend/spec/features/admin/orders/payments_spec.rb @@ -225,7 +225,7 @@ context "user existing card" do let!(:cc) do - create(:credit_card, payment_method: payment_method, gateway_customer_profile_id: "BGS-RFRE", user: order.user) + create(:credit_card, payment_method:, gateway_customer_profile_id: "BGS-RFRE", user: order.user) end before do @@ -259,7 +259,7 @@ context 'with a soft-deleted payment method' do let(:order) { create(:completed_order_with_totals, line_items_count: 1) } let!(:payment_method) { create(:check_payment_method) } - let!(:payment) { create_payment(payment_method: payment_method) } + let!(:payment) { create_payment(payment_method:) } before do payment_method.discard @@ -299,7 +299,7 @@ let(:order) do create(:order_with_line_items, { line_items_count: 1, - line_items_attributes: [{ quantity: 11, product: product }], + line_items_attributes: [{ quantity: 11, product: }], stock_location: product.master.stock_locations.first }) end @@ -325,10 +325,10 @@ def create_payment(opts = {}) create( :payment, { - order: order, + order:, amount: order.outstanding_balance, payment_method: create(:credit_card_payment_method), - state: state + state: }.merge(opts) ) end diff --git a/backend/spec/features/admin/orders/return_authorizations_spec.rb b/backend/spec/features/admin/orders/return_authorizations_spec.rb index 37cf5c77cf5..b3c6b6e09c1 100644 --- a/backend/spec/features/admin/orders/return_authorizations_spec.rb +++ b/backend/spec/features/admin/orders/return_authorizations_spec.rb @@ -60,7 +60,7 @@ def create_return_authorization end describe "when a return authorization exists" do - let!(:return_authorization) { create(:return_authorization, order: order) } + let!(:return_authorization) { create(:return_authorization, order:) } it "can visit the return authorizations list page" do visit spree.admin_order_return_authorizations_path(order) diff --git a/backend/spec/features/admin/orders/shipments_spec.rb b/backend/spec/features/admin/orders/shipments_spec.rb index 3ef15183e6f..3ee41570a16 100644 --- a/backend/spec/features/admin/orders/shipments_spec.rb +++ b/backend/spec/features/admin/orders/shipments_spec.rb @@ -127,7 +127,7 @@ def ship_shipment create( :order_ready_to_ship, number: "R100", - line_items_attributes: [{ variant: variant, quantity: 5 }] + line_items_attributes: [{ variant:, quantity: 5 }] ) end diff --git a/backend/spec/features/admin/payments/store_credits_spec.rb b/backend/spec/features/admin/payments/store_credits_spec.rb index 1f7d172ae94..14fbf8ef126 100644 --- a/backend/spec/features/admin/payments/store_credits_spec.rb +++ b/backend/spec/features/admin/payments/store_credits_spec.rb @@ -9,7 +9,7 @@ let(:payment) do FactoryBot.create( :store_credit_payment, - order: order, + order:, amount: 20 ) end diff --git a/backend/spec/features/admin/products/edit/images_spec.rb b/backend/spec/features/admin/products/edit/images_spec.rb index aadf2737931..0972bc41341 100644 --- a/backend/spec/features/admin/products/edit/images_spec.rb +++ b/backend/spec/features/admin/products/edit/images_spec.rb @@ -7,8 +7,8 @@ let(:file_path) { file_fixture("ror_ringer.jpeg") } let!(:product) { create(:product) } - let!(:variant1) { create(:variant, product: product) } - let!(:variant2) { create(:variant, product: product) } + let!(:variant1) { create(:variant, product:) } + let!(:variant2) { create(:variant, product:) } before do # Ensure attachment style keys are symbolized before running all tests diff --git a/backend/spec/features/admin/products/pricing_spec.rb b/backend/spec/features/admin/products/pricing_spec.rb index 8d32dd6301b..ac069b5fdae 100644 --- a/backend/spec/features/admin/products/pricing_spec.rb +++ b/backend/spec/features/admin/products/pricing_spec.rb @@ -100,7 +100,7 @@ let!(:variants) do v = [] 3.times do |i| - v << create(:variant, price: i * 10, product: product) + v << create(:variant, price: i * 10, product:) end v end diff --git a/backend/spec/features/admin/products/products_spec.rb b/backend/spec/features/admin/products/products_spec.rb index bb11bc15ca8..0e319641f61 100644 --- a/backend/spec/features/admin/products/products_spec.rb +++ b/backend/spec/features/admin/products/products_spec.rb @@ -11,7 +11,7 @@ end def build_option_type_with_values(name, values) - ot = FactoryBot.create(:option_type, name: name) + ot = FactoryBot.create(:option_type, name:) values.each do |val| ot.option_values.create(name: val.downcase, presentation: val) end @@ -156,7 +156,7 @@ def build_option_type_with_values(name, values) # Regression test for https://github.com/solidusio/solidus/issues/2016 it "should be able to search and sort by price" do product = create(:product, name: 'apache baseball cap', sku: "A001") - create(:variant, product: product, sku: "A002") + create(:variant, product:, sku: "A002") create(:product, name: 'zomg shirt', sku: "Z001") click_nav "Products" diff --git a/backend/spec/features/admin/products/stock_management_spec.rb b/backend/spec/features/admin/products/stock_management_spec.rb index c661c79c00c..0f902aeaafe 100644 --- a/backend/spec/features/admin/products/stock_management_spec.rb +++ b/backend/spec/features/admin/products/stock_management_spec.rb @@ -12,10 +12,10 @@ context "given a product with a variant and a stock location" do let!(:stock_location) { create(:stock_location, name: 'Default') } let!(:product) { create(:product, name: 'apache baseball cap', price: 10) } - let!(:variant) { create(:variant, product: product) } - let!(:variant2) { create(:variant, product: product, track_inventory: false) } - let(:stock_item) { variant.stock_items.find_by(stock_location: stock_location) } - let(:stock_item2) { variant2.stock_items.find_by(stock_location: stock_location) } + let!(:variant) { create(:variant, product:) } + let!(:variant2) { create(:variant, product:, track_inventory: false) } + let(:stock_item) { variant.stock_items.find_by(stock_location:) } + let(:stock_item2) { variant2.stock_items.find_by(stock_location:) } before do stock_location.stock_item(variant).update_column(:count_on_hand, 10) diff --git a/backend/spec/features/admin/products/variant_spec.rb b/backend/spec/features/admin/products/variant_spec.rb index b3872f557fe..66c0c0143c6 100644 --- a/backend/spec/features/admin/products/variant_spec.rb +++ b/backend/spec/features/admin/products/variant_spec.rb @@ -37,7 +37,7 @@ end let!(:variant) do - create(:variant, product: product, price: 19.99) + create(:variant, product:, price: 19.99) end # Regression test for https://github.com/spree/spree/issues/2737 @@ -51,8 +51,8 @@ end context 'displaying discarded variants' do - let!(:existing_variant) { create(:variant, sku: 'existing_variant_sku', product: product) } - let!(:discarded_variant) { create(:variant, sku: 'discarded_variant_sku', product: product) } + let!(:existing_variant) { create(:variant, sku: 'existing_variant_sku', product:) } + let!(:discarded_variant) { create(:variant, sku: 'discarded_variant_sku', product:) } before { discarded_variant.discard! } @@ -73,7 +73,7 @@ end context 'displaying variants with unconfigured prices' do - let!(:variant) { create(:variant, sku: 'priceless_variant', product: product) } + let!(:variant) { create(:variant, sku: 'priceless_variant', product:) } before { variant.prices.delete_all } @@ -87,11 +87,11 @@ end context "editing existent variant" do - let!(:variant) { create(:variant, product: product) } + let!(:variant) { create(:variant, product:) } context "if product has an option type" do let!(:option_type) { create(:option_type) } - let!(:option_value) { create(:option_value, option_type: option_type) } + let!(:option_value) { create(:option_value, option_type:) } before do product.option_types << option_type @@ -107,9 +107,9 @@ end context "deleting a variant", js: true do - let!(:variant) { create(:variant, product: product) } + let!(:variant) { create(:variant, product:) } let!(:option_type) { create(:option_type) } - let!(:option_value) { create(:option_value, option_type: option_type) } + let!(:option_value) { create(:option_value, option_type:) } it "can delete a variant" do visit spree.admin_product_variants_path(product) diff --git a/backend/spec/helpers/admin/navigation_helper_spec.rb b/backend/spec/helpers/admin/navigation_helper_spec.rb index 021a98ee858..d6d189beea4 100644 --- a/backend/spec/helpers/admin/navigation_helper_spec.rb +++ b/backend/spec/helpers/admin/navigation_helper_spec.rb @@ -86,7 +86,7 @@ end context "when the match_path is a callable" do - subject { helper.tab(label: :orders, match_path: match_path) } + subject { helper.tab(label: :orders, match_path:) } context "when the callable returns false" do let(:match_path) { ->(_request) { false } } diff --git a/backend/spec/helpers/admin/stock_movements_helper_spec.rb b/backend/spec/helpers/admin/stock_movements_helper_spec.rb index 830d42444a1..76ef89d7eb9 100644 --- a/backend/spec/helpers/admin/stock_movements_helper_spec.rb +++ b/backend/spec/helpers/admin/stock_movements_helper_spec.rb @@ -6,7 +6,7 @@ describe "#pretty_originator" do let!(:stock_location) { create(:stock_location_with_items) } let!(:stock_item) { stock_location.stock_items.first } - let(:stock_movement) { create(:stock_movement, stock_item: stock_item, originator: originator) } + let(:stock_movement) { create(:stock_movement, stock_item:, originator:) } subject { helper.pretty_originator(stock_movement) } diff --git a/backend/spec/helpers/admin/store_credit_events_helper_spec.rb b/backend/spec/helpers/admin/store_credit_events_helper_spec.rb index 9283ee92a92..fd4c3a24103 100644 --- a/backend/spec/helpers/admin/store_credit_events_helper_spec.rb +++ b/backend/spec/helpers/admin/store_credit_events_helper_spec.rb @@ -4,7 +4,7 @@ describe Spree::Admin::StoreCreditEventsHelper, type: :helper do describe "#store_credit_event_admin_action_name" do - let(:store_credit_event) { create(:store_credit_event, action: action) } + let(:store_credit_event) { create(:store_credit_event, action:) } subject { store_credit_event_admin_action_name(store_credit_event) } @@ -58,7 +58,7 @@ end describe "#store_credit_event_originator_link" do - let(:store_credit_event) { create(:store_credit_adjustment_event, originator: originator) } + let(:store_credit_event) { create(:store_credit_adjustment_event, originator:) } subject { store_credit_event_originator_link(store_credit_event) } diff --git a/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb b/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb index 3ab7a39eeae..eae7d026b20 100644 --- a/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb +++ b/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb @@ -69,7 +69,7 @@ end describe "#url" do - subject { described_class.new(url: url).url } + subject { described_class.new(url:).url } context "if url is a string" do let(:url) { "/admin/orders" } diff --git a/bin/build-ci b/bin/build-ci index 0569fac0418..4f234c34046 100755 --- a/bin/build-ci +++ b/bin/build-ci @@ -114,7 +114,6 @@ class Project end end - if ENV['CIRCLE_NODE_INDEX'] # Run projects on a CI node projects = Project.weighted_projects( node_total: Integer(ENV.fetch('CIRCLE_NODE_TOTAL', 1)), diff --git a/bin/release/extract-pipeline-context b/bin/release/extract-pipeline-context index 51929afc9b1..19c1e64d32e 100755 --- a/bin/release/extract-pipeline-context +++ b/bin/release/extract-pipeline-context @@ -27,7 +27,7 @@ context_hash = { current_tag: latest_version.tag, current_diff_source_tag: diff_source_version.tag, candidate_tag: candidate_version.tag, - candidate_version: candidate_version, + candidate_version:, candidate_minor_version: candidate_version.segments[0..1].join('.'), candidate_patch_branch: candidate_version.branch, candidate_next_patch_dev_version: candidate_version.bump(:patch).dev, diff --git a/bin/release/update-release-draft b/bin/release/update-release-draft index 4b74aa7b638..a3738b1d936 100755 --- a/bin/release/update-release-draft +++ b/bin/release/update-release-draft @@ -24,7 +24,7 @@ candidate_tag_name = ARGV.shift or abort(opts.to_s) pull_numbers = OCTOKIT.post("/repos/solidusio/solidus/releases/generate-notes", { tag_name: candidate_tag_name, target_commitish: branch, - previous_tag_name: previous_tag_name, + previous_tag_name:, }).body.scan(%r{(?:#|pull/)(\d+)$}).flatten.uniq # Group PRs by label diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rb index e41ec1cad7c..83a96bc266d 100644 --- a/core/app/helpers/spree/base_helper.rb +++ b/core/app/helpers/spree/base_helper.rb @@ -48,7 +48,7 @@ def meta_data def meta_data_tags meta_data.map do |name, content| - tag('meta', name: name, content: content) + tag('meta', name:, content:) end.join("\n") end @@ -111,7 +111,7 @@ def taxons_tree(root_taxon, current_taxon, max_level = 1) end def available_countries(restrict_to_zone: Spree::Config[:checkout_zone]) - countries = Spree::Country.available(restrict_to_zone: restrict_to_zone) + countries = Spree::Country.available(restrict_to_zone:) country_names = Carmen::Country.all.map do |country| [country.code, country.name] diff --git a/core/app/mailers/spree/base_mailer.rb b/core/app/mailers/spree/base_mailer.rb index 34404bba393..66c922e35b5 100644 --- a/core/app/mailers/spree/base_mailer.rb +++ b/core/app/mailers/spree/base_mailer.rb @@ -11,7 +11,7 @@ def bcc_address(store) end def money(amount, currency = Spree::Config[:currency]) - Spree::Money.new(amount, currency: currency).to_s + Spree::Money.new(amount, currency:).to_s end helper_method :money diff --git a/core/app/mailers/spree/carton_mailer.rb b/core/app/mailers/spree/carton_mailer.rb index 962535665f6..dbb2169ff37 100644 --- a/core/app/mailers/spree/carton_mailer.rb +++ b/core/app/mailers/spree/carton_mailer.rb @@ -19,7 +19,7 @@ def shipped_email(options) @store = @order.store subject = (options[:resend] ? "[#{t('spree.resend').upcase}] " : '') subject += "#{@store.name} #{t('spree.shipment_mailer.shipped_email.subject')} ##{@order.number}" - mail(to: @order.email, from: from_address(@store), subject: subject) + mail(to: @order.email, from: from_address(@store), subject:) end end end diff --git a/core/app/mailers/spree/order_mailer.rb b/core/app/mailers/spree/order_mailer.rb index ed60ffa8dc0..e81c9e6ed46 100644 --- a/core/app/mailers/spree/order_mailer.rb +++ b/core/app/mailers/spree/order_mailer.rb @@ -7,7 +7,7 @@ def confirm_email(order, resend = false) @store = @order.store subject = build_subject(t('.subject'), resend) - mail(to: @order.email, bcc: bcc_address(@store), from: from_address(@store), subject: subject) + mail(to: @order.email, bcc: bcc_address(@store), from: from_address(@store), subject:) end def cancel_email(order, resend = false) @@ -15,7 +15,7 @@ def cancel_email(order, resend = false) @store = @order.store subject = build_subject(t('.subject'), resend) - mail(to: @order.email, from: from_address(@store), subject: subject) + mail(to: @order.email, from: from_address(@store), subject:) end def inventory_cancellation_email(order, inventory_units, resend = false) @@ -23,7 +23,7 @@ def inventory_cancellation_email(order, inventory_units, resend = false) @store = @order.store subject = build_subject(t('spree.order_mailer.inventory_cancellation.subject'), resend) - mail(to: @order.email, from: from_address(@store), subject: subject) + mail(to: @order.email, from: from_address(@store), subject:) end private diff --git a/core/app/mailers/spree/reimbursement_mailer.rb b/core/app/mailers/spree/reimbursement_mailer.rb index 349e684ed2a..08cce2814e3 100644 --- a/core/app/mailers/spree/reimbursement_mailer.rb +++ b/core/app/mailers/spree/reimbursement_mailer.rb @@ -7,7 +7,7 @@ def reimbursement_email(reimbursement, resend = false) store = @reimbursement.order.store subject = (resend ? "[#{t('spree.resend').upcase}] " : '') subject += "#{store.name} #{t('.subject')} ##{@reimbursement.order.number}" - mail(to: @reimbursement.order.email, from: from_address(store), subject: subject) + mail(to: @reimbursement.order.email, from: from_address(store), subject:) end end end diff --git a/core/app/models/concerns/spree/active_storage_adapter.rb b/core/app/models/concerns/spree/active_storage_adapter.rb index fab81ac452e..144169e8f92 100644 --- a/core/app/models/concerns/spree/active_storage_adapter.rb +++ b/core/app/models/concerns/spree/active_storage_adapter.rb @@ -34,7 +34,7 @@ def override_reader method_name = attachment_name override = Module.new do define_method method_name do |*args| - attachment = Attachment.new(super(), styles: styles) + attachment = Attachment.new(super(), styles:) if args.empty? attachment else diff --git a/core/app/models/concerns/spree/active_storage_adapter/normalization.rb b/core/app/models/concerns/spree/active_storage_adapter/normalization.rb index 9ac95fbef08..5f56e2211ae 100644 --- a/core/app/models/concerns/spree/active_storage_adapter/normalization.rb +++ b/core/app/models/concerns/spree/active_storage_adapter/normalization.rb @@ -32,7 +32,7 @@ def attachable_io(attachable) end attachable.rewind - { io: attachable, filename: filename } + { io: attachable, filename: } end end end diff --git a/core/app/models/concerns/spree/display_money.rb b/core/app/models/concerns/spree/display_money.rb index dfe62fb8b33..0853a9f098e 100644 --- a/core/app/models/concerns/spree/display_money.rb +++ b/core/app/models/concerns/spree/display_money.rb @@ -24,7 +24,7 @@ def money_methods(*args) money_method = { money_method => {} } unless money_method.is_a? Hash money_method.each do |method_name, opts| define_method("display_#{method_name}") do - default_opts = respond_to?(:currency) ? { currency: currency } : {} + default_opts = respond_to?(:currency) ? { currency: } : {} Spree::Money.new(send(method_name), default_opts.merge(opts)) end end diff --git a/core/app/models/concerns/spree/ordered_property_value_list.rb b/core/app/models/concerns/spree/ordered_property_value_list.rb index 9233a609e53..b8d2e3f5bb7 100644 --- a/core/app/models/concerns/spree/ordered_property_value_list.rb +++ b/core/app/models/concerns/spree/ordered_property_value_list.rb @@ -18,8 +18,8 @@ def property_name def property_name=(name) unless name.blank? - unless property = Spree::Property.find_by(name: name) - property = Spree::Property.create(name: name, presentation: name) + unless property = Spree::Property.find_by(name:) + property = Spree::Property.create(name:, presentation: name) end self.property = property end diff --git a/core/app/models/concerns/spree/user_address_book.rb b/core/app/models/concerns/spree/user_address_book.rb index 1f924b23bae..4b9c7cbcc93 100644 --- a/core/app/models/concerns/spree/user_address_book.rb +++ b/core/app/models/concerns/spree/user_address_book.rb @@ -120,7 +120,7 @@ def save_in_address_book(address_attributes, default = false, address_type = :sh remove_from_address_book(address_attributes[:id]) end - user_addresses.mark_default(user_address, address_type: address_type) if default || first_one + user_addresses.mark_default(user_address, address_type:) if default || first_one if persisted? user_address.save! @@ -140,15 +140,15 @@ def save_in_address_book(address_attributes, default = false, address_type = :sh end def mark_default_ship_address(address) - user_addresses.mark_default(user_addresses.find_by(address: address)) + user_addresses.mark_default(user_addresses.find_by(address:)) end def mark_default_bill_address(address) - user_addresses.mark_default(user_addresses.find_by(address: address), address_type: :billing) + user_addresses.mark_default(user_addresses.find_by(address:), address_type: :billing) end def remove_from_address_book(address_id) - user_address = user_addresses.find_by(address_id: address_id) + user_address = user_addresses.find_by(address_id:) if user_address remove_user_address_reference(address_id) user_address.update(archived: true, default: false) diff --git a/core/app/models/concerns/spree/user_methods.rb b/core/app/models/concerns/spree/user_methods.rb index eaf9103d507..9218e26cd7a 100644 --- a/core/app/models/concerns/spree/user_methods.rb +++ b/core/app/models/concerns/spree/user_methods.rb @@ -58,7 +58,7 @@ def auto_generate_spree_api_key def last_incomplete_spree_order(store: nil, only_frontend_viewable: true) self_orders = orders self_orders = self_orders.where(frontend_viewable: true) if only_frontend_viewable - self_orders = self_orders.where(store: store) if store + self_orders = self_orders.where(store:) if store self_orders = self_orders.where('updated_at > ?', Spree::Config.completable_order_updated_cutoff_days.days.ago) if Spree::Config.completable_order_updated_cutoff_days self_orders = self_orders.where('created_at > ?', Spree::Config.completable_order_created_cutoff_days.days.ago) if Spree::Config.completable_order_created_cutoff_days last_order = self_orders.order(:created_at).last @@ -73,8 +73,8 @@ def available_store_credit_total(currency:) def display_available_store_credit_total(currency:) Spree::Money.new( - available_store_credit_total(currency: currency), - currency: currency, + available_store_credit_total(currency:), + currency:, ) end diff --git a/core/app/models/spree/address.rb b/core/app/models/spree/address.rb index 4866d0d9787..7e03938d937 100644 --- a/core/app/models/spree/address.rb +++ b/core/app/models/spree/address.rb @@ -97,14 +97,14 @@ def ==(other_address) # @return [Hash] an ActiveMerchant compatible address hash def active_merchant_hash { - name: name, - address1: address1, - address2: address2, - city: city, + name:, + address1:, + address2:, + city:, state: state_text, zip: zipcode, country: country.try(:iso), - phone: phone + phone: } end @@ -132,7 +132,7 @@ def readonly? # @return [Country] setter that sets self.country to the Country with a matching 2 letter iso # @raise [ActiveRecord::RecordNotFound] if country with the iso doesn't exist def country_iso=(iso) - self.country = Spree::Country.find_by!(iso: iso) + self.country = Spree::Country.find_by!(iso:) end def country_iso diff --git a/core/app/models/spree/carton.rb b/core/app/models/spree/carton.rb index 971adf19355..6e154a273f7 100644 --- a/core/app/models/spree/carton.rb +++ b/core/app/models/spree/carton.rb @@ -46,11 +46,11 @@ def display_shipped_at end def manifest - @manifest ||= Spree::ShippingManifest.new(inventory_units: inventory_units).items + @manifest ||= Spree::ShippingManifest.new(inventory_units:).items end def manifest_for_order(order) - Spree::ShippingManifest.new(inventory_units: inventory_units).for_order(order).items + Spree::ShippingManifest.new(inventory_units:).for_order(order).items end def any_exchanges? diff --git a/core/app/models/spree/credit_card.rb b/core/app/models/spree/credit_card.rb index 8b5c9460055..479a31c687c 100644 --- a/core/app/models/spree/credit_card.rb +++ b/core/app/models/spree/credit_card.rb @@ -155,12 +155,12 @@ def last_name # card that represents this credit card def to_active_merchant ActiveMerchant::Billing::CreditCard.new( - number: number, - month: month, - year: year, - verification_value: verification_value, - first_name: first_name, - last_name: last_name + number:, + month:, + year:, + verification_value:, + first_name:, + last_name: ) end diff --git a/core/app/models/spree/fulfilment_changer.rb b/core/app/models/spree/fulfilment_changer.rb index 61a4234716f..77b38f23a5f 100644 --- a/core/app/models/spree/fulfilment_changer.rb +++ b/core/app/models/spree/fulfilment_changer.rb @@ -107,14 +107,14 @@ def run_tracking_inventory # We order by state, because `'backordered' < 'on_hand'`. current_shipment. inventory_units. - where(variant: variant). + where(variant:). order(state: :asc). limit(new_on_hand_quantity). update_all(shipment_id: desired_shipment.id, state: :on_hand) current_shipment. inventory_units. - where(variant: variant). + where(variant:). order(state: :asc). limit(quantity - new_on_hand_quantity). update_all(shipment_id: desired_shipment.id, state: :backordered) @@ -127,7 +127,7 @@ def run_without_tracking_inventory ActiveRecord::Base.transaction do current_shipment. inventory_units. - where(variant: variant). + where(variant:). order(state: :asc). limit(quantity). update_all(shipment_id: desired_shipment.id) @@ -145,7 +145,7 @@ def default_on_hand_quantity if current_stock_location != desired_stock_location 0 else - current_shipment.inventory_units.where(variant: variant).on_hand.count + current_shipment.inventory_units.where(variant:).on_hand.count end end diff --git a/core/app/models/spree/inventory_unit.rb b/core/app/models/spree/inventory_unit.rb index d023f152ee8..ab1ec848108 100644 --- a/core/app/models/spree/inventory_unit.rb +++ b/core/app/models/spree/inventory_unit.rb @@ -64,7 +64,7 @@ def order=(_) # stock location that is associated with this inventory unit's variant def find_stock_item Spree::StockItem.where(stock_location_id: shipment.stock_location_id, - variant_id: variant_id).first + variant_id:).first end # @return [Spree::ReturnItem] a valid return item for this inventory unit @@ -114,7 +114,7 @@ def current_return_item def ensure_can_destroy if !backordered? && !on_hand? - errors.add(:state, :cannot_destroy, state: state) + errors.add(:state, :cannot_destroy, state:) throw :abort end diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 01f79e25a14..b9b1810b917 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -179,7 +179,7 @@ def self.by_customer(customer) end def self.by_state(state) - where(state: state) + where(state:) end def self.complete @@ -314,7 +314,7 @@ def associate_user!(user, override_email = true) if persisted? # immediately persist the changes we just made, but don't use save since we might have an invalid address associated - self.class.unscoped.where(id: id).update_all(attrs_to_set) + self.class.unscoped.where(id:).update_all(attrs_to_set) end assign_attributes(attrs_to_set) @@ -570,7 +570,7 @@ def tax_total def add_store_credit_payments return if user.nil? - return if payments.store_credits.checkout.empty? && user.available_store_credit_total(currency: currency).zero? + return if payments.store_credits.checkout.empty? && user.available_store_credit_total(currency:).zero? payments.store_credits.checkout.each(&:invalidate!) @@ -581,7 +581,7 @@ def add_store_credit_payments remaining_total = outstanding_balance - authorized_total - matching_store_credits = user.store_credits.where(currency: currency) + matching_store_credits = user.store_credits.where(currency:) if matching_store_credits.any? payment_method = Spree::PaymentMethod::StoreCredit.first @@ -593,7 +593,7 @@ def add_store_credit_payments amount_to_take = [credit.amount_remaining, remaining_total].min payments.create!(source: credit, - payment_method: payment_method, + payment_method:, amount: amount_to_take, state: 'checkout', response_code: credit.generate_authorization_code) @@ -617,13 +617,13 @@ def add_store_credit_payments def covered_by_store_credit? return false unless user - user.available_store_credit_total(currency: currency) >= total + user.available_store_credit_total(currency:) >= total end alias_method :covered_by_store_credit, :covered_by_store_credit? def total_available_store_credit return 0.0 unless user - user.available_store_credit_total(currency: currency) + user.available_store_credit_total(currency:) end def order_total_after_store_credit @@ -634,16 +634,16 @@ def total_applicable_store_credit if can_complete? || complete? valid_store_credit_payments.to_a.sum(&:amount) else - [total, user.try(:available_store_credit_total, currency: currency) || 0.0].min + [total, user.try(:available_store_credit_total, currency:) || 0.0].min end end def display_total_applicable_store_credit - Spree::Money.new(-total_applicable_store_credit, { currency: currency }) + Spree::Money.new(-total_applicable_store_credit, { currency: }) end def display_store_credit_remaining_after_capture - Spree::Money.new(total_available_store_credit - total_applicable_store_credit, { currency: currency }) + Spree::Money.new(total_available_store_credit - total_applicable_store_credit, { currency: }) end def bill_address_attributes=(attributes) diff --git a/core/app/models/spree/order_cancellations.rb b/core/app/models/spree/order_cancellations.rb index d708dbd4a87..9c0a25c7e4d 100644 --- a/core/app/models/spree/order_cancellations.rb +++ b/core/app/models/spree/order_cancellations.rb @@ -36,7 +36,7 @@ def short_ship(inventory_units, created_by: nil) Spree::OrderMutex.with_lock!(@order) do Spree::InventoryUnit.transaction do inventory_units.each do |iu| - unit_cancels << short_ship_unit(iu, created_by: created_by) + unit_cancels << short_ship_unit(iu, created_by:) end update_shipped_shipments(inventory_units) @@ -67,9 +67,9 @@ def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, creat Spree::OrderMutex.with_lock!(@order) do unit_cancel = Spree::UnitCancel.create!( - inventory_unit: inventory_unit, - reason: reason, - created_by: created_by + inventory_unit:, + reason:, + created_by: ) inventory_unit.cancel! @@ -89,8 +89,8 @@ def reimburse_units(inventory_units, created_by:) Spree::OrderMutex.with_lock!(@order) do return_items = inventory_units.map(&:current_or_new_return_item) - reimbursement = Spree::Reimbursement.new(order: @order, return_items: return_items) - reimbursement.return_all(created_by: created_by) + reimbursement = Spree::Reimbursement.new(order: @order, return_items:) + reimbursement.return_all(created_by:) end reimbursement @@ -100,9 +100,9 @@ def reimburse_units(inventory_units, created_by:) def short_ship_unit(inventory_unit, created_by: nil) unit_cancel = Spree::UnitCancel.create!( - inventory_unit: inventory_unit, + inventory_unit:, reason: Spree::UnitCancel::SHORT_SHIP, - created_by: created_by + created_by: ) unit_cancel.adjust! inventory_unit.cancel! diff --git a/core/app/models/spree/order_mutex.rb b/core/app/models/spree/order_mutex.rb index 4fca9fd193a..97e5fe3dad9 100644 --- a/core/app/models/spree/order_mutex.rb +++ b/core/app/models/spree/order_mutex.rb @@ -16,10 +16,10 @@ def with_lock!(order) raise ArgumentError, "order must be supplied" if order.nil? # limit the maximum lock time just in case a lock is somehow left in place accidentally - expired.where(order: order).delete_all + expired.where(order:).delete_all begin - order_mutex = create!(order: order) + order_mutex = create!(order:) rescue ActiveRecord::RecordNotUnique error = LockFailed.new("Could not obtain lock on order #{order.id}") logger.error error.inspect diff --git a/core/app/models/spree/order_shipping.rb b/core/app/models/spree/order_shipping.rb index 15b23cda18a..e70ccd2b3bc 100644 --- a/core/app/models/spree/order_shipping.rb +++ b/core/app/models/spree/order_shipping.rb @@ -22,11 +22,11 @@ def ship_shipment(shipment, external_number: nil, tracking_number: nil, suppress address: shipment.order.ship_address, shipping_method: shipment.shipping_method, shipped_at: Time.current, - external_number: external_number, + external_number:, # TODO: Remove the `|| shipment.tracking` once Shipment#ship! is called by # OrderShipping#ship rather than vice versa tracking_number: tracking_number || shipment.tracking, - suppress_mailer: suppress_mailer + suppress_mailer: ) end @@ -51,12 +51,12 @@ def ship(inventory_units:, stock_location:, address:, shipping_method:, inventory_units.each(&:ship!) carton = Spree::Carton.create!( - stock_location: stock_location, - address: address, - shipping_method: shipping_method, - inventory_units: inventory_units, - shipped_at: shipped_at, - external_number: external_number, + stock_location:, + address:, + shipping_method:, + inventory_units:, + shipped_at:, + external_number:, tracking: tracking_number ) end @@ -80,7 +80,7 @@ def ship(inventory_units:, stock_location:, address:, shipping_method:, def send_shipment_emails(carton) carton.orders.each do |order| - Spree::Config.carton_shipped_email_class.shipped_email(order: order, carton: carton).deliver_later + Spree::Config.carton_shipped_email_class.shipped_email(order:, carton:).deliver_later end end end diff --git a/core/app/models/spree/order_updater.rb b/core/app/models/spree/order_updater.rb index 2554c09b657..6c06b022efc 100644 --- a/core/app/models/spree/order_updater.rb +++ b/core/app/models/spree/order_updater.rb @@ -26,7 +26,7 @@ def recalculate update_shipments update_shipment_state end - Spree::Bus.publish :order_recalculated, order: order + Spree::Bus.publish(:order_recalculated, order:) persist_totals end end @@ -188,7 +188,7 @@ def log_state_change(name) order.state_changes.new( previous_state: old_state, next_state: new_state, - name: name, + name:, user_id: order.user_id ) end diff --git a/core/app/models/spree/payment.rb b/core/app/models/spree/payment.rb index 8708b379d04..2e08205caba 100644 --- a/core/app/models/spree/payment.rb +++ b/core/app/models/spree/payment.rb @@ -69,7 +69,7 @@ def transaction_id # @return [Spree::Money] this amount of this payment as money object def money - Spree::Money.new(amount, { currency: currency }) + Spree::Money.new(amount, { currency: }) end alias display_amount money @@ -211,7 +211,7 @@ def update_order def set_unique_identifier loop do self.number = generate_identifier - break unless self.class.exists?(number: number) + break unless self.class.exists?(number:) end end diff --git a/core/app/models/spree/payment/processing.rb b/core/app/models/spree/payment/processing.rb index c2804258ed2..a6c1b58a857 100644 --- a/core/app/models/spree/payment/processing.rb +++ b/core/app/models/spree/payment/processing.rb @@ -64,7 +64,7 @@ def purchase! complete! if handle_response(response) end - capture_events.create!(amount: amount) + capture_events.create!(amount:) end # Takes the amount in cents to capture. @@ -243,7 +243,7 @@ def basic_response_info(response) cvv_result: response.cvv_result, error_code: response.error_code, emv_authorization: response.emv_authorization, - gateway_order_id: gateway_order_id, + gateway_order_id:, order_number: order.number } end diff --git a/core/app/models/spree/payment_create.rb b/core/app/models/spree/payment_create.rb index 327c63cdcf6..9892bb7fa2c 100644 --- a/core/app/models/spree/payment_create.rb +++ b/core/app/models/spree/payment_create.rb @@ -72,7 +72,7 @@ def build_from_payment_source(payment_source) def available_cards if user_id = order.user_id - Spree::CreditCard.where(user_id: user_id) + Spree::CreditCard.where(user_id:) else Spree::CreditCard.none end diff --git a/core/app/models/spree/payment_method/store_credit.rb b/core/app/models/spree/payment_method/store_credit.rb index 6f43cb2a9ca..7a3f277e157 100644 --- a/core/app/models/spree/payment_method/store_credit.rb +++ b/core/app/models/spree/payment_method/store_credit.rb @@ -107,7 +107,7 @@ def handle_action(action, action_name, auth_code) store_credit = Spree::StoreCreditEvent.find_by(authorization_code: auth_code).try(:store_credit) if store_credit.nil? - ActiveMerchant::Billing::Response.new(false, I18n.t('spree.store_credit.unable_to_find_for_action', auth_code: auth_code, action: action_name), {}, {}) + ActiveMerchant::Billing::Response.new(false, I18n.t('spree.store_credit.unable_to_find_for_action', auth_code:, action: action_name), {}, {}) else handle_action_call(store_credit, action, action_name, auth_code) end diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index 107a8767597..1754e939497 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -57,6 +57,8 @@ class Product < Spree::Base has_many :line_items, through: :variants_including_master has_many :orders, through: :line_items + has_many :option_values, -> { distinct }, through: :variants_including_master + scope :sort_by_master_default_price_amount_asc, -> { with_default_price.order('spree_prices.amount ASC') } @@ -127,26 +129,8 @@ def find_or_build_master alias :options :product_option_types - # The :variants_option_values ransacker filters Spree::Product based on - # variant option values ids. - # - # Usage: - # Spree::Product.ransack( - # variants_option_values_in: [option_value_id1, option_value_id2] - # ).result - ransacker :variants_option_values, formatter: proc { |v| - if OptionValue.exists?(v) - joins(variants_including_master: :option_values) - .where(spree_option_values: { id: v }) - .distinct - .select(:id).arel - end - } do |parent| - parent.table[:id] - end - - self.allowed_ransackable_associations = %w[stores variants_including_master master variants] - self.allowed_ransackable_attributes = %w[name slug variants_option_values] + self.allowed_ransackable_associations = %w[stores variants_including_master master variants option_values] + self.allowed_ransackable_attributes = %w[name slug] self.allowed_ransackable_scopes = %i[available with_discarded with_all_variant_sku_cont with_kept_variant_sku_cont] # @return [Boolean] true if there are any variants @@ -266,7 +250,7 @@ def set_property(property_name, property_value) ActiveRecord::Base.transaction do # Works around spree_i18n https://github.com/spree/spree/issues/301 property = Spree::Property.create_with(presentation: property_name).find_or_create_by(name: property_name) - product_property = Spree::ProductProperty.where(product: self, property: property).first_or_initialize + product_property = Spree::ProductProperty.where(product: self, property:).first_or_initialize product_property.value = property_value product_property.save! end @@ -379,7 +363,7 @@ def touch_taxons end def remove_taxon(taxon) - removed_classifications = classifications.where(taxon: taxon) + removed_classifications = classifications.where(taxon:) removed_classifications.each(&:remove_from_list) end end diff --git a/core/app/models/spree/refund.rb b/core/app/models/spree/refund.rb index c694c79a880..87187331af3 100644 --- a/core/app/models/spree/refund.rb +++ b/core/app/models/spree/refund.rb @@ -21,7 +21,7 @@ class Refund < Spree::Base delegate :currency, to: :payment def money - Spree::Money.new(amount, { currency: currency }) + Spree::Money.new(amount, { currency: }) end alias display_amount money diff --git a/core/app/models/spree/reimbursement.rb b/core/app/models/spree/reimbursement.rb index b6e179f2a31..824f1edccf7 100644 --- a/core/app/models/spree/reimbursement.rb +++ b/core/app/models/spree/reimbursement.rb @@ -57,7 +57,7 @@ class << self def build_from_customer_return(customer_return) order = customer_return.order order.reimbursements.build({ - customer_return: customer_return, + customer_return:, return_items: customer_return.return_items.accepted.not_reimbursed }) end @@ -88,7 +88,7 @@ def perform!(created_by:) reload update!(total: calculated_total) - reimbursement_performer.perform(self, created_by: created_by) + reimbursement_performer.perform(self, created_by:) if unpaid_amount_within_tolerance? reimbursed! @@ -108,7 +108,7 @@ def simulate(created_by:) reload update!(total: calculated_total) - reimbursement_performer.simulate(self, created_by: created_by) + reimbursement_performer.simulate(self, created_by:) end def return_items_requiring_exchange @@ -131,7 +131,7 @@ def all_exchanges? def return_all(created_by:) return_items.each(&:accept!) save! - perform!(created_by: created_by) + perform!(created_by:) end # The returned category is used as the category diff --git a/core/app/models/spree/reimbursement_performer.rb b/core/app/models/spree/reimbursement_performer.rb index a7e439c8c8d..7e0d7a8fd10 100644 --- a/core/app/models/spree/reimbursement_performer.rb +++ b/core/app/models/spree/reimbursement_performer.rb @@ -12,12 +12,12 @@ class << self # - #display_amount # so they can be displayed in the Admin UI appropriately. def simulate(reimbursement, created_by:) - execute(reimbursement, true, created_by: created_by) + execute(reimbursement, true, created_by:) end # Actually perform the reimbursement def perform(reimbursement, created_by:) - execute(reimbursement, false, created_by: created_by) + execute(reimbursement, false, created_by:) end private @@ -26,7 +26,7 @@ def execute(reimbursement, simulate, created_by:) reimbursement_type_hash = calculate_reimbursement_types(reimbursement) reimbursement_type_hash.flat_map do |reimbursement_type, return_items| - reimbursement_type.reimburse(reimbursement, return_items, simulate, created_by: created_by) + reimbursement_type.reimburse(reimbursement, return_items, simulate, created_by:) end end diff --git a/core/app/models/spree/reimbursement_tax_calculator.rb b/core/app/models/spree/reimbursement_tax_calculator.rb index 780c3972fc3..500b77ffcab 100644 --- a/core/app/models/spree/reimbursement_tax_calculator.rb +++ b/core/app/models/spree/reimbursement_tax_calculator.rb @@ -26,8 +26,8 @@ def set_tax!(return_item) included_tax_total = percent_of_tax * return_item.inventory_unit.included_tax_total return_item.update!({ - additional_tax_total: additional_tax_total, - included_tax_total: included_tax_total + additional_tax_total:, + included_tax_total: }) end end diff --git a/core/app/models/spree/reimbursement_type/credit.rb b/core/app/models/spree/reimbursement_type/credit.rb index 76e8c53ca59..0f8758f07ac 100644 --- a/core/app/models/spree/reimbursement_type/credit.rb +++ b/core/app/models/spree/reimbursement_type/credit.rb @@ -7,7 +7,7 @@ class ReimbursementType::Credit < Spree::ReimbursementType class << self def reimburse(reimbursement, return_items, simulate, created_by:) unpaid_amount = return_items.sum(&:total).round(2, :down) - reimbursement_list, _unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate, created_by: created_by) + reimbursement_list, _unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate, created_by:) reimbursement_list end end diff --git a/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb b/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb index 74ea042a7b2..6a50a61fea7 100644 --- a/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb +++ b/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb @@ -21,7 +21,7 @@ def create_refunds(reimbursement, payments, unpaid_amount, simulate, reimburseme end def create_credits(reimbursement, unpaid_amount, simulate, reimbursement_list = [], created_by:) - credits = [create_credit(reimbursement, unpaid_amount, simulate, created_by: created_by)] + credits = [create_credit(reimbursement, unpaid_amount, simulate, created_by:)] unpaid_amount -= credits.sum(&:amount) reimbursement_list += credits @@ -32,8 +32,8 @@ def create_credits(reimbursement, unpaid_amount, simulate, reimbursement_list = def create_refund(reimbursement, payment, amount, simulate) refund = reimbursement.refunds.build({ - payment: payment, - amount: amount, + payment:, + amount:, reason: Spree::RefundReason.return_processing_reason }) @@ -50,8 +50,8 @@ def create_refund(reimbursement, payment, amount, simulate) # If you have multiple methods of crediting a customer, overwrite this method # Must return an array of objects the respond to #description, #display_amount def create_credit(reimbursement, unpaid_amount, simulate, created_by:) - creditable = create_creditable(reimbursement, unpaid_amount, created_by: created_by) - credit = reimbursement.credits.build(creditable: creditable, amount: unpaid_amount) + creditable = create_creditable(reimbursement, unpaid_amount, created_by:) + credit = reimbursement.credits.build(creditable:, amount: unpaid_amount) simulate ? credit.readonly! : credit.save! credit end @@ -61,7 +61,7 @@ def create_creditable(reimbursement, unpaid_amount, created_by:) user: reimbursement.order.user, amount: unpaid_amount, category: reimbursement.store_credit_category, - created_by: created_by, + created_by:, memo: "Refund for uncreditable payments on order #{reimbursement.order.number}", currency: reimbursement.order.currency ) diff --git a/core/app/models/spree/reimbursement_type/store_credit.rb b/core/app/models/spree/reimbursement_type/store_credit.rb index 42286d90bec..fa71d5a0e8b 100644 --- a/core/app/models/spree/reimbursement_type/store_credit.rb +++ b/core/app/models/spree/reimbursement_type/store_credit.rb @@ -25,7 +25,7 @@ def reimburse(reimbursement, return_items, simulate, created_by:) unpaid_amount, simulate, reimbursement_list, - created_by: created_by + created_by: ) end diff --git a/core/app/models/spree/return_item.rb b/core/app/models/spree/return_item.rb index 5aee0ee53ad..2a2ec45c90a 100644 --- a/core/app/models/spree/return_item.rb +++ b/core/app/models/spree/return_item.rb @@ -53,7 +53,7 @@ class ReturnItem < Spree::Base scope :not_expired, -> { where.not(reception_status: 'expired') } scope :received, -> { where(reception_status: 'received') } INTERMEDIATE_RECEPTION_STATUSES.each do |reception_status| - scope reception_status, -> { where(reception_status: reception_status) } + scope reception_status, -> { where(reception_status:) } end scope :pending, -> { where(acceptance_status: 'pending') } scope :accepted, -> { where(acceptance_status: 'accepted') } @@ -93,8 +93,8 @@ def reception_completed? # @return [Spree::ReturnItem] a valid return item for the given inventory # unit if one exists, or a new one if one does not def self.from_inventory_unit(inventory_unit) - valid.find_by(inventory_unit: inventory_unit) || - new(inventory_unit: inventory_unit).tap(&:set_default_amount) + valid.find_by(inventory_unit:) || + new(inventory_unit:).tap(&:set_default_amount) end # @return [Boolean] true when an exchange has been requested on this return @@ -130,7 +130,7 @@ def total_excluding_vat # @return [ActiveRecord::Relation] the variants eligible # for exchange for this return item def eligible_exchange_variants(stock_locations = nil) - exchange_variant_engine.eligible_variants(variant, stock_locations: stock_locations) + exchange_variant_engine.eligible_variants(variant, stock_locations:) end # Builds the exchange inventory unit for this return item, only if an @@ -248,20 +248,20 @@ def set_exchange_amount def validate_no_other_completed_return_items other_return_item = Spree::ReturnItem.where({ - inventory_unit_id: inventory_unit_id, + inventory_unit_id:, reception_status: COMPLETED_RECEPTION_STATUSES - }).where.not(id: id).first + }).where.not(id:).first if other_return_item && (new_record? || COMPLETED_RECEPTION_STATUSES.include?(reception_status.to_sym)) errors.add(:inventory_unit, :other_completed_return_item_exists, - inventory_unit_id: inventory_unit_id, + inventory_unit_id:, return_item_id: other_return_item.id) end end def cancel_others - Spree::ReturnItem.where(inventory_unit_id: inventory_unit_id) - .where.not(id: id) + Spree::ReturnItem.where(inventory_unit_id:) + .where.not(id:) .valid .each(&:cancel!) end diff --git a/core/app/models/spree/shipment.rb b/core/app/models/spree/shipment.rb index 54381a87fbc..6808518448d 100644 --- a/core/app/models/spree/shipment.rb +++ b/core/app/models/spree/shipment.rb @@ -31,7 +31,7 @@ class Shipment < Spree::Base scope :ready, -> { with_state('ready') } scope :shipped, -> { with_state('shipped') } scope :trackable, -> { where("tracking IS NOT NULL AND tracking != ''") } - scope :with_state, ->(*state) { where(state: state) } + scope :with_state, ->(*state) { where(state:) } # sort by most recent shipped_at, falling back to created_at. add "id desc" to make specs that involve this scope more deterministic. scope :reverse_chronological, -> { order(Arel.sql("coalesce(#{Spree::Shipment.table_name}.shipped_at, #{Spree::Shipment.table_name}.created_at) desc"), id: :desc) @@ -175,7 +175,7 @@ def selected_shipping_rate end def manifest - @manifest ||= Spree::ShippingManifest.new(inventory_units: inventory_units).items + @manifest ||= Spree::ShippingManifest.new(inventory_units:).items end def selected_shipping_rate_id @@ -217,7 +217,7 @@ def determine_state(order) def set_up_inventory(state, variant, _order, line_item) inventory_units.create( - state: state, + state:, variant_id: variant.id, line_item_id: line_item.id ) @@ -263,7 +263,7 @@ def update_amounts self.cost = selected_shipping_rate.cost if changed? update_columns( - cost: cost, + cost:, updated_at: Time.current ) end @@ -312,7 +312,7 @@ def finalize_pending_inventory_units end def after_ship - order.shipping.ship_shipment(self, suppress_mailer: suppress_mailer) + order.shipping.ship_shipment(self, suppress_mailer:) end def can_get_rates? @@ -339,7 +339,7 @@ def set_cost_zero_when_nil def ensure_can_destroy if shipped? || canceled? - errors.add(:state, :cannot_destroy, state: state) + errors.add(:state, :cannot_destroy, state:) throw :abort end end diff --git a/core/app/models/spree/shipping_rate.rb b/core/app/models/spree/shipping_rate.rb index fa16cc87b8e..2bb8b2ae2f1 100644 --- a/core/app/models/spree/shipping_rate.rb +++ b/core/app/models/spree/shipping_rate.rb @@ -31,7 +31,7 @@ def display_price tax_explanations = taxes.map(&:label).join(tax_label_separator) I18n.t 'spree.shipping_rate.display_price.display_price_with_explanations', - price: price, + price:, explanations: tax_explanations end alias_method :display_cost, :display_price diff --git a/core/app/models/spree/simple_order_contents.rb b/core/app/models/spree/simple_order_contents.rb index 5eb63689b46..0676544835f 100644 --- a/core/app/models/spree/simple_order_contents.rb +++ b/core/app/models/spree/simple_order_contents.rb @@ -81,7 +81,7 @@ def add_to_line_item(variant, quantity, options = {}) line_item ||= order.line_items.new( quantity: 0, - variant: variant, + variant:, adjustments: [] ) diff --git a/core/app/models/spree/stock/estimator.rb b/core/app/models/spree/stock/estimator.rb index bb992f0116b..73fc905b378 100644 --- a/core/app/models/spree/stock/estimator.rb +++ b/core/app/models/spree/stock/estimator.rb @@ -39,7 +39,7 @@ def calculate_shipping_rates(package) cost = shipping_method.calculator.compute(package) if cost rate = shipping_method.shipping_rates.new( - cost: cost, + cost:, shipment: package.shipment ) tax_calculator.calculate(rate).each do |tax| diff --git a/core/app/models/spree/stock/inventory_unit_builder.rb b/core/app/models/spree/stock/inventory_unit_builder.rb index 342adc0d258..5cdfda1bcaf 100644 --- a/core/app/models/spree/stock/inventory_unit_builder.rb +++ b/core/app/models/spree/stock/inventory_unit_builder.rb @@ -25,7 +25,7 @@ def build_units(line_item, quantity) Spree::InventoryUnit.new( pending: true, variant: line_item.variant, - line_item: line_item + line_item: ) end end diff --git a/core/app/models/spree/stock/package.rb b/core/app/models/spree/stock/package.rb index 9fcd5c970c1..ccec973c974 100644 --- a/core/app/models/spree/stock/package.rb +++ b/core/app/models/spree/stock/package.rb @@ -124,8 +124,8 @@ def to_shipment contents.each { |content_item| content_item.inventory_unit.state = content_item.state.to_s } Spree::Shipment.new( - order: order, - stock_location: stock_location, + order:, + stock_location:, inventory_units: contents.map(&:inventory_unit) ) end diff --git a/core/app/models/spree/stock/simple_coordinator.rb b/core/app/models/spree/stock/simple_coordinator.rb index fa5a11308aa..69bf4ef57e0 100644 --- a/core/app/models/spree/stock/simple_coordinator.rb +++ b/core/app/models/spree/stock/simple_coordinator.rb @@ -41,7 +41,7 @@ def initialize(order, inventory_units = nil) @desired = Spree::StockQuantities.new(inventory_units_by_variant.transform_values(&:count)) @availability = Spree::Stock::Availability.new( variants: desired.variants, - stock_locations: stock_locations + stock_locations: ) @allocator = Spree::Config.stock.allocator_class.new(availability) diff --git a/core/app/models/spree/stock_location.rb b/core/app/models/spree/stock_location.rb index f3f6215d62d..4ded3100981 100644 --- a/core/app/models/spree/stock_location.rb +++ b/core/app/models/spree/stock_location.rb @@ -39,7 +39,7 @@ def state_text # Wrapper for creating a new stock item respecting the backorderable config def propagate_variant(variant) - stock_items.create!(variant: variant, backorderable: backorderable_default) + stock_items.create!(variant:, backorderable: backorderable_default) end # Return either an existing stock item or create a new one. Useful in @@ -55,7 +55,7 @@ def set_up_stock_item(variant) # # @return [StockItem] Corresponding StockItem for the StockLocation's variant. def stock_item(variant_id) - stock_items.where(variant_id: variant_id).order(:id).first + stock_items.where(variant_id:).order(:id).first end # Attempts to look up StockItem for the variant, and creates one if not found. @@ -101,8 +101,8 @@ def move(variant, quantity, originator = nil) if quantity < 1 && !stock_item(variant) raise InvalidMovementError.new(I18n.t('spree.negative_movement_absent_item')) end - stock_item_or_create(variant).stock_movements.create!(quantity: quantity, - originator: originator) + stock_item_or_create(variant).stock_movements.create!(quantity:, + originator:) end def fill_status(variant, quantity) @@ -121,7 +121,7 @@ def create_stock_items def ensure_one_default if default - Spree::StockLocation.where(default: true).where.not(id: id).find_each do |stock_location| + Spree::StockLocation.where(default: true).where.not(id:).find_each do |stock_location| stock_location.default = false stock_location.save! end diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb index 1f269ab754e..9350fb0a2b8 100644 --- a/core/app/models/spree/store.rb +++ b/core/app/models/spree/store.rb @@ -58,7 +58,7 @@ def default_cart_tax_location def ensure_default_exists_and_is_unique if default - Spree::Store.where.not(id: id).update_all(default: false) + Spree::Store.where.not(id:).update_all(default: false) elsif Spree::Store.where(default: true).count == 0 self.default = true end diff --git a/core/app/models/spree/store_credit.rb b/core/app/models/spree/store_credit.rb index 79019056753..9f5fabc85ff 100644 --- a/core/app/models/spree/store_credit.rb +++ b/core/app/models/spree/store_credit.rb @@ -58,7 +58,7 @@ def amount_remaining def authorize(amount, order_currency, options = {}) authorization_code = options[:action_authorization_code] if authorization_code - if store_credit_events.find_by(action: AUTHORIZE_ACTION, authorization_code: authorization_code) + if store_credit_events.find_by(action: AUTHORIZE_ACTION, authorization_code:) # Don't authorize again on capture return true end @@ -92,7 +92,7 @@ def validate_authorization(amount, order_currency) def capture(amount, authorization_code, order_currency, options = {}) return false unless authorize(amount, order_currency, action_authorization_code: authorization_code) - auth_event = store_credit_events.find_by!(action: AUTHORIZE_ACTION, authorization_code: authorization_code) + auth_event = store_credit_events.find_by!(action: AUTHORIZE_ACTION, authorization_code:) if amount <= auth_event.amount if currency != order_currency @@ -117,7 +117,7 @@ def capture(amount, authorization_code, order_currency, options = {}) end def void(authorization_code, options = {}) - if auth_event = store_credit_events.find_by(action: AUTHORIZE_ACTION, authorization_code: authorization_code) + if auth_event = store_credit_events.find_by(action: AUTHORIZE_ACTION, authorization_code:) update!({ action: VOID_ACTION, action_amount: auth_event.amount, @@ -135,7 +135,7 @@ def void(authorization_code, options = {}) def credit(amount, authorization_code, order_currency, options = {}) # Find the amount related to this authorization_code in order to add the store credit back - capture_event = store_credit_events.find_by(action: CAPTURE_ACTION, authorization_code: authorization_code) + capture_event = store_credit_events.find_by(action: CAPTURE_ACTION, authorization_code:) if currency != order_currency # sanity check to make sure the order currency hasn't changed since the auth errors.add(:base, I18n.t('spree.store_credit.currency_mismatch')) @@ -221,25 +221,25 @@ def create_credit_record(amount, action_attributes = {}) def create_credit_record_params(amount) { - amount: amount, - user_id: user_id, - category_id: category_id, - created_by_id: created_by_id, - currency: currency, - type_id: type_id, + amount:, + user_id:, + category_id:, + created_by_id:, + currency:, + type_id:, memo: credit_allocation_memo } end def credit_allocation_memo - I18n.t("spree.store_credit.credit_allocation_memo", id: id) + I18n.t("spree.store_credit.credit_allocation_memo", id:) end def store_event return unless saved_change_to_amount? || saved_change_to_amount_used? || saved_change_to_amount_authorized? || [ELIGIBLE_ACTION, INVALIDATE_ACTION].include?(action) event = if action - store_credit_events.build(action: action) + store_credit_events.build(action:) else store_credit_events.where(action: ALLOCATION_ACTION).first_or_initialize end @@ -247,10 +247,10 @@ def store_event event.update!({ amount: action_amount || amount, authorization_code: action_authorization_code || event.authorization_code || generate_authorization_code, - amount_remaining: amount_remaining, - user_total_amount: user.available_store_credit_total(currency: currency), + amount_remaining:, + user_total_amount: user.available_store_credit_total(currency:), originator: action_originator, - store_credit_reason: store_credit_reason + store_credit_reason: }) end diff --git a/core/app/models/spree/store_credit_event.rb b/core/app/models/spree/store_credit_event.rb index ae5ab017aa4..e20a4a99d6d 100644 --- a/core/app/models/spree/store_credit_event.rb +++ b/core/app/models/spree/store_credit_event.rb @@ -33,15 +33,15 @@ def action_requires_reason? end def display_amount - Spree::Money.new(amount, { currency: currency }) + Spree::Money.new(amount, { currency: }) end def display_user_total_amount - Spree::Money.new(user_total_amount, { currency: currency }) + Spree::Money.new(user_total_amount, { currency: }) end def display_remaining_amount - Spree::Money.new(amount_remaining, { currency: currency }) + Spree::Money.new(amount_remaining, { currency: }) end def display_event_date diff --git a/core/app/models/spree/tax_calculator/default.rb b/core/app/models/spree/tax_calculator/default.rb index 5d24115f475..29c192cbae7 100644 --- a/core/app/models/spree/tax_calculator/default.rb +++ b/core/app/models/spree/tax_calculator/default.rb @@ -46,7 +46,7 @@ def order_rates Spree::Tax::ItemTax.new( label: rate.adjustment_label(amount), tax_rate: rate, - amount: amount, + amount:, included_in_price: rate.included_in_price ) end @@ -89,7 +89,7 @@ def calculate_rates(item) item_id: item.id, label: rate.adjustment_label(amount), tax_rate: rate, - amount: amount, + amount:, included_in_price: rate.included_in_price ) end diff --git a/core/app/models/spree/tax_calculator/shipping_rate.rb b/core/app/models/spree/tax_calculator/shipping_rate.rb index c7bea0d8449..8bbb3ba19cd 100644 --- a/core/app/models/spree/tax_calculator/shipping_rate.rb +++ b/core/app/models/spree/tax_calculator/shipping_rate.rb @@ -35,7 +35,7 @@ def calculate(shipping_rate) item_id: shipping_rate.id, label: rate.adjustment_label(amount), tax_rate: rate, - amount: amount + amount: ) end end diff --git a/core/app/models/spree/tax_category.rb b/core/app/models/spree/tax_category.rb index d4dc8f857ff..3b047cf8f46 100644 --- a/core/app/models/spree/tax_category.rb +++ b/core/app/models/spree/tax_category.rb @@ -30,7 +30,7 @@ def self.default def ensure_one_default if is_default - Spree::TaxCategory.where(is_default: true).where.not(id: id).update_all(is_default: false, updated_at: Time.current) + Spree::TaxCategory.where(is_default: true).where.not(id:).update_all(is_default: false, updated_at: Time.current) end end end diff --git a/core/app/models/spree/tax_rate.rb b/core/app/models/spree/tax_rate.rb index 39b6ef8aaab..629cd2a1249 100644 --- a/core/app/models/spree/tax_rate.rb +++ b/core/app/models/spree/tax_rate.rb @@ -37,7 +37,7 @@ class TaxRate < Spree::Base # Finds all tax rates whose zones match a given address scope :for_address, ->(address) { joins(:zone).merge(Spree::Zone.for_address(address)) } scope :for_country, - ->(country) { for_address(Spree::Tax::TaxLocation.new(country: country)) } + ->(country) { for_address(Spree::Tax::TaxLocation.new(country:)) } scope :active, -> do table = arel_table time = Time.current diff --git a/core/app/models/spree/taxonomy.rb b/core/app/models/spree/taxonomy.rb index 1809f913bbf..bd8ecd0ef73 100644 --- a/core/app/models/spree/taxonomy.rb +++ b/core/app/models/spree/taxonomy.rb @@ -21,11 +21,11 @@ class Taxonomy < Spree::Base def set_name if root root.update_columns( - name: name, + name:, updated_at: Time.current ) else - self.root = Spree::Taxon.create!(taxonomy_id: id, name: name) + self.root = Spree::Taxon.create!(taxonomy_id: id, name:) end end end diff --git a/core/app/models/spree/unit_cancel.rb b/core/app/models/spree/unit_cancel.rb index 54284c2c992..6daf32795d9 100644 --- a/core/app/models/spree/unit_cancel.rb +++ b/core/app/models/spree/unit_cancel.rb @@ -20,7 +20,7 @@ def adjust! self.adjustment = inventory_unit.line_item.adjustments.create!( source: self, - amount: amount, + amount:, order: inventory_unit.order, label: "#{I18n.t('spree.cancellation')} - #{reason}", finalized: true diff --git a/core/app/models/spree/variant/vat_price_generator.rb b/core/app/models/spree/variant/vat_price_generator.rb index 1b7a0bd5b21..a7f1bf96192 100644 --- a/core/app/models/spree/variant/vat_price_generator.rb +++ b/core/app/models/spree/variant/vat_price_generator.rb @@ -41,7 +41,7 @@ def run def find_or_initialize_price_by(country_iso, currency) variant.prices.detect do |price| price.country_iso == country_iso && price.currency == currency - end || variant.prices.build(country_iso: country_iso, currency: currency) + end || variant.prices.build(country_iso:, currency:) end # nil is added to the array so we always have an export price. diff --git a/core/app/models/spree/wallet.rb b/core/app/models/spree/wallet.rb index 4f588edaaa8..d1edbcda11c 100644 --- a/core/app/models/spree/wallet.rb +++ b/core/app/models/spree/wallet.rb @@ -28,7 +28,7 @@ def wallet_payment_sources # @param payment_source [PaymentSource] The payment source to add to the wallet # @return [WalletPaymentSource] the generated WalletPaymentSource def add(payment_source) - user.wallet_payment_sources.find_or_create_by!(payment_source: payment_source) + user.wallet_payment_sources.find_or_create_by!(payment_source:) end # Remove a PaymentSource from the wallet. @@ -37,7 +37,7 @@ def add(payment_source) # @raise [ActiveRecord::RecordNotFound] if the source is not in the wallet. # @return [WalletPaymentSource] the destroyed WalletPaymentSource def remove(payment_source) - user.wallet_payment_sources.find_by!(payment_source: payment_source).destroy! + user.wallet_payment_sources.find_by!(payment_source:).destroy! end # Find a WalletPaymentSource in the wallet by id. diff --git a/core/db/default/spree/states.rb b/core/db/default/spree/states.rb index e4aaab0ad51..d180f3364f9 100644 --- a/core/db/default/spree/states.rb +++ b/core/db/default/spree/states.rb @@ -2,7 +2,7 @@ def create_states(subregions, country) subregions.each do |subregion| - Spree::State.where(abbr: subregion.code, country: country).first_or_create!( + Spree::State.where(abbr: subregion.code, country:).first_or_create!( name: subregion.name ) end diff --git a/core/lib/generators/solidus/update/update_generator.rb b/core/lib/generators/solidus/update/update_generator.rb index 8f448fffa7c..ee6521d692a 100644 --- a/core/lib/generators/solidus/update/update_generator.rb +++ b/core/lib/generators/solidus/update/update_generator.rb @@ -110,7 +110,7 @@ def api_changes_template(from, to) end def changes_template_for(klass, from, to) - changes = Spree::Preferences::PreferenceDifferentiator.new(klass).call(from: from, to: to) + changes = Spree::Preferences::PreferenceDifferentiator.new(klass).call(from:, to:) return '# No changes' if changes.empty? [ diff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rb index e20dbb6f540..c9ca87e1198 100644 --- a/core/lib/spree/core.rb +++ b/core/lib/spree/core.rb @@ -22,8 +22,6 @@ require 'ransack' require 'state_machines-activerecord' -require_relative './ransack_4_1_patch' - # This is required because ActiveModel::Validations#invalid? conflicts with the # invalid state of a Payment. In the future this should be removed. StateMachines::Machine.ignore_method_conflicts = true diff --git a/core/lib/spree/core/controller_helpers/payment_parameters.rb b/core/lib/spree/core/controller_helpers/payment_parameters.rb index 4aacced01fc..dc106e80349 100644 --- a/core/lib/spree/core/controller_helpers/payment_parameters.rb +++ b/core/lib/spree/core/controller_helpers/payment_parameters.rb @@ -106,7 +106,7 @@ def move_wallet_payment_source_id_into_payments_attributes(params) params[:order][:payments_attributes] = [ { source_attributes: { - wallet_payment_source_id: wallet_payment_source_id, + wallet_payment_source_id:, verification_value: cvc_confirm } } diff --git a/core/lib/spree/core/importer/order.rb b/core/lib/spree/core/importer/order.rb index d29da457a7f..e5bc853be16 100644 --- a/core/lib/spree/core/importer/order.rb +++ b/core/lib/spree/core/importer/order.rb @@ -74,7 +74,7 @@ def self.create_shipments_from_params(shipments_hash, order) # able to find the line item if line_item.variant_id |= iu.variant_id shipment.inventory_units.new( variant_id: inventory_unit[:variant_id], - line_item: line_item + line_item: ) end @@ -91,7 +91,7 @@ def self.create_shipments_from_params(shipments_hash, order) shipment.save! shipping_method = Spree::ShippingMethod.find_by(name: target[:shipping_method]) || Spree::ShippingMethod.find_by!(admin_name: target[:shipping_method]) - rate = shipment.shipping_rates.create!(shipping_method: shipping_method, + rate = shipment.shipping_rates.create!(shipping_method:, cost: target[:cost]) shipment.selected_shipping_rate_id = rate.id shipment.update_amounts @@ -129,7 +129,7 @@ def self.create_adjustments_from_params(adjustments, order) return [] unless adjustments adjustments.each do |target| adjustment = order.adjustments.build( - order: order, + order:, amount: target[:amount].to_d, label: target[:label] ) @@ -141,7 +141,7 @@ def self.create_adjustments_from_params(adjustments, order) def self.create_payments_from_params(payments_hash, order) return [] unless payments_hash payments_hash.each do |target| - payment = order.payments.build order: order + payment = order.payments.build(order:) payment.amount = target[:amount].to_f # Order API should be using state as that's the normal payment field. # spree_wombat serializes payment state as status so imported orders should fall back to status field. @@ -170,7 +170,7 @@ def self.create_source_payment_from_params(source_hash, payment) def self.ensure_variant_id_from_params(hash) sku = hash.delete(:sku) unless hash[:variant_id].present? - hash[:variant_id] = Spree::Variant.with_prices.find_by!(sku: sku).id + hash[:variant_id] = Spree::Variant.with_prices.find_by!(sku:).id end hash end diff --git a/core/lib/spree/core/importer/product.rb b/core/lib/spree/core/importer/product.rb index c338d7466be..8ace36be166 100644 --- a/core/lib/spree/core/importer/product.rb +++ b/core/lib/spree/core/importer/product.rb @@ -18,7 +18,7 @@ def create if product.save variants_attrs.each do |variant_attribute| # make sure the product is assigned before the options= - product.variants.create({ product: product }.merge(variant_attribute)) + product.variants.create({ product: }.merge(variant_attribute)) end set_up_options @@ -35,7 +35,7 @@ def update product.variants.find(variant_attribute['id'].to_i).update(variant_attribute) else # make sure the product is assigned before the options= - product.variants.create({ product: product }.merge(variant_attribute)) + product.variants.create({ product: }.merge(variant_attribute)) end end @@ -49,7 +49,7 @@ def update def set_up_options options_attrs.each do |name| - option_type = Spree::OptionType.where(name: name).first_or_initialize do |ot| + option_type = Spree::OptionType.where(name:).first_or_initialize do |ot| ot.presentation = name ot.save! end diff --git a/core/lib/spree/core/product_filters.rb b/core/lib/spree/core/product_filters.rb index d22bd0ba6ae..aa76566d66a 100644 --- a/core/lib/spree/core/product_filters.rb +++ b/core/lib/spree/core/product_filters.rb @@ -112,7 +112,7 @@ def self.brand_filter { name: 'Brands', scope: :brand_any, - conds: conds, + conds:, labels: brands.sort.map { |key| [key, key] } } end diff --git a/core/lib/spree/core/validators/email.rb b/core/lib/spree/core/validators/email.rb index e7d38c62b7a..7c0718c1fa3 100644 --- a/core/lib/spree/core/validators/email.rb +++ b/core/lib/spree/core/validators/email.rb @@ -14,7 +14,7 @@ module Spree class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless Spree::Config.default_email_regexp.match? value - record.errors.add(attribute, :invalid, **{ value: value }.merge!(options)) + record.errors.add(attribute, :invalid, **{ value: }.merge!(options)) end end end diff --git a/core/lib/spree/i18n.rb b/core/lib/spree/i18n.rb index bfc813e0240..10edfc7788e 100644 --- a/core/lib/spree/i18n.rb +++ b/core/lib/spree/i18n.rb @@ -5,7 +5,7 @@ module Spree def self.i18n_available_locales I18n.available_locales.select do |locale| - I18n.t('spree.i18n.this_file_language', locale: locale, fallback: false, default: nil) + I18n.t('spree.i18n.this_file_language', locale:, fallback: false, default: nil) end end diff --git a/core/lib/spree/mailer_previews/carton_preview.rb b/core/lib/spree/mailer_previews/carton_preview.rb index a1c4653a263..809af298491 100644 --- a/core/lib/spree/mailer_previews/carton_preview.rb +++ b/core/lib/spree/mailer_previews/carton_preview.rb @@ -7,7 +7,7 @@ def shipped carton = Carton.joins(:orders).last raise "Your database needs at least one shipped order with a carton to render this preview" unless carton - Spree::Config.carton_shipped_email_class.shipped_email(order: carton.orders.first, carton: carton) + Spree::Config.carton_shipped_email_class.shipped_email(order: carton.orders.first, carton:) end end end diff --git a/core/lib/spree/permission_sets/default_customer.rb b/core/lib/spree/permission_sets/default_customer.rb index 4de18ce3420..e4d82c216cd 100644 --- a/core/lib/spree/permission_sets/default_customer.rb +++ b/core/lib/spree/permission_sets/default_customer.rb @@ -54,7 +54,7 @@ def activate! # via API, just like with show and update (order.guest_token.present? && token == order.guest_token) end - can [:show, :update], Order, Order.where(user: user) do |order, token| + can [:show, :update], Order, Order.where(user:) do |order, token| order.user == user || (order.guest_token.present? && token == order.guest_token) end cannot :update, Order do |order| diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb index 90e4a7d18ec..a09a6eb53e6 100644 --- a/core/lib/spree/permitted_attributes.rb +++ b/core/lib/spree/permitted_attributes.rb @@ -95,7 +95,7 @@ module PermittedAttributes :number, :month, :year, :expiry, :verification_value, :first_name, :last_name, :cc_type, :gateway_customer_profile_id, :gateway_payment_profile_id, :last_digits, :name, :encrypted_data, - :wallet_payment_source_id, address_attributes: address_attributes + :wallet_payment_source_id, address_attributes: ] @@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id] @@ -153,7 +153,7 @@ module PermittedAttributes @@checkout_payment_attributes = [ payments_attributes: payment_attributes + [ - source_attributes: source_attributes + source_attributes: ] ] diff --git a/core/lib/spree/preferences/store.rb b/core/lib/spree/preferences/store.rb index b48af928ddf..e9a1f87c249 100644 --- a/core/lib/spree/preferences/store.rb +++ b/core/lib/spree/preferences/store.rb @@ -19,7 +19,7 @@ def set(key, value) def exist?(key) @cache.exist?(key) || - should_persist? && Spree::Preference.where(key: key).exists? + should_persist? && Spree::Preference.where(key:).exists? end def get(key) @@ -35,7 +35,7 @@ def get(key) # has been cleared from the cache # does it exist in the database? - if preference = Spree::Preference.find_by(key: key) + if preference = Spree::Preference.find_by(key:) # it does exist val = preference.value else diff --git a/core/lib/spree/ransack_4_1_patch.rb b/core/lib/spree/ransack_4_1_patch.rb deleted file mode 100644 index f531de330d8..00000000000 --- a/core/lib/spree/ransack_4_1_patch.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "ransack/version" - -return unless Ransack::VERSION.start_with?("4.1.") - -module RansackNodeConditionPatch - private - - # Waiting for https://github.com/activerecord-hackery/ransack/pull/1468 - def casted_array?(predicate) - predicate.is_a?(Arel::Nodes::Casted) && predicate.value.is_a?(Array) - end - - Ransack::Nodes::Condition.prepend(self) -end diff --git a/core/lib/spree/testing_support/capybara_ext.rb b/core/lib/spree/testing_support/capybara_ext.rb index ca42e4e8215..2b259eb1105 100644 --- a/core/lib/spree/testing_support/capybara_ext.rb +++ b/core/lib/spree/testing_support/capybara_ext.rb @@ -23,7 +23,7 @@ def fill_in_with_force(locator, with:) field.dispatchEvent(event); JS else - fill_in locator, with: with + fill_in locator, with: end end diff --git a/core/lib/spree/testing_support/dummy_app.rb b/core/lib/spree/testing_support/dummy_app.rb index f9e9ed64f8b..8b9c4591235 100644 --- a/core/lib/spree/testing_support/dummy_app.rb +++ b/core/lib/spree/testing_support/dummy_app.rb @@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base # @private class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true end # @private diff --git a/core/lib/spree/testing_support/dummy_app/migrations.rb b/core/lib/spree/testing_support/dummy_app/migrations.rb index 79d0e3d0c74..2a0a504ab1c 100644 --- a/core/lib/spree/testing_support/dummy_app/migrations.rb +++ b/core/lib/spree/testing_support/dummy_app/migrations.rb @@ -4,21 +4,6 @@ module DummyApp module Migrations extend self - # Ensure database exists - def database_exists? - ActiveRecord::Base.connection - rescue ActiveRecord::NoDatabaseError - false - else - true - end - - def needs_migration? - return true if !database_exists? - - ActiveRecord::Base.connection.migration_context.needs_migration? - end - def auto_migrate if needs_migration? puts "Configuration changed. Re-running migrations" @@ -35,6 +20,14 @@ def auto_migrate private + def needs_migration? + ActiveRecord::Migration.check_all_pending! + rescue ActiveRecord::PendingMigrationError, ActiveRecord::NoDatabaseError + true + else + false + end + def sh(cmd) puts cmd system cmd diff --git a/core/lib/spree/testing_support/dummy_app/rake_tasks.rb b/core/lib/spree/testing_support/dummy_app/rake_tasks.rb index 942be162967..c30241f6965 100644 --- a/core/lib/spree/testing_support/dummy_app/rake_tasks.rb +++ b/core/lib/spree/testing_support/dummy_app/rake_tasks.rb @@ -10,8 +10,8 @@ def initialize(gem_root:, lib_name:) require lib_name require 'spree/testing_support/dummy_app' DummyApp.setup( - gem_root: gem_root, - lib_name: lib_name, + gem_root:, + lib_name:, auto_migrate: false ) end diff --git a/core/lib/spree/testing_support/factories/carton_factory.rb b/core/lib/spree/testing_support/factories/carton_factory.rb index 369ea450222..74edcafbda7 100644 --- a/core/lib/spree/testing_support/factories/carton_factory.rb +++ b/core/lib/spree/testing_support/factories/carton_factory.rb @@ -13,8 +13,8 @@ # ensure the shipment uses the same stock location as the carton shipment: build( :shipment, - stock_location: stock_location, - shipping_method: shipping_method + stock_location:, + shipping_method: ) ) ] diff --git a/core/lib/spree/testing_support/factories/customer_return_factory.rb b/core/lib/spree/testing_support/factories/customer_return_factory.rb index 0f7897a3973..9f688f757d8 100644 --- a/core/lib/spree/testing_support/factories/customer_return_factory.rb +++ b/core/lib/spree/testing_support/factories/customer_return_factory.rb @@ -7,13 +7,13 @@ transient do line_items_count { 1 } return_items_count { line_items_count } - shipped_order { create :shipped_order, line_items_count: line_items_count } + shipped_order { create :shipped_order, line_items_count: } return_authorization { create :return_authorization, order: shipped_order } end before(:create) do |customer_return, evaluator| evaluator.shipped_order.inventory_units.take(evaluator.return_items_count).each do |inventory_unit| - customer_return.return_items << build(:return_item, inventory_unit: inventory_unit, return_authorization: evaluator.return_authorization) + customer_return.return_items << build(:return_item, inventory_unit:, return_authorization: evaluator.return_authorization) end end diff --git a/core/lib/spree/testing_support/factories/inventory_unit_factory.rb b/core/lib/spree/testing_support/factories/inventory_unit_factory.rb index 240626a972f..03ce19dc508 100644 --- a/core/lib/spree/testing_support/factories/inventory_unit_factory.rb +++ b/core/lib/spree/testing_support/factories/inventory_unit_factory.rb @@ -10,15 +10,15 @@ association :variant, strategy: :create line_item do if order - build(:line_item, variant: variant, order: order) + build(:line_item, variant:, order:) else - build(:line_item, variant: variant) + build(:line_item, variant:) end end state { 'on_hand' } shipment do if stock_location - build(:shipment, state: 'pending', order: line_item.order, stock_location: stock_location) + build(:shipment, state: 'pending', order: line_item.order, stock_location:) else build(:shipment, state: 'pending', order: line_item.order) end diff --git a/core/lib/spree/testing_support/factories/order_factory.rb b/core/lib/spree/testing_support/factories/order_factory.rb index d6e45999e26..de577c2cdda 100644 --- a/core/lib/spree/testing_support/factories/order_factory.rb +++ b/core/lib/spree/testing_support/factories/order_factory.rb @@ -43,12 +43,12 @@ evaluator.stock_location # must evaluate before creating line items evaluator.line_items_attributes.each do |attributes| - attributes = { order: order, price: evaluator.line_items_price }.merge(attributes) + attributes = { order:, price: evaluator.line_items_price }.merge(attributes) create(:line_item, attributes) end order.line_items.reload - create(:shipment, order: order, cost: evaluator.shipment_cost, shipping_method: evaluator.shipping_method, stock_location: evaluator.stock_location) + create(:shipment, order:, cost: evaluator.shipment_cost, shipping_method: evaluator.shipping_method, stock_location: evaluator.stock_location) order.shipments.reload order.recalculate @@ -65,7 +65,7 @@ after(:create) do |order, evaluator| create(evaluator.payment_type, { amount: order.total, - order: order, + order:, state: order.payment_state }) @@ -88,7 +88,7 @@ factory :completed_order_with_pending_payment do after(:create) do |order| - create(:payment, amount: order.total, order: order, state: 'pending') + create(:payment, amount: order.total, order:, state: 'pending') end end @@ -101,7 +101,7 @@ end after(:create) do |order, evaluator| - create(evaluator.payment_type, amount: order.total, order: order, state: 'completed') + create(evaluator.payment_type, amount: order.total, order:, state: 'completed') order.shipments.each do |shipment| shipment.update_column('state', 'ready') end diff --git a/core/lib/spree/testing_support/factories/product_factory.rb b/core/lib/spree/testing_support/factories/product_factory.rb index 20e815209b3..ab4dd99b983 100644 --- a/core/lib/spree/testing_support/factories/product_factory.rb +++ b/core/lib/spree/testing_support/factories/product_factory.rb @@ -40,7 +40,7 @@ end factory :product_with_option_types do - after(:create) { |product| create(:product_option_type, product: product) } + after(:create) { |product| create(:product_option_type, product:) } end end end diff --git a/core/lib/spree/testing_support/factories/shipment_factory.rb b/core/lib/spree/testing_support/factories/shipment_factory.rb index 53dff3df8d0..4050918f858 100644 --- a/core/lib/spree/testing_support/factories/shipment_factory.rb +++ b/core/lib/spree/testing_support/factories/shipment_factory.rb @@ -15,7 +15,7 @@ after(:create) do |shipment, evaluator| shipping_method = evaluator.shipping_method || create(:shipping_method, cost: evaluator.cost) shipment.shipping_rates.create!( - shipping_method: shipping_method, + shipping_method:, cost: evaluator.cost, selected: true ) diff --git a/core/lib/spree/testing_support/factories/stock_package_factory.rb b/core/lib/spree/testing_support/factories/stock_package_factory.rb index 5ebdd5ebb80..1ae5506a88e 100644 --- a/core/lib/spree/testing_support/factories/stock_package_factory.rb +++ b/core/lib/spree/testing_support/factories/stock_package_factory.rb @@ -14,7 +14,7 @@ after(:build) do |package, evaluator| evaluator.variants_contents.each do |variant, count| - package.add_multiple build_list(:inventory_unit, count, variant: variant, stock_location: evaluator.stock_location) + package.add_multiple build_list(:inventory_unit, count, variant:, stock_location: evaluator.stock_location) end end diff --git a/core/lib/spree/testing_support/factories/user_factory.rb b/core/lib/spree/testing_support/factories/user_factory.rb index cfe2f5d4896..5cb5db5653a 100644 --- a/core/lib/spree/testing_support/factories/user_factory.rb +++ b/core/lib/spree/testing_support/factories/user_factory.rb @@ -14,7 +14,7 @@ trait :with_orders do after(:create) do |user, _| - create(:order, user: user) + create(:order, user:) end end diff --git a/core/lib/spree/testing_support/factories/zone_factory.rb b/core/lib/spree/testing_support/factories/zone_factory.rb index e673dd401ac..7c3b99f58d9 100644 --- a/core/lib/spree/testing_support/factories/zone_factory.rb +++ b/core/lib/spree/testing_support/factories/zone_factory.rb @@ -6,7 +6,7 @@ zone_members do |proxy| zone = proxy.instance_eval { @instance } Spree::Country.all.map do |c| - Spree::ZoneMember.create(zoneable: c, zone: zone) + Spree::ZoneMember.create(zoneable: c, zone:) end end end diff --git a/core/lib/spree/testing_support/order_walkthrough.rb b/core/lib/spree/testing_support/order_walkthrough.rb index 1a9cbb0ddcf..e2f8b7ae531 100644 --- a/core/lib/spree/testing_support/order_walkthrough.rb +++ b/core/lib/spree/testing_support/order_walkthrough.rb @@ -4,7 +4,7 @@ module Spree module TestingSupport class OrderWalkthrough def self.up_to(state, user: nil) - new.up_to(state, user: user) + new.up_to(state, user:) end def up_to(state, user: nil) @@ -23,7 +23,7 @@ def up_to(state, user: nil) end order = Spree::Order.create!( - user: user, + user:, email: "solidus@example.com", store: Spree::Store.first || ::FactoryBot.create(:store) ) @@ -47,7 +47,7 @@ def up_to(state, user: nil) private def add_line_item!(order) - ::FactoryBot.create(:line_item, order: order) + ::FactoryBot.create(:line_item, order:) order.reload end diff --git a/core/lib/spree/testing_support/shared_examples/order_factory.rb b/core/lib/spree/testing_support/shared_examples/order_factory.rb index 8c647544e47..47c4657d568 100644 --- a/core/lib/spree/testing_support/shared_examples/order_factory.rb +++ b/core/lib/spree/testing_support/shared_examples/order_factory.rb @@ -8,7 +8,7 @@ expect( create( factory, - shipping_method: shipping_method + shipping_method: ).shipments.map(&:shipping_method) ).to all(eq(shipping_method)) end @@ -17,7 +17,7 @@ expect( build( factory, - shipping_method: shipping_method + shipping_method: ).shipments.map(&:shipping_method) ).to all(eq(shipping_method)) end @@ -35,13 +35,13 @@ let(:order) do create( factory, - stock_location: stock_location, + stock_location:, line_items_attributes: [ { variant: first_variant, quantity: 1, price: 1 }, { variant: second_variant, quantity: 2, price: 2 } ], shipment_cost: 3, - shipping_method: shipping_method + shipping_method: ) end @@ -62,7 +62,7 @@ expect(order.shipments.count).to eq 1 expect(order.shipments[0]).to have_attributes( amount: 3.0, - stock_location: stock_location + stock_location: ) expect(order.shipments[0].shipping_method).to eq(shipping_method) @@ -73,21 +73,21 @@ expect(inventory_units.count).to eq(3) expect(inventory_units[0]).to have_attributes( - order: order, + order:, shipment: order.shipments[0], line_item: order.line_items[0], variant: order.line_items[0].variant, state: expected_inventory_unit_state ) expect(inventory_units[1]).to have_attributes( - order: order, + order:, shipment: order.shipments[0], line_item: order.line_items[1], variant: order.line_items[1].variant, state: expected_inventory_unit_state ) expect(inventory_units[2]).to have_attributes( - order: order, + order:, shipment: order.shipments[0], line_item: order.line_items[1], variant: order.line_items[1].variant, @@ -110,10 +110,10 @@ let!(:tax_rate) { create(:tax_rate, amount: 0.10, zone: tax_zone, tax_categories: [tax_category]) } let(:tax_category) { create(:tax_category) } - let(:shipping_method) { create(:shipping_method, tax_category: tax_category, zones: [tax_zone]) } + let(:shipping_method) { create(:shipping_method, tax_category:, zones: [tax_zone]) } it 'shipments get a tax adjustment' do - order = create(factory, ship_address: ship_address, shipping_method: shipping_method) + order = create(factory, ship_address:, shipping_method:) shipment = order.shipments[0] expect(shipment.additional_tax_total).to be > 0 @@ -124,7 +124,7 @@ RSpec.shared_examples 'supplied completed_at is respected' do context 'when passed a completed_at timestamp' do let(:completed_at) { 2.days.ago } - let(:order) { create(factory, completed_at: completed_at) } + let(:order) { create(factory, completed_at:) } it 'respects the timestamp' do expect(order.completed_at).to be_within(5.seconds).of(completed_at) diff --git a/core/lib/tasks/colorado_delivery_fee.rake b/core/lib/tasks/colorado_delivery_fee.rake index 900a0d0c01b..c04ee696399 100644 --- a/core/lib/tasks/colorado_delivery_fee.rake +++ b/core/lib/tasks/colorado_delivery_fee.rake @@ -16,8 +16,8 @@ namespace :taxes do calculator = Spree::Calculator::FlatFee.new rate = Spree::TaxRate.create!( name: "Colorado Delivery Fee", - calculator: calculator, - zone: zone, + calculator:, + zone:, amount: 0.27, show_rate_in_label: false, level: "order" diff --git a/core/solidus_core.gemspec b/core/solidus_core.gemspec index 43ec266f676..e816bd641e9 100644 --- a/core/solidus_core.gemspec +++ b/core/solidus_core.gemspec @@ -20,19 +20,19 @@ Gem::Specification.new do |s| f.match(%r{^(spec|script)/}) end - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' %w[ actionmailer actionpack actionview activejob activemodel activerecord activestorage activesupport railties ].each do |rails_dep| - s.add_dependency rails_dep, ['>= 7.0', '< 7.2'] + s.add_dependency rails_dep, ['>= 7.0', '< 8.0'] end s.add_dependency 'activemerchant', '~> 1.66' s.add_dependency 'acts_as_list', '< 2.0' - s.add_dependency 'awesome_nested_set', '~> 3.3' + s.add_dependency 'awesome_nested_set', ['~> 3.3', '>= 3.7.0'] s.add_dependency 'cancancan', ['>= 2.2', '< 4.0'] s.add_dependency 'carmen', '~> 1.1.0' s.add_dependency 'discard', '~> 1.0' @@ -43,9 +43,7 @@ Gem::Specification.new do |s| s.add_dependency 'monetize', '~> 1.8' s.add_dependency 'kt-paperclip', ['>= 6.3', '< 8'] s.add_dependency 'psych', ['>= 4.0.1', '< 6.0'] - # @note ransack 4.2 contains a bug which has not yet been addressed. - # @see https://github.com/activerecord-hackery/ransack/pull/1468 - s.add_dependency 'ransack', ['~> 4.0', '< 4.2'] + s.add_dependency 'ransack', ['~> 4.0', '< 5'] s.add_dependency 'sprockets-rails', '!= 3.5.0' s.add_dependency 'state_machines-activerecord', '~> 0.6' s.add_dependency 'omnes', '~> 0.2.2' diff --git a/core/spec/helpers/base_helper_spec.rb b/core/spec/helpers/base_helper_spec.rb index 08d27b3d135..81219b4c43d 100644 --- a/core/spec/helpers/base_helper_spec.rb +++ b/core/spec/helpers/base_helper_spec.rb @@ -48,7 +48,7 @@ context "checkout zone is of type state" do before do state_zone = create(:zone, name: "StateZone") - state = create(:state, country: country) + state = create(:state, country:) state_zone.members.create(zoneable: state) stub_spree_preferences(checkout_zone: state_zone.name) end diff --git a/core/spec/helpers/products_helper_spec.rb b/core/spec/helpers/products_helper_spec.rb index 2edbb51abe8..09963dc1770 100644 --- a/core/spec/helpers/products_helper_spec.rb +++ b/core/spec/helpers/products_helper_spec.rb @@ -8,10 +8,10 @@ module Spree let(:product) { create(:product, price: product_price) } let(:product_price) { 10 } - let(:variant) { create(:variant, product: product, price: variant_price) } + let(:variant) { create(:variant, product:, price: variant_price) } let(:currency) { 'USD' } let(:pricing_options) do - Spree::Config.pricing_options_class.new(currency: currency) + Spree::Config.pricing_options_class.new(currency:) end before do @@ -51,8 +51,8 @@ module Spree let(:currency) { 'JPY' } before do - variant.prices.each { |p| p.update(currency: currency) } - product.master.prices.each { |p| p.update(currency: currency) } + variant.prices.each { |p| p.update(currency:) } + product.master.prices.each { |p| p.update(currency:) } end context "when variant is more than master" do @@ -70,7 +70,7 @@ module Spree end context "#variant_price_full" do - let!(:variant_2) { create(:variant, product: product, price: variant_2_price) } + let!(:variant_2) { create(:variant, product:, price: variant_2_price) } let(:variant_2_price) { 20 } let(:variant_price) { 15 } @@ -92,8 +92,8 @@ module Spree let(:variant_price) { 150 } before do - variant.prices.each { |p| p.update(currency: currency) } - product.master.prices.each { |p| p.update(currency: currency) } + variant.prices.each { |p| p.update(currency:) } + product.master.prices.each { |p| p.update(currency:) } end it "should return the variant price if the price is different than master" do diff --git a/core/spec/helpers/taxons_helper_spec.rb b/core/spec/helpers/taxons_helper_spec.rb index b24de8d1a67..8918205a564 100644 --- a/core/spec/helpers/taxons_helper_spec.rb +++ b/core/spec/helpers/taxons_helper_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Spree::TaxonsHelper, type: :helper do let(:currency) { 'USD' } let(:pricing_options) do - Spree::Config.pricing_options_class.new(currency: currency) + Spree::Config.pricing_options_class.new(currency:) end before do without_partial_double_verification do diff --git a/core/spec/lib/search/variant_spec.rb b/core/spec/lib/search/variant_spec.rb index 8d210e1d81c..cfeddbf0e95 100644 --- a/core/spec/lib/search/variant_spec.rb +++ b/core/spec/lib/search/variant_spec.rb @@ -13,7 +13,7 @@ def refute_found(query_string, variant) end let(:product) { FactoryBot.create(:product, name: "My Special Product", slug: "my-special-product") } - let!(:variant) { FactoryBot.create(:variant, product: product, sku: "abc-123") } + let!(:variant) { FactoryBot.create(:variant, product:, sku: "abc-123") } context "blank string" do it { assert_found(nil, variant) } @@ -106,8 +106,8 @@ def search_terms(word) end end - let!(:numeric_sku_variant) { FactoryBot.create(:variant, product: product, sku: "123") } - let!(:non_numeric_sku_variant) { FactoryBot.create(:variant, product: product, sku: "abc") } + let!(:numeric_sku_variant) { FactoryBot.create(:variant, product:, sku: "123") } + let!(:non_numeric_sku_variant) { FactoryBot.create(:variant, product:, sku: "abc") } it { expect(NumericSkuSearcher.new('123').results).to include numeric_sku_variant } it { expect(NumericSkuSearcher.new('abc').results).not_to include non_numeric_sku_variant } diff --git a/core/spec/lib/spree/core/controller_helpers/order_spec.rb b/core/spec/lib/spree/core/controller_helpers/order_spec.rb index b8046612f0a..f6ec2ce1ee8 100644 --- a/core/spec/lib/spree/core/controller_helpers/order_spec.rb +++ b/core/spec/lib/spree/core/controller_helpers/order_spec.rb @@ -11,7 +11,7 @@ } let(:user) { create(:user) } - let(:order) { create(:order, user: user, store: store) } + let(:order) { create(:order, user:, store:) } let(:store) { create(:store) } before do @@ -22,7 +22,7 @@ describe '#current_order' do context 'create_order_if_necessary option is false' do - let!(:order) { create :order, user: user, store: store } + let!(:order) { create :order, user:, store: } it 'returns current order' do expect(controller.current_order).to eq order end @@ -87,7 +87,7 @@ end describe '#set_current_order' do - let(:incomplete_order) { create(:order, store: incomplete_order_store, user: user) } + let(:incomplete_order) { create(:order, store: incomplete_order_store, user:) } context 'when current order not equal to users incomplete orders' do before { allow(controller).to receive_messages(current_order: order, last_incomplete_order: incomplete_order, cookies: double(signed: { guest_token: 'guest_token' })) } diff --git a/core/spec/lib/spree/core/controller_helpers/pricing_spec.rb b/core/spec/lib/spree/core/controller_helpers/pricing_spec.rb index 6c7fe6fc663..e8b0d5fe60a 100644 --- a/core/spec/lib/spree/core/controller_helpers/pricing_spec.rb +++ b/core/spec/lib/spree/core/controller_helpers/pricing_spec.rb @@ -43,7 +43,7 @@ context "country_iso" do subject { controller.current_pricing_options.country_iso } - let(:store) { FactoryBot.create(:store, cart_tax_country_iso: cart_tax_country_iso) } + let(:store) { FactoryBot.create(:store, cart_tax_country_iso:) } context "when the store has a cart tax country set" do let(:cart_tax_country_iso) { "DE" } diff --git a/core/spec/lib/spree/core/importer/order_spec.rb b/core/spec/lib/spree/core/importer/order_spec.rb index d43ed22dd35..56c244fb20d 100644 --- a/core/spec/lib/spree/core/importer/order_spec.rb +++ b/core/spec/lib/spree/core/importer/order_spec.rb @@ -7,7 +7,7 @@ module Core RSpec.describe Importer::Order do let!(:store) { create(:store) } let!(:country) { create(:country) } - let!(:state) { country.states.first || create(:state, country: country) } + let!(:state) { country.states.first || create(:state, country:) } let!(:stock_location) { create(:stock_location, admin_name: 'Admin Name') } let(:user) { stub_model(LegacyUser, email: 'fox@mudler.com') } @@ -131,7 +131,7 @@ module Core it 'can build an order from API with variant sku' do params = { line_items_attributes: { - "0" => { sku: sku, quantity: 5 } + "0" => { sku:, quantity: 5 } } } @@ -145,7 +145,7 @@ module Core it 'handle when line items is an array' do params = { line_items_attributes: [ - { variant_id: variant_id, quantity: 7 } + { variant_id:, quantity: 7 } ] } order = Importer::Order.import(user, params) @@ -299,7 +299,7 @@ module Core cost: '14.99', shipping_method: shipping_method.name, stock_location: stock_location.name, - inventory_units: [{ sku: sku }] + inventory_units: [{ sku: }] } ] } @@ -358,7 +358,7 @@ module Core shipped_at: 1.day.ago, shipping_method: shipping_method.name, stock_location: stock_location.name, - inventory_units: [{ sku: sku }] + inventory_units: [{ sku: }] } ] } @@ -394,7 +394,7 @@ module Core shipped_at: 1.day.ago, shipping_method: shipping_method.name, stock_location: stock_location.name, - inventory_units: [{ sku: sku }] + inventory_units: [{ sku: }] } ] } diff --git a/core/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb b/core/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb index 5530f8cbcb5..231ca3abec6 100644 --- a/core/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb +++ b/core/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb @@ -38,7 +38,7 @@ let(:country) { create(:country, iso: 'IT' )} context 'when given a state but no country' do - subject { build(:address, state: state) } + subject { build(:address, state:) } it 'infers the country from the state' do expect(subject).to be_valid @@ -48,7 +48,7 @@ end context 'when given a country but no state' do - subject { build(:address, country: country) } + subject { build(:address, country:) } it 'automatically finds or creates an appropriate state' do expect(subject).to be_valid @@ -58,7 +58,7 @@ end context 'when given a country, no state but a state_name' do - subject { build(:address, country: country, state_name: 'Bogus state') } + subject { build(:address, country:, state_name: 'Bogus state') } it 'does not automatically find or create an appropriate state' do expect(subject).to be_valid @@ -69,7 +69,7 @@ end describe 'country not requiring a state' do - subject { build(:address, country: country) } + subject { build(:address, country:) } let(:country) { create(:country, iso: 'AI' )} it 'does not automatically find or create an appropriate state' do @@ -80,7 +80,7 @@ end describe 'when passing in a state and country ISO' do - subject { build(:address, country_iso_code: country_iso_code, state_code: state_code) } + subject { build(:address, country_iso_code:, state_code:) } context 'when the country has a state with proper code' do let(:country_iso_code) { "US" } diff --git a/core/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb b/core/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb index cd8117a9b56..fd3e2675ac7 100644 --- a/core/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +++ b/core/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb @@ -20,7 +20,7 @@ it 'uses the orders bill address for the credit card' do address = create(:address) order = create(:order, bill_address: address) - payment = create(factory, order: order) + payment = create(factory, order:) expect(payment.source.address).to eq address end diff --git a/core/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb b/core/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb index 1d897f7fa11..5c54198ceee 100644 --- a/core/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb +++ b/core/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb @@ -56,7 +56,7 @@ describe 'when given a country record' do let(:country) { build(:country, iso: "DE") } - let(:state) { build(:state, country: country) } + let(:state) { build(:state, country:) } it 'creates the first state for that country it finds in carmen' do expect(state.abbr).to eq("BW") expect(state.name).to eq("Baden-Württemberg") diff --git a/core/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb b/core/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb index 7866762fe8a..b74459283e6 100644 --- a/core/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb +++ b/core/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb @@ -28,7 +28,7 @@ let(:country) { create(:country, iso: 'HK') } it 'succeeds' do expect( - create(:stock_location, country: country) + create(:stock_location, country:) ).to be_a(Spree::StockLocation) end end diff --git a/core/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb b/core/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb index 9243ad67660..0f4d357ad40 100644 --- a/core/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb +++ b/core/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb @@ -29,7 +29,7 @@ end context "when a taxonomy is given" do - subject { create(:taxon, taxonomy: taxonomy) } + subject { create(:taxon, taxonomy:) } let!(:taxonomy) { create(:taxonomy) } diff --git a/core/spec/lib/spree/core_spec.rb b/core/spec/lib/spree/core_spec.rb index 7ae4c40626f..7c58f64572c 100644 --- a/core/spec/lib/spree/core_spec.rb +++ b/core/spec/lib/spree/core_spec.rb @@ -49,7 +49,7 @@ initializer_name = File.basename(__FILE__) expect( - Spree::Core.has_install_generator_been_run?(rails_paths: rails_paths, initializer_name: initializer_name, dummy_app_name: 'Foo') + Spree::Core.has_install_generator_been_run?(rails_paths:, initializer_name:, dummy_app_name: 'Foo') ).to be(true) end end @@ -59,7 +59,7 @@ initializer_name = 'xxxxxxxxxxxxxxxxxxxxxx' expect( - Spree::Core.has_install_generator_been_run?(rails_paths: rails_paths, initializer_name: initializer_name, dummy_app_name: 'Foo') + Spree::Core.has_install_generator_been_run?(rails_paths:, initializer_name:, dummy_app_name: 'Foo') ).to be(false) end end @@ -69,7 +69,7 @@ initializer_name = 'xxxxxxxxxxxxxxxxxxxxxx' expect( - Spree::Core.has_install_generator_been_run?(rails_paths: rails_paths, initializer_name: initializer_name) + Spree::Core.has_install_generator_been_run?(rails_paths:, initializer_name:) ).to be(true) end end diff --git a/core/spec/lib/spree/money_spec.rb b/core/spec/lib/spree/money_spec.rb index 12ee9067b70..5bcc916881d 100644 --- a/core/spec/lib/spree/money_spec.rb +++ b/core/spec/lib/spree/money_spec.rb @@ -9,7 +9,7 @@ describe '#initialize' do subject do - described_class.new(amount, currency: currency, with_currency: true).to_s + described_class.new(amount, currency:, with_currency: true).to_s end context 'with no currency' do diff --git a/core/spec/mailers/carton_mailer_spec.rb b/core/spec/mailers/carton_mailer_spec.rb index f4ce1d05582..7193b47d91f 100644 --- a/core/spec/mailers/carton_mailer_spec.rb +++ b/core/spec/mailers/carton_mailer_spec.rb @@ -8,7 +8,7 @@ # Regression test for https://github.com/spree/spree/issues/2196 it "doesn't include out of stock in the email body" do - shipment_email = Spree::CartonMailer.shipped_email(order: order, carton: carton) + shipment_email = Spree::CartonMailer.shipped_email(order:, carton:) expect(shipment_email.parts.first.body).not_to include(%{Out of Stock}) expect(shipment_email.parts.first.body).to include(%{Your order has been shipped}) expect(shipment_email.subject).to eq "#{order.store.name} Shipment Notification ##{order.number}" @@ -16,7 +16,7 @@ context "with resend option" do subject do - Spree::CartonMailer.shipped_email(order: order, carton: carton, resend: true).subject + Spree::CartonMailer.shipped_email(order:, carton:, resend: true).subject end it { is_expected.to match /^\[RESEND\] / } end @@ -35,7 +35,7 @@ end specify do - shipped_email = Spree::CartonMailer.shipped_email(order: order, carton: carton) + shipped_email = Spree::CartonMailer.shipped_email(order:, carton:) expect(shipped_email.parts.first.body).to include("Caro Cliente,") end end diff --git a/core/spec/mailers/order_mailer_spec.rb b/core/spec/mailers/order_mailer_spec.rb index 57deec8b676..24bfe66e6cd 100644 --- a/core/spec/mailers/order_mailer_spec.rb +++ b/core/spec/mailers/order_mailer_spec.rb @@ -6,10 +6,10 @@ let(:order) do order = create(:order) product = stub_model(Spree::Product, name: %{The "BEST" product}) - variant = stub_model(Spree::Variant, product: product) - price = stub_model(Spree::Price, variant: variant, amount: 5.00) + variant = stub_model(Spree::Variant, product:) + price = stub_model(Spree::Price, variant:, amount: 5.00) store = FactoryBot.build :store, mail_from_address: "store@example.com", bcc_email: "bcc@example.com" - line_item = stub_model(Spree::LineItem, variant: variant, order: order, quantity: 1, price: 4.99) + line_item = stub_model(Spree::LineItem, variant:, order:, quantity: 1, price: 4.99) allow(variant).to receive_messages(default_price: price) allow(order).to receive_messages(line_items: [line_item]) allow(order).to receive(:store).and_return(store) @@ -36,7 +36,7 @@ create( :adjustment, adjustable: order, - order: order, + order:, label: 'Order Adjustment' ) end diff --git a/core/spec/models/spree/address/state_validator_spec.rb b/core/spec/models/spree/address/state_validator_spec.rb index d3c2d8b0faa..464afad91ed 100644 --- a/core/spec/models/spree/address/state_validator_spec.rb +++ b/core/spec/models/spree/address/state_validator_spec.rb @@ -4,8 +4,8 @@ RSpec.describe Spree::Address::StateValidator do let(:country) { create :country, states_required: true } - let(:state) { create :state, name: 'maryland', abbr: 'md', country: country } - let(:address) { build(:address, country: country) } + let(:state) { create :state, name: 'maryland', abbr: 'md', country: } + let(:address) { build(:address, country:) } subject { described_class.new(address).perform } diff --git a/core/spec/models/spree/address_spec.rb b/core/spec/models/spree/address_spec.rb index a17af6f1d57..0f2eea77233 100644 --- a/core/spec/models/spree/address_spec.rb +++ b/core/spec/models/spree/address_spec.rb @@ -7,8 +7,8 @@ context "validation" do let(:country) { create :country, states_required: true } - let(:state) { create :state, name: 'maryland', abbr: 'md', country: country } - let(:address) { build(:address, country: country) } + let(:state) { create :state, name: 'maryland', abbr: 'md', country: } + let(:address) { build(:address, country:) } context 'state validation' do let(:state_validator) { instance_spy(Spree::Address.state_validator_class) } @@ -278,13 +278,13 @@ context 'both name and abbr is present' do let(:state) { Spree::State.new name: 'virginia', abbr: 'va' } - let(:address) { Spree::Address.new state: state } + let(:address) { Spree::Address.new state: } specify { expect(address.state_text).to eq('va') } end context 'only name is present' do let(:state) { Spree::State.new name: 'virginia', abbr: nil } - let(:address) { Spree::Address.new state: state } + let(:address) { Spree::Address.new state: } specify { expect(address.state_text).to eq('virginia') } end end diff --git a/core/spec/models/spree/adjustment_spec.rb b/core/spec/models/spree/adjustment_spec.rb index 3a2933900e1..f2a8df00b74 100644 --- a/core/spec/models/spree/adjustment_spec.rb +++ b/core/spec/models/spree/adjustment_spec.rb @@ -5,12 +5,12 @@ RSpec.describe Spree::Adjustment, type: :model do let!(:store) { create :store } let(:order) { create :order } - let(:line_item) { create :line_item, order: order } + let(:line_item) { create :line_item, order: } - let(:adjustment) { Spree::Adjustment.create!(label: 'Adjustment', adjustable: order, order: order, amount: 5) } + let(:adjustment) { Spree::Adjustment.create!(label: 'Adjustment', adjustable: order, order:, amount: 5) } context '#save' do - let(:adjustment) { Spree::Adjustment.create(label: "Adjustment", amount: 5, order: order, adjustable: line_item) } + let(:adjustment) { Spree::Adjustment.create(label: "Adjustment", amount: 5, order:, adjustable: line_item) } it 'touches the adjustable' do line_item.update_columns(updated_at: 1.day.ago) @@ -30,15 +30,15 @@ end let!(:tax_adjustment) do - create(:adjustment, adjustable: order, order: order, source: create(:tax_rate)) + create(:adjustment, adjustable: order, order:, source: create(:tax_rate)) end let!(:non_tax_adjustment_with_source) do - create(:adjustment, adjustable: order, order: order, source_type: 'Spree::Order', source_id: nil) + create(:adjustment, adjustable: order, order:, source_type: 'Spree::Order', source_id: nil) end let!(:non_tax_adjustment_without_source) do - create(:adjustment, adjustable: order, order: order, source: nil) + create(:adjustment, adjustable: order, order:, source: nil) end it 'select non-tax adjustments' do @@ -85,7 +85,7 @@ describe "#finalize" do let(:adjustable) { create(:order) } - let(:adjustment) { build(:adjustment, finalized: false, adjustable: adjustable) } + let(:adjustment) { build(:adjustment, finalized: false, adjustable:) } subject { adjustment.finalize } @@ -98,7 +98,7 @@ end context "for an invalid adjustment" do - let(:adjustment) { build(:adjustment, finalized: false, amount: nil, adjustable: adjustable) } + let(:adjustment) { build(:adjustment, finalized: false, amount: nil, adjustable:) } it "raises no error, returns false, does not persist the adjustment" do expect { subject }.not_to change { adjustment.persisted? }.from(false) @@ -109,7 +109,7 @@ describe "#unfinalize" do let(:adjustable) { create(:order) } - let(:adjustment) { build(:adjustment, finalized: true, adjustable: adjustable) } + let(:adjustment) { build(:adjustment, finalized: true, adjustable:) } subject { adjustment.unfinalize } @@ -122,7 +122,7 @@ end context "for an invalid adjustment" do - let(:adjustment) { build(:adjustment, finalized: false, amount: nil, adjustable: adjustable) } + let(:adjustment) { build(:adjustment, finalized: false, amount: nil, adjustable:) } it "raises no error, returns false, does not persist the adjustment" do expect { subject }.not_to change { adjustment.persisted? }.from(false) @@ -133,7 +133,7 @@ describe "#unfinalize!" do let(:adjustable) { create(:order) } - let(:adjustment) { build(:adjustment, finalized: true, adjustable: adjustable) } + let(:adjustment) { build(:adjustment, finalized: true, adjustable:) } subject { adjustment.unfinalize! } @@ -146,7 +146,7 @@ end context "for an invalid adjustment" do - let(:adjustment) { build(:adjustment, finalized: false, amount: nil, adjustable: adjustable) } + let(:adjustment) { build(:adjustment, finalized: false, amount: nil, adjustable:) } it "raises an error" do expect { subject }.to raise_exception(ActiveRecord::RecordInvalid) diff --git a/core/spec/models/spree/calculator/default_tax_spec.rb b/core/spec/models/spree/calculator/default_tax_spec.rb index 35352d9d13c..2985b58e1c2 100644 --- a/core/spec/models/spree/calculator/default_tax_spec.rb +++ b/core/spec/models/spree/calculator/default_tax_spec.rb @@ -12,8 +12,8 @@ let(:expires_at) { nil } let!(:rate) do create(:tax_rate, tax_categories: [tax_category], amount: 0.05, - included_in_price: included_in_price, zone: zone, - starts_at: starts_at, expires_at: expires_at) + included_in_price:, zone:, + starts_at:, expires_at:) end let(:included_in_price) { false } subject(:calculator) { Spree::Calculator::DefaultTax.new(calculable: rate ) } @@ -26,8 +26,8 @@ create( :order_with_line_items, line_items_attributes: [ - { price: 10, quantity: 3, tax_category: tax_category }.merge(line_item_one_options), - { price: 10, quantity: 3, tax_category: tax_category }.merge(line_item_two_options) + { price: 10, quantity: 3, tax_category: }.merge(line_item_one_options), + { price: 10, quantity: 3, tax_category: }.merge(line_item_two_options) ], ship_address: address ) @@ -189,9 +189,9 @@ :line_item, price: 10, quantity: 3, - adjustments: adjustments, - order: order, - tax_category: tax_category + adjustments:, + order:, + tax_category: ) end @@ -202,7 +202,7 @@ let(:shipping_method) do build_stubbed( :shipping_method, - tax_category: tax_category + tax_category: ) end @@ -210,7 +210,7 @@ build_stubbed( :shipping_rate, selected: true, - shipping_method: shipping_method + shipping_method: ) end @@ -218,8 +218,8 @@ build_stubbed( :shipment, cost: 30, - adjustments: adjustments, - order: order, + adjustments:, + order:, shipping_rates: [shipping_rate] ) end @@ -231,14 +231,14 @@ let(:shipping_method) do build_stubbed( :shipping_method, - tax_category: tax_category + tax_category: ) end let(:shipment) do build_stubbed( :shipment, - order: order + order: ) end @@ -250,8 +250,8 @@ :shipping_rate, cost: 30 + adjustment_total, selected: true, - shipping_method: shipping_method, - shipment: shipment + shipping_method:, + shipment: ) end diff --git a/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb b/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb index a871e382b7f..3691bf04a27 100644 --- a/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +++ b/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb @@ -7,9 +7,9 @@ let(:line_item_quantity) { 3 } let(:line_item_price) { 100.0 } let(:line_item) { create(:line_item, price: line_item_price, quantity: line_item_quantity) } - let(:shipment) { create(:shipment, order: order) } - let(:inventory_unit) { build(:inventory_unit, shipment: shipment, line_item: line_item) } - let(:return_item) { build(:return_item, inventory_unit: inventory_unit ) } + let(:shipment) { create(:shipment, order:) } + let(:inventory_unit) { build(:inventory_unit, shipment:, line_item:) } + let(:return_item) { build(:return_item, inventory_unit: ) } let(:calculator) { Spree::Calculator::Returns::DefaultRefundAmount.new } let(:order) { line_item.order } @@ -29,7 +29,7 @@ order.adjustments << create( :adjustment, adjustable: order, - order: order, + order:, amount: adjustment_amount, label: 'Adjustment', source_type: 'Spree::Order' @@ -50,7 +50,7 @@ context "shipping adjustments" do let(:adjustment_total) { -50.0 } - before { order.shipments << Spree::Shipment.new(adjustment_total: adjustment_total) } + before { order.shipments << Spree::Shipment.new(adjustment_total:) } it { is_expected.to eq line_item_price } end diff --git a/core/spec/models/spree/carton_spec.rb b/core/spec/models/spree/carton_spec.rb index 7dd8196c1af..d699dc64240 100644 --- a/core/spec/models/spree/carton_spec.rb +++ b/core/spec/models/spree/carton_spec.rb @@ -26,7 +26,7 @@ carton.tracking_url end - let(:carton) { create(:carton, shipping_method: shipping_method) } + let(:carton) { create(:carton, shipping_method:) } let(:shipping_method) do create(:shipping_method, tracking_url: "https://example.com/:tracking") end @@ -37,7 +37,7 @@ context "when tracking is present" do let(:carton) do - create(:carton, shipping_method: shipping_method, tracking: "1Z12345") + create(:carton, shipping_method:, tracking: "1Z12345") end it "uses shipping method to determine url" do @@ -81,8 +81,8 @@ let(:email) { 'something@something.com' } before do - first_order.update!(email: email) - second_order.update!(email: email) + first_order.update!(email:) + second_order.update!(email:) end it "returns a unique list of the order emails it is associated to" do diff --git a/core/spec/models/spree/classification_spec.rb b/core/spec/models/spree/classification_spec.rb index 880f0fc399e..a9c260ce4c2 100644 --- a/core/spec/models/spree/classification_spec.rb +++ b/core/spec/models/spree/classification_spec.rb @@ -19,7 +19,7 @@ module Spree products << create(:base_product) end - create(:taxon, products: products) + create(:taxon, products:) end def positions_to_be_valid(taxon) diff --git a/core/spec/models/spree/concerns/user_address_book_spec.rb b/core/spec/models/spree/concerns/user_address_book_spec.rb index d1df52f645d..9b76829a3e3 100644 --- a/core/spec/models/spree/concerns/user_address_book_spec.rb +++ b/core/spec/models/spree/concerns/user_address_book_spec.rb @@ -111,7 +111,7 @@ module Spree let(:address) { create(:address) } before do - user.user_addresses.create(address: address, default: false) + user.user_addresses.create(address:, default: false) end context "properly sets the default flag" do @@ -453,7 +453,7 @@ module Spree describe "generating a new user with a ship_address at once" do let(:ship_address) { build(:ship_address) } - subject { create(:user, ship_address: ship_address) } + subject { create(:user, ship_address:) } it "stores the ship_address" do expect(subject.ship_address).to eq ship_address diff --git a/core/spec/models/spree/concerns/user_methods_spec.rb b/core/spec/models/spree/concerns/user_methods_spec.rb index 0389373060c..c03c7a3250a 100644 --- a/core/spec/models/spree/concerns/user_methods_spec.rb +++ b/core/spec/models/spree/concerns/user_methods_spec.rb @@ -8,7 +8,7 @@ describe '#has_spree_role?' do subject { test_user.has_spree_role? name } - let(:role) { Spree::Role.create(name: name) } + let(:role) { Spree::Role.create(name:) } let(:name) { 'test' } context 'with a role' do @@ -37,7 +37,7 @@ def initialize(_user) it 'can add accessible roles' do user = create(:user, spree_roles: []) - user.update_spree_roles([accessible_role], ability: ability) + user.update_spree_roles([accessible_role], ability:) expect(user.reload.spree_roles).to eq([accessible_role]) end @@ -45,7 +45,7 @@ def initialize(_user) it 'can remove accessible roles' do user = create(:user, spree_roles: [accessible_role]) - user.update_spree_roles([], ability: ability) + user.update_spree_roles([], ability:) expect(user.reload.spree_roles).to eq([]) end @@ -53,7 +53,7 @@ def initialize(_user) it "can't add non accessible roles" do user = create(:user, spree_roles: []) - user.update_spree_roles([non_accessible_role], ability: ability) + user.update_spree_roles([non_accessible_role], ability:) expect(user.reload.spree_roles).to eq([]) end @@ -61,7 +61,7 @@ def initialize(_user) it "can't remove non accessible roles" do user = create(:user, spree_roles: [non_accessible_role]) - user.update_spree_roles([], ability: ability) + user.update_spree_roles([], ability:) expect(user.reload.spree_roles).to eq([non_accessible_role]) end diff --git a/core/spec/models/spree/credit_card_spec.rb b/core/spec/models/spree/credit_card_spec.rb index cb567c87687..6227e6d7791 100644 --- a/core/spec/models/spree/credit_card_spec.rb +++ b/core/spec/models/spree/credit_card_spec.rb @@ -89,7 +89,7 @@ def self.payment_states let!(:persisted_card) { Spree::CreditCard.find(credit_card.id) } let(:country) { create(:country, states_required: true) } - let(:state) { create(:state, country: country) } + let(:state) { create(:state, country:) } let(:valid_address_attributes) do { name: "Hugo Furst", diff --git a/core/spec/models/spree/customer_return_spec.rb b/core/spec/models/spree/customer_return_spec.rb index 3db59900158..da31b8dfcf7 100644 --- a/core/spec/models/spree/customer_return_spec.rb +++ b/core/spec/models/spree/customer_return_spec.rb @@ -97,7 +97,7 @@ let(:customer_return) { create(:customer_return, line_items_count: 2) } before do - Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(amount: amount, additional_tax_total: tax_amount) + Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(amount:, additional_tax_total: tax_amount) customer_return.reload end @@ -118,7 +118,7 @@ describe "#currency" do let(:order) { stub_model(Spree::Order, currency: "GBP") } - let(:customer_return) { stub_model(Spree::CustomerReturn, order: order) } + let(:customer_return) { stub_model(Spree::CustomerReturn, order:) } it 'returns the order currency' do expect(Spree::Config.currency).to eq("USD") @@ -131,7 +131,7 @@ let(:customer_return) { create(:customer_return, line_items_count: 2) } before do - Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(amount: amount) + Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(amount:) end subject { customer_return.amount } @@ -183,7 +183,7 @@ context ".after_save" do let(:inventory_unit) { create(:inventory_unit, state: 'shipped', order: create(:shipped_order)) } - let(:return_item) { build(:return_item, inventory_unit: inventory_unit) } + let(:return_item) { build(:return_item, inventory_unit:) } context "to the initial stock location" do it "should mark the received inventory units are returned" do @@ -287,7 +287,7 @@ end context 'when all return items have a reimbursement' do - let!(:reimbursement) { create(:reimbursement, customer_return: customer_return) } + let!(:reimbursement) { create(:reimbursement, customer_return:) } context 'when some reimbursements are not reimbursed' do it { is_expected.to be false } diff --git a/core/spec/models/spree/distributed_amounts_handler_spec.rb b/core/spec/models/spree/distributed_amounts_handler_spec.rb index cc11043675f..ffa9c1f1b6b 100644 --- a/core/spec/models/spree/distributed_amounts_handler_spec.rb +++ b/core/spec/models/spree/distributed_amounts_handler_spec.rb @@ -6,7 +6,7 @@ let(:order) do FactoryBot.create( :order_with_line_items, - line_items_attributes: line_items_attributes + line_items_attributes: ) end diff --git a/core/spec/models/spree/exchange_spec.rb b/core/spec/models/spree/exchange_spec.rb index 4c95f7572e7..655763e96fd 100644 --- a/core/spec/models/spree/exchange_spec.rb +++ b/core/spec/models/spree/exchange_spec.rb @@ -32,10 +32,10 @@ module Spree end describe "#perform!" do - let(:return_item) { create(:exchange_return_item, inventory_unit: inventory_unit) } + let(:return_item) { create(:exchange_return_item, inventory_unit:) } let(:return_items) { [return_item] } - let(:inventory_unit) { create(:inventory_unit, order: order, line_item: line_item) } + let(:inventory_unit) { create(:inventory_unit, order:, line_item:) } let(:order) { create(:shipped_order, line_items_count: 1) } let(:line_item) { order.line_items.first } diff --git a/core/spec/models/spree/fulfilment_changer_spec.rb b/core/spec/models/spree/fulfilment_changer_spec.rb index b850d2d4af7..4d2aba9cc1b 100644 --- a/core/spec/models/spree/fulfilment_changer_spec.rb +++ b/core/spec/models/spree/fulfilment_changer_spec.rb @@ -12,7 +12,7 @@ line_items_attributes: [ { quantity: current_shipment_inventory_unit_count, - variant: variant + variant: } ] ) @@ -26,11 +26,11 @@ let(:shipment_splitter) do described_class.new( - current_shipment: current_shipment, - desired_shipment: desired_shipment, - variant: variant, - quantity: quantity, - track_inventory: track_inventory + current_shipment:, + desired_shipment:, + variant:, + quantity:, + track_inventory: ) end @@ -103,7 +103,7 @@ let!(:stock_item) do variant.stock_items.find_or_create_by!( stock_location: desired_stock_location, - variant: variant, + variant:, ) end @@ -153,7 +153,7 @@ let!(:stock_item) do variant.stock_items.find_or_create_by!( stock_location: desired_stock_location, - variant: variant, + variant:, ) end @@ -207,7 +207,7 @@ let!(:stock_item) do variant.stock_items.find_or_create_by!( stock_location: desired_stock_location, - variant: variant, + variant:, ) end @@ -300,8 +300,8 @@ end context "when the original shipment had some backordered units" do - let(:current_stock_item) { current_shipment.stock_location.stock_items.find_by(variant: variant) } - let(:desired_stock_item) { desired_shipment.stock_location.stock_items.find_by(variant: variant) } + let(:current_stock_item) { current_shipment.stock_location.stock_items.find_by(variant:) } + let(:desired_stock_item) { desired_shipment.stock_location.stock_items.find_by(variant:) } let(:backordered_units) { 6 } before do @@ -385,7 +385,7 @@ line_items_attributes: [ { quantity: current_shipment_inventory_unit_count, - variant: variant + variant: } ] ) diff --git a/core/spec/models/spree/inventory_unit_spec.rb b/core/spec/models/spree/inventory_unit_spec.rb index c87f9184763..15ef2734c86 100644 --- a/core/spec/models/spree/inventory_unit_spec.rb +++ b/core/spec/models/spree/inventory_unit_spec.rb @@ -20,9 +20,9 @@ let(:order) do order = create(:order, state: 'complete', ship_address: create(:ship_address)) order.completed_at = Time.current - create(:shipment, order: order, stock_location: stock_location) + create(:shipment, order:, stock_location:) order.shipments.reload - create(:line_item, order: order, variant: stock_item.variant) + create(:line_item, order:, variant: stock_item.variant) order.line_items.reload order.tap(&:save!) end @@ -162,13 +162,13 @@ let(:line_item_additional_tax_total) { 10.00 } let(:line_item) do build(:line_item, { - quantity: quantity, + quantity:, additional_tax_total: line_item_additional_tax_total }) end subject do - build(:inventory_unit, line_item: line_item) + build(:inventory_unit, line_item:) end it 'is the correct amount' do @@ -181,13 +181,13 @@ let(:line_item_included_tax_total) { 10.00 } let(:line_item) do build(:line_item, { - quantity: quantity, + quantity:, included_tax_total: line_item_included_tax_total }) end subject do - build(:inventory_unit, line_item: line_item) + build(:inventory_unit, line_item:) end it 'is the correct amount' do @@ -200,13 +200,13 @@ let(:line_item_additional_tax_total) { 10.00 } let(:line_item) do build(:line_item, { - quantity: quantity, + quantity:, additional_tax_total: line_item_additional_tax_total }) end subject do - build(:inventory_unit, line_item: line_item) + build(:inventory_unit, line_item:) end it 'is the correct amount' do @@ -219,13 +219,13 @@ let(:line_item_included_tax_total) { 10.00 } let(:line_item) do build(:line_item, { - quantity: quantity, + quantity:, included_tax_total: line_item_included_tax_total }) end subject do - build(:inventory_unit, line_item: line_item) + build(:inventory_unit, line_item:) end it 'is the correct amount' do diff --git a/core/spec/models/spree/line_item_spec.rb b/core/spec/models/spree/line_item_spec.rb index e67dab00bc2..9d225059cbc 100644 --- a/core/spec/models/spree/line_item_spec.rb +++ b/core/spec/models/spree/line_item_spec.rb @@ -40,7 +40,7 @@ describe 'line item creation' do let(:variant) { create :variant } - subject(:line_item) { Spree::LineItem.new(variant: variant, order: order) } + subject(:line_item) { Spree::LineItem.new(variant:, order:) } # Tests for https://github.com/spree/spree/issues/3391 context 'before validation' do @@ -97,9 +97,9 @@ context 'setting a line item price' do let(:store) { create(:store, default: true) } - let(:order) { Spree::Order.new(currency: "RUB", store: store) } + let(:order) { Spree::Order.new(currency: "RUB", store:) } let(:variant) { Spree::Variant.new(product: Spree::Product.new) } - let(:line_item) { Spree::LineItem.new(order: order, variant: variant) } + let(:line_item) { Spree::LineItem.new(order:, variant:) } before { expect(variant).to receive(:price_for_options).at_least(:once).and_return(price) } @@ -150,7 +150,7 @@ describe 'money_price=' do let(:currency) { "USD" } - let(:new_price) { Spree::Money.new(99.00, currency: currency) } + let(:new_price) { Spree::Money.new(99.00, currency:) } it 'assigns a new price' do line_item.money_price = new_price diff --git a/core/spec/models/spree/order/callbacks_spec.rb b/core/spec/models/spree/order/callbacks_spec.rb index b254c5d1c50..96d9122dfba 100644 --- a/core/spec/models/spree/order/callbacks_spec.rb +++ b/core/spec/models/spree/order/callbacks_spec.rb @@ -24,7 +24,7 @@ let(:user) { double(:user, email: "test@example.com") } before do - allow(order).to receive_messages user: user + allow(order).to receive_messages(user:) end it "should assign the email address of the user" do diff --git a/core/spec/models/spree/order/checkout_spec.rb b/core/spec/models/spree/order/checkout_spec.rb index 1aa6d7495e3..ff9b2b43820 100644 --- a/core/spec/models/spree/order/checkout_spec.rb +++ b/core/spec/models/spree/order/checkout_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Spree::Order, type: :model do let!(:store) { create(:store) } - let(:order) { create(:order, store: store) } + let(:order) { create(:order, store:) } def assert_state_changed(order, from, to) state_change_exists = order.state_changes.where(previous_state: from, next_state: to).exists? @@ -168,7 +168,7 @@ def assert_state_changed(order, from, to) context "from address" do let(:ship_address) { create(:ship_address) } - let!(:line_item) { create(:line_item, order: order, price: 10) } + let!(:line_item) { create(:line_item, order:, price: 10) } let!(:shipping_method) { create(:shipping_method) } before do @@ -189,7 +189,7 @@ def assert_state_changed(order, from, to) it "recalculates tax and updates totals" do zone = create(:zone, countries: [order.tax_address.country]) - create(:tax_rate, tax_categories: [line_item.tax_category], amount: 0.05, zone: zone) + create(:tax_rate, tax_categories: [line_item.tax_category], amount: 0.05, zone:) order.next! expect(order).to have_attributes( adjustment_total: 0.5, @@ -242,11 +242,11 @@ def assert_state_changed(order, from, to) end context 'when order has default selected_shipping_rate_id', partial_double_verification: false do - let(:shipment) { create(:shipment, order: order) } + let(:shipment) { create(:shipment, order:) } let(:shipping_method) { create(:shipping_method) } let(:shipping_rate) { [ - Spree::ShippingRate.create!(shipping_method: shipping_method, cost: 10.00, shipment: shipment) + Spree::ShippingRate.create!(shipping_method:, cost: 10.00, shipment:) ] } @@ -267,7 +267,7 @@ def assert_state_changed(order, from, to) context "cannot transition to delivery" do context "if there are no shipping rates for any shipment" do - let!(:line_item){ create :line_item, order: order } + let!(:line_item){ create :line_item, order: } before do order.state = 'address' order.email = 'user@example.com' @@ -364,7 +364,7 @@ def assert_state_changed(order, from, to) before do user = create(:user, email: 'solidus@example.org', bill_address: user_bill_address) - default_credit_card.update(user: user) + default_credit_card.update(user:) wallet_payment_source = user.wallet.add(default_credit_card) user.wallet.default_wallet_payment_source = wallet_payment_source order.user = user @@ -503,7 +503,7 @@ def assert_state_changed(order, from, to) context "with a payment in the pending state" do let(:order) { create :order_ready_to_complete } - let(:payment) { create :payment, order: order, state: "pending", amount: order.total } + let(:payment) { create :payment, order:, state: "pending", amount: order.total } it "allows the order to complete" do expect { order.complete! }. @@ -556,7 +556,7 @@ def assert_state_changed(order, from, to) order.user = FactoryBot.create(:user) order.store = FactoryBot.create(:store) order.email = 'solidus@example.org' - order.payments << FactoryBot.create(:payment, order: order) + order.payments << FactoryBot.create(:payment, order:) # make sure we will actually capture a payment allow(order).to receive_messages(payment_required?: true) @@ -610,7 +610,7 @@ def assert_state_changed(order, from, to) let(:order) { create(:order_with_line_items) } it 'can complete the order' do - create(:payment, state: 'completed', order: order, amount: order.total) + create(:payment, state: 'completed', order:, amount: order.total) order.recalculate expect(order.complete).to eq(true) end @@ -662,7 +662,7 @@ def assert_state_changed(order, from, to) # Regression test for https://github.com/spree/spree/issues/3665 context "with only a complete step" do - let!(:line_item){ create :line_item, order: order } + let!(:line_item){ create :line_item, order: } before do @old_checkout_flow = Spree::Order.checkout_flow diff --git a/core/spec/models/spree/order/finalizing_spec.rb b/core/spec/models/spree/order/finalizing_spec.rb index b580e2545ed..c4964b9ea24 100644 --- a/core/spec/models/spree/order/finalizing_spec.rb +++ b/core/spec/models/spree/order/finalizing_spec.rb @@ -25,7 +25,7 @@ end it "should freeze all adjustments" do - adjustment = create(:adjustment, order: order) + adjustment = create(:adjustment, order:) expect { order.complete! }.to change { adjustment.reload.finalized }.from(false).to(true) end diff --git a/core/spec/models/spree/order/outstanding_balance_integration_spec.rb b/core/spec/models/spree/order/outstanding_balance_integration_spec.rb index 040fb771473..c2d067259e2 100644 --- a/core/spec/models/spree/order/outstanding_balance_integration_spec.rb +++ b/core/spec/models/spree/order/outstanding_balance_integration_spec.rb @@ -35,11 +35,11 @@ end context 'when the order is fully paid' do - let!(:payment) { create(:payment, :completed, order: order, amount: order.total) } + let!(:payment) { create(:payment, :completed, order:, amount: order.total) } it { should eq 0 } context 'and there is a full refund' do - let!(:refund) { create(:refund, payment: payment, amount: payment.amount) } + let!(:refund) { create(:refund, payment:, amount: payment.amount) } it { should eq 19 } end @@ -53,12 +53,12 @@ end context 'and there is a full refund' do - let!(:refund) { create(:refund, payment: payment, amount: payment.amount) } + let!(:refund) { create(:refund, payment:, amount: payment.amount) } it { should eq 0 } end context 'and there is a partial refund' do - let!(:refund) { create(:refund, payment: payment, amount: 6) } + let!(:refund) { create(:refund, payment:, amount: 6) } it { should eq(-13) } end end @@ -67,15 +67,15 @@ before do item_amount = item_1.total order.contents.remove(item_1.variant) - create(:refund, payment: payment, amount: item_amount) + create(:refund, payment:, amount: item_amount) end it { should eq(0) } end context 'when the order is adjusted downward by an admin' do - let!(:adjustment) { create(:adjustment, order: order, adjustable: item_1, amount: -1, source: nil) } - let!(:refund) { create(:refund, payment: payment, amount: 1) } + let!(:adjustment) { create(:adjustment, order:, adjustable: item_1, amount: -1, source: nil) } + let!(:refund) { create(:refund, payment:, amount: 1) } it { should eq(0) } end @@ -107,11 +107,11 @@ end context 'when the order is partly paid' do - let!(:payment) { create(:payment, :completed, order: order, amount: 10) } + let!(:payment) { create(:payment, :completed, order:, amount: 10) } it { should eq 9 } context 'and there is a full refund' do - let!(:refund) { create(:refund, payment: payment, amount: payment.amount) } + let!(:refund) { create(:refund, payment:, amount: payment.amount) } it { should eq 19 } end @@ -125,12 +125,12 @@ end context 'and there is a full refund' do - let!(:refund) { create(:refund, payment: payment, amount: payment.amount) } + let!(:refund) { create(:refund, payment:, amount: payment.amount) } it { should eq 0 } end context 'and there is a partial refund' do - let!(:refund) { create(:refund, payment: payment, amount: 6) } + let!(:refund) { create(:refund, payment:, amount: 6) } it { should eq(-4) } end end diff --git a/core/spec/models/spree/order/payment_spec.rb b/core/spec/models/spree/order/payment_spec.rb index e3ea791d98c..f9487bafc7e 100644 --- a/core/spec/models/spree/order/payment_spec.rb +++ b/core/spec/models/spree/order/payment_spec.rb @@ -18,12 +18,12 @@ module Spree let(:payment_method) { create(:credit_card_payment_method) } let!(:payment_1) do - create(:payment, payment_method: payment_method, order: order, amount: 50) + create(:payment, payment_method:, order:, amount: 50) end context 'sharing the same payment method' do let!(:payment_2) do - create(:payment, payment_method: payment_method, order: order, amount: 50) + create(:payment, payment_method:, order:, amount: 50) end it 'processes only new payments' do @@ -39,7 +39,7 @@ module Spree end context 'with different payment methods that are store credit' do - let!(:payment_2) { create(:store_credit_payment, order: order, amount: 50) } + let!(:payment_2) { create(:store_credit_payment, order:, amount: 50) } it 'processes all checkout payments' do order.process_payments! @@ -53,7 +53,7 @@ module Spree end context 'with over paid payments' do - let!(:payment_3) { create(:store_credit_payment, order: order, amount: 50) } + let!(:payment_3) { create(:store_credit_payment, order:, amount: 50) } it 'does not go over total for order' do order.process_payments! @@ -71,8 +71,8 @@ module Spree context 'with failed payments' do let!(:payment_2) do create(:payment, - payment_method: payment_method, - order: order, + payment_method:, + order:, amount: 50, state: 'failed') end @@ -205,9 +205,9 @@ module Spree # Set the payment amount to actually be the order total of 110 reimbursement.order.payments.first.update_column :amount, amount # Creates a refund of 110 - create :refund, amount: amount, + create(:refund, amount:, payment: reimbursement.order.payments.first, - reimbursement: reimbursement + reimbursement:) # Update the order totals so payment_total goes to 0 reflecting the refund.. order.recalculate end diff --git a/core/spec/models/spree/order/state_machine_spec.rb b/core/spec/models/spree/order/state_machine_spec.rb index 0f9920bf424..6ee3032a085 100644 --- a/core/spec/models/spree/order/state_machine_spec.rb +++ b/core/spec/models/spree/order/state_machine_spec.rb @@ -14,7 +14,7 @@ context "when payment processing succeeds" do let!(:payment) do - create(:payment, state: 'checkout', order: order) + create(:payment, state: 'checkout', order:) end it "should finalize order when transitioning to complete state" do @@ -25,7 +25,7 @@ context "when credit card processing fails" do let!(:payment) do - create(:payment, :failing, state: 'checkout', order: order) + create(:payment, :failing, state: 'checkout', order:) end it "should not complete the order" do @@ -85,7 +85,7 @@ describe "#complete" do context "when the confirm step has been taken out of the checkout flow" do - let!(:payment) { create(:payment, state: 'checkout', order: order) } + let!(:payment) { create(:payment, state: 'checkout', order:) } before :all do class Spree::Order diff --git a/core/spec/models/spree/order_cancellations_spec.rb b/core/spec/models/spree/order_cancellations_spec.rb index 08d7bd8145e..a120078b98e 100644 --- a/core/spec/models/spree/order_cancellations_spec.rb +++ b/core/spec/models/spree/order_cancellations_spec.rb @@ -102,7 +102,7 @@ subject { described_class.new(order).short_ship(inventory_units) } let(:quantity) { 4 } - let!(:order) { create(:order_with_line_items, line_items_attributes: [{ quantity: quantity }]) } + let!(:order) { create(:order_with_line_items, line_items_attributes: [{ quantity: }]) } let(:inventory_units) { Spree::InventoryUnit.find(order.line_items.first.inventory_units.pluck(:id)) } it "adjusts the order" do @@ -155,7 +155,7 @@ # make the total $1.67 so it divides unevenly line_item.adjustments.create!( - order: order, + order:, amount: 0.01, label: 'some promo', source: nil, diff --git a/core/spec/models/spree/order_inventory_spec.rb b/core/spec/models/spree/order_inventory_spec.rb index 8383322e39d..bda449affb7 100644 --- a/core/spec/models/spree/order_inventory_spec.rb +++ b/core/spec/models/spree/order_inventory_spec.rb @@ -302,7 +302,7 @@ context "inventory unit line item and variant points to different products" do let(:new_quantity) { 0 } - let(:different_line_item) { create(:line_item, order: order) } + let(:different_line_item) { create(:line_item, order:) } let!(:different_inventory) do shipment.set_up_inventory("on_hand", variant, order, different_line_item) @@ -317,7 +317,7 @@ end context 'when the order has no suitable shipment for the variant' do - let(:new_line_item) { create :line_item, order: order } + let(:new_line_item) { create :line_item, order: } before do new_line_item.inventory_units.destroy_all diff --git a/core/spec/models/spree/order_shipping_spec.rb b/core/spec/models/spree/order_shipping_spec.rb index ec60f5ae615..b8ec4ef4c7b 100644 --- a/core/spec/models/spree/order_shipping_spec.rb +++ b/core/spec/models/spree/order_shipping_spec.rb @@ -56,10 +56,10 @@ def emails describe "#ship" do subject do order.shipping.ship( - inventory_units: inventory_units, - stock_location: stock_location, - address: address, - shipping_method: shipping_method + inventory_units:, + stock_location:, + address:, + shipping_method: ) end @@ -74,10 +74,10 @@ def emails context "with an external_number" do subject do order.shipping.ship( - inventory_units: inventory_units, - stock_location: stock_location, - address: address, - shipping_method: shipping_method, + inventory_units:, + stock_location:, + address:, + shipping_method:, external_number: 'some-external-number' ) end @@ -90,10 +90,10 @@ def emails context "with a tracking number" do subject do order.shipping.ship( - inventory_units: inventory_units, - stock_location: stock_location, - address: address, - shipping_method: shipping_method, + inventory_units:, + stock_location:, + address:, + shipping_method:, tracking_number: 'tracking-number' ) end @@ -106,10 +106,10 @@ def emails context "when told to suppress the mailer" do subject do order.shipping.ship( - inventory_units: inventory_units, - stock_location: stock_location, - address: address, - shipping_method: shipping_method, + inventory_units:, + stock_location:, + address:, + shipping_method:, suppress_mailer: true ) end @@ -220,7 +220,7 @@ def emails it "sets the order to shipped state" do order.shipping.ship_shipment(order.shipments.first) - unshipped_shipment = create(:shipment, order: order, state: "ready") + unshipped_shipment = create(:shipment, order:, state: "ready") order.reload order.recalculate @@ -247,7 +247,7 @@ def emails let(:shipment) do FactoryBot.create( :shipment, - order: order + order: ) end diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index cdf75f80306..07296deb22f 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Spree::Order, type: :model do let(:store) { create(:store) } let(:user) { create(:user, email: "solidus@example.com") } - let(:order) { create(:order, user: user, store: store) } + let(:order) { create(:order, user:, store:) } context '#store' do it { is_expected.to respond_to(:store) } @@ -77,10 +77,10 @@ context "when the payment is fully refunded" do let(:order) { create(:completed_order_with_totals) } let(:payment_amount) { 50 } - let(:payment) { create(:payment, order: order, amount: payment_amount, state: 'completed') } + let(:payment) { create(:payment, order:, amount: payment_amount, state: 'completed') } it "cancels the order" do - create(:refund, payment: payment, amount: payment_amount) + create(:refund, payment:, amount: payment_amount) expect{ subject }.to change{ order.can_cancel? }.from(true).to(false) expect(order).to be_canceled @@ -117,7 +117,7 @@ context 'with a store credit payment' do let(:order) { create(:completed_order_with_totals) } - let(:payment) { create(:store_credit_payment, amount: order.total, order: order) } + let(:payment) { create(:store_credit_payment, amount: order.total, order:) } context 'when the payment is pending' do let(:store_credit) { payment.source } @@ -239,9 +239,9 @@ let!(:order) { create(:order) } before do - create(:line_item, order: order) - create(:shipment, order: order) - create(:adjustment, source: nil, adjustable: order, order: order) + create(:line_item, order:) + create(:shipment, order:) + create(:adjustment, source: nil, adjustable: order, order:) order.recalculate # Make sure we are asserting changes @@ -274,7 +274,7 @@ order.cancellations.short_ship([order.inventory_units.first]) expect(order.outstanding_balance).to be_negative expect(order.payment_state).to eq('credit_owed') - create(:refund, amount: order.outstanding_balance.abs, payment: payment, transaction_id: nil).perform! + create(:refund, amount: order.outstanding_balance.abs, payment:, transaction_id: nil).perform! order.reload expect(order.outstanding_balance).to eq(0) expect(order.payment_state).to eq('paid') @@ -373,7 +373,7 @@ def merge!(other_order, user = nil) context "ensure shipments will be updated" do subject(:order) { create :order } before do - Spree::Shipment.create!(order: order) + Spree::Shipment.create!(order:) end ['payment', 'confirm'].each do |order_state| @@ -485,10 +485,10 @@ def merge!(other_order, user = nil) end describe "#tax_address" do - let(:order) { build(:order, ship_address: ship_address, bill_address: bill_address, store: store) } + let(:order) { build(:order, ship_address:, bill_address:, store:) } let(:store) { build(:store) } - before { stub_spree_preferences(tax_using_ship_address: tax_using_ship_address) } + before { stub_spree_preferences(tax_using_ship_address:) } subject { order.tax_address } context "when the order has no addresses" do @@ -988,7 +988,7 @@ def generate context "#amount" do before do - @order = create(:order, user: user) + @order = create(:order, user:) @order.line_items = [create(:line_item, price: 1.0, quantity: 2), create(:line_item, price: 1.0, quantity: 1)] end @@ -1084,8 +1084,8 @@ def generate context "#refund_total" do let(:order) { create(:order_with_line_items) } - let!(:payment) { create(:payment_with_refund, order: order, amount: 5, refund_amount: 3) } - let!(:payment2) { create(:payment_with_refund, order: order, amount: 5, refund_amount: 2.5) } + let!(:payment) { create(:payment_with_refund, order:, amount: 5, refund_amount: 3) } + let!(:payment2) { create(:payment_with_refund, order:, amount: 5, refund_amount: 2.5) } it "sums the reimbursment refunds on the order" do expect(order.refund_total).to eq(5.5) @@ -1215,7 +1215,7 @@ def generate context "with valid payments" do let(:order) { payment.order } let!(:payment) { create(:store_credit_payment) } - let!(:second_payment) { create(:store_credit_payment, order: order) } + let!(:second_payment) { create(:store_credit_payment, order:) } subject { order } @@ -1246,7 +1246,7 @@ def generate let(:order) { create(:order, total: order_total) } context "there is a credit card payment" do - let!(:cc_payment) { create(:payment, order: order, amount: order_total) } + let!(:cc_payment) { create(:payment, order:, amount: order_total) } before do # callbacks recalculate total based on line items @@ -1266,9 +1266,9 @@ def generate end context 'there is store credit in another currency' do - let(:order) { create(:order_with_totals, user: user, line_items_price: order_total).tap(&:recalculate) } - let!(:store_credit_usd) { create(:store_credit, user: user, amount: 1, currency: 'USD') } - let!(:store_credit_gbp) { create(:store_credit, user: user, amount: 1, currency: 'GBP') } + let(:order) { create(:order_with_totals, user:, line_items_price: order_total).tap(&:recalculate) } + let!(:store_credit_usd) { create(:store_credit, user:, amount: 1, currency: 'USD') } + let!(:store_credit_gbp) { create(:store_credit, user:, amount: 1, currency: 'GBP') } let(:user) { create(:user) } it 'only adds the credit in the matching currency' do @@ -1303,7 +1303,7 @@ def generate context "there is a credit card payment" do it "invalidates the credit card payment" do - cc_payment = create(:payment, order: order) + cc_payment = create(:payment, order:) expect { subject }.to change { cc_payment.reload.state }.to 'invalid' end end @@ -1323,7 +1323,7 @@ def generate end context "there is a completed credit card payment" do - let!(:cc_payment) { create(:payment, order: order, state: "completed", amount: 100) } + let!(:cc_payment) { create(:payment, order:, state: "completed", amount: 100) } it "successfully creates the store credit payments" do expect { subject }.to change { order.payments.count }.from(1).to(2) @@ -1332,7 +1332,7 @@ def generate end context "there is a credit card payment" do - let!(:cc_payment) { create(:payment, order: order, state: "checkout") } + let!(:cc_payment) { create(:payment, order:, state: "checkout") } before do subject @@ -1393,7 +1393,7 @@ def generate order.covered_by_store_credit end - let(:order) { create(:order_with_line_items, user: user, store: store) } + let(:order) { create(:order_with_line_items, user:, store:) } context "order doesn't have an associated user" do let(:user) { nil } @@ -1402,12 +1402,12 @@ def generate context "order has an associated user" do context "user has enough store credit to pay for the order" do - let!(:credit) { create(:store_credit, user: user, amount: 1000) } + let!(:credit) { create(:store_credit, user:, amount: 1000) } it { is_expected.to eq(true) } end context "user does not have enough store credit to pay for the order" do - let!(:credit) { create(:store_credit, user: user, amount: 1) } + let!(:credit) { create(:store_credit, user:, amount: 1) } it { is_expected.to eq(false) } end end @@ -1424,7 +1424,7 @@ def generate end context "order has an associated user" do - let!(:credit) { create(:store_credit, user: user, amount: 25) } + let!(:credit) { create(:store_credit, user:, amount: 25) } it { is_expected.to eq(25) } end end @@ -1519,7 +1519,7 @@ def generate subject { create(:order) } - before { allow(subject).to receive_messages(total_applicable_store_credit: total_applicable_store_credit) } + before { allow(subject).to receive_messages(total_applicable_store_credit:) } it "returns a money instance" do expect(subject.display_total_applicable_store_credit).to be_a(Spree::Money) @@ -1562,7 +1562,7 @@ def generate subject { create(:order) } - before { allow(subject).to receive_messages(order_total_after_store_credit: order_total_after_store_credit) } + before { allow(subject).to receive_messages(order_total_after_store_credit:) } it "returns a money instance" do expect(subject.display_order_total_after_store_credit).to be_a(Spree::Money) @@ -1578,7 +1578,7 @@ def generate subject { create(:order) } - before { allow(subject).to receive_messages(total_available_store_credit: total_available_store_credit) } + before { allow(subject).to receive_messages(total_available_store_credit:) } it "returns a money instance" do expect(subject.display_total_available_store_credit).to be_a(Spree::Money) @@ -1596,8 +1596,8 @@ def generate subject { create(:order) } before do - allow(subject).to receive_messages(total_available_store_credit: total_available_store_credit, - total_applicable_store_credit: total_applicable_store_credit) + allow(subject).to receive_messages(total_available_store_credit:, + total_applicable_store_credit:) end it "returns a money instance" do @@ -1667,7 +1667,7 @@ def generate subject { order.create_shipments_for_line_item(line_item) } let(:order) { create :order, shipments: [] } - let(:line_item) { build(:line_item, order: order) } + let(:line_item) { build(:line_item, order:) } it 'creates at least one new shipment for the order' do expect { subject }.to change { order.shipments.count }.from(0).to(1) @@ -1699,7 +1699,7 @@ def initialize(order) Object.send(:remove_const, :TestInventoryUnitBuilder) end - let(:arbitrary_inventory_unit) { build :inventory_unit, order: order, line_item: line_item, variant: line_item.variant } + let(:arbitrary_inventory_unit) { build :inventory_unit, order:, line_item:, variant: line_item.variant } it "relies on the custom builder" do expect { subject }.to change { order.shipments.count }.from(0).to(1) @@ -1846,7 +1846,7 @@ def validate(line_item) describe ".by_customer" do let(:user) { create(:user, email: "customer@example.com") } - let!(:order) { create(:order, user: user) } + let!(:order) { create(:order, user:) } let!(:other_order) { create(:order) } let(:email) { user.email } @@ -1914,7 +1914,7 @@ def validate(line_item) end describe "#shipped_shipments" do - let(:order) { create(:order, shipments: shipments) } + let(:order) { create(:order, shipments:) } let(:shipments) { [shipped_shipment, unshipped_shipment] } let(:shipped_shipment) { create(:shipment, state: "shipped") } let(:unshipped_shipment) { create(:shipment, state: "ready") } @@ -1930,7 +1930,7 @@ def validate(line_item) let(:bill_address) { create(:address, name: "John Doe") } let(:ship_address) { create(:address, name: "Jane Doe") } - let(:order) { create(:order, bill_address: bill_address, ship_address: ship_address) } + let(:order) { create(:order, bill_address:, ship_address:) } subject { order.name } @@ -1998,7 +1998,7 @@ def validate(line_item) end describe "#shipping_eq_billing_address?" do - let(:order) { create(:order, bill_address: bill_address, ship_address: ship_address) } + let(:order) { create(:order, bill_address:, ship_address:) } let(:bill_address) { create(:address) } let(:ship_address) { create(:address) } @@ -2014,7 +2014,7 @@ def validate(line_item) end describe "#can_approve?" do - let(:order) { create(:order, approved_at: approved_at) } + let(:order) { create(:order, approved_at:) } let(:approved_at) { nil } subject { order.can_approve? } @@ -2082,7 +2082,7 @@ def validate(line_item) end describe "#shipped?" do - let(:order) { Spree::Order.new(shipment_state: shipment_state) } + let(:order) { Spree::Order.new(shipment_state:) } let(:shipment_state) { "ready" } subject { order.shipped? } diff --git a/core/spec/models/spree/order_update_attributes_spec.rb b/core/spec/models/spree/order_update_attributes_spec.rb index ed674c7a94a..df136baafe4 100644 --- a/core/spec/models/spree/order_update_attributes_spec.rb +++ b/core/spec/models/spree/order_update_attributes_spec.rb @@ -7,7 +7,7 @@ module Spree let(:order) { create(:order) } let(:payment_method) { create(:payment_method) } let(:request_env) { nil } - let(:update) { described_class.new(order, attributes, request_env: request_env) } + let(:update) { described_class.new(order, attributes, request_env:) } context 'empty attributes' do let(:attributes){ {} } diff --git a/core/spec/models/spree/order_updater_spec.rb b/core/spec/models/spree/order_updater_spec.rb index c6b80031935..86c9a6b102a 100644 --- a/core/spec/models/spree/order_updater_spec.rb +++ b/core/spec/models/spree/order_updater_spec.rb @@ -11,13 +11,13 @@ module Spree context "order totals" do before do 2.times do - create(:line_item, order: order, price: 10) + create(:line_item, order:, price: 10) end end context 'with refund' do it "updates payment totals" do - create(:payment_with_refund, order: order, amount: 33.25, refund_amount: 3) + create(:payment_with_refund, order:, amount: 33.25, refund_amount: 3) updater.recalculate expect(order.payment_total).to eq(30.25) end @@ -30,16 +30,16 @@ module Spree end it "update shipment total" do - create(:shipment, order: order, cost: 10) + create(:shipment, order:, cost: 10) expect { updater.recalculate }.to change { order.shipment_total }.to 10 end context 'with a source-less line item adjustment' do - let(:line_item) { create(:line_item, order: order, price: 10) } + let(:line_item) { create(:line_item, order:, price: 10) } before do - create(:adjustment, source: nil, adjustable: line_item, order: order, amount: -5) + create(:adjustment, source: nil, adjustable: line_item, order:, amount: -5) end it "updates the line item total" do @@ -48,7 +48,7 @@ module Spree end it "update order adjustments" do - create(:adjustment, adjustable: order, order: order, source: nil, amount: 10) + create(:adjustment, adjustable: order, order:, source: nil, amount: 10) expect { updater.recalculate @@ -76,13 +76,13 @@ module Spree let(:order) do create( :order_with_line_items, - line_items_attributes: [{ price: 10, variant: variant }], - ship_address: ship_address, + line_items_attributes: [{ price: 10, variant: }], + ship_address:, ) end let(:line_item) { order.line_items[0] } - let(:variant) { create(:variant, tax_category: tax_category) } + let(:variant) { create(:variant, tax_category:) } let(:tax_category) { create(:tax_category) } context 'when the item quantity has changed' do @@ -114,7 +114,7 @@ module Spree order_taxes: [ Spree::Tax::ItemTax.new( label: "Delivery Fee", - tax_rate: tax_rate, + tax_rate:, amount: 2.60, included_in_price: false ) @@ -123,7 +123,7 @@ module Spree Spree::Tax::ItemTax.new( item_id: line_item.id, label: "Item Tax", - tax_rate: tax_rate, + tax_rate:, amount: 1.40, included_in_price: false ) @@ -169,15 +169,15 @@ module Spree ["shipped", "ready", "pending"].each do |state| it "is #{state}" do - create(:shipment, order: order, state: state) + create(:shipment, order:, state:) updater.update_shipment_state expect(order.shipment_state).to eq(state) end end it "is partial" do - create(:shipment, order: order, state: 'pending') - create(:shipment, order: order, state: 'ready') + create(:shipment, order:, state: 'pending') + create(:shipment, order:, state: 'ready') updater.update_shipment_state expect(order.shipment_state).to eq('partial') end @@ -190,7 +190,7 @@ module Spree context 'no valid payments with non-zero order total' do it "is failed" do - create(:payment, order: order, state: 'invalid') + create(:payment, order:, state: 'invalid') order.total = 1 order.payment_total = 0 @@ -263,7 +263,7 @@ module Spree it "is credit_owed" do order.payment_total = 30 order.total = 30 - create(:payment, order: order, state: 'completed', amount: 30) + create(:payment, order:, state: 'completed', amount: 30) expect { updater.update_payment_state }.to change { order.payment_state }.to 'credit_owed' @@ -296,7 +296,7 @@ module Spree end context 'with a shipment' do - before { create(:shipment, order: order) } + before { create(:shipment, order:) } let(:shipment){ order.shipments[0] } it "updates each shipment" do @@ -335,7 +335,7 @@ module Spree end context "with item with no adjustment and incorrect totals" do - let!(:line_item) { create(:line_item, order: order, price: 10) } + let!(:line_item) { create(:line_item, order:, price: 10) } it "updates the totals" do line_item.update!(adjustment_total: 100) diff --git a/core/spec/models/spree/payment/cancellation_spec.rb b/core/spec/models/spree/payment/cancellation_spec.rb index 0c1ac38ed3d..a6e6b3e44ad 100644 --- a/core/spec/models/spree/payment/cancellation_spec.rb +++ b/core/spec/models/spree/payment/cancellation_spec.rb @@ -21,7 +21,7 @@ subject { described_class.new.cancel(payment) } let(:payment_method) { create(:payment_method) } - let(:payment) { create(:payment, payment_method: payment_method, amount: 10) } + let(:payment) { create(:payment, payment_method:, amount: 10) } context 'if payment method returns void response' do before do diff --git a/core/spec/models/spree/payment_create_spec.rb b/core/spec/models/spree/payment_create_spec.rb index c0c1ae173c0..ff20feeac88 100644 --- a/core/spec/models/spree/payment_create_spec.rb +++ b/core/spec/models/spree/payment_create_spec.rb @@ -5,9 +5,9 @@ module Spree RSpec.describe PaymentCreate do let(:user) { nil } - let(:order) { create :order, user: user } + let(:order) { create :order, user: } let(:request_env) { {} } - let(:payment_create) { described_class.new(order, attributes, request_env: request_env) } + let(:payment_create) { described_class.new(order, attributes, request_env:) } let(:payment_method) { create(:payment_method) } let(:new_payment) { payment_create.build } @@ -28,7 +28,7 @@ module Spree let(:attributes) do { amount: 100, - payment_method: payment_method, + payment_method:, source_attributes: { expiry: "01 / 99", number: '1234567890123', @@ -55,7 +55,7 @@ module Spree let(:attributes) do { amount: 100, - payment_method: payment_method, + payment_method:, source_attributes: { expiry: "1 / 12" } } end @@ -74,7 +74,7 @@ module Spree let(:valid_attributes) do { amount: 100, - payment_method: payment_method, + payment_method:, source_attributes: { expiry: "01 / 99", number: '1234567890123', @@ -116,7 +116,7 @@ module Spree it "creates a payment with all attributes" do expect(new_payment).to have_attributes( amount: 100, - payment_method: payment_method, + payment_method:, source: kind_of(CreditCard) ) end diff --git a/core/spec/models/spree/payment_method/check_spec.rb b/core/spec/models/spree/payment_method/check_spec.rb index c4b3b26bd4f..5848c82f091 100644 --- a/core/spec/models/spree/payment_method/check_spec.rb +++ b/core/spec/models/spree/payment_method/check_spec.rb @@ -7,7 +7,7 @@ subject { described_class.new } context "#can_capture?" do - let(:payment) { create(:payment, order: order, state: state) } + let(:payment) { create(:payment, order:, state:) } context "with payment in state checkout" do let(:state) { "checkout" } @@ -35,7 +35,7 @@ end context "#can_void?" do - let(:payment) { create(:payment, order: order, state: state) } + let(:payment) { create(:payment, order:, state:) } context "with payment in state checkout" do let(:state) { "checkout" } diff --git a/core/spec/models/spree/payment_method/credit_card_spec.rb b/core/spec/models/spree/payment_method/credit_card_spec.rb index 42e9c45c03b..b9247a75cf4 100644 --- a/core/spec/models/spree/payment_method/credit_card_spec.rb +++ b/core/spec/models/spree/payment_method/credit_card_spec.rb @@ -6,19 +6,19 @@ context "fetching payment sources" do let(:store) { create :store } let(:user) { create :user } - let(:order) { Spree::Order.create(user: user, completed_at: completed_at, store: store) } + let(:order) { Spree::Order.create(user:, completed_at:, store:) } let(:payment_method) { create(:credit_card_payment_method) } let(:cc) do create(:credit_card, - payment_method: payment_method, + payment_method:, gateway_customer_profile_id: "EFWE", user: cc_user) end let(:payment) do - create(:payment, order: order, source: cc, payment_method: payment_method) + create(:payment, order:, source: cc, payment_method:) end context 'order is not complete and credit card user is nil' do diff --git a/core/spec/models/spree/payment_method/store_credit_spec.rb b/core/spec/models/spree/payment_method/store_credit_spec.rb index 6a1127b1807..6a99c22522c 100644 --- a/core/spec/models/spree/payment_method/store_credit_spec.rb +++ b/core/spec/models/spree/payment_method/store_credit_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Spree::PaymentMethod::StoreCredit do let(:order) { create(:order) } - let(:payment) { create(:payment, order: order) } + let(:payment) { create(:payment, order:) } let(:gateway_options) { payment.gateway_options } context "#authorize" do @@ -14,7 +14,7 @@ let(:auth_amount) { store_credit.amount_remaining * 100 } let(:store_credit) { create(:store_credit) } - let(:gateway_options) { super().merge(originator: originator) } + let(:gateway_options) { super().merge(originator:) } let(:originator) { nil } context 'without an invalid store credit' do @@ -70,10 +70,10 @@ let(:capture_amount) { 10_00 } let(:auth_code) { auth_event.authorization_code } - let(:gateway_options) { super().merge(originator: originator) } + let(:gateway_options) { super().merge(originator:) } let(:authorized_amount) { capture_amount / 100.0 } - let(:auth_event) { create(:store_credit_auth_event, store_credit: store_credit, amount: authorized_amount) } + let(:auth_event) { create(:store_credit_auth_event, store_credit:, amount: authorized_amount) } let(:store_credit) { create(:store_credit, amount_authorized: authorized_amount) } let(:originator) { nil } @@ -132,7 +132,7 @@ end let(:auth_code) { auth_event.authorization_code } - let(:gateway_options) { super().merge(originator: originator) } + let(:gateway_options) { super().merge(originator:) } let(:auth_event) { create(:store_credit_auth_event) } let(:originator) { nil } @@ -175,10 +175,10 @@ store_credit = create(:store_credit) auth_code = store_credit.generate_authorization_code store_credit.store_credit_events.create!(action: Spree::StoreCredit::ELIGIBLE_ACTION, - amount: amount, + amount:, authorization_code: auth_code) store_credit.store_credit_events.create!(action: Spree::StoreCredit::CAPTURE_ACTION, - amount: amount, + amount:, authorization_code: auth_code) resp = subject.purchase(amount * 100.0, store_credit, gateway_options) @@ -191,7 +191,7 @@ store_credit = create(:store_credit) auth_code = store_credit.generate_authorization_code store_credit.store_credit_events.create!(action: Spree::StoreCredit::ELIGIBLE_ACTION, - amount: amount, + amount:, authorization_code: auth_code) resp = subject.purchase(amount * 100.0, store_credit, gateway_options) @@ -207,7 +207,7 @@ let(:credit_amount) { 100.0 } let(:auth_code) { auth_event.authorization_code } - let(:gateway_options) { super().merge(originator: originator) } + let(:gateway_options) { super().merge(originator:) } let(:auth_event) { create(:store_credit_auth_event) } let(:originator) { nil } @@ -270,7 +270,7 @@ create(:store_credit_capture_event, authorization_code: auth_code, amount: captured_amount, - store_credit: store_credit) + store_credit:) end it { is_expected.to be(false) } @@ -280,8 +280,8 @@ let!(:payment) do create(:payment, - order: order, - payment_method: payment_method, + order:, + payment_method:, source: store_credit, amount: captured_amount, response_code: auth_code) @@ -301,7 +301,7 @@ create(:store_credit_auth_event, authorization_code: auth_code, amount: captured_amount, - store_credit: store_credit) + store_credit:) end it_behaves_like "a spree payment method" diff --git a/core/spec/models/spree/payment_method_spec.rb b/core/spec/models/spree/payment_method_spec.rb index 35dce08a1bb..2b1ce78216d 100644 --- a/core/spec/models/spree/payment_method_spec.rb +++ b/core/spec/models/spree/payment_method_spec.rb @@ -221,7 +221,7 @@ def credit; 'credit'; end end describe "#try_void" do - let(:payment) { create(:payment, payment_method: payment_method) } + let(:payment) { create(:payment, payment_method:) } context "when the payment method supports payment profiles" do let(:payment_method) { create(:credit_card_payment_method) } diff --git a/core/spec/models/spree/payment_spec.rb b/core/spec/models/spree/payment_spec.rb index 820aee38edd..c3d12681e5b 100644 --- a/core/spec/models/spree/payment_spec.rb +++ b/core/spec/models/spree/payment_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Spree::Payment, type: :model do let(:store) { create :store } - let(:order) { Spree::Order.create(store: store) } + let(:order) { Spree::Order.create(store:) } let(:refund_reason) { create(:refund_reason) } let(:gateway) do @@ -268,7 +268,7 @@ describe 'billing_address option' do context 'when the source is a credit card with an address' do - let(:card) { create(:credit_card, address: address) } + let(:card) { create(:credit_card, address:) } let(:address) { create(:address) } it 'sends the credit card address' do @@ -672,7 +672,7 @@ payment.amount = 100 expect { - create(:refund, payment: payment, amount: 80) + create(:refund, payment:, amount: 80) }.to change { payment.credit_allowed }.from(100).to(20) end end @@ -700,8 +700,8 @@ context 'when refund total equals payment amount' do before do - create(:refund, payment: payment, amount: 50) - create(:refund, payment: payment, amount: 50) + create(:refund, payment:, amount: 50) + create(:refund, payment:, amount: 50) end it { is_expected.to be true } @@ -711,7 +711,7 @@ describe "#save" do context "captured payments" do it "update order payment total" do - payment = create(:payment, order: order, state: 'completed') + payment = create(:payment, order:, state: 'completed') expect(order.payment_total).to eq payment.amount end end @@ -719,7 +719,7 @@ context "not completed payments" do it "doesn't update order payment total" do expect { - Spree::Payment.create(amount: 100, order: order) + Spree::Payment.create(amount: 100, order:) }.not_to change { order.payment_total } end end @@ -728,7 +728,7 @@ let(:payment) do Spree::Payment.create( amount: 100, - order: order, + order:, state: 'completed' ) end @@ -746,7 +746,7 @@ it "updates payment_state and shipments" do expect(order.recalculator).to receive(:update_payment_state) expect(order.recalculator).to receive(:update_shipment_state) - Spree::Payment.create!(amount: 100, order: order, payment_method: payment_method) + Spree::Payment.create!(amount: 100, order:, payment_method:) end end @@ -762,7 +762,7 @@ expect do Spree::Payment.create( amount: 100, - order: order, + order:, source: card, payment_method: gateway ) @@ -798,7 +798,7 @@ expect(payment.payment_method).to receive :create_profile Spree::Payment.create( amount: 100, - order: order, + order:, source: card, payment_method: gateway ) @@ -813,7 +813,7 @@ expect(gateway).not_to receive :create_profile Spree::Payment.create( amount: 100, - order: order, + order:, source: card, payment_method: gateway ) @@ -824,7 +824,7 @@ describe '#invalidate_old_payments' do it 'should not invalidate other payments if not valid' do payment.save - invalid_payment = Spree::Payment.new(amount: 100, order: order, state: 'invalid', payment_method: gateway) + invalid_payment = Spree::Payment.new(amount: 100, order:, state: 'invalid', payment_method: gateway) invalid_payment.save expect(payment.reload.state).to eq('checkout') end @@ -834,7 +834,7 @@ create(:payment, payment_method: existing_payment_method, source: existing_payment_source, - order: order, + order:, amount: 5) end @@ -842,9 +842,9 @@ let(:payment_source) { create(:credit_card) } let(:payment) do build(:payment, - payment_method: payment_method, + payment_method:, source: payment_source, - order: order, + order:, amount: 5) end @@ -939,7 +939,7 @@ end context 'with an existing credit card' do - let(:order) { create(:order, user: user) } + let(:order) { create(:order, user:) } let(:user) { create(:user) } let!(:credit_card) { create(:credit_card, user_id: order.user_id) } let!(:wallet_payment_source) { user.wallet.add(credit_card) } @@ -1049,7 +1049,7 @@ # Sets the payment's order to a different Ruby object entirely payment.order = Spree::Order.find(payment.order_id) email = 'foo@example.com' - order.update(email: email) + order.update(email:) expect(payment.gateway_options[:email]).to eq(email) end end diff --git a/core/spec/models/spree/preference_spec.rb b/core/spec/models/spree/preference_spec.rb index d6f32e25cef..5096bf94b68 100644 --- a/core/spec/models/spree/preference_spec.rb +++ b/core/spec/models/spree/preference_spec.rb @@ -17,7 +17,7 @@ def round_trip_preference(key, value) element.key = key element.save - Spree::Preference.find_by(key: key) + Spree::Preference.find_by(key:) end it ":boolean" do diff --git a/core/spec/models/spree/price_spec.rb b/core/spec/models/spree/price_spec.rb index 5d3f4f26552..863d49c9c99 100644 --- a/core/spec/models/spree/price_spec.rb +++ b/core/spec/models/spree/price_spec.rb @@ -12,7 +12,7 @@ describe 'validations' do let(:variant) { stub_model Spree::Variant } - subject { Spree::Price.new variant: variant, amount: amount } + subject { Spree::Price.new variant:, amount: } context 'when the amount is nil' do let(:amount) { nil } @@ -51,7 +51,7 @@ end context '#country_iso' do - subject(:price) { build(:price, country_iso: country_iso) } + subject(:price) { build(:price, country_iso:) } context 'when country iso is nil' do let(:country_iso) { nil } @@ -127,7 +127,7 @@ describe "#currency" do let(:variant) { stub_model Spree::Variant } - subject { Spree::Price.new variant: variant, amount: 10, currency: currency } + subject { Spree::Price.new variant:, amount: 10, currency: } describe "validation" do context "with an invalid currency" do @@ -171,7 +171,7 @@ describe '.for_any_country' do let(:country) { create(:country) } let!(:fallback_price) { create(:price, country_iso: nil) } - let!(:country_price) { create(:price, country: country) } + let!(:country_price) { create(:price, country:) } subject { described_class.for_any_country } @@ -182,11 +182,11 @@ describe 'net_amount' do let(:country) { create(:country, iso: "DE") } let(:zone) { create(:zone, countries: [country]) } - let!(:tax_rate) { create(:tax_rate, included_in_price: true, zone: zone, tax_categories: [variant.tax_category]) } + let!(:tax_rate) { create(:tax_rate, included_in_price: true, zone:, tax_categories: [variant.tax_category]) } let(:variant) { create(:product).master } - let(:price) { variant.prices.create(amount: 20, country: country) } + let(:price) { variant.prices.create(amount: 20, country:) } subject { price.net_amount } diff --git a/core/spec/models/spree/product/scopes_spec.rb b/core/spec/models/spree/product/scopes_spec.rb index 9be70c23383..d485bb61a66 100644 --- a/core/spec/models/spree/product/scopes_spec.rb +++ b/core/spec/models/spree/product/scopes_spec.rb @@ -40,7 +40,7 @@ it 'after ordering changed' do [@child_taxon, other_taxon].each do |taxon| - Spree::Classification.find_by(taxon: taxon, product: product).insert_at(2) + Spree::Classification.find_by(taxon:, product:).insert_at(2) expect(Spree::Product.in_taxon(taxon)).to eq([product_2, product]) end end @@ -50,11 +50,11 @@ context "property scopes" do let(:name) { "A proper tee" } let(:value) { "A proper value" } - let!(:property) { create(:property, name: name) } + let!(:property) { create(:property, name:) } before do product.properties << property - product.product_properties.find_by(property: property).update_column(:value, value) + product.product_properties.find_by(property:).update_column(:value, value) end context "with_property" do @@ -197,7 +197,7 @@ end describe ".with_all_variant_sku_cont" do - let!(:product) { create(:product, sku: sku) } + let!(:product) { create(:product, sku:) } let(:sku) { "SEARCH-SKU-1" } subject { Spree::Product.with_all_variant_sku_cont("SEARCH") } @@ -224,7 +224,7 @@ end describe ".with_kept_variant_sku_cont" do - let!(:product) { create(:product, sku: sku) } + let!(:product) { create(:product, sku:) } let(:sku) { "SEARCH-SKU-1" } subject { Spree::Product.with_kept_variant_sku_cont("SEARCH") } diff --git a/core/spec/models/spree/product_duplicator_spec.rb b/core/spec/models/spree/product_duplicator_spec.rb index e5720c0642a..74741b364ec 100644 --- a/core/spec/models/spree/product_duplicator_spec.rb +++ b/core/spec/models/spree/product_duplicator_spec.rb @@ -77,11 +77,11 @@ module Spree context "with variants" do let(:option_type) { create(:option_type, name: "MyOptionType") } - let(:option_value1) { create(:option_value, name: "OptionValue1", option_type: option_type) } - let(:option_value2) { create(:option_value, name: "OptionValue2", option_type: option_type) } + let(:option_value1) { create(:option_value, name: "OptionValue1", option_type:) } + let(:option_value2) { create(:option_value, name: "OptionValue2", option_type:) } - let!(:variant1) { create(:variant, product: product, option_values: [option_value1]) } - let!(:variant2) { create(:variant, product: product, option_values: [option_value2]) } + let!(:variant1) { create(:variant, product:, option_values: [option_value1]) } + let!(:variant2) { create(:variant, product:, option_values: [option_value2]) } it "will duplciate the variants" do # will change the count by 3, since there will be a master variant as well diff --git a/core/spec/models/spree/product_spec.rb b/core/spec/models/spree/product_spec.rb index 19f6752731c..c5d8132f636 100644 --- a/core/spec/models/spree/product_spec.rb +++ b/core/spec/models/spree/product_spec.rb @@ -12,7 +12,7 @@ class Extension < Spree::Base RSpec.describe Spree::Product, type: :model do context 'product instance' do let(:product) { create(:product) } - let(:variant) { create(:variant, product: product) } + let(:variant) { create(:variant, product:) } context '#duplicate' do before do @@ -122,7 +122,7 @@ class Extension < Spree::Base context "product has variants" do before do - create(:variant, product: product) + create(:variant, product:) end context "#discard" do @@ -242,8 +242,8 @@ class Extension < Spree::Base end context "variants_and_option_values_for" do - let!(:high) { create(:variant, product: product) } - let!(:low) { create(:variant, product: product) } + let!(:high) { create(:variant, product:) } + let!(:low) { create(:variant, product:) } context "when one product does not have option values" do before { high.option_values.destroy_all } @@ -284,7 +284,7 @@ class Extension < Spree::Base let(:size_small) { create(:option_value, name: 'small', option_type: size, position: 3) } let(:size_medium) { create(:option_value, name: 'medium', option_type: size, position: 1) } let(:size_large) { create(:option_value, name: 'large', option_type: size, position: 2) } - let!(:variant) { create(:variant, product: product, option_values: [size_small, size_medium]) } + let!(:variant) { create(:variant, product:, option_values: [size_small, size_medium]) } subject { product.variant_option_values_by_option_type } @@ -300,7 +300,7 @@ class Extension < Spree::Base context "a matching rule exists" do let!(:rule) do - create(:variant_property_rule, product: product, option_value: option_value) + create(:variant_property_rule, product:, option_value:) end it "returns the rule" do @@ -318,9 +318,9 @@ class Extension < Spree::Base describe 'Variants sorting' do let(:master){ product.master } - let!(:second) { create(:variant, product: product) } - let!(:third) { create(:variant, product: product) } - let!(:first) { create(:variant, product: product) } + let!(:second) { create(:variant, product:) } + let!(:third) { create(:variant, product:) } + let!(:first) { create(:variant, product:) } before do first.update_columns(position: 2) @@ -347,7 +347,7 @@ class Extension < Spree::Base let(:stock_item) { variant.stock_items.first } it "doesnt raise ReadOnlyRecord error" do - Spree::StockMovement.create!(stock_item: stock_item, quantity: 1) + Spree::StockMovement.create!(stock_item:, quantity: 1) product.discard end end @@ -401,7 +401,7 @@ class Extension < Spree::Base let(:product) { create(:product, slug: 'my-awesome-product') } it "destroys related associations" do - create(:variant, product: product) + create(:variant, product:) product.option_types = [create(:option_type)] product.master.images = [create(:image)] product.taxons = [create(:taxon)] @@ -627,13 +627,13 @@ class Extension < Spree::Base end end - context "ransacker :variants_option_values" do + describe "ransack :option_values_id_in" do it "filters products based on option values of their variants" do product_1 = create(:product) option_value_1 = create(:option_value) create(:variant, product: product_1, option_values: [option_value_1]) - result = Spree::Product.ransack(variants_option_values_in: [option_value_1.id]).result + result = Spree::Product.ransack(option_values_id_in: [option_value_1.id]).result expect(result).to contain_exactly(product_1) end @@ -644,13 +644,13 @@ class Extension < Spree::Base create(:variant, product: product_1, option_values: [option_value_1]) create(:variant, product: product_2, option_values: [option_value_1]) - result = Spree::Product.ransack(variants_option_values_in: [option_value_1.id]).result + result = Spree::Product.ransack(option_values_id_in: [option_value_1.id]).result expect(result).to contain_exactly(product_1, product_2) end it "returns no products if there is no match" do non_existing_option_value_id = 99999 - result = Spree::Product.ransack(variants_option_values_in: [non_existing_option_value_id]).result + result = Spree::Product.ransack(option_values_id_in: [non_existing_option_value_id]).result expect(result).to be_empty end @@ -662,7 +662,7 @@ class Extension < Spree::Base create(:variant, product: product_1, option_values: [option_value_1]) create(:variant, product: product_2, option_values: [option_value_2]) - result = Spree::Product.ransack(variants_option_values_in: [option_value_1.id, option_value_2.id]).result + result = Spree::Product.ransack(option_values_id_in: [option_value_1.id, option_value_2.id]).result expect(result).to contain_exactly(product_1, product_2) end @@ -674,7 +674,7 @@ class Extension < Spree::Base create(:variant, product: product_1, option_values: [option_value_1]) create(:variant, product: product_2, option_values: [option_value_2]) - result = Spree::Product.ransack(variants_option_values_in: [option_value_1.id]).result + result = Spree::Product.ransack(option_values_id_in: [option_value_1.id]).result expect(result).not_to include(product_2) end end diff --git a/core/spec/models/spree/refund_spec.rb b/core/spec/models/spree/refund_spec.rb index 10ff8c13917..3f230326caa 100644 --- a/core/spec/models/spree/refund_spec.rb +++ b/core/spec/models/spree/refund_spec.rb @@ -6,7 +6,7 @@ let(:amount) { 100.0 } let(:amount_in_cents) { amount * 100 } - let(:payment) { create(:payment, amount: payment_amount, payment_method: payment_method) } + let(:payment) { create(:payment, amount: payment_amount, payment_method:) } let(:payment_amount) { amount * 2 } let(:payment_method) { create(:credit_card_payment_method) } @@ -17,10 +17,10 @@ let(:refund) do create( :refund, - payment: payment, - amount: amount, + payment:, + amount:, reason: refund_reason, - transaction_id: transaction_id + transaction_id: ) end diff --git a/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb b/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb index df41684c6bd..44b260f13b8 100644 --- a/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +++ b/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb @@ -17,7 +17,7 @@ class DummyClass let(:return_item) do create( :return_item, - preferred_reimbursement_type: preferred_reimbursement_type + preferred_reimbursement_type: ) end let(:dummy) { DummyClass.new } diff --git a/core/spec/models/spree/reimbursement_spec.rb b/core/spec/models/spree/reimbursement_spec.rb index 507d149ea80..d78e3ac051d 100644 --- a/core/spec/models/spree/reimbursement_spec.rb +++ b/core/spec/models/spree/reimbursement_spec.rb @@ -6,7 +6,7 @@ describe ".create" do let(:customer_return) { create(:customer_return) } let(:order) { customer_return.order } - let(:reimbursement) { build(:reimbursement, order: order) } + let(:reimbursement) { build(:reimbursement, order:) } subject { reimbursement.save } @@ -19,7 +19,7 @@ end context "when total is present" do - let(:reimbursement) { build(:reimbursement, order: order, total: 10) } + let(:reimbursement) { build(:reimbursement, order:, total: 10) } it { expect { subject }.not_to change(reimbursement, :total).from(10) } end @@ -29,7 +29,7 @@ describe "#generate_number" do context "number is assigned" do let(:number) { '123' } - let(:reimbursement) { Spree::Reimbursement.new(number: number) } + let(:reimbursement) { Spree::Reimbursement.new(number:) } it "should return the assigned number" do reimbursement.save @@ -55,8 +55,8 @@ describe "#display_total" do let(:total) { 100.50 } let(:currency) { "USD" } - let(:order) { Spree::Order.new(currency: currency) } - let(:reimbursement) { Spree::Reimbursement.new(total: total, order: order) } + let(:order) { Spree::Order.new(currency:) } + let(:reimbursement) { Spree::Reimbursement.new(total:, order:) } subject { reimbursement.display_total } @@ -76,18 +76,18 @@ let!(:tax_zone) { create :zone, :with_country } let(:shipping_method) { create :shipping_method, zones: [tax_zone] } let(:variant) { create :variant } - let(:order) { create(:order_with_line_items, state: 'payment', line_items_attributes: [{ variant: variant, price: line_items_price }], shipment_cost: 0, shipping_method: shipping_method) } + let(:order) { create(:order_with_line_items, state: 'payment', line_items_attributes: [{ variant:, price: line_items_price }], shipment_cost: 0, shipping_method:) } let(:line_items_price) { BigDecimal(10) } let(:line_item) { order.line_items.first } let(:inventory_unit) { line_item.inventory_units.first } - let(:payment) { build(:payment, amount: payment_amount, order: order, state: 'checkout') } + let(:payment) { build(:payment, amount: payment_amount, order:, state: 'checkout') } let(:payment_amount) { order.total } let(:customer_return) { build(:customer_return, return_items: [return_item]) } - let(:return_item) { build(:return_item, inventory_unit: inventory_unit) } + let(:return_item) { build(:return_item, inventory_unit:) } let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) } - let(:reimbursement) { create(:reimbursement, customer_return: customer_return, order: order, return_items: [return_item]) } + let(:reimbursement) { create(:reimbursement, customer_return:, order:, return_items: [return_item]) } let(:created_by_user) { create(:user, email: 'user@email.com') } subject { reimbursement.perform!(created_by: created_by_user) } @@ -152,7 +152,7 @@ end context 'when reimbursement cannot be fully performed' do - let!(:non_return_refund) { create(:refund, amount: 1, payment: payment) } + let!(:non_return_refund) { create(:refund, amount: 1, payment:) } it 'does not send a reimbursement email and raises IncompleteReimbursement error' do expect(Spree::ReimbursementMailer).not_to receive(:reimbursement_email) @@ -259,8 +259,8 @@ let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) } let(:order) { create(:shipped_order, line_items_count: 1) } let(:inventory_unit) { order.inventory_units.first } - let(:return_item) { build(:return_item, inventory_unit: inventory_unit) } - let(:reimbursement) { build(:reimbursement, order: order, return_items: [return_item]) } + let(:return_item) { build(:return_item, inventory_unit:) } + let(:reimbursement) { build(:reimbursement, order:, return_items: [return_item]) } let(:created_by_user) { create(:user, email: 'user@email.com') } it "accepts all the return items" do diff --git a/core/spec/models/spree/return_authorization_spec.rb b/core/spec/models/spree/return_authorization_spec.rb index 245b6777446..39fb9091e2c 100644 --- a/core/spec/models/spree/return_authorization_spec.rb +++ b/core/spec/models/spree/return_authorization_spec.rb @@ -10,7 +10,7 @@ let(:variant) { order.variants.first } let(:return_authorization) do - Spree::ReturnAuthorization.new(order: order, + Spree::ReturnAuthorization.new(order:, stock_location_id: stock_location.id, return_reason_id: rma_reason.id) end @@ -28,7 +28,7 @@ let(:order) { create(:shipped_order, line_items_count: 2) } let!(:previous_exchange_return_item) { create(:exchange_return_item, inventory_unit: order.inventory_units.last) } let(:return_item) { create(:return_item, inventory_unit: order.inventory_units.last) } - let(:return_authorization) { build(:return_authorization, order: order, return_items: [return_item]) } + let(:return_authorization) { build(:return_authorization, order:, return_items: [return_item]) } it "should be invalid" do return_authorization.save @@ -39,7 +39,7 @@ context "an inventory unit is not being exchanged" do let(:order) { create(:shipped_order, line_items_count: 2) } let(:return_item) { create(:return_item, inventory_unit: order.inventory_units.last) } - let(:return_authorization) { build(:return_authorization, order: order, return_items: [return_item]) } + let(:return_authorization) { build(:return_authorization, order:, return_items: [return_item]) } it "is valid" do return_authorization.save @@ -81,13 +81,13 @@ describe "#total_excluding_vat" do let(:amount_1) { 15.0 } - let!(:return_item_1) { create(:return_item, return_authorization: return_authorization, amount: amount_1) } + let!(:return_item_1) { create(:return_item, return_authorization:, amount: amount_1) } let(:amount_2) { 50.0 } - let!(:return_item_2) { create(:return_item, return_authorization: return_authorization, amount: amount_2) } + let!(:return_item_2) { create(:return_item, return_authorization:, amount: amount_2) } let(:amount_3) { 5.0 } - let!(:return_item_3) { create(:return_item, return_authorization: return_authorization, amount: amount_3) } + let!(:return_item_3) { create(:return_item, return_authorization:, amount: amount_3) } subject { return_authorization.reload.total_excluding_vat } @@ -167,7 +167,7 @@ end describe 'cancel_return_items' do - let(:return_authorization) { create(:return_authorization, return_items: return_items) } + let(:return_authorization) { create(:return_authorization, return_items:) } let(:return_items) { [return_item] } let(:return_item) { create(:return_item) } @@ -193,7 +193,7 @@ end describe '#can_cancel?' do - subject { create(:return_authorization, return_items: return_items).can_cancel? } + subject { create(:return_authorization, return_items:).can_cancel? } let(:return_items) { [return_item_1, return_item_2] } let(:return_item_1) { create(:return_item) } let(:return_item_2) { create(:return_item) } diff --git a/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb b/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb index ab88c292cfb..fea8c0ecf8f 100644 --- a/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +++ b/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe Spree::ReturnItem::EligibilityValidator::OrderCompleted do - let(:shipment) { create(:shipment, order: order) } - let(:inventory_unit) { create(:inventory_unit, shipment: shipment) } - let(:return_item) { create(:return_item, inventory_unit: inventory_unit) } + let(:shipment) { create(:shipment, order:) } + let(:inventory_unit) { create(:inventory_unit, shipment:) } + let(:return_item) { create(:return_item, inventory_unit:) } let(:validator) { Spree::ReturnItem::EligibilityValidator::OrderCompleted.new(return_item) } describe "#eligible_for_return?" do diff --git a/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb b/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb index ddf631d89da..1ec3a604daa 100644 --- a/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +++ b/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb @@ -21,10 +21,10 @@ module ReturnItem::ExchangeVariantEligibility let(:product) { create(:product, option_types: [color_option_type, waist_option_type, inseam_option_type]) } - let!(:variant) { create(:variant, product: product, option_values: [blue_option_value, three_two_waist_option_value, three_zero_inseam_option_value]) } - let!(:same_option_values_variant) { create(:variant, product: product, option_values: [blue_option_value, three_two_waist_option_value, three_one_inseam_option_value]) } - let!(:different_color_option_value_variant) { create(:variant, product: product, option_values: [red_option_value, three_two_waist_option_value, three_one_inseam_option_value]) } - let!(:different_waist_option_value_variant) { create(:variant, product: product, option_values: [blue_option_value, three_four_waist_option_value, three_one_inseam_option_value]) } + let!(:variant) { create(:variant, product:, option_values: [blue_option_value, three_two_waist_option_value, three_zero_inseam_option_value]) } + let!(:same_option_values_variant) { create(:variant, product:, option_values: [blue_option_value, three_two_waist_option_value, three_one_inseam_option_value]) } + let!(:different_color_option_value_variant) { create(:variant, product:, option_values: [red_option_value, three_two_waist_option_value, three_one_inseam_option_value]) } + let!(:different_waist_option_value_variant) { create(:variant, product:, option_values: [blue_option_value, three_four_waist_option_value, three_one_inseam_option_value]) } before do @original_option_type_restrictions = SameOptionValue.option_type_restrictions diff --git a/core/spec/models/spree/return_item_spec.rb b/core/spec/models/spree/return_item_spec.rb index e67b1b92569..3e335e89796 100644 --- a/core/spec/models/spree/return_item_spec.rb +++ b/core/spec/models/spree/return_item_spec.rb @@ -23,7 +23,7 @@ let(:order) { create(:shipped_order) } let(:inventory_unit) { create(:inventory_unit, state: 'shipped') } let!(:customer_return) { create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: inventory_unit.shipment.stock_location_id) } - let(:return_item) { create(:return_item, inventory_unit: inventory_unit) } + let(:return_item) { create(:return_item, inventory_unit:) } before do inventory_unit.update!(state: 'shipped') @@ -44,7 +44,7 @@ end context 'when there is a received return item with the same inventory unit' do - let!(:return_item_with_dupe_inventory_unit) { create(:return_item, inventory_unit: inventory_unit, reception_status: 'received') } + let!(:return_item_with_dupe_inventory_unit) { create(:return_item, inventory_unit:, reception_status: 'received') } before do expect { subject }.to raise_error { StateMachines::InvalidTransition } @@ -61,7 +61,7 @@ context 'when the received item is actually the exchange (aka customer changed mind about exchange)' do let(:exchange_inventory_unit) { create(:inventory_unit, state: 'shipped') } - let!(:return_item_with_exchange) { create(:return_item, inventory_unit: inventory_unit, exchange_inventory_unit: exchange_inventory_unit) } + let!(:return_item_with_exchange) { create(:return_item, inventory_unit:, exchange_inventory_unit:) } let!(:return_item_in_lieu) { create(:return_item, inventory_unit: exchange_inventory_unit) } it 'unexchanges original return item' do @@ -145,7 +145,7 @@ describe "#display_total_excluding_vat" do let(:amount) { 21.22 } let(:included_tax_total) { 1.22 } - let(:return_item) { build(:return_item, amount: amount, included_tax_total: included_tax_total) } + let(:return_item) { build(:return_item, amount:, included_tax_total:) } it "returns a Spree::Money" do expect(return_item.display_total_excluding_vat).to eq Spree::Money.new(amount - included_tax_total) @@ -162,7 +162,7 @@ let(:inventory_unit) { create(:inventory_unit) } context "amount is not specified" do - subject { create(:return_item, inventory_unit: inventory_unit) } + subject { create(:return_item, inventory_unit:) } context "not an exchange" do it { expect(subject.amount).to eq Spree::Calculator::Returns::DefaultRefundAmount.new.compute(subject) } @@ -176,7 +176,7 @@ end context "amount is specified" do - subject { build(:return_item, inventory_unit: inventory_unit, amount: 100) } + subject { build(:return_item, inventory_unit:, amount: 100) } it { expect(subject.amount).to eq 100 } end @@ -188,19 +188,19 @@ subject { Spree::ReturnItem.from_inventory_unit(inventory_unit) } context "with a cancelled return item" do - let!(:return_item) { create(:return_item, inventory_unit: inventory_unit, reception_status: 'cancelled') } + let!(:return_item) { create(:return_item, inventory_unit:, reception_status: 'cancelled') } it { is_expected.not_to be_persisted } end context 'with a expired item' do - let!(:return_item) { create(:return_item, inventory_unit: inventory_unit, reception_status: 'expired') } + let!(:return_item) { create(:return_item, inventory_unit:, reception_status: 'expired') } it { is_expected.not_to be_persisted } end context "with a non-cancelled return item" do - let!(:return_item) { create(:return_item, inventory_unit: inventory_unit) } + let!(:return_item) { create(:return_item, inventory_unit:) } it { is_expected.to be_persisted } end @@ -254,7 +254,7 @@ describe "#receive" do let(:order) { create(:shipped_order) } let(:inventory_unit) { create(:inventory_unit, shipment: order.shipments.first) } - let(:return_item) { create(:return_item, reception_status: status, inventory_unit: inventory_unit) } + let(:return_item) { create(:return_item, reception_status: status, inventory_unit:) } subject { return_item.receive! } @@ -307,7 +307,7 @@ short_shipped: 'short_shipped' }.each do |transition, status| describe "##{transition}" do - let(:return_item) { create(:return_item, reception_status: status, inventory_unit: inventory_unit) } + let(:return_item) { create(:return_item, reception_status: status, inventory_unit:) } let(:inventory_unit) { create(:inventory_unit, state: 'shipped') } subject { return_item.public_send("#{transition}!") } context "awaiting status" do @@ -489,7 +489,7 @@ end describe 'validity for reimbursements' do - let(:return_item) { create(:return_item, acceptance_status: acceptance_status) } + let(:return_item) { create(:return_item, acceptance_status:) } let(:acceptance_status) { 'pending' } before { return_item.reimbursement = build(:reimbursement) } @@ -716,7 +716,7 @@ let(:return_item) do create( :return_item, - inventory_unit: inventory_unit, + inventory_unit:, included_tax_total: 5 ) end diff --git a/core/spec/models/spree/shipment_spec.rb b/core/spec/models/spree/shipment_spec.rb index e1a5293a357..384413166d6 100644 --- a/core/spec/models/spree/shipment_spec.rb +++ b/core/spec/models/spree/shipment_spec.rb @@ -13,18 +13,18 @@ cost: 1, inventory_units: order.inventory_units, shipping_rates: [shipping_rate], - stock_location: stock_location + stock_location: ) end let(:shipping_rate) do Spree::ShippingRate.create!( - shipping_method: shipping_method, + shipping_method:, selected: true ) end let(:variant) { mock_model(Spree::Variant) } - let(:line_item) { mock_model(Spree::LineItem, variant: variant) } + let(:line_item) { mock_model(Spree::LineItem, variant:) } # Regression test for https://github.com/spree/spree/issues/4063 context "number generation" do @@ -103,8 +103,8 @@ let(:order) do create( :order_ready_to_ship, - line_items_attributes: [{ price: 10, variant: variant }], - ship_address: ship_address, + line_items_attributes: [{ price: 10, variant: }], + ship_address:, ) end @@ -112,7 +112,7 @@ let!(:tax_zone) { create(:global_zone) } # will include the above address let!(:tax_rate) { create(:tax_rate, amount: 0.1, zone: tax_zone, tax_categories: [tax_category]) } let(:tax_category) { create(:tax_category) } - let(:variant) { create(:variant, tax_category: tax_category) } + let(:variant) { create(:variant, tax_category:) } it 'should equal line items final amount with tax' do expect(shipment.item_cost).to eql(11.0) @@ -190,7 +190,7 @@ end context 'refresh_rates' do - let(:mock_estimator) { double('estimator', shipping_rates: shipping_rates) } + let(:mock_estimator) { double('estimator', shipping_rates:) } before { allow(shipment).to receive(:can_get_rates?){ true } } it 'should request new rates, and maintain shipping_method selection' do @@ -227,8 +227,8 @@ context 'to_package' do let(:inventory_units) do - [build(:inventory_unit, line_item: line_item, variant: variant, state: 'on_hand'), - build(:inventory_unit, line_item: line_item, variant: variant, state: 'backordered')] + [build(:inventory_unit, line_item:, variant:, state: 'on_hand'), + build(:inventory_unit, line_item:, variant:, state: 'backordered')] end before do @@ -339,7 +339,7 @@ # Regression test for https://github.com/spree/spree/issues/4347 context "with adjustments" do before do - shipment.adjustments << Spree::Adjustment.create(order: order, label: "Label", amount: 5) + shipment.adjustments << Spree::Adjustment.create(order:, label: "Label", amount: 5) end it "transitions to shipped" do @@ -474,7 +474,7 @@ context "when the shipment is canceled" do let(:address){ create(:address) } let(:order){ create(:order_with_line_items, ship_address: address) } - let(:shipment_with_inventory_units) { create(:shipment, order: order, state: 'canceled') } + let(:shipment_with_inventory_units) { create(:shipment, order:, state: 'canceled') } let(:subject) { shipment_with_inventory_units.ship! } it 'unstocks them items' do @@ -486,7 +486,7 @@ ['ready', 'canceled'].each do |state| context "from #{state}" do before do - allow(shipment).to receive_messages(state: state) + allow(shipment).to receive_messages(state:) end it "finalizes adjustments" do @@ -527,7 +527,7 @@ let(:order) do create( :order_ready_to_ship, - ship_address: ship_address, + ship_address:, shipment_cost: 10, shipping_method: ten_dollar_shipping_method, line_items_count: 1, @@ -535,13 +535,13 @@ ) end - let(:ten_dollar_shipping_method) { create(:shipping_method, tax_category: tax_category, zones: [tax_zone], cost: 10) } - let(:twenty_dollar_shipping_method) { create(:shipping_method, tax_category: tax_category, zones: [tax_zone], cost: 20) } + let(:ten_dollar_shipping_method) { create(:shipping_method, tax_category:, zones: [tax_zone], cost: 10) } + let(:twenty_dollar_shipping_method) { create(:shipping_method, tax_category:, zones: [tax_zone], cost: 20) } let(:shipment) { order.shipments[0] } let(:twenty_dollar_shipping_rate) do - create(:shipping_rate, cost: 20, shipment: shipment, shipping_method: twenty_dollar_shipping_method) + create(:shipping_rate, cost: 20, shipment:, shipping_method: twenty_dollar_shipping_method) end it "updates everything around order shipment total and state" do @@ -617,7 +617,7 @@ { variant_id: variant.id, state: 'on_hand', line_item_id: line_item.id } end - before { allow(shipment).to receive_messages inventory_units: inventory_units } + before { allow(shipment).to receive_messages(inventory_units:) } it "associates variant and order" do expect(inventory_units).to receive(:create).with(params) @@ -629,7 +629,7 @@ context "#destroy" do let(:shipping_rate) do Spree::ShippingRate.create!( - shipping_method: shipping_method, + shipping_method:, selected: true, taxes: [Spree::ShippingRateTax.new(amount: 20)] ) @@ -669,8 +669,8 @@ let(:unshippable_shipment) do create( :shipment, - order: order, - stock_location: stock_location + order:, + stock_location: ) end @@ -721,7 +721,7 @@ describe "#finalize!" do let(:inventory_unit) { shipment.inventory_units.first } - let(:stock_item) { inventory_unit.variant.stock_items.find_by(stock_location: stock_location) } + let(:stock_item) { inventory_unit.variant.stock_items.find_by(stock_location:) } let(:inventory_unit_finalizer) { double(:inventory_unit_finalizer, run!: [true]) } before do @@ -835,7 +835,7 @@ end describe '#can_transition_from_pending_to_ready?' do - let(:shipment) { create(:shipment, order: order) } + let(:shipment) { create(:shipment, order:) } subject { shipment.can_transition_from_pending_to_ready? } diff --git a/core/spec/models/spree/shipping_manifest_spec.rb b/core/spec/models/spree/shipping_manifest_spec.rb index 8a6345e1b60..c5c9781036d 100644 --- a/core/spec/models/spree/shipping_manifest_spec.rb +++ b/core/spec/models/spree/shipping_manifest_spec.rb @@ -7,11 +7,11 @@ module Spree let!(:store) { create :store } let(:order) { Order.create! } let(:variant) { create :variant } - let!(:shipment) { create(:shipment, state: 'pending', order: order) } - subject(:manifest) { described_class.new(inventory_units: inventory_units) } + let!(:shipment) { create(:shipment, state: 'pending', order:) } + subject(:manifest) { described_class.new(inventory_units:) } def build_unit(variant, attrs = {}) - attrs = { variant: variant, shipment: shipment }.merge(attrs) + attrs = { variant:, shipment: }.merge(attrs) attrs[:line_item] = order.contents.add(variant) InventoryUnit.new(attrs) end @@ -29,7 +29,7 @@ def build_unit(variant, attrs = {}) it "has correct item" do expect(manifest.items.count).to eq 1 expect(manifest.items[0]).to have_attributes( - variant: variant, + variant:, quantity: 1, states: { "on_hand" => 1 } ) @@ -41,7 +41,7 @@ def build_unit(variant, attrs = {}) it "has correct item" do expect(manifest.items.count).to eq 1 expect(manifest.items[0]).to have_attributes( - variant: variant, + variant:, quantity: 2, states: { "on_hand" => 2 } ) @@ -54,7 +54,7 @@ def build_unit(variant, attrs = {}) it "has correct item" do expect(manifest.items.count).to eq 2 expect(manifest.items[0]).to have_attributes( - variant: variant, + variant:, quantity: 1, states: { "on_hand" => 1 } ) diff --git a/core/spec/models/spree/shipping_method_spec.rb b/core/spec/models/spree/shipping_method_spec.rb index 1fc8471c86c..fa27cb0288f 100644 --- a/core/spec/models/spree/shipping_method_spec.rb +++ b/core/spec/models/spree/shipping_method_spec.rb @@ -11,7 +11,7 @@ class DummyShippingCalculator < Spree::ShippingCalculator let!(:shipping_method) { create(:shipping_method) } let!(:shipment) do shipment = create(:shipment) - shipment.shipping_rates.create!(shipping_method: shipping_method) + shipment.shipping_rates.create!(shipping_method:) shipment end diff --git a/core/spec/models/spree/shipping_rate_spec.rb b/core/spec/models/spree/shipping_rate_spec.rb index 4d7bb217ce8..58244272d6c 100644 --- a/core/spec/models/spree/shipping_rate_spec.rb +++ b/core/spec/models/spree/shipping_rate_spec.rb @@ -6,14 +6,14 @@ let(:address) { create(:address) } let(:foreign_address) { create :address, country_iso_code: "DE" } let(:order) { create :order, ship_address: address } - let(:shipment) { create(:shipment, order: order) } - let(:shipping_method) { create(:shipping_method, tax_category: tax_category) } + let(:shipment) { create(:shipment, order:) } + let(:shipping_method) { create(:shipping_method, tax_category:) } let(:tax_category) { create :tax_category } subject(:shipping_rate) do Spree::ShippingRate.new( - shipment: shipment, - shipping_method: shipping_method, + shipment:, + shipping_method:, cost: 10 ) end @@ -40,7 +40,7 @@ before do shipping_rate.taxes.build( amount: 0.91, - tax_rate: tax_rate, + tax_rate:, ) end @@ -73,7 +73,7 @@ before do shipping_rate.taxes.build( amount: 1.0, - tax_rate: tax_rate, + tax_rate:, ) end @@ -115,7 +115,7 @@ before do shipping_rate.taxes.build( amount: 1.0, - tax_rate: tax_rate, + tax_rate:, ) shipping_rate.taxes.build( diff --git a/core/spec/models/spree/shipping_rate_tax_spec.rb b/core/spec/models/spree/shipping_rate_tax_spec.rb index 134e208b54a..7e69d1c6af4 100644 --- a/core/spec/models/spree/shipping_rate_tax_spec.rb +++ b/core/spec/models/spree/shipping_rate_tax_spec.rb @@ -11,7 +11,7 @@ module Spree it { is_expected.to respond_to(:shipping_rate) } describe 'absolute_amount' do - subject(:shipping_rate_tax) { described_class.new(amount: amount).absolute_amount } + subject(:shipping_rate_tax) { described_class.new(amount:).absolute_amount } context 'with a negative amount' do let(:amount) { -19 } @@ -32,7 +32,7 @@ module Spree end describe '#currency' do - subject(:shipping_rate_tax) { described_class.new(amount: 10, shipping_rate: shipping_rate).currency } + subject(:shipping_rate_tax) { described_class.new(amount: 10, shipping_rate:).currency } context 'when we have a shipping rate' do let(:shipping_rate) { build_stubbed(:shipping_rate) } @@ -53,7 +53,7 @@ module Spree end describe '#label' do - subject(:shipping_rate_tax) { described_class.new(amount: amount, tax_rate: tax_rate).label } + subject(:shipping_rate_tax) { described_class.new(amount:, tax_rate:).label } context 'with an included tax rate' do let(:tax_rate) { build_stubbed(:tax_rate, included_in_price: true, name: "VAT") } diff --git a/core/spec/models/spree/simple_order_contents_spec.rb b/core/spec/models/spree/simple_order_contents_spec.rb index e9f5af69d06..409edaaa070 100644 --- a/core/spec/models/spree/simple_order_contents_spec.rb +++ b/core/spec/models/spree/simple_order_contents_spec.rb @@ -21,32 +21,32 @@ end context 'given a shipment' do - let!(:shipment) { create(:shipment, order: order) } + let!(:shipment) { create(:shipment, order:) } it "ensure shipment calls update_amounts instead of order calling check_shipments_and_restart_checkout" do expect(subject.order).to_not receive(:check_shipments_and_restart_checkout) expect(shipment).to receive(:update_amounts).at_least(:once) - subject.add(variant, 1, shipment: shipment) + subject.add(variant, 1, shipment:) end context "with quantity=1" do it "creates correct inventory" do - subject.add(variant, 1, shipment: shipment) + subject.add(variant, 1, shipment:) expect(order.inventory_units.count).to eq(1) end end context "with quantity=2" do it "creates correct inventory" do - subject.add(variant, 2, shipment: shipment) + subject.add(variant, 2, shipment:) expect(order.inventory_units.count).to eq(2) end end context "called multiple times" do it "creates correct inventory" do - subject.add(variant, 1, shipment: shipment) - subject.add(variant, 1, shipment: shipment) + subject.add(variant, 1, shipment:) + subject.add(variant, 1, shipment:) expect(order.inventory_units.count).to eq(2) end end @@ -85,7 +85,7 @@ describe 'tax calculations' do let!(:zone) { create(:global_zone) } let!(:tax_rate) do - create(:tax_rate, zone: zone, tax_categories: [variant.tax_category]) + create(:tax_rate, zone:, tax_categories: [variant.tax_category]) end context 'when the order has a taxable address' do @@ -139,7 +139,7 @@ shipment = create(:shipment) expect(subject.order).to_not receive(:check_shipments_and_restart_checkout) expect(shipment).to receive(:update_amounts) - subject.remove(variant, 1, shipment: shipment) + subject.remove(variant, 1, shipment:) end end @@ -194,7 +194,7 @@ shipment = create(:shipment) expect(subject.order).to_not receive(:check_shipments_and_restart_checkout) expect(shipment).to receive(:update_amounts) - subject.remove_line_item(line_item, shipment: shipment) + subject.remove_line_item(line_item, shipment:) end end @@ -315,7 +315,7 @@ let(:user) { create(:user) } it 'approves the order' do - order.contents.approve(user: user) + order.contents.approve(user:) expect(order.approver).to eq(user) expect(order.approver_name).to be_nil expect(order.approved_at).to be_present @@ -327,7 +327,7 @@ let(:user) { create(:user) } it 'approves the order' do - order.contents.approve(user: user, name: 'Jordan') + order.contents.approve(user:, name: 'Jordan') expect(order.approver).to eq(user) expect(order.approver_name).to eq('Jordan') expect(order.approved_at).to be_present diff --git a/core/spec/models/spree/stock/availability_spec.rb b/core/spec/models/spree/stock/availability_spec.rb index bdfd9c785d4..431ab24fa67 100644 --- a/core/spec/models/spree/stock/availability_spec.rb +++ b/core/spec/models/spree/stock/availability_spec.rb @@ -7,7 +7,7 @@ module Spree::Stock let(:variants) { Spree::Variant.all.to_a } let(:infinity) { Float::INFINITY } - let(:availability) { described_class.new(variants: variants) } + let(:availability) { described_class.new(variants:) } let!(:stock_location1) { create(:stock_location) } @@ -23,7 +23,7 @@ module Spree::Stock it "maintains the StockLocation order with which it is initialised" do stock_location2 = create(:stock_location) stock_location3 = create(:stock_location) - sorted_availability = described_class.new(variants: variants, stock_locations: [ + sorted_availability = described_class.new(variants:, stock_locations: [ stock_location3, stock_location1, stock_location2 @@ -114,7 +114,7 @@ module Spree::Stock it "maintains the StockLocation order with which it is initialised" do stock_location2 = create(:stock_location) stock_location3 = create(:stock_location) - sorted_availability = described_class.new(variants: variants, stock_locations: [ + sorted_availability = described_class.new(variants:, stock_locations: [ stock_location3, stock_location1, stock_location2 diff --git a/core/spec/models/spree/stock/availability_validator_spec.rb b/core/spec/models/spree/stock/availability_validator_spec.rb index 56b71da51d8..4d3cacc6841 100644 --- a/core/spec/models/spree/stock/availability_validator_spec.rb +++ b/core/spec/models/spree/stock/availability_validator_spec.rb @@ -73,7 +73,7 @@ module Stock before do shipment = order.shipments.create(stock_location: stock_location_1) - order.contents.add(variant, 1, shipment: shipment) + order.contents.add(variant, 1, shipment:) end context "but no stock in either location" do @@ -117,7 +117,7 @@ module Stock before do shipment_two = order.shipments.create!(stock_location: order.shipments.first.stock_location) order.contents.add(variant, 1, shipment: shipment_two) - variant.stock_items.first.update_columns(count_on_hand: count_on_hand, backorderable: false) + variant.stock_items.first.update_columns(count_on_hand:, backorderable: false) end context "and there is just enough stock" do diff --git a/core/spec/models/spree/stock/estimator_spec.rb b/core/spec/models/spree/stock/estimator_spec.rb index 1d6d35c0ca7..f29705e490f 100644 --- a/core/spec/models/spree/stock/estimator_spec.rb +++ b/core/spec/models/spree/stock/estimator_spec.rb @@ -6,13 +6,13 @@ module Spree module Stock RSpec.describe Estimator, type: :model do let(:shipping_rate) { 4.00 } - let!(:shipping_method) { create(:shipping_method, cost: shipping_rate, currency: currency) } + let!(:shipping_method) { create(:shipping_method, cost: shipping_rate, currency:) } let(:package) do build(:stock_package, contents: inventory_units.map { |unit| ContentItem.new(unit) }).tap do |package| package.shipment = package.to_shipment end end - let(:order) { create(:order_with_line_items, shipping_method: shipping_method) } + let(:order) { create(:order_with_line_items, shipping_method:) } let(:inventory_units) { order.inventory_units } subject { Estimator.new } @@ -213,7 +213,7 @@ def compute_package(_package) context "includes tax adjustments if applicable" do let(:zone) { create(:zone, countries: [order.tax_address.country]) } - let!(:tax_rate) { create(:tax_rate, zone: zone) } + let!(:tax_rate) { create(:tax_rate, zone:) } before do shipping_method.update!(tax_category: tax_rate.tax_categories.first) diff --git a/core/spec/models/spree/stock/inventory_units_finalizer_spec.rb b/core/spec/models/spree/stock/inventory_units_finalizer_spec.rb index 67a5bf808b9..382034bedad 100644 --- a/core/spec/models/spree/stock/inventory_units_finalizer_spec.rb +++ b/core/spec/models/spree/stock/inventory_units_finalizer_spec.rb @@ -7,7 +7,7 @@ module Stock RSpec.describe InventoryUnitsFinalizer, type: :model do context "when finalizing an order with one line_item" do let(:order) { build(:order_with_line_items) } - let(:inventory_unit) { build(:inventory_unit, order: order, variant: variant, line_item: line_item, shipment: order.shipments.first) } + let(:inventory_unit) { build(:inventory_unit, order:, variant:, line_item:, shipment: order.shipments.first) } let(:stock_item) { inventory_unit.variant.stock_items.first } let(:line_item) { order.line_items.first } let(:variant) { create(:variant) } @@ -40,8 +40,8 @@ module Stock context "when finalizing an order with multiple line_items" do let(:order) { build(:order_with_line_items, line_items_count: 2) } - let(:inventory_unit) { build(:inventory_unit, order: order, variant: order.line_items.first.variant, shipment: order.shipments.first) } - let(:inventory_unit_2) { build(:inventory_unit, order: order, variant: order.line_items.second.variant, shipment: order.shipments.first) } + let(:inventory_unit) { build(:inventory_unit, order:, variant: order.line_items.first.variant, shipment: order.shipments.first) } + let(:inventory_unit_2) { build(:inventory_unit, order:, variant: order.line_items.second.variant, shipment: order.shipments.first) } let(:stock_item) { inventory_unit.variant.stock_items.first } let(:stock_item_2) { inventory_unit.variant.stock_items.first } diff --git a/core/spec/models/spree/stock/package_spec.rb b/core/spec/models/spree/stock/package_spec.rb index 51268e68b4a..a942c3b04eb 100644 --- a/core/spec/models/spree/stock/package_spec.rb +++ b/core/spec/models/spree/stock/package_spec.rb @@ -8,12 +8,12 @@ module Stock let(:variant) { build(:variant, weight: 25.0) } let(:stock_location) { build(:stock_location) } let(:order) { build(:order) } - let(:line_item) { build(:line_item, order: order) } + let(:line_item) { build(:line_item, order:) } subject { Package.new(stock_location) } def build_inventory_unit - build(:inventory_unit, variant: variant, line_item: line_item) + build(:inventory_unit, variant:, line_item:) end it 'calculates the weight of all the contents' do @@ -90,7 +90,7 @@ def build_inventory_unit it 'builds an empty list of shipping methods when no categories' do variant = mock_model(Variant, shipping_category_id: nil) - contents = [ContentItem.new(build(:inventory_unit, variant: variant))] + contents = [ContentItem.new(build(:inventory_unit, variant:))] package = Package.new(stock_location, contents) expect(package.shipping_methods).to be_empty end @@ -102,7 +102,7 @@ def build_inventory_unit shipping_method = build(:shipping_method) shipment = subject.to_shipment - shipment.shipping_rates = [Spree::ShippingRate.new(shipping_method: shipping_method, cost: 10.00, selected: true)] + shipment.shipping_rates = [Spree::ShippingRate.new(shipping_method:, cost: 10.00, selected: true)] expect(shipment.stock_location).to eq subject.stock_location expect(shipment.inventory_units.size).to eq 3 diff --git a/core/spec/models/spree/stock/simple_coordinator_spec.rb b/core/spec/models/spree/stock/simple_coordinator_spec.rb index 02a245b1288..6b67af344af 100644 --- a/core/spec/models/spree/stock/simple_coordinator_spec.rb +++ b/core/spec/models/spree/stock/simple_coordinator_spec.rb @@ -113,7 +113,7 @@ module Stock end let!(:order) { create(:order) } - let!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 5) } + let!(:line_item) { create(:line_item, order:, variant:, quantity: 5) } before { order.reload } let(:shipments) { subject.shipments } diff --git a/core/spec/models/spree/stock/splitter/backordered_spec.rb b/core/spec/models/spree/stock/splitter/backordered_spec.rb index 7093c40bd5e..42d5390edba 100644 --- a/core/spec/models/spree/stock/splitter/backordered_spec.rb +++ b/core/spec/models/spree/stock/splitter/backordered_spec.rb @@ -14,8 +14,8 @@ module Splitter it 'splits packages by status' do package = Package.new(stock_location) - 4.times { package.add build(:inventory_unit, variant: variant) } - 5.times { package.add build(:inventory_unit, variant: variant), :backordered } + 4.times { package.add build(:inventory_unit, variant:) } + 5.times { package.add build(:inventory_unit, variant:), :backordered } packages = subject.split([package]) expect(packages.count).to eq 2 diff --git a/core/spec/models/spree/stock/splitter/shipping_category_spec.rb b/core/spec/models/spree/stock/splitter/shipping_category_spec.rb index 23d9448d3a6..654bf29fc01 100644 --- a/core/spec/models/spree/stock/splitter/shipping_category_spec.rb +++ b/core/spec/models/spree/stock/splitter/shipping_category_spec.rb @@ -13,13 +13,13 @@ module Stock let(:shipping_category_2) { create(:shipping_category, name: 'B') } def inventory_unit1 - build(:inventory_unit, variant: variant1, order: order, line_item: line_item).tap do |inventory_unit| + build(:inventory_unit, variant: variant1, order:, line_item:).tap do |inventory_unit| inventory_unit.variant.product.shipping_category = shipping_category_1 end end def inventory_unit2 - build(:inventory_unit, variant: variant2, order: order, line_item: line_item).tap do |inventory_unit| + build(:inventory_unit, variant: variant2, order:, line_item:).tap do |inventory_unit| inventory_unit.variant.product.shipping_category = shipping_category_2 end end diff --git a/core/spec/models/spree/stock/splitter/weight_spec.rb b/core/spec/models/spree/stock/splitter/weight_spec.rb index 383bb4abc8e..9a911af477c 100644 --- a/core/spec/models/spree/stock/splitter/weight_spec.rb +++ b/core/spec/models/spree/stock/splitter/weight_spec.rb @@ -13,7 +13,7 @@ module Splitter it 'splits and keeps splitting until all packages are underweight' do package = Package.new(stock_location) - 4.times { package.add build(:inventory_unit, variant: variant) } + 4.times { package.add build(:inventory_unit, variant:) } packages = subject.split([package]) expect(packages.size).to eq 4 end @@ -21,7 +21,7 @@ module Splitter it 'handles packages that can not be reduced' do package = Package.new(stock_location) allow(variant).to receive_messages(weight: 200) - 2.times { package.add build(:inventory_unit, variant: variant) } + 2.times { package.add build(:inventory_unit, variant:) } packages = subject.split([package]) expect(packages.size).to eq 2 end diff --git a/core/spec/models/spree/stock_item_spec.rb b/core/spec/models/spree/stock_item_spec.rb index d0b05321f0c..aa86840acd4 100644 --- a/core/spec/models/spree/stock_item_spec.rb +++ b/core/spec/models/spree/stock_item_spec.rb @@ -196,7 +196,7 @@ context "inventory_cache_threshold is set" do before do - stub_spree_preferences(inventory_cache_threshold: inventory_cache_threshold) + stub_spree_preferences(inventory_cache_threshold:) end let(:inventory_cache_threshold) { 5 } diff --git a/core/spec/models/spree/stock_location_spec.rb b/core/spec/models/spree/stock_location_spec.rb index 583f4237f13..739842f78fe 100644 --- a/core/spec/models/spree/stock_location_spec.rb +++ b/core/spec/models/spree/stock_location_spec.rb @@ -244,13 +244,13 @@ module Spree context 'both name and abbr is present' do let(:state) { stub_model(Spree::State, name: 'virginia', abbr: 'va') } - subject { StockLocation.create(name: "testing", state: state, state_name: nil) } + subject { StockLocation.create(name: "testing", state:, state_name: nil) } specify { expect(subject.state_text).to eq('va') } end context 'only name is present' do let(:state) { stub_model(Spree::State, name: 'virginia', abbr: nil) } - subject { StockLocation.create(name: "testing", state: state, state_name: nil) } + subject { StockLocation.create(name: "testing", state:, state_name: nil) } specify { expect(subject.state_text).to eq('virginia') } end end diff --git a/core/spec/models/spree/stock_movement_spec.rb b/core/spec/models/spree/stock_movement_spec.rb index 19e3b8ad8fc..d3f1e3bed3e 100644 --- a/core/spec/models/spree/stock_movement_spec.rb +++ b/core/spec/models/spree/stock_movement_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Spree::StockMovement, type: :model do let(:stock_location) { create(:stock_location_with_items) } let(:stock_item) { stock_location.stock_items.order(:id).first } - subject { build(:stock_movement, stock_item: stock_item) } + subject { build(:stock_movement, stock_item:) } it 'should belong to a stock item' do expect(subject).to respond_to(:stock_item) diff --git a/core/spec/models/spree/store_credit_event_spec.rb b/core/spec/models/spree/store_credit_event_spec.rb index d832b063bd3..b0b89554ba8 100644 --- a/core/spec/models/spree/store_credit_event_spec.rb +++ b/core/spec/models/spree/store_credit_event_spec.rb @@ -10,7 +10,7 @@ ].each do |action| let(:action) { action } it "excludes #{action} actions" do - event = create(:store_credit_event, action: action) + event = create(:store_credit_event, action:) expect(described_class.exposed_events).not_to include event end end @@ -22,7 +22,7 @@ Spree::StoreCredit::ALLOCATION_ACTION ].each do |action| it "includes #{action} actions" do - event = create(:store_credit_event, action: action) + event = create(:store_credit_event, action:) expect(described_class.exposed_events).to include event end end @@ -209,7 +209,7 @@ describe "#display_user_total_amount" do let(:user_total_amount) { 300.0 } - subject { create(:store_credit_auth_event, user_total_amount: user_total_amount) } + subject { create(:store_credit_auth_event, user_total_amount:) } it "returns a Spree::Money instance" do expect(subject.display_user_total_amount).to be_instance_of(Spree::Money) @@ -223,7 +223,7 @@ describe "#display_remaining_amount" do let(:amount_remaining) { 300.0 } - subject { create(:store_credit_auth_event, amount_remaining: amount_remaining) } + subject { create(:store_credit_auth_event, amount_remaining:) } it "returns a Spree::Money instance" do expect(subject.display_remaining_amount).to be_instance_of(Spree::Money) @@ -316,9 +316,9 @@ context "there is an associated payment with the event" do let(:authorization_code) { "1-SC-TEST" } let(:order) { create(:order) } - let!(:payment) { create(:store_credit_payment, order: order, response_code: authorization_code) } + let!(:payment) { create(:store_credit_payment, order:, response_code: authorization_code) } - subject { create(:store_credit_auth_event, action: Spree::StoreCredit::CAPTURE_ACTION, authorization_code: authorization_code) } + subject { create(:store_credit_auth_event, action: Spree::StoreCredit::CAPTURE_ACTION, authorization_code:) } it "returns the order associated with the payment" do expect(subject.order).to eq order diff --git a/core/spec/models/spree/store_credit_spec.rb b/core/spec/models/spree/store_credit_spec.rb index c78591e4b0c..1612b24e257 100644 --- a/core/spec/models/spree/store_credit_spec.rb +++ b/core/spec/models/spree/store_credit_spec.rb @@ -162,7 +162,7 @@ end describe "#amount=" do - let(:store_credit) { described_class.new(amount: amount) } + let(:store_credit) { described_class.new(amount:) } context "with an imperial price format" do let(:amount) { "1,000.50" } @@ -219,7 +219,7 @@ context "the amount_used is defined" do let(:amount_used) { 10.0 } - before { store_credit.update(amount_used: amount_used) } + before { store_credit.update(amount_used:) } context "the authorized amount is not defined" do it "subtracts the amount used from the credited amount" do @@ -270,7 +270,7 @@ end context "authorization has already happened" do - let!(:auth_event) { create(:store_credit_auth_event, store_credit: store_credit) } + let!(:auth_event) { create(:store_credit_auth_event, store_credit:) } before { store_credit.update(amount_authorized: store_credit.amount) } @@ -439,7 +439,7 @@ action: Spree::StoreCredit::CAPTURE_ACTION, authorization_code: auth_code, amount: captured_amount, - store_credit: store_credit) + store_credit:) } it "returns false" do @@ -459,7 +459,7 @@ create(:store_credit_auth_event, authorization_code: auth_code, amount: authorized_amount, - store_credit: store_credit) + store_credit:) } it "returns true" do @@ -484,13 +484,13 @@ describe "#credit" do let(:event_auth_code) { "1-SC-20141111111111" } let(:amount_used) { 10.0 } - let(:store_credit) { create(:store_credit, amount_used: amount_used) } + let(:store_credit) { create(:store_credit, amount_used:) } let!(:capture_event) { create(:store_credit_auth_event, action: Spree::StoreCredit::CAPTURE_ACTION, authorization_code: event_auth_code, amount: captured_amount, - store_credit: store_credit) + store_credit:) } let(:originator) { nil } @@ -629,7 +629,7 @@ context "amount used is defined" do let(:amount_used) { 100.0 } - subject { create(:store_credit, amount_used: amount_used) } + subject { create(:store_credit, amount_used:) } it "returns the attribute value" do expect(subject.amount_used).to eq amount_used @@ -649,7 +649,7 @@ context "amount authorized is defined" do let(:amount_authorized) { 100.0 } - subject { create(:store_credit, amount_authorized: amount_authorized) } + subject { create(:store_credit, amount_authorized:) } it "returns the attribute value" do expect(subject.amount_authorized).to eq amount_authorized @@ -820,7 +820,7 @@ let!(:store_credits) do [ - create(:store_credit, user: user, amount: store_credit_amount), + create(:store_credit, user:, amount: store_credit_amount), create(:store_credit, user: user.reload, amount: additional_store_credit_amount) ] end diff --git a/core/spec/models/spree/store_selector/by_server_name_spec.rb b/core/spec/models/spree/store_selector/by_server_name_spec.rb index 4d214e830ed..8ffddca7d78 100644 --- a/core/spec/models/spree/store_selector/by_server_name_spec.rb +++ b/core/spec/models/spree/store_selector/by_server_name_spec.rb @@ -24,7 +24,7 @@ context "with a domain match" do let(:request) { double(headers: {}, env: { "SERVER_NAME" => url } ) } let(:url) { "server-name.org" } - let!(:store_2) { create :store, default: false, url: url } + let!(:store_2) { create :store, default: false, url: } it "returns the store with the matching domain" do expect(subject).to eq(store_2) diff --git a/core/spec/models/spree/store_selector/legacy_spec.rb b/core/spec/models/spree/store_selector/legacy_spec.rb index 8b90d40a016..32dd3a24a8b 100644 --- a/core/spec/models/spree/store_selector/legacy_spec.rb +++ b/core/spec/models/spree/store_selector/legacy_spec.rb @@ -17,7 +17,7 @@ context "with a domain match" do let(:request) { double(headers: {}, env: { "SERVER_NAME" => url } ) } let(:url) { "server-name.org" } - let!(:store_2) { create :store, default: false, url: url } + let!(:store_2) { create :store, default: false, url: } it "returns the store with the matching domain" do expect(subject).to eq(store_2) diff --git a/core/spec/models/spree/store_spec.rb b/core/spec/models/spree/store_spec.rb index 95a6a34d74b..8492d4da26b 100644 --- a/core/spec/models/spree/store_spec.rb +++ b/core/spec/models/spree/store_spec.rb @@ -32,7 +32,7 @@ end describe '#default_cart_tax_location' do - subject { described_class.new(cart_tax_country_iso: cart_tax_country_iso) } + subject { described_class.new(cart_tax_country_iso:) } context "when there is no cart_tax_country_iso set" do let(:cart_tax_country_iso) { '' } it "responds with an empty default_cart_tax_location" do @@ -45,7 +45,7 @@ let(:cart_tax_country_iso) { country.iso } it "responds with a default_cart_tax_location with that country" do - expect(subject.default_cart_tax_location).to eq(Spree::Tax::TaxLocation.new(country: country)) + expect(subject.default_cart_tax_location).to eq(Spree::Tax::TaxLocation.new(country:)) end end end diff --git a/core/spec/models/spree/tax/tax_helpers_spec.rb b/core/spec/models/spree/tax/tax_helpers_spec.rb index c941052959c..1fd2bf892f5 100644 --- a/core/spec/models/spree/tax/tax_helpers_spec.rb +++ b/core/spec/models/spree/tax/tax_helpers_spec.rb @@ -16,12 +16,12 @@ def valid_rates(item) let(:tax_category) { create(:tax_category) } let(:irrelevant_tax_category) { create(:tax_category) } - let(:item) { create(:line_item, tax_category: tax_category) } + let(:item) { create(:line_item, tax_category:) } let(:tax_address) { item.order.tax_address } let(:zone) { create(:zone, name: "Country Zone", countries: [tax_address.country]) } let!(:tax_rate) do - create(:tax_rate, tax_categories: [tax_category], zone: zone) + create(:tax_rate, tax_categories: [tax_category], zone:) end describe '#rates_for_item' do @@ -34,8 +34,8 @@ def valid_rates(item) let(:expires_at) { 2.days.from_now } let!(:invalid_tax_rate) do - create(:tax_rate, tax_categories: [tax_category], zone: zone, - starts_at: starts_at, expires_at: expires_at) + create(:tax_rate, tax_categories: [tax_category], zone:, + starts_at:, expires_at:) end it 'returns only active rates that match the tax category of given item' do diff --git a/core/spec/models/spree/tax/tax_location_spec.rb b/core/spec/models/spree/tax/tax_location_spec.rb index 26d7109166a..e3b740b4271 100644 --- a/core/spec/models/spree/tax/tax_location_spec.rb +++ b/core/spec/models/spree/tax/tax_location_spec.rb @@ -30,7 +30,7 @@ subject { described_class.new(**args) } context 'with a country object' do - let(:args) { { country: country } } + let(:args) { { country: } } it "will yield a location with that country's id" do expect(subject.country_id).to eq(country.id) @@ -43,7 +43,7 @@ subject { described_class.new(**args).country } context 'with a country object' do - let(:args) { { country: country } } + let(:args) { { country: } } it { is_expected.to eq(country) } end @@ -59,13 +59,13 @@ subject { described_class.new(**args).empty? } context 'with a country present' do - let(:args) { { country: country } } + let(:args) { { country: } } it { is_expected.to be false } end context 'with a state present' do - let(:args) { { state: state } } + let(:args) { { state: } } it { is_expected.to be false } end diff --git a/core/spec/models/spree/tax_rate_spec.rb b/core/spec/models/spree/tax_rate_spec.rb index c9550b2f633..7205b8896f4 100644 --- a/core/spec/models/spree/tax_rate_spec.rb +++ b/core/spec/models/spree/tax_rate_spec.rb @@ -109,7 +109,7 @@ let(:default_zone) { create(:zone, :with_country) } let(:included_in_price) { false } let!(:rate) do - create(:tax_rate, zone: default_zone, included_in_price: included_in_price) + create(:tax_rate, zone: default_zone, included_in_price:) end context "when the zone is the default zone" do diff --git a/core/spec/models/spree/taxon_spec.rb b/core/spec/models/spree/taxon_spec.rb index b02f39384ff..2b254a19ba5 100644 --- a/core/spec/models/spree/taxon_spec.rb +++ b/core/spec/models/spree/taxon_spec.rb @@ -86,7 +86,7 @@ context "with parent taxon" do let(:parent) { FactoryBot.build(:taxon, permalink: "brands") } - before { allow(taxon).to receive_messages parent: parent } + before { allow(taxon).to receive_messages(parent:) } it "should set permalink correctly when taxon has parent" do taxon.set_permalink @@ -126,9 +126,9 @@ context "updating permalink" do let(:taxonomy) { create(:taxonomy, name: 't') } let(:root) { taxonomy.root } - let(:taxon1) { create(:taxon, name: 't1', taxonomy: taxonomy, parent: root) } - let(:taxon2) { create(:taxon, name: 't2', taxonomy: taxonomy, parent: root) } - let(:taxon2_child) { create(:taxon, name: 't2_child', taxonomy: taxonomy, parent: taxon2) } + let(:taxon1) { create(:taxon, name: 't1', taxonomy:, parent: root) } + let(:taxon2) { create(:taxon, name: 't2', taxonomy:, parent: root) } + let(:taxon2_child) { create(:taxon, name: 't2_child', taxonomy:, parent: taxon2) } context "changing parent" do subject { taxon2.update!(parent: taxon1) } @@ -202,17 +202,17 @@ end it "allows for multiple taxons under a taxonomy" do - taxon = taxonomy.root.children.create!(name: 'First child', taxonomy: taxonomy) + taxon = taxonomy.root.children.create!(name: 'First child', taxonomy:) expect(taxon).to be_valid expect(taxonomy.taxons.many?).to eq(true) - second_taxon = taxonomy.root.children.create!(name: 'Second child', taxonomy: taxonomy) + second_taxon = taxonomy.root.children.create!(name: 'Second child', taxonomy:) expect(second_taxon).to be_valid expect(taxonomy.root.children.many?).to eq(true) end # Regression test https://github.com/solidusio/solidus/issues/5187 it "does not invalidate the root taxon after having children taxons" do - taxonomy.root.children.create!(name: 'New node', taxonomy: taxonomy) + taxonomy.root.children.create!(name: 'New node', taxonomy:) expect(taxonomy.taxons.many?).to eq(true) expect(taxonomy.root).to be_valid end @@ -238,9 +238,9 @@ context 'leaves of the taxon tree' do let(:taxonomy) { create(:taxonomy, name: 't') } let(:root) { taxonomy.root } - let(:taxon) { create(:taxon, name: 't1', taxonomy: taxonomy, parent: root) } - let(:child) { create(:taxon, name: 'child taxon', taxonomy: taxonomy, parent: taxon) } - let(:grandchild) { create(:taxon, name: 'grandchild taxon', taxonomy: taxonomy, parent: child) } + let(:taxon) { create(:taxon, name: 't1', taxonomy:, parent: root) } + let(:child) { create(:taxon, name: 'child taxon', taxonomy:, parent: taxon) } + let(:grandchild) { create(:taxon, name: 'grandchild taxon', taxonomy:, parent: child) } let(:product1) { create(:product) } let(:product2) { create(:product) } let(:product3) { create(:product) } diff --git a/core/spec/models/spree/unit_cancel_spec.rb b/core/spec/models/spree/unit_cancel_spec.rb index 139b8e2067d..948eea11675 100644 --- a/core/spec/models/spree/unit_cancel_spec.rb +++ b/core/spec/models/spree/unit_cancel_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Spree::UnitCancel do - let(:unit_cancel) { described_class.create!(inventory_unit: inventory_unit, reason: described_class::SHORT_SHIP) } + let(:unit_cancel) { described_class.create!(inventory_unit:, reason: described_class::SHORT_SHIP) } let(:inventory_unit) { create(:inventory_unit) } describe '#adjust!' do @@ -65,7 +65,7 @@ context "multiple inventory units" do let(:quantity) { 4 } - let(:order) { create(:order_with_line_items, line_items_attributes: [{ quantity: quantity }]) } + let(:order) { create(:order_with_line_items, line_items_attributes: [{ quantity: }]) } let(:line_item) { order.line_items.first } let(:inventory_units) { line_item.inventory_units } @@ -75,7 +75,7 @@ it "properly creates adjustments for line_item" do inventory_units.each do |inventory_unit| - described_class.create!(inventory_unit: inventory_unit, reason: described_class::SHORT_SHIP).adjust! + described_class.create!(inventory_unit:, reason: described_class::SHORT_SHIP).adjust! inventory_unit.cancel! end expect(line_item.reload.total.to_d).to eq(0) @@ -85,7 +85,7 @@ context 'when line item has additional taxes' do let(:world_zone) { create(:zone, :with_country) } let(:tax_category) { create :tax_category } - let(:product) { create :product, tax_category: tax_category } + let(:product) { create :product, tax_category: } let!(:additional_tax_rate) do create( :tax_rate, @@ -101,7 +101,7 @@ create :shipping_method, cost: 8.00, shipping_categories: [shipping_category], - tax_category: tax_category, + tax_category:, zones: [world_zone] end let(:shipping_address) { create :address, country_iso_code: world_zone.countries.first.iso } @@ -109,7 +109,7 @@ create( :order_with_line_items, ship_address: shipping_address, - line_items_attributes: [{ product: product }] + line_items_attributes: [{ product: }] ) end let(:line_item) { order.line_items.first } diff --git a/core/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb b/core/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb index 121ab331139..639c82ef9e1 100644 --- a/core/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb +++ b/core/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb @@ -5,10 +5,10 @@ RSpec.describe Spree::UserLastUrlStorer::Rules::AuthenticationRule do describe '#match?' do let(:login_path) { '/sign_in' } - let(:request) { double(fullpath: fullpath) } + let(:request) { double(fullpath:) } let(:controller) do double( - request: request, + request:, spree_login_path: login_path, controller_name: 'controller_double' ) diff --git a/core/spec/models/spree/user_last_url_storer_spec.rb b/core/spec/models/spree/user_last_url_storer_spec.rb index aa3c7794583..26f93436777 100644 --- a/core/spec/models/spree/user_last_url_storer_spec.rb +++ b/core/spec/models/spree/user_last_url_storer_spec.rb @@ -7,12 +7,12 @@ let(:fullpath) { '/products/baseball-cap' } let(:session) { {} } - let(:request) { double(fullpath: fullpath) } + let(:request) { double(fullpath:) } let(:controller) do instance_double( ApplicationController, - request: request, - session: session, + request:, + session:, controller_name: 'app_controller_double' ) end diff --git a/core/spec/models/spree/user_spec.rb b/core/spec/models/spree/user_spec.rb index 0de49d08328..159f6284dcb 100644 --- a/core/spec/models/spree/user_spec.rb +++ b/core/spec/models/spree/user_spec.rb @@ -7,30 +7,30 @@ let!(:user) { create(:user) } it "excludes orders that are not frontend_viewable" do - create(:order, user: user, frontend_viewable: false) + create(:order, user:, frontend_viewable: false) expect(user.last_incomplete_spree_order).to eq nil end it "can include orders that are not frontend viewable" do - order = create(:order, user: user, frontend_viewable: false) + order = create(:order, user:, frontend_viewable: false) expect(user.last_incomplete_spree_order(only_frontend_viewable: false)).to eq order end it "can scope to a store" do store = create(:store) - store_1_order = create(:order, user: user, store: store) - create(:order, user: user, store: create(:store)) - expect(user.last_incomplete_spree_order(store: store)).to eq store_1_order + store_1_order = create(:order, user:, store:) + create(:order, user:, store: create(:store)) + expect(user.last_incomplete_spree_order(store:)).to eq store_1_order end it "excludes completed orders" do - create(:completed_order_with_totals, user: user, created_by: user) + create(:completed_order_with_totals, user:, created_by: user) expect(user.last_incomplete_spree_order).to eq nil end it "excludes orders created prior to the user's last completed order" do - create(:order, user: user, created_by: user, created_at: 1.second.ago) - create(:completed_order_with_totals, user: user, created_by: user) + create(:order, user:, created_by: user, created_at: 1.second.ago) + create(:completed_order_with_totals, user:, created_by: user) expect(user.last_incomplete_spree_order).to eq nil end @@ -40,7 +40,7 @@ end it "excludes orders created outside of the cutoff date" do - create(:order, user: user, created_by: user, created_at: 3.days.ago, updated_at: 2.days.ago) + create(:order, user:, created_by: user, created_at: 3.days.ago, updated_at: 2.days.ago) expect(user.last_incomplete_spree_order).to eq nil end end @@ -51,21 +51,21 @@ end it "excludes orders updated outside of the cutoff date" do - create(:order, user: user, created_by: user, created_at: 3.days.ago, updated_at: 2.days.ago) + create(:order, user:, created_by: user, created_at: 3.days.ago, updated_at: 2.days.ago) expect(user.last_incomplete_spree_order).to eq nil end end it "chooses the most recently created incomplete order" do - create(:order, user: user, created_at: 1.second.ago) - order_2 = create(:order, user: user) + create(:order, user:, created_at: 1.second.ago) + order_2 = create(:order, user:) expect(user.last_incomplete_spree_order).to eq order_2 end context "persists order address" do let(:bill_address) { create(:address) } let(:ship_address) { create(:address) } - let(:order) { create(:order, user: user, bill_address: bill_address, ship_address: ship_address) } + let(:order) { create(:order, user:, bill_address:, ship_address:) } it "doesn't create new addresses" do user.user_addresses.create(address: bill_address) diff --git a/core/spec/models/spree/validations/db_maximum_length_validator_spec.rb b/core/spec/models/spree/validations/db_maximum_length_validator_spec.rb index 134d6eb3494..0b71a19659a 100644 --- a/core/spec/models/spree/validations/db_maximum_length_validator_spec.rb +++ b/core/spec/models/spree/validations/db_maximum_length_validator_spec.rb @@ -31,7 +31,7 @@ class LimitedProduct < ActiveRecord::Base Object.send(:remove_const, :LimitedProduct) end - let(:record) { LimitedProduct.new(slug: slug) } + let(:record) { LimitedProduct.new(slug:) } context "when slug is below limit" do let(:slug) { 'a' * 255 } diff --git a/core/spec/models/spree/variant/price_selector_spec.rb b/core/spec/models/spree/variant/price_selector_spec.rb index e94c9ed2757..dae1083835a 100644 --- a/core/spec/models/spree/variant/price_selector_spec.rb +++ b/core/spec/models/spree/variant/price_selector_spec.rb @@ -40,7 +40,7 @@ context "with a price for that country present" do before do - variant.prices.create(amount: 44.44, country: country, currency: Spree::Config.currency) + variant.prices.create(amount: 44.44, country:, currency: Spree::Config.currency) end it "returns the correct price and currency", :aggregate_failures do diff --git a/core/spec/models/spree/variant/pricing_options_spec.rb b/core/spec/models/spree/variant/pricing_options_spec.rb index 5093921fcd9..0de0007a0b0 100644 --- a/core/spec/models/spree/variant/pricing_options_spec.rb +++ b/core/spec/models/spree/variant/pricing_options_spec.rb @@ -61,7 +61,7 @@ context ".from_price" do let(:country) { create(:country) } - let(:price) { create(:price, country: country) } + let(:price) { create(:price, country:) } subject { described_class.from_price(price) } it "gets the currency from the previous price" do diff --git a/core/spec/models/spree/variant/scopes_spec.rb b/core/spec/models/spree/variant/scopes_spec.rb index 8a9ed403673..e1c9247415d 100644 --- a/core/spec/models/spree/variant/scopes_spec.rb +++ b/core/spec/models/spree/variant/scopes_spec.rb @@ -4,8 +4,8 @@ RSpec.describe "Variant scopes", type: :model do let!(:product) { create(:product) } - let!(:variant_1) { create(:variant, product: product) } - let!(:variant_2) { create(:variant, product: product) } + let!(:variant_1) { create(:variant, product:) } + let!(:variant_2) { create(:variant, product:) } describe ".with_prices" do context "when searching for the default pricing options" do @@ -69,13 +69,13 @@ describe ".has_option" do let!(:option_type) { create(:option_type, name: "bar") } let!(:option_value_1) do - option_value = create(:option_value, name: "foo", option_type: option_type) + option_value = create(:option_value, name: "foo", option_type:) variant_1.option_values << option_value option_value end let!(:option_value_2) do - option_value = create(:option_value, name: "fizz", option_type: option_type) + option_value = create(:option_value, name: "fizz", option_type:) variant_1.option_values << option_value option_value end diff --git a/core/spec/models/spree/variant/vat_price_generator_spec.rb b/core/spec/models/spree/variant/vat_price_generator_spec.rb index b07e023186d..d1a95382a06 100644 --- a/core/spec/models/spree/variant/vat_price_generator_spec.rb +++ b/core/spec/models/spree/variant/vat_price_generator_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Spree::Variant::VatPriceGenerator do let(:tax_category) { create(:tax_category) } let(:product) { variant.product } - let(:variant) { create(:variant, price: 10, tax_category: tax_category) } + let(:variant) { create(:variant, price: 10, tax_category:) } subject { described_class.new(variant).run } diff --git a/core/spec/models/spree/variant_property_rule_spec.rb b/core/spec/models/spree/variant_property_rule_spec.rb index 67890ca3120..ec843bda903 100644 --- a/core/spec/models/spree/variant_property_rule_spec.rb +++ b/core/spec/models/spree/variant_property_rule_spec.rb @@ -55,7 +55,7 @@ describe "#applies_to_variant?" do let(:variant_option_value_1) { create(:option_value) } let(:variant_option_value_2) { create(:option_value) } - let!(:variant) { create(:variant, option_values: option_values) } + let!(:variant) { create(:variant, option_values:) } let(:rule_option_value) { create(:option_value) } let(:rule) { create(:variant_property_rule, option_value: rule_option_value) } diff --git a/core/spec/models/spree/variant_spec.rb b/core/spec/models/spree/variant_spec.rb index def0b21ff3c..d543cfe87e1 100644 --- a/core/spec/models/spree/variant_spec.rb +++ b/core/spec/models/spree/variant_spec.rb @@ -9,7 +9,7 @@ describe 'delegates' do let(:product) { build(:product) } - let(:variant) { build(:variant, product: product) } + let(:variant) { build(:variant, product:) } it 'discontinue_on to product' do expect(product).to receive(:discontinue_on) @@ -116,7 +116,7 @@ let!(:high_vat) { create(:tax_rate, included_in_price: true, amount: 0.25, zone: high_vat_zone, tax_categories: [tax_category]) } let!(:low_vat) { create(:tax_rate, included_in_price: true, amount: 0.15, zone: low_vat_zone, tax_categories: [tax_category]) } - let(:product) { build(:product, tax_category: tax_category) } + let(:product) { build(:product, tax_category:) } subject(:new_variant) { build(:variant, price: 15) } @@ -133,7 +133,7 @@ context "when the products price changes" do context "and rebuild_vat_prices is set to true" do - subject { variant.update(price: 99, rebuild_vat_prices: true, tax_category: tax_category) } + subject { variant.update(price: 99, rebuild_vat_prices: true, tax_category:) } it "creates new appropriate prices for this variant" do expect { subject }.to change { Spree::Price.count }.by(3) @@ -145,7 +145,7 @@ end context "and rebuild_vat_prices is not set" do - subject { variant.update(price: 99, tax_category: tax_category) } + subject { variant.update(price: 99, tax_category:) } it "does not create new prices" do expect { subject }.not_to change { Spree::Price.count } @@ -279,8 +279,8 @@ it 'prioritizes prices recently updated' do variant = create(:variant) - price = create(:price, variant: variant, currency: 'USD') - create(:price, variant: variant, currency: 'USD') + price = create(:price, variant:, currency: 'USD') + create(:price, variant:, currency: 'USD') price.touch variant.prices.reload @@ -291,7 +291,7 @@ variant = create(:variant) price = build(:price, currency: 'USD', amount: 1, variant_id: variant.id) variant.prices.build(price.attributes) - create(:price, variant: variant, currency: 'USD', amount: 2) + create(:price, variant:, currency: 'USD', amount: 2) expect(variant.default_price.attributes).to eq(price.attributes) end @@ -409,14 +409,14 @@ context "when both variants have a price" do let(:product) { create(:product, price: 25) } - let(:variant) { create(:variant, product: product, price: 35) } + let(:variant) { create(:variant, product:, price: 35) } it { is_expected.to eq(Spree::Money.new(10, currency: Spree::Config.currency)) } end context "when the master variant does not have a price" do let(:product) { create(:product, price: 25) } - let(:variant) { create(:variant, product: product, price: 35) } + let(:variant) { create(:variant, product:, price: 35) } before do allow(product.master).to receive(:price_for_options).and_return(nil) @@ -427,7 +427,7 @@ context "when the variant does not have a price" do let(:product) { create(:product, price: 25) } - let(:variant) { create(:variant, product: product, price: 35) } + let(:variant) { create(:variant, product:, price: 35) } before do allow(variant).to receive(:price_for_options).and_return(nil) @@ -712,7 +712,7 @@ describe '#tax_category' do context 'when tax_category is nil' do let(:product) { build(:product) } - let(:variant) { build(:variant, product: product, tax_category_id: nil) } + let(:variant) { build(:variant, product:, tax_category_id: nil) } it 'returns the parent products tax_category' do expect(variant.tax_category).to eq(product.tax_category) end @@ -720,7 +720,7 @@ context 'when tax_category is set' do let(:tax_category) { create(:tax_category) } - let(:variant) { build(:variant, tax_category: tax_category) } + let(:variant) { build(:variant, tax_category:) } it 'returns the tax_category set on itself' do expect(variant.tax_category).to eq(tax_category) end @@ -730,8 +730,8 @@ describe '#shipping_category' do context 'when shipping_category is nil' do let(:shipping_category) { build(:shipping_category) } - let(:product) { build(:product, shipping_category: shipping_category) } - let(:variant) { build(:variant, product: product, shipping_category_id: nil) } + let(:product) { build(:product, shipping_category:) } + let(:variant) { build(:variant, product:, shipping_category_id: nil) } it 'returns the parent products shipping_category' do expect(variant.shipping_category).to eq(shipping_category) end @@ -739,7 +739,7 @@ context 'when shipping_category is set' do let(:shipping_category) { create(:shipping_category) } - let(:variant) { build(:variant, shipping_category: shipping_category) } + let(:variant) { build(:variant, shipping_category:) } it 'returns the shipping_category set on itself' do expect(variant.shipping_category).to eq(shipping_category) end @@ -749,8 +749,8 @@ describe '#shipping_category_id' do context 'when shipping_category_id is nil' do let(:shipping_category) { build(:shipping_category) } - let(:product) { build(:product, shipping_category: shipping_category) } - let(:variant) { build(:variant, product: product, shipping_category_id: nil) } + let(:product) { build(:product, shipping_category:) } + let(:variant) { build(:variant, product:, shipping_category_id: nil) } it 'returns the parent products shipping_category_id' do expect(variant.shipping_category_id).to eq(shipping_category.id) end @@ -858,10 +858,10 @@ context "there's stock in the location" do before do in_stock_variant. - stock_items.find_by(stock_location: stock_location). + stock_items.find_by(stock_location:). update_column(:count_on_hand, 10) out_of_stock_variant. - stock_items.where.not(stock_location: stock_location).first. + stock_items.where.not(stock_location:).first. update_column(:count_on_hand, 10) end @@ -967,7 +967,7 @@ context "when variant.images is empty" do let(:product) { create(:product) } - let(:variant) { create(:variant, product: product) } + let(:variant) { create(:variant, product:) } it "fallbacks to variant.product.master.images" do product.master.images = [create(:image)] @@ -1007,7 +1007,7 @@ it { is_expected.to be_zero } context "with a backordered inventory_unit" do - let!(:backordered_inventory_unit) { create(:inventory_unit, variant: variant, state: :backordered) } + let!(:backordered_inventory_unit) { create(:inventory_unit, variant:, state: :backordered) } it { is_expected.to eq(1) } end @@ -1031,7 +1031,7 @@ describe "#name_and_sku" do let(:product) { build(:product, name: "Ernie and Bert" )} - let(:variant) { build(:variant, product: product, sku: "EB1") } + let(:variant) { build(:variant, product:, sku: "EB1") } subject { variant.name_and_sku } diff --git a/core/spec/models/spree/wallet/add_payment_sources_to_wallet_spec.rb b/core/spec/models/spree/wallet/add_payment_sources_to_wallet_spec.rb index 7cdf56a79d7..73bdb5dec24 100644 --- a/core/spec/models/spree/wallet/add_payment_sources_to_wallet_spec.rb +++ b/core/spec/models/spree/wallet/add_payment_sources_to_wallet_spec.rb @@ -22,8 +22,8 @@ context "when the default wallet payment source is used and a more recent wallet payment exists" do before do - credit_card_one = user.wallet.add(create(:credit_card, user: user)) - user.wallet.add(create(:credit_card, user: user)) + credit_card_one = user.wallet.add(create(:credit_card, user:)) + user.wallet.add(create(:credit_card, user:)) user.wallet.default_wallet_payment_source = credit_card_one # must be the first created card order.payments.first.update!(source: credit_card_one.payment_source) end diff --git a/core/spec/models/spree/wallet_payment_source_spec.rb b/core/spec/models/spree/wallet_payment_source_spec.rb index 7555c7623f5..9822cf511d6 100644 --- a/core/spec/models/spree/wallet_payment_source_spec.rb +++ b/core/spec/models/spree/wallet_payment_source_spec.rb @@ -40,8 +40,8 @@ class NonPaymentSource < ActiveRecord::Base it "errors when `payment_source` is not a `Spree::PaymentSource`" do wallet_payment_source = Spree::WalletPaymentSource.new( - payment_source: payment_source, - user: user + payment_source:, + user: ) expect(wallet_payment_source).not_to be_valid @@ -52,14 +52,14 @@ class NonPaymentSource < ActiveRecord::Base end it "is invalid if `payment_source` is already in the user's wallet" do - credit_card = create(:credit_card, user: user) + credit_card = create(:credit_card, user:) Spree::WalletPaymentSource.create( payment_source: credit_card, - user: user + user: ) wallet_payment_source = subject.new( payment_source: credit_card, - user: user + user: ) expect(wallet_payment_source).not_to be_valid expect(wallet_payment_source.errors.messages).to eq( @@ -70,7 +70,7 @@ class NonPaymentSource < ActiveRecord::Base it "is invalid when `payment_source` is not owned by the user" do wallet_payment_source = subject.new( payment_source: create(:credit_card), - user: user + user: ) expect(wallet_payment_source).not_to be_valid expect(wallet_payment_source.errors.messages).to eq( @@ -80,16 +80,16 @@ class NonPaymentSource < ActiveRecord::Base it "is valid with a `credit_card` as `payment_source`" do valid_attrs = { - payment_source: create(:credit_card, user: user), - user: user + payment_source: create(:credit_card, user:), + user: } expect(subject.new(valid_attrs)).to be_valid end it "is valid with `store_credit` as `payment_source`" do valid_attrs = { - payment_source: create(:store_credit, user: user), - user: user + payment_source: create(:store_credit, user:), + user: } expect(subject.new(valid_attrs)).to be_valid end diff --git a/core/spec/models/spree/zone_spec.rb b/core/spec/models/spree/zone_spec.rb index 1a41b8d6a07..ca15af5ee6d 100644 --- a/core/spec/models/spree/zone_spec.rb +++ b/core/spec/models/spree/zone_spec.rb @@ -75,7 +75,7 @@ context "#include?" do let(:state) { create(:state) } let(:country) { state.country } - let(:address) { create(:address, state: state) } + let(:address) { create(:address, state:) } context "when zone is country type" do let(:country_zone) { create(:zone, name: 'CountryZone') } @@ -146,7 +146,7 @@ end context "has states associated" do - let!(:state) { create(:state, country: country) } + let!(:state) { create(:state, country:) } let!(:zone) do create(:zone, states: [state]) end @@ -211,7 +211,7 @@ end context "finding potential matches for a state zone" do - let!(:state) { create(:state, country: country) } + let!(:state) { create(:state, country:) } let!(:state2) { create(:state, country: country2, name: 'OtherState') } let!(:state3) { create(:state, country: country2, name: 'State') } let!(:zone) do diff --git a/core/spec/subscribers/spree/order_mailer_subscriber_spec.rb b/core/spec/subscribers/spree/order_mailer_subscriber_spec.rb index da85aec5260..9d055d575d4 100644 --- a/core/spec/subscribers/spree/order_mailer_subscriber_spec.rb +++ b/core/spec/subscribers/spree/order_mailer_subscriber_spec.rb @@ -19,13 +19,13 @@ expect(Spree::OrderMailer).to receive(:confirm_email).and_call_original - bus.publish(:order_finalized, order: order) + bus.publish(:order_finalized, order:) end it 'marks the order as having the confirmation email delivered' do order = create(:order, confirmation_delivered: false) - bus.publish(:order_finalized, order: order) + bus.publish(:order_finalized, order:) expect(order.confirmation_delivered).to be(true) end @@ -35,7 +35,7 @@ expect(Spree::OrderMailer).not_to receive(:confirm_email) - bus.publish(:order_finalized, order: order) + bus.publish(:order_finalized, order:) end end @@ -45,7 +45,7 @@ expect(Spree::ReimbursementMailer).to receive(:reimbursement_email).and_call_original - bus.publish(:reimbursement_reimbursed, reimbursement: reimbursement) + bus.publish(:reimbursement_reimbursed, reimbursement:) end end end diff --git a/core/spec/support/concerns/payment_source.rb b/core/spec/support/concerns/payment_source.rb index c64c3ea93e8..f114730c966 100644 --- a/core/spec/support/concerns/payment_source.rb +++ b/core/spec/support/concerns/payment_source.rb @@ -19,7 +19,7 @@ let!(:wallet_payment_source) do # There are nasty validations that do not matter for this test payment_source.save(validate: false) - Spree::WalletPaymentSource.new(user: user, payment_source: payment_source).tap do |wps| + Spree::WalletPaymentSource.new(user:, payment_source:).tap do |wps| wps.save(validate: false) end end diff --git a/core/spec/support/shared_examples/attachment.rb b/core/spec/support/shared_examples/attachment.rb index e0abf64e26a..12e3f6b8672 100644 --- a/core/spec/support/shared_examples/attachment.rb +++ b/core/spec/support/shared_examples/attachment.rb @@ -16,7 +16,7 @@ it 'returns definition' do expect(subject.class.attachment_definitions[attachment_name]) - .to include(default_style: default_style) + .to include(default_style:) end it 'returns if present' do diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb b/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb index 2d2b8a6b5ec..658158ec1e6 100644 --- a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb +++ b/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb @@ -37,7 +37,7 @@ def recalculate # Persist only if changed # This is only not a save! to avoid the extra queries to load the order # (for validations) and to touch the adjustment. - update_columns(eligible: eligible, amount: amount, updated_at: Time.current) if changed? + update_columns(eligible:, amount:, updated_at: Time.current) if changed? end amount end @@ -49,7 +49,7 @@ def recalculate # @return [true,false] Whether this adjustment is eligible def calculate_eligibility if !finalized? && source && promotion? - source.promotion.eligible?(adjustable, promotion_code: promotion_code) + source.promotion.eligible?(adjustable, promotion_code:) else eligible? end diff --git a/legacy_promotions/app/models/spree/promotion.rb b/legacy_promotions/app/models/spree/promotion.rb index 996ccd9365d..4f1d4a17445 100644 --- a/legacy_promotions/app/models/spree/promotion.rb +++ b/legacy_promotions/app/models/spree/promotion.rb @@ -110,12 +110,12 @@ def activate(order:, line_item: nil, user: nil, path: nil, promotion_code: nil) return unless self.class.order_activatable?(order) payload = { - order: order, + order:, promotion: self, - line_item: line_item, - user: user, - path: path, - promotion_code: promotion_code + line_item:, + user:, + path:, + promotion_code: } # Track results from actions to see if any action has been taken. @@ -131,7 +131,7 @@ def activate(order:, line_item: nil, user: nil, path: nil, promotion_code: nil) # connect to the order order.order_promotions.find_or_create_by!( promotion: self, - promotion_code: promotion_code, + promotion_code:, ) order.promotions.reset order_promotions.reset @@ -147,8 +147,8 @@ def eligible?(promotable, promotion_code: nil) return false if blacklisted?(promotable) excluded_orders = eligibility_excluded_orders(promotable) - return false if usage_limit_exceeded?(excluded_orders: excluded_orders) - return false if promotion_code&.usage_limit_exceeded?(excluded_orders: excluded_orders) + return false if usage_limit_exceeded?(excluded_orders:) + return false if promotion_code&.usage_limit_exceeded?(excluded_orders:) !!eligible_rules(promotable, {}) end @@ -183,7 +183,7 @@ def products # @return true or false def usage_limit_exceeded?(excluded_orders: []) if usage_limit - usage_count(excluded_orders: excluded_orders) >= usage_limit + usage_count(excluded_orders:) >= usage_limit end end @@ -202,7 +202,7 @@ def usage_count(excluded_orders: []) def line_item_actionable?(order, line_item, promotion_code: nil) return false if blacklisted?(line_item) - if eligible?(order, promotion_code: promotion_code) + if eligible?(order, promotion_code:) rules = eligible_rules(order) if rules.blank? true @@ -218,7 +218,7 @@ def used_by?(user, excluded_orders = []) discounted_orders. complete. where.not(id: excluded_orders.map(&:id)). - where(user: user). + where(user:). where.not(spree_orders: { state: :canceled }). exists? end diff --git a/legacy_promotions/app/models/spree/promotion/actions/create_adjustment.rb b/legacy_promotions/app/models/spree/promotion/actions/create_adjustment.rb index b981c731494..1fe3430914a 100644 --- a/legacy_promotions/app/models/spree/promotion/actions/create_adjustment.rb +++ b/legacy_promotions/app/models/spree/promotion/actions/create_adjustment.rb @@ -30,8 +30,8 @@ def perform(options = {}) amount = compute_amount(order) order.adjustments.create!( - amount: amount, - order: order, + amount:, + order:, source: self, promotion_code: options[:promotion_code], label: I18n.t('spree.adjustment_labels.order', promotion: Spree::Promotion.model_name.human, promotion_name: promotion.name) diff --git a/legacy_promotions/app/models/spree/promotion/actions/create_item_adjustments.rb b/legacy_promotions/app/models/spree/promotion/actions/create_item_adjustments.rb index 19a3bf5b10f..b2195fc884f 100644 --- a/legacy_promotions/app/models/spree/promotion/actions/create_item_adjustments.rb +++ b/legacy_promotions/app/models/spree/promotion/actions/create_item_adjustments.rb @@ -63,9 +63,9 @@ def create_adjustment(adjustable, order, promotion_code) return if amount == 0 adjustable.adjustments.create!( source: self, - amount: amount, - order: order, - promotion_code: promotion_code, + amount:, + order:, + promotion_code:, label: I18n.t('spree.adjustment_labels.line_item', promotion: Spree::Promotion.model_name.human, promotion_name: promotion.name) ) true diff --git a/legacy_promotions/app/models/spree/promotion/actions/free_shipping.rb b/legacy_promotions/app/models/spree/promotion/actions/free_shipping.rb index 4b74ff5ffe9..2322491cb0d 100644 --- a/legacy_promotions/app/models/spree/promotion/actions/free_shipping.rb +++ b/legacy_promotions/app/models/spree/promotion/actions/free_shipping.rb @@ -16,8 +16,8 @@ def perform(payload = {}) order: shipment.order, amount: compute_amount(shipment), source: self, - promotion_code: promotion_code, - label: label + promotion_code:, + label: ) end diff --git a/legacy_promotions/app/models/spree/promotion/rules/first_order.rb b/legacy_promotions/app/models/spree/promotion/rules/first_order.rb index fa1f7e2bee0..dc15639574e 100644 --- a/legacy_promotions/app/models/spree/promotion/rules/first_order.rb +++ b/legacy_promotions/app/models/spree/promotion/rules/first_order.rb @@ -28,7 +28,7 @@ def completed_orders end def orders_by_email - Spree::Order.where(email: email).complete + Spree::Order.where(email:).complete end end end diff --git a/legacy_promotions/app/models/spree/promotion_code.rb b/legacy_promotions/app/models/spree/promotion_code.rb index fc1d9d6d666..c3c72e414bc 100644 --- a/legacy_promotions/app/models/spree/promotion_code.rb +++ b/legacy_promotions/app/models/spree/promotion_code.rb @@ -19,7 +19,7 @@ class Spree::PromotionCode < Spree::Base # @return true or false def usage_limit_exceeded?(excluded_orders: []) if usage_limit - usage_count(excluded_orders: excluded_orders) >= usage_limit + usage_count(excluded_orders:) >= usage_limit end end diff --git a/legacy_promotions/app/models/spree/promotion_code/batch_builder.rb b/legacy_promotions/app/models/spree/promotion_code/batch_builder.rb index 422690d32e9..84ee3c572e4 100644 --- a/legacy_promotions/app/models/spree/promotion_code/batch_builder.rb +++ b/legacy_promotions/app/models/spree/promotion_code/batch_builder.rb @@ -43,9 +43,9 @@ def generate_random_codes codes_for_current_batch.filter! do |value| Spree::PromotionCode.create!( - value: value, - promotion: promotion, - promotion_code_batch: promotion_code_batch + value:, + promotion:, + promotion_code_batch: ) rescue ActiveRecord::RecordInvalid false diff --git a/legacy_promotions/app/models/spree/promotion_handler/cart.rb b/legacy_promotions/app/models/spree/promotion_handler/cart.rb index d961bc89156..24360fbd82d 100644 --- a/legacy_promotions/app/models/spree/promotion_handler/cart.rb +++ b/legacy_promotions/app/models/spree/promotion_handler/cart.rb @@ -25,7 +25,7 @@ def initialize(order, line_item = nil) def activate promotions.each do |promotion| if (line_item && promotion.eligible?(line_item, promotion_code: promotion_code(promotion))) || promotion.eligible?(order, promotion_code: promotion_code(promotion)) - promotion.activate(line_item: line_item, order: order, promotion_code: promotion_code(promotion)) + promotion.activate(line_item:, order:, promotion_code: promotion_code(promotion)) end end end @@ -45,7 +45,7 @@ def promotions def preload(records:, associations:) if Rails::VERSION::MAJOR >= 7 - ActiveRecord::Associations::Preloader.new(records: records, associations: associations).call + ActiveRecord::Associations::Preloader.new(records:, associations:).call else ActiveRecord::Associations::Preloader.new.preload(records, associations) end diff --git a/legacy_promotions/app/models/spree/promotion_handler/coupon.rb b/legacy_promotions/app/models/spree/promotion_handler/coupon.rb index 4e5ab2835f4..2a76f8ab359 100644 --- a/legacy_promotions/app/models/spree/promotion_handler/coupon.rb +++ b/legacy_promotions/app/models/spree/promotion_handler/coupon.rb @@ -73,14 +73,14 @@ def handle_present_promotion(promotion) return promotion_usage_limit_exceeded if promotion.usage_limit_exceeded? || promotion_code.usage_limit_exceeded? return promotion_applied if promotion_exists_on_order?(order, promotion) - unless promotion.eligible?(order, promotion_code: promotion_code) + unless promotion.eligible?(order, promotion_code:) set_promotion_eligibility_error_code(promotion) return error || ineligible_for_this_order end # If any of the actions for the promotion return `true`, # then result here will also be `true`. - result = promotion.activate(order: order, promotion_code: promotion_code) + result = promotion.activate(order:, promotion_code:) if result order.recalculate set_success_code :coupon_code_applied diff --git a/legacy_promotions/app/models/spree/promotion_handler/page.rb b/legacy_promotions/app/models/spree/promotion_handler/page.rb index b96825c41da..8a06285e363 100644 --- a/legacy_promotions/app/models/spree/promotion_handler/page.rb +++ b/legacy_promotions/app/models/spree/promotion_handler/page.rb @@ -12,14 +12,14 @@ def initialize(order, path) def activate if promotion && promotion.eligible?(order) - promotion.activate(order: order) + promotion.activate(order:) end end private def promotion - @promotion ||= Spree::Promotion.active.find_by(path: path) + @promotion ||= Spree::Promotion.active.find_by(path:) end end end diff --git a/legacy_promotions/app/models/spree/promotion_handler/shipping.rb b/legacy_promotions/app/models/spree/promotion_handler/shipping.rb index b6d0a28f66d..e83c838cf4f 100644 --- a/legacy_promotions/app/models/spree/promotion_handler/shipping.rb +++ b/legacy_promotions/app/models/spree/promotion_handler/shipping.rb @@ -15,7 +15,7 @@ def activate connected_promotions.each do |order_promotion| if order_promotion.promotion.eligible?(order) order_promotion.promotion.activate( - order: order, + order:, promotion_code: order_promotion.promotion_code, ) end @@ -23,7 +23,7 @@ def activate not_connected_automatic_promotions.each do |promotion| if promotion.eligible?(order) - promotion.activate(order: order) + promotion.activate(order:) end end end diff --git a/legacy_promotions/app/models/spree/promotion_rule.rb b/legacy_promotions/app/models/spree/promotion_rule.rb index 1d10f7f239e..61b1139beec 100644 --- a/legacy_promotions/app/models/spree/promotion_rule.rb +++ b/legacy_promotions/app/models/spree/promotion_rule.rb @@ -9,7 +9,7 @@ class PromotionRule < Spree::Base belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_rules, optional: true - scope :of_type, ->(type) { where(type: type) } + scope :of_type, ->(type) { where(type:) } validates :promotion, presence: true validate :unique_per_promotion, on: :create @@ -43,7 +43,7 @@ def to_partial_path private def unique_per_promotion - if Spree::PromotionRule.exists?(promotion_id: promotion_id, type: self.class.name) + if Spree::PromotionRule.exists?(promotion_id:, type: self.class.name) errors[:base] << "Promotion already contains this rule type" end end diff --git a/legacy_promotions/lib/components/admin/solidus_admin/promotions/index/component.rb b/legacy_promotions/lib/components/admin/solidus_admin/promotions/index/component.rb index b44b5114db3..b6fe1730f7e 100644 --- a/legacy_promotions/lib/components/admin/solidus_admin/promotions/index/component.rb +++ b/legacy_promotions/lib/components/admin/solidus_admin/promotions/index/component.rb @@ -70,7 +70,7 @@ def columns header: :code, data: ->(promotion) do count = promotion.codes.count - (count == 1) ? promotion.codes.pick(:value) : t('spree.number_of_codes', count: count) + (count == 1) ? promotion.codes.pick(:value) : t('spree.number_of_codes', count:) end }, { diff --git a/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/order_factory.rb b/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/order_factory.rb index ce3eb69cb2d..fd101768877 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/order_factory.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/order_factory.rb @@ -9,10 +9,10 @@ after(:create) do |order, evaluator| promotion = evaluator.promotion || create(:promotion, code: "test") - promotion_code = promotion.codes.first || create(:promotion_code, promotion: promotion) + promotion_code = promotion.codes.first || create(:promotion_code, promotion:) - promotion.activate(order: order, promotion_code: promotion_code) - order.order_promotions.create!(promotion: promotion, promotion_code: promotion_code) + promotion.activate(order:, promotion_code:) + order.order_promotions.create!(promotion:, promotion_code:) # Complete the order after the promotion has been activated order.update_column(:completed_at, evaluator.completed_at) diff --git a/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/promotion_factory.rb b/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/promotion_factory.rb index 36ed4698f6b..be19b44a73c 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/promotion_factory.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions/testing_support/factories/promotion_factory.rb @@ -9,7 +9,7 @@ end before(:create) do |promotion, evaluator| if evaluator.code - promotion.codes << build(:promotion_code, promotion: promotion, value: evaluator.code) + promotion.codes << build(:promotion_code, promotion:, value: evaluator.code) end end @@ -33,7 +33,7 @@ after(:create) do |promotion, evaluator| calculator = evaluator.calculator_class.new calculator.preferred_amount = evaluator.preferred_amount - evaluator.promotion_action_class.create!(calculator: calculator, promotion: promotion) + evaluator.promotion_action_class.create!(calculator:, promotion:) end end @@ -52,7 +52,7 @@ trait :with_free_shipping do after(:create) do |promotion| - Spree::Promotion::Actions::FreeShipping.create!(promotion: promotion) + Spree::Promotion::Actions::FreeShipping.create!(promotion:) end end @@ -75,7 +75,7 @@ after(:create) do |promotion, evaluator| rule = Spree::Promotion::Rules::ItemTotal.create!( - promotion: promotion, + promotion:, preferred_operator: 'gte', preferred_amount: evaluator.item_total_threshold_amount ) @@ -87,7 +87,7 @@ trait :with_first_order_rule do after(:create) do |promotion, _evaluator| rule = Spree::Promotion::Rules::FirstOrder.create!( - promotion: promotion, + promotion:, ) promotion.rules << rule promotion.save! diff --git a/legacy_promotions/solidus_legacy_promotions.gemspec b/legacy_promotions/solidus_legacy_promotions.gemspec index a31c951abd4..8f5586e6839 100644 --- a/legacy_promotions/solidus_legacy_promotions.gemspec +++ b/legacy_promotions/solidus_legacy_promotions.gemspec @@ -20,10 +20,10 @@ Gem::Specification.new do |s| f.match(%r{^(spec|script)/}) end - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' - s.add_dependency 'solidus_core', s.version s.add_dependency 'solidus_api', s.version + s.add_dependency 'solidus_core', s.version s.add_dependency 'solidus_support' end diff --git a/legacy_promotions/spec/controllers/spree/admin/promotion_codes_controller_spec.rb b/legacy_promotions/spec/controllers/spree/admin/promotion_codes_controller_spec.rb index f64ab8d8ee4..ff724a07b32 100644 --- a/legacy_promotions/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +++ b/legacy_promotions/spec/controllers/spree/admin/promotion_codes_controller_spec.rb @@ -7,9 +7,9 @@ render_views let!(:promotion) { create(:promotion) } - let!(:code1) { create(:promotion_code, promotion: promotion) } - let!(:code2) { create(:promotion_code, promotion: promotion) } - let!(:code3) { create(:promotion_code, promotion: promotion) } + let!(:code1) { create(:promotion_code, promotion:) } + let!(:code2) { create(:promotion_code, promotion:) } + let!(:code3) { create(:promotion_code, promotion:) } it "can create a CSV file with all promotion codes" do get :index, params: { promotion_id: promotion.id, format: 'csv' } @@ -21,13 +21,13 @@ it "can create a new code" do post :create, params: { promotion_id: promotion.id, promotion_code: { value: "new_code" } } expect(response).to redirect_to(spree.admin_promotion_promotion_codes_path(promotion)) - expect(Spree::PromotionCode.where(promotion: promotion).count).to eql(4) + expect(Spree::PromotionCode.where(promotion:).count).to eql(4) end it "cannot create an existing code" do post :create, params: { promotion_id: promotion.id, promotion_code: { value: code1.value } } expect(flash[:error]).not_to be_nil - expect(Spree::PromotionCode.where(promotion: promotion).count).to eql(3) + expect(Spree::PromotionCode.where(promotion:).count).to eql(3) end it "can't create a new code on promotions that apply automatically" do diff --git a/legacy_promotions/spec/controllers/spree/admin/promotions_controller_spec.rb b/legacy_promotions/spec/controllers/spree/admin/promotions_controller_spec.rb index d16fe392d9b..62eeb56b5d2 100644 --- a/legacy_promotions/spec/controllers/spree/admin/promotions_controller_spec.rb +++ b/legacy_promotions/spec/controllers/spree/admin/promotions_controller_spec.rb @@ -59,7 +59,7 @@ end describe "#create" do - subject { post :create, params: params } + subject { post :create, params: } let(:params) { { promotion: { name: 'some promo' } } } context "it succeeds" do diff --git a/legacy_promotions/spec/features/api/checkout_spec.rb b/legacy_promotions/spec/features/api/checkout_spec.rb index 3455f07d366..54540716a34 100644 --- a/legacy_promotions/spec/features/api/checkout_spec.rb +++ b/legacy_promotions/spec/features/api/checkout_spec.rb @@ -57,7 +57,7 @@ def update_order(order_params: {}) def create_line_item(variant, quantity = 1) expect { post "/api/orders/#{@order.number}/line_items", - params: { line_item: { variant_id: variant.id, quantity: quantity } } + params: { line_item: { variant_id: variant.id, quantity: } } }.to change { @order.line_items.count }.by 1 expect(response).to have_http_status(:created) end diff --git a/legacy_promotions/spec/features/backend/orders/adjustments_spec.rb b/legacy_promotions/spec/features/backend/orders/adjustments_spec.rb index 77488f9becb..8c9432f913f 100644 --- a/legacy_promotions/spec/features/backend/orders/adjustments_spec.rb +++ b/legacy_promotions/spec/features/backend/orders/adjustments_spec.rb @@ -13,17 +13,17 @@ let!(:order) do create( :completed_order_with_totals, - line_items_attributes: [{ price: 10, variant: variant }] * 5, - ship_address: ship_address + line_items_attributes: [{ price: 10, variant: }] * 5, + ship_address: ) end let!(:line_item) { order.line_items[0] } let(:tax_category) { create(:tax_category) } - let(:variant) { create(:variant, tax_category: tax_category) } + let(:variant) { create(:variant, tax_category:) } - let!(:non_eligible_adjustment) { order.adjustments.create!(order: order, label: "Non-Eligible", amount: 10, eligible: false) } - let!(:adjustment) { order.adjustments.create!(order: order, label: "Rebate", amount: 10) } + let!(:non_eligible_adjustment) { order.adjustments.create!(order:, label: "Non-Eligible", amount: 10, eligible: false) } + let!(:adjustment) { order.adjustments.create!(order:, label: "Rebate", amount: 10) } before(:each) do order.recalculate diff --git a/legacy_promotions/spec/features/backend/orders/listing_spec.rb b/legacy_promotions/spec/features/backend/orders/listing_spec.rb index bef2d81a1c7..9106242f1d3 100644 --- a/legacy_promotions/spec/features/backend/orders/listing_spec.rb +++ b/legacy_promotions/spec/features/backend/orders/listing_spec.rb @@ -19,8 +19,8 @@ before(:each) do @order1.order_promotions.build( - promotion: promotion, - promotion_code: promotion_code + promotion:, + promotion_code: ) @order1.save visit spree.admin_orders_path diff --git a/legacy_promotions/spec/features/backend/promotions/product_rule_spec.rb b/legacy_promotions/spec/features/backend/promotions/product_rule_spec.rb index 4fee323f227..1dfe0bdd874 100644 --- a/legacy_promotions/spec/features/backend/promotions/product_rule_spec.rb +++ b/legacy_promotions/spec/features/backend/promotions/product_rule_spec.rb @@ -6,7 +6,7 @@ stub_authorization! given!(:product) { create :product, name: "BlamCo Mac & Cheese", sku: "PRODUCT_SKU" } - given!(:variant) { create :variant, sku: "VARIANT_SKU", product: product } + given!(:variant) { create :variant, sku: "VARIANT_SKU", product: } given!(:option_value) { variant.option_values.first } given(:promotion) { create :promotion } diff --git a/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb b/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb index 2c7157050d1..d2aebec8e1d 100644 --- a/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb +++ b/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "Orders", type: :feature, solidus_admin: true do let(:promotion) { create(:promotion, name: "10OFF") } - let!(:order_with_promotion) { create(:completed_order_with_promotion, number: "R123456789", promotion: promotion) } + let!(:order_with_promotion) { create(:completed_order_with_promotion, number: "R123456789", promotion:) } let!(:order_without_promotion) { create(:completed_order_with_totals, number: "R987654321") } before { sign_in create(:admin_user, email: "admin@example.com") } diff --git a/legacy_promotions/spec/features/solidus_admin/orders/show/adjustments_spec.rb b/legacy_promotions/spec/features/solidus_admin/orders/show/adjustments_spec.rb index 6b27dc8852b..b25286cf80e 100644 --- a/legacy_promotions/spec/features/solidus_admin/orders/show/adjustments_spec.rb +++ b/legacy_promotions/spec/features/solidus_admin/orders/show/adjustments_spec.rb @@ -17,7 +17,7 @@ before do Spree::Adjustment.create!( - order: order, + order:, source: promotion.actions.first, adjustable: order.line_items.first, amount: 2, diff --git a/legacy_promotions/spec/jobs/spree/promotion_code_batch_job_spec.rb b/legacy_promotions/spec/jobs/spree/promotion_code_batch_job_spec.rb index 80f0727751b..12ea4a1ebb0 100644 --- a/legacy_promotions/spec/jobs/spree/promotion_code_batch_job_spec.rb +++ b/legacy_promotions/spec/jobs/spree/promotion_code_batch_job_spec.rb @@ -8,7 +8,7 @@ promotion_id: create(:promotion).id, base_code: "test", number_of_codes: 10, - email: email + email: ) end context "with a successful build" do @@ -36,7 +36,7 @@ def codes promotion_id: create(:promotion).id, base_code: "test", number_of_codes: 10, - email: email, + email:, join_characters: '-' ) end diff --git a/legacy_promotions/spec/lib/solidus_legacy_promotions/testing_support/factories/order_factory_spec.rb b/legacy_promotions/spec/lib/solidus_legacy_promotions/testing_support/factories/order_factory_spec.rb index 37629e82bd9..ec03e9aa6fc 100644 --- a/legacy_promotions/spec/lib/solidus_legacy_promotions/testing_support/factories/order_factory_spec.rb +++ b/legacy_promotions/spec/lib/solidus_legacy_promotions/testing_support/factories/order_factory_spec.rb @@ -30,7 +30,7 @@ context 'with a promotion with an action' do let(:promotion) { create(:promotion, :with_line_item_adjustment) } it "has the expected attributes" do - order = create(factory, promotion: promotion) + order = create(factory, promotion:) aggregate_failures do expect(order).to be_completed expect(order).to be_complete diff --git a/legacy_promotions/spec/mailers/spree/order_mailer_spec.rb b/legacy_promotions/spec/mailers/spree/order_mailer_spec.rb index 8bf2ab1374a..3ac8fa3a015 100644 --- a/legacy_promotions/spec/mailers/spree/order_mailer_spec.rb +++ b/legacy_promotions/spec/mailers/spree/order_mailer_spec.rb @@ -6,10 +6,10 @@ let(:order) do order = create(:order) product = stub_model(Spree::Product, name: %{The "BEST" product}) - variant = stub_model(Spree::Variant, product: product) - price = stub_model(Spree::Price, variant: variant, amount: 5.00) + variant = stub_model(Spree::Variant, product:) + price = stub_model(Spree::Price, variant:, amount: 5.00) store = FactoryBot.build :store, mail_from_address: "store@example.com", bcc_email: "bcc@example.com" - line_item = stub_model(Spree::LineItem, variant: variant, order: order, quantity: 1, price: 4.99) + line_item = stub_model(Spree::LineItem, variant:, order:, quantity: 1, price: 4.99) allow(variant).to receive_messages(default_price: price) allow(order).to receive_messages(line_items: [line_item]) allow(order).to receive(:store).and_return(store) @@ -21,7 +21,7 @@ create( :adjustment, adjustable: order, - order: order, + order:, eligible: true, label: 'Eligible Adjustment' ) @@ -29,7 +29,7 @@ create( :adjustment, adjustable: order, - order: order, + order:, eligible: false, label: 'Ineligible Adjustment' ) diff --git a/legacy_promotions/spec/models/spree/adjustment_spec.rb b/legacy_promotions/spec/models/spree/adjustment_spec.rb index d41f3f921ac..e1d6079d96d 100644 --- a/legacy_promotions/spec/models/spree/adjustment_spec.rb +++ b/legacy_promotions/spec/models/spree/adjustment_spec.rb @@ -5,9 +5,9 @@ RSpec.describe Spree::Adjustment, type: :model do let!(:store) { create :store } let(:order) { create :order } - let(:line_item) { create :line_item, order: order } + let(:line_item) { create :line_item, order: } - let(:adjustment) { Spree::Adjustment.create!(label: 'Adjustment', adjustable: order, order: order, amount: 5) } + let(:adjustment) { Spree::Adjustment.create!(label: 'Adjustment', adjustable: order, order:, amount: 5) } it { is_expected.to respond_to(:promotion_code) } context '#recalculate' do @@ -15,11 +15,11 @@ let(:adjustment) do line_item.adjustments.create!( label: 'Adjustment', - order: order, + order:, adjustable: order, amount: 5, - finalized: finalized, - source: source, + finalized:, + source:, ) end let(:order) { create(:order_with_line_items, line_items_price: 100) } @@ -139,7 +139,7 @@ end context "when the promotion has a code" do - let!(:promotion_code) { create(:promotion_code, promotion: promotion) } + let!(:promotion_code) { create(:promotion_code, promotion:) } it { is_expected.to include("can't be blank") } end @@ -155,7 +155,7 @@ context "when the promotion has a code" do let!(:promotion_code) do - promotion.codes << build(:promotion_code, promotion: promotion) + promotion.codes << build(:promotion_code, promotion:) end it { is_expected.to be_blank } diff --git a/legacy_promotions/spec/models/spree/calculator/distributed_amount_spec.rb b/legacy_promotions/spec/models/spree/calculator/distributed_amount_spec.rb index 578ddfa514a..7577d897fb1 100644 --- a/legacy_promotions/spec/models/spree/calculator/distributed_amount_spec.rb +++ b/legacy_promotions/spec/models/spree/calculator/distributed_amount_spec.rb @@ -20,7 +20,7 @@ before do calculator.preferred_amount = 15 calculator.preferred_currency = currency - Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator: calculator, promotion: promotion) + Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator:, promotion:) end context "when the order currency matches the store's currency" do diff --git a/legacy_promotions/spec/models/spree/calculator/flexi_rate_spec.rb b/legacy_promotions/spec/models/spree/calculator/flexi_rate_spec.rb index 8d1beb573bb..497c27b2309 100644 --- a/legacy_promotions/spec/models/spree/calculator/flexi_rate_spec.rb +++ b/legacy_promotions/spec/models/spree/calculator/flexi_rate_spec.rb @@ -19,7 +19,7 @@ let(:order) do mock_model( - Spree::Order, quantity: quantity + Spree::Order, quantity: ) end diff --git a/legacy_promotions/spec/models/spree/order/checkout_spec.rb b/legacy_promotions/spec/models/spree/order/checkout_spec.rb index 11468b718d8..bc6428d05f8 100644 --- a/legacy_promotions/spec/models/spree/order/checkout_spec.rb +++ b/legacy_promotions/spec/models/spree/order/checkout_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Spree::Order, type: :model do let!(:store) { create(:store) } - let(:order) { create(:order, store: store) } + let(:order) { create(:order, store:) } context "from delivery", partial_double_verification: false do before do diff --git a/legacy_promotions/spec/models/spree/order/totals_spec.rb b/legacy_promotions/spec/models/spree/order/totals_spec.rb index 6e2665ee8e5..be67dd27183 100644 --- a/legacy_promotions/spec/models/spree/order/totals_spec.rb +++ b/legacy_promotions/spec/models/spree/order/totals_spec.rb @@ -10,7 +10,7 @@ module Spree context "adds item to cart and activates promo" do let(:promotion) { Promotion.create name: 'Huhu', apply_automatically: true } let(:calculator) { Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) } - let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) } + let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion:, calculator:) } before { order.contents.add(shirt, 1) } diff --git a/legacy_promotions/spec/models/spree/order_contents_spec.rb b/legacy_promotions/spec/models/spree/order_contents_spec.rb index 472a00d49a3..3bf4abddf90 100644 --- a/legacy_promotions/spec/models/spree/order_contents_spec.rb +++ b/legacy_promotions/spec/models/spree/order_contents_spec.rb @@ -22,7 +22,7 @@ end context "one active order promotion" do - let!(:action) { Spree::Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) } + let!(:action) { Spree::Promotion::Actions::CreateAdjustment.create(promotion:, calculator:) } it "creates valid discount on order" do subject.add(variant, 1) @@ -33,7 +33,7 @@ end context "one active line item promotion" do - let!(:action) { Spree::Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) } + let!(:action) { Spree::Promotion::Actions::CreateItemAdjustments.create(promotion:, calculator:) } it "creates valid discount on order" do subject.add(variant, 1) diff --git a/legacy_promotions/spec/models/spree/order_promotion_spec.rb b/legacy_promotions/spec/models/spree/order_promotion_spec.rb index a2aaadd7fd7..685f9f4ab17 100644 --- a/legacy_promotions/spec/models/spree/order_promotion_spec.rb +++ b/legacy_promotions/spec/models/spree/order_promotion_spec.rb @@ -24,7 +24,7 @@ context "when the promotion has a code" do let!(:promotion_code) do - promotion.codes << build(:promotion_code, promotion: promotion) + promotion.codes << build(:promotion_code, promotion:) end it { is_expected.to include("can't be blank") } @@ -48,7 +48,7 @@ context "when the promotion has a code" do let!(:promotion_code) do - promotion.codes << build(:promotion_code, promotion: promotion) + promotion.codes << build(:promotion_code, promotion:) end it { is_expected.to be_blank } diff --git a/legacy_promotions/spec/models/spree/order_spec.rb b/legacy_promotions/spec/models/spree/order_spec.rb index 4cf80c5d3d6..9680149ed50 100644 --- a/legacy_promotions/spec/models/spree/order_spec.rb +++ b/legacy_promotions/spec/models/spree/order_spec.rb @@ -47,10 +47,10 @@ let(:code) { promotion.codes.first } before do - create(:line_item, order: order) - create(:shipment, order: order) - create(:adjustment, adjustable: order, order: order) - promotion.activate(order: order, promotion_code: code) + create(:line_item, order:) + create(:shipment, order:) + create(:adjustment, adjustable: order, order:) + promotion.activate(order:, promotion_code: code) order.recalculate # Make sure we are asserting changes @@ -92,7 +92,7 @@ end describe "#can_add_coupon?" do - let(:order) { Spree::Order.new(state: state) } + let(:order) { Spree::Order.new(state:) } subject { order.can_add_coupon? } diff --git a/legacy_promotions/spec/models/spree/order_updater_spec.rb b/legacy_promotions/spec/models/spree/order_updater_spec.rb index d68b9dea0a7..7015a3341a3 100644 --- a/legacy_promotions/spec/models/spree/order_updater_spec.rb +++ b/legacy_promotions/spec/models/spree/order_updater_spec.rb @@ -11,7 +11,7 @@ module Spree context "order totals" do before do 2.times do - create(:line_item, order: order, price: 10) + create(:line_item, order:, price: 10) end end @@ -21,15 +21,15 @@ module Spree let(:promotion_action) do Promotion::Actions::CreateAdjustment.create!({ - calculator: calculator, - promotion: promotion + calculator:, + promotion: }) end before do updater.recalculate - create(:adjustment, source: promotion_action, adjustable: order, order: order) - create(:line_item, order: order, price: 10) # in addition to the two already created + create(:adjustment, source: promotion_action, adjustable: order, order:) + create(:line_item, order:, price: 10) # in addition to the two already created order.line_items.reload # need to pick up the extra line item updater.recalculate end @@ -40,7 +40,7 @@ module Spree end it "update order adjustments" do - create(:adjustment, adjustable: order, order: order, source: nil, amount: 10) + create(:adjustment, adjustable: order, order:, source: nil, amount: 10) expect { updater.recalculate @@ -58,7 +58,7 @@ module Spree let(:promotion) { create(:promotion, :with_line_item_adjustment, adjustment_rate: 1) } it 'updates in-memory items' do - promotion.activate(order: order) + promotion.activate(order:) expect(line_item.promo_total).to eq(0) expect(order.promo_total).to eq(0) diff --git a/legacy_promotions/spec/models/spree/product_spec.rb b/legacy_promotions/spec/models/spree/product_spec.rb index a2623be5fb3..b31279196dd 100644 --- a/legacy_promotions/spec/models/spree/product_spec.rb +++ b/legacy_promotions/spec/models/spree/product_spec.rb @@ -22,7 +22,7 @@ let!(:promotion) { create(:promotion, :with_action, advertise: true, starts_at: 1.day.ago) } let!(:rule) do Spree::Promotion::Rules::Product.create( - promotion: promotion, + promotion:, products: [product] ) end diff --git a/legacy_promotions/spec/models/spree/promotion/actions/create_adjustment_spec.rb b/legacy_promotions/spec/models/spree/promotion/actions/create_adjustment_spec.rb index c1310d7a941..9079f28c7ab 100644 --- a/legacy_promotions/spec/models/spree/promotion/actions/create_adjustment_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/actions/create_adjustment_spec.rb @@ -6,14 +6,14 @@ let(:order) { create(:order_with_line_items, line_items_count: 1) } let(:promotion) { create(:promotion) } let(:action) { Spree::Promotion::Actions::CreateAdjustment.new } - let(:payload) { { order: order } } + let(:payload) { { order: } } # From promotion spec: context "#perform" do before do action.calculator = Spree::Calculator::FlatRate.new(preferred_amount: 10) promotion.promotion_actions = [action] - allow(action).to receive_messages(promotion: promotion) + allow(action).to receive_messages(promotion:) end it "does apply an adjustment if the amount is 0" do @@ -49,7 +49,7 @@ context "when a promotion code is used" do let(:promotion_code) { create(:promotion_code) } let(:promotion) { promotion_code.promotion } - let(:payload) { { order: order, promotion_code: promotion_code } } + let(:payload) { { order:, promotion_code: } } it "should connect the adjustment to the promotion_code" do expect { @@ -64,7 +64,7 @@ let(:action) { promotion.actions.first! } let(:promotion) { create(:promotion, :with_order_adjustment) } - let!(:unrelated_adjustment) { create(:adjustment, order: order, source: nil) } + let!(:unrelated_adjustment) { create(:adjustment, order:, source: nil) } before do action.perform(payload) diff --git a/legacy_promotions/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb b/legacy_promotions/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb index 762d4ea03d4..5c3ef9bcef8 100644 --- a/legacy_promotions/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb @@ -9,7 +9,7 @@ module Spree let(:adjustment_amount) { 10 } let(:action) { promotion.actions.first! } let(:line_item) { order.line_items.to_a.first } - let(:payload) { { order: order, promotion: promotion } } + let(:payload) { { order:, promotion: } } before do allow(action).to receive(:promotion).and_return(promotion) @@ -79,8 +79,8 @@ module Spree end context "when a promotion code is used" do - let!(:promotion_code) { create(:promotion_code, promotion: promotion) } - let(:payload) { { order: order, promotion: promotion, promotion_code: promotion_code } } + let!(:promotion_code) { create(:promotion_code, promotion:) } + let(:payload) { { order:, promotion:, promotion_code: } } it "should connect the adjustment to the promotion_code" do expect { @@ -124,7 +124,7 @@ module Spree describe '#remove_from' do # this adjustment should not get removed - let!(:other_adjustment) { create(:adjustment, adjustable: line_item, order: order, source: nil) } + let!(:other_adjustment) { create(:adjustment, adjustable: line_item, order:, source: nil) } before do action.perform(payload) @@ -150,7 +150,7 @@ module Spree let(:order) { create(:order) } it 'destroys adjustments' do - order.adjustments.create!(label: 'Check', amount: 0, order: order, source: action) + order.adjustments.create!(label: 'Check', amount: 0, order:, source: action) expect { subject @@ -163,7 +163,7 @@ module Spree it "does not change adjustments for completed orders" do order = create :order, completed_at: Time.current - adjustment = action.adjustments.create!(label: "Check", amount: 0, order: order, adjustable: order) + adjustment = action.adjustments.create!(label: "Check", amount: 0, order:, adjustable: order) expect { expect { @@ -176,7 +176,7 @@ module Spree end it "doesnt mess with unrelated adjustments" do - order.adjustments.create!(label: "Check", amount: 0, order: order, source: action) + order.adjustments.create!(label: "Check", amount: 0, order:, source: action) expect { subject diff --git a/legacy_promotions/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb b/legacy_promotions/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb index e19f7c4f78b..353661742f4 100644 --- a/legacy_promotions/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb @@ -4,18 +4,18 @@ module Spree::Promotion::Actions RSpec.describe CreateQuantityAdjustments do - let(:action) { CreateQuantityAdjustments.create!(calculator: calculator, promotion: promotion) } + let(:action) { CreateQuantityAdjustments.create!(calculator:, promotion:) } let(:order) do create( :order_with_line_items, - line_items_attributes: line_items_attributes + line_items_attributes: ) end let(:line_items_attributes) do [ - { price: 10, quantity: quantity } + { price: 10, quantity: } ] end @@ -71,7 +71,7 @@ module Spree::Promotion::Actions ] end - before { action.perform({ order: order, promotion: promotion }) } + before { action.perform({ order:, promotion: }) } describe "the adjustment for the first item" do let(:line_item) { order.line_items.first } @@ -102,7 +102,7 @@ module Spree::Promotion::Actions before do action.preferred_group_size = 2 - action.perform({ order: other_order, promotion: promotion }) + action.perform({ order: other_order, promotion: }) end it { is_expected.to eq(-10) } @@ -125,7 +125,7 @@ module Spree::Promotion::Actions context "with a quantity group of 3" do before do action.preferred_group_size = 3 - action.perform({ order: order, promotion: promotion }) + action.perform({ order:, promotion: }) end context "and 2x item A and 1x item B" do @@ -181,7 +181,7 @@ module Spree::Promotion::Actions context "with a quantity group of 3" do before do action.preferred_group_size = 3 - action.perform({ order: order, promotion: promotion }) + action.perform({ order:, promotion: }) end context "and 2x item A and 1x item B" do @@ -217,7 +217,7 @@ module Spree::Promotion::Actions end describe Spree::Promotion::Actions::CreateQuantityAdjustments::PartialLineItem do - let!(:item) { FactoryBot.create :line_item, order: order, quantity: quantity, price: 10 } + let!(:item) { FactoryBot.create :line_item, order:, quantity:, price: 10 } let(:quantity) { 5 } subject { described_class.new(item) } diff --git a/legacy_promotions/spec/models/spree/promotion/actions/free_shipping_spec.rb b/legacy_promotions/spec/models/spree/promotion/actions/free_shipping_spec.rb index ff7891941e0..c6a8b8930ea 100644 --- a/legacy_promotions/spec/models/spree/promotion/actions/free_shipping_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/actions/free_shipping_spec.rb @@ -7,7 +7,7 @@ let(:shipment) { order.shipments.to_a.first } let(:promotion) { create(:promotion, code: 'somecode', promotion_actions: [action]) } let(:action) { Spree::Promotion::Actions::FreeShipping.new } - let(:payload) { { order: order, promotion_code: promotion_code } } + let(:payload) { { order:, promotion_code: } } let(:promotion_code) { promotion.codes.first! } # From promotion spec: @@ -49,10 +49,10 @@ before do shipments.each do |shipment| shipment.adjustments.create!( - order: order, + order:, amount: shipment.cost * -1, source: action, - promotion_code: promotion_code, + promotion_code:, label: 'somelabel' ) end @@ -74,10 +74,10 @@ shipment = shipments.last shipment.adjustments.create!( - order: order, + order:, amount: shipment.cost * -1, source: action, - promotion_code: promotion_code, + promotion_code:, label: 'somelabel' ) end @@ -97,7 +97,7 @@ describe '#remove_from' do # this adjustment should not get removed - let!(:other_adjustment) { create(:adjustment, adjustable: shipment, order: order, source: nil) } + let!(:other_adjustment) { create(:adjustment, adjustable: shipment, order:, source: nil) } before do action.perform(payload) diff --git a/legacy_promotions/spec/models/spree/promotion/order_adjustments_recalculator_spec.rb b/legacy_promotions/spec/models/spree/promotion/order_adjustments_recalculator_spec.rb index 13b25e912c7..1f80f03e1f5 100644 --- a/legacy_promotions/spec/models/spree/promotion/order_adjustments_recalculator_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/order_adjustments_recalculator_spec.rb @@ -12,11 +12,11 @@ context 'when the item quantity has changed' do let(:promotion) { create(:promotion, promotion_actions: [promotion_action]) } - let(:promotion_action) { Spree::Promotion::Actions::CreateItemAdjustments.new(calculator: calculator) } + let(:promotion_action) { Spree::Promotion::Actions::CreateItemAdjustments.new(calculator:) } let(:calculator) { Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) } before do - promotion.activate(order: order) + promotion.activate(order:) order.recalculate line_item.update!(quantity: 2) end @@ -69,8 +69,8 @@ def initialize(_adjustments) let(:source) do Spree::Promotion::Actions::CreateItemAdjustments.create!( - calculator: calculator, - promotion: promotion, + calculator:, + promotion:, ) end let(:promotion) { create(:promotion) } @@ -78,12 +78,12 @@ def initialize(_adjustments) def create_adjustment(label, amount) create( :adjustment, - order: order, + order:, adjustable: line_item, - source: source, - amount: amount, + source:, + amount:, finalized: true, - label: label, + label:, ) end @@ -91,7 +91,7 @@ def create_adjustment(label, amount) create_adjustment('Promotion A', -100) create_adjustment('Promotion B', -200) create_adjustment('Promotion C', -300) - create(:adjustment, order: order, + create(:adjustment, order:, adjustable: line_item, source: nil, amount: -500, @@ -153,8 +153,8 @@ def create_adjustment(label, amount) context "with promo sequence #{promo_sequence}" do it 'should pick the best order-level promo according to current eligibility' do # apply both promos to the order, even though only promo1 is eligible - order_promos[promo_sequence[0]].activate order: order - order_promos[promo_sequence[1]].activate order: order + order_promos[promo_sequence[0]].activate(order:) + order_promos[promo_sequence[1]].activate(order:) subject order.reload @@ -174,8 +174,8 @@ def create_adjustment(label, amount) it 'should pick the best line-item-level promo according to current eligibility' do # apply both promos to the order, even though only promo1 is eligible - line_item_promos[promo_sequence[0]].activate order: order - line_item_promos[promo_sequence[1]].activate order: order + line_item_promos[promo_sequence[0]].activate(order:) + line_item_promos[promo_sequence[1]].activate(order:) order.reload expect(order.all_adjustments.count).to eq(1), 'Expected one adjustment' diff --git a/legacy_promotions/spec/models/spree/promotion/rules/first_order_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/first_order_spec.rb index 05e131c05e0..aa64aec627f 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/first_order_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/first_order_spec.rb @@ -24,18 +24,18 @@ end specify do - allow(order).to receive_messages(user: user) + allow(order).to receive_messages(user:) expect(rule).to be_eligible(order) end it "should be eligible when user passed in payload data" do - expect(rule).to be_eligible(order, user: user) + expect(rule).to be_eligible(order, user:) end end context "with completed orders" do before(:each) do - allow(order).to receive_messages(user: user) + allow(order).to receive_messages(user:) end it "should be eligible when checked against first completed order" do diff --git a/legacy_promotions/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb index 6ad792f1098..d3366e6aceb 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb @@ -41,10 +41,10 @@ let(:order_completion_date_1) { 1.day.ago } let(:order_completion_date_2) { 1.day.ago } before do - old_order_1 = create :completed_order_with_totals, user: user + old_order_1 = create(:completed_order_with_totals, user:) old_order_1.update(completed_at: order_completion_date_1) - old_order_2 = create :completed_order_with_totals, user: user + old_order_2 = create(:completed_order_with_totals, user:) old_order_2.update(completed_at: order_completion_date_2) end diff --git a/legacy_promotions/spec/models/spree/promotion/rules/item_total_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/item_total_spec.rb index 138a3e65f03..365839d0077 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/item_total_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/item_total_spec.rb @@ -5,11 +5,11 @@ RSpec.describe Spree::Promotion::Rules::ItemTotal, type: :model do let(:rule) do Spree::Promotion::Rules::ItemTotal.new( - preferred_amount: preferred_amount, - preferred_operator: preferred_operator + preferred_amount:, + preferred_operator: ) end - let(:order) { double(:order, item_total: item_total, currency: order_currency) } + let(:order) { double(:order, item_total:, currency: order_currency) } let(:preferred_amount) { 50 } let(:order_currency) { 'USD' } diff --git a/legacy_promotions/spec/models/spree/promotion/rules/nth_order_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/nth_order_spec.rb index 843d7cc99a0..10a72ded1ea 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/nth_order_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/nth_order_spec.rb @@ -39,7 +39,7 @@ context "when the user has completed orders" do before do - old_order = create :completed_order_with_totals, user: user + old_order = create(:completed_order_with_totals, user:) old_order.update(completed_at: 1.day.ago) end diff --git a/legacy_promotions/spec/models/spree/promotion/rules/one_use_per_user_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/one_use_per_user_spec.rb index 5d7b4286dcf..b504a351e48 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/one_use_per_user_spec.rb @@ -7,7 +7,7 @@ describe '#eligible?(order)' do subject { rule.eligible?(order) } - let(:order) { double Spree::Order, user: user } + let(:order) { double Spree::Order, user: } let(:user) { double Spree::LegacyUser } let(:promotion) { stub_model Spree::Promotion, used_by?: used_by } let(:used_by) { false } diff --git a/legacy_promotions/spec/models/spree/promotion/rules/option_value_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/option_value_spec.rb index 706a44280e9..1cf134dde66 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/option_value_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/option_value_spec.rb @@ -27,7 +27,7 @@ describe "#eligible?" do let(:variant) { create :variant } - let(:line_item) { create :line_item, variant: variant } + let(:line_item) { create :line_item, variant: } let(:promotable) { line_item.order } subject { rule.eligible?(promotable) } context "when there are any applicable line items" do diff --git a/legacy_promotions/spec/models/spree/promotion/rules/product_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/product_spec.rb index afe73223aa0..5543e03a473 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/product_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/product_spec.rb @@ -107,7 +107,7 @@ Spree::Promotion::Rules::Product.create!( promotion: create(:promotion), product_promotion_rules: [ - Spree::ProductPromotionRule.new(product: product), + Spree::ProductPromotionRule.new(product:), ], ).tap do |rule| rule.preferred_match_policy = 'invalid' diff --git a/legacy_promotions/spec/models/spree/promotion/rules/user_logged_in_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/user_logged_in_spec.rb index a54acb811da..c185a3df32d 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/user_logged_in_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/user_logged_in_spec.rb @@ -10,7 +10,7 @@ it "should be eligible if order has an associated user" do user = double('User') - allow(order).to receive_messages(user: user) + allow(order).to receive_messages(user:) expect(rule).to be_eligible(order) end diff --git a/legacy_promotions/spec/models/spree/promotion/rules/user_role_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/user_role_spec.rb index baba3f51609..73a8e65484c 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/user_role_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/user_role_spec.rb @@ -52,7 +52,7 @@ end context 'order with user' do - let(:order) { Spree::Order.new(user: user) } + let(:order) { Spree::Order.new(user:) } context 'with any match policy' do before { rule.preferred_match_policy = 'any' } diff --git a/legacy_promotions/spec/models/spree/promotion/rules/user_spec.rb b/legacy_promotions/spec/models/spree/promotion/rules/user_spec.rb index abb1fc520ed..0354726750a 100644 --- a/legacy_promotions/spec/models/spree/promotion/rules/user_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion/rules/user_spec.rb @@ -15,8 +15,8 @@ it "should be eligible if users include user placing the order" do user = mock_model(Spree::LegacyUser) users = [user, mock_model(Spree::LegacyUser)] - allow(rule).to receive_messages(users: users) - allow(order).to receive_messages(user: user) + allow(rule).to receive_messages(users:) + allow(order).to receive_messages(user:) expect(rule).to be_eligible(order) end @@ -24,7 +24,7 @@ it "should not be eligible if user placing the order is not listed" do allow(order).to receive_messages(user: mock_model(Spree::LegacyUser)) users = [mock_model(Spree::LegacyUser), mock_model(Spree::LegacyUser)] - allow(rule).to receive_messages(users: users) + allow(rule).to receive_messages(users:) expect(rule).not_to be_eligible(order) end diff --git a/legacy_promotions/spec/models/spree/promotion_action_spec.rb b/legacy_promotions/spec/models/spree/promotion_action_spec.rb index bfa8ae43d46..4f17b2d26c3 100644 --- a/legacy_promotions/spec/models/spree/promotion_action_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_action_spec.rb @@ -13,7 +13,7 @@ class MyPromotionAction < Spree::PromotionAction def perform(options = {}) order = options[:order] - order.adjustments.create!(amount: 1, order: order, source: self, label: 'foo') + order.adjustments.create!(amount: 1, order:, source: self, label: 'foo') true end @@ -27,17 +27,17 @@ def remove_from(_order) let(:order) { create(:order) } # this adjustment should not get removed - let!(:other_adjustment) { create(:adjustment, order: order, source: nil) } + let!(:other_adjustment) { create(:adjustment, order:, source: nil) } it "generates its own partial path" do - action.perform(order: order) + action.perform(order:) @action_adjustment = order.adjustments.where(source: action).first! expect(action.to_partial_path).to eq 'spree/admin/promotions/actions/my_promotion_action' end it 'executes the remove logic' do - action.perform(order: order) + action.perform(order:) @action_adjustment = order.adjustments.where(source: action).first! expect(action.remove_from(order)).to eq('Implement your remove logic') diff --git a/legacy_promotions/spec/models/spree/promotion_advertiser_spec.rb b/legacy_promotions/spec/models/spree/promotion_advertiser_spec.rb index b94f027dd6d..91a40ffbb20 100644 --- a/legacy_promotions/spec/models/spree/promotion_advertiser_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_advertiser_spec.rb @@ -10,7 +10,7 @@ let!(:promotion) { create(:promotion, :with_action, advertise: true, starts_at: 1.day.ago) } let!(:rule) do Spree::Promotion::Rules::Product.create( - promotion: promotion, + promotion:, products: [product] ) end diff --git a/legacy_promotions/spec/models/spree/promotion_category_spec.rb b/legacy_promotions/spec/models/spree/promotion_category_spec.rb index 46ce994bc21..934cf23e9a9 100644 --- a/legacy_promotions/spec/models/spree/promotion_category_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_category_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Spree::PromotionCategory, type: :model do describe 'validation' do let(:name) { 'Nom' } - subject { Spree::PromotionCategory.new name: name } + subject { Spree::PromotionCategory.new name: } context 'when all required attributes are specified' do it { is_expected.to be_valid } diff --git a/legacy_promotions/spec/models/spree/promotion_code/batch_builder_spec.rb b/legacy_promotions/spec/models/spree/promotion_code/batch_builder_spec.rb index d9f0c06b53d..22cd3fe5d33 100644 --- a/legacy_promotions/spec/models/spree/promotion_code/batch_builder_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_code/batch_builder_spec.rb @@ -10,8 +10,8 @@ let(:promotion_code_batch) do Spree::PromotionCodeBatch.create!( promotion_id: promotion.id, - base_code: base_code, - number_of_codes: number_of_codes, + base_code:, + number_of_codes:, email: "test@email.com" ) end @@ -81,7 +81,7 @@ raise_exception = false raise(ActiveRecord::RecordInvalid) else - create(:promotion_code, promotion: promotion) + create(:promotion_code, promotion:) end end end @@ -94,7 +94,7 @@ context "when same promotion_codes are already present" do before do - create_list(:promotion_code, 11, promotion: promotion, promotion_code_batch: promotion_code_batch) + create_list(:promotion_code, 11, promotion:, promotion_code_batch:) end it "creates only the missing promotion_codes" do @@ -118,8 +118,8 @@ let(:promotion_code_batch) do Spree::PromotionCodeBatch.create!( promotion_id: promotion.id, - base_code: base_code, - number_of_codes: number_of_codes, + base_code:, + number_of_codes:, email: "test@email.com", join_characters: "x" ) diff --git a/legacy_promotions/spec/models/spree/promotion_code_spec.rb b/legacy_promotions/spec/models/spree/promotion_code_spec.rb index c04e3ae115c..b16311c5fe0 100644 --- a/legacy_promotions/spec/models/spree/promotion_code_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_code_spec.rb @@ -7,7 +7,7 @@ subject { promotion_code.save } describe '#normalize_code' do - let(:promotion) { create(:promotion, code: code) } + let(:promotion) { create(:promotion, code:) } before { subject } @@ -76,7 +76,7 @@ before do FactoryBot.create( :completed_order_with_promotion, - promotion: promotion + promotion: ) code.adjustments.update_all(eligible: true) end @@ -107,7 +107,7 @@ let(:promotable) do FactoryBot.create( :completed_order_with_promotion, - promotion: promotion + promotion: ) end it_behaves_like "it should" @@ -124,8 +124,8 @@ end before do promotion.actions.first.perform({ - order: order, - promotion: promotion, + order:, + promotion:, promotion_code: code }) end @@ -162,14 +162,14 @@ context "when the code is applied to a non-complete order" do let(:order) { FactoryBot.create(:order_with_line_items) } - before { promotion.activate(order: order, promotion_code: code) } + before { promotion.activate(order:, promotion_code: code) } it { is_expected.to eq 0 } end context "when the code is applied to a complete order" do let!(:order) do FactoryBot.create( :completed_order_with_promotion, - promotion: promotion + promotion: ) end context "and the promo is eligible" do @@ -190,7 +190,7 @@ it "cannot create promotion code on apply automatically promotion" do promotion = create(:promotion, apply_automatically: true) expect { - create(:promotion_code, promotion: promotion) + create(:promotion_code, promotion:) }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: Could not create promotion code on promotion that apply automatically" end end diff --git a/legacy_promotions/spec/models/spree/promotion_handler/cart_spec.rb b/legacy_promotions/spec/models/spree/promotion_handler/cart_spec.rb index bb41cdd60af..9db3fac966d 100644 --- a/legacy_promotions/spec/models/spree/promotion_handler/cart_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_handler/cart_spec.rb @@ -29,7 +29,7 @@ module PromotionHandler end context "activates in LineItem level" do - let!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) } + let!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion:, calculator:) } let(:adjustable) { line_item } context "promotion with no rules" do @@ -54,7 +54,7 @@ module PromotionHandler end context "promotion includes item involved" do - let!(:rule) { Promotion::Rules::Product.create(products: [line_item.product], promotion: promotion) } + let!(:rule) { Promotion::Rules::Product.create(products: [line_item.product], promotion:) } include_context "creates the adjustment" include_context "creates an order promotion" @@ -62,7 +62,7 @@ module PromotionHandler context "promotion has item total rule" do let(:shirt) { create(:product) } - let!(:rule) { Promotion::Rules::ItemTotal.create(preferred_operator: 'gt', preferred_amount: 50, promotion: promotion) } + let!(:rule) { Promotion::Rules::ItemTotal.create(preferred_operator: 'gt', preferred_amount: 50, promotion:) } before do # Makes the order eligible for this promotion @@ -76,7 +76,7 @@ module PromotionHandler end context "activates in Order level" do - let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) } + let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion:, calculator:) } let(:adjustable) { order } context "promotion with no rules" do @@ -92,7 +92,7 @@ module PromotionHandler context "promotion has item total rule" do let(:shirt) { create(:product) } - let!(:rule) { Promotion::Rules::ItemTotal.create(preferred_operator: 'gt', preferred_amount: 50, promotion: promotion) } + let!(:rule) { Promotion::Rules::ItemTotal.create(preferred_operator: 'gt', preferred_amount: 50, promotion:) } before do # Makes the order eligible for this promotion @@ -111,7 +111,7 @@ module PromotionHandler let(:adjustable) { order } before do - Spree::OrderPromotion.create!(promotion: promotion, order: order, promotion_code: promotion_code) + Spree::OrderPromotion.create!(promotion:, order:, promotion_code:) order.recalculate end @@ -123,7 +123,7 @@ module PromotionHandler end it "checks if the promotion code is eligible" do - expect_any_instance_of(Spree::Promotion).to receive(:eligible?).at_least(2).times.with(anything, promotion_code: promotion_code).and_return(false) + expect_any_instance_of(Spree::Promotion).to receive(:eligible?).at_least(2).times.with(anything, promotion_code:).and_return(false) subject.activate end end diff --git a/legacy_promotions/spec/models/spree/promotion_handler/coupon_spec.rb b/legacy_promotions/spec/models/spree/promotion_handler/coupon_spec.rb index 20b85361dfa..2f637792f0a 100644 --- a/legacy_promotions/spec/models/spree/promotion_handler/coupon_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_handler/coupon_spec.rb @@ -24,7 +24,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) end describe "#can_apply?" do - let(:order) { Spree::Order.new(state: state) } + let(:order) { Spree::Order.new(state:) } subject { described_class.new(order).can_apply? } @@ -124,7 +124,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) context "existing coupon code promotion" do let!(:promotion) { promotion_code.promotion } let(:promotion_code) { create(:promotion_code, value: '10off') } - let!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) } + let!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion:, calculator:) } let(:calculator) { Calculator::FlatRate.new(preferred_amount: 10) } it "fetches with given code" do @@ -142,9 +142,9 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) expect(order.total).to eq(130) subject.apply expect(subject.success).to be_present - expect_order_connection(order: order, promotion: promotion, promotion_code: promotion_code) + expect_order_connection(order:, promotion:, promotion_code:) order.line_items.each do |line_item| - expect_adjustment_creation(adjustable: line_item, promotion: promotion, promotion_code: promotion_code) + expect_adjustment_creation(adjustable: line_item, promotion:, promotion_code:) end # Ensure that applying the adjustment actually affects the order's total! expect(order.reload.total).to eq(100) @@ -165,9 +165,9 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) expect(order.total).to eq(130) subject.apply expect(subject.success).to be_present - expect_order_connection(order: order, promotion: promotion, promotion_code: promotion_code) + expect_order_connection(order:, promotion:, promotion_code:) order.line_items.each do |line_item| - expect_adjustment_creation(adjustable: line_item, promotion: promotion, promotion_code: promotion_code) + expect_adjustment_creation(adjustable: line_item, promotion:, promotion_code:) end # Ensure that applying the adjustment actually affects the order's total! expect(order.reload.total).to eq(100) @@ -182,7 +182,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) order.coupon_code = "10off" calculator = Calculator::FlatRate.new(preferred_amount: 10) general_promo = create(:promotion, apply_automatically: true, name: "General Promo") - Promotion::Actions::CreateItemAdjustments.create(promotion: general_promo, calculator: calculator) + Promotion::Actions::CreateItemAdjustments.create(promotion: general_promo, calculator:) order.contents.add create(:variant) end @@ -191,9 +191,9 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) it "successfully activates promo" do subject.apply expect(subject).to be_successful - expect_order_connection(order: order, promotion: promotion, promotion_code: promotion_code) + expect_order_connection(order:, promotion:, promotion_code:) order.line_items.each do |line_item| - expect_adjustment_creation(adjustable: line_item, promotion: promotion, promotion_code: promotion_code) + expect_adjustment_creation(adjustable: line_item, promotion:, promotion_code:) end end end @@ -205,7 +205,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) order.coupon_code = "10off" calculator = Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) general_promo = create(:promotion, apply_automatically: true, name: "General Promo") - Promotion::Actions::CreateItemAdjustments.create!(promotion: general_promo, calculator: calculator) + Promotion::Actions::CreateItemAdjustments.create!(promotion: general_promo, calculator:) order.contents.add create(:variant, price: 500) order.contents.add create(:variant, price: 10) @@ -218,14 +218,14 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) expect(subject).to be_successful order.line_items.each do |line_item| expect(line_item.adjustments.count).to eq 2 - expect_adjustment_creation(adjustable: line_item, promotion: promotion, promotion_code: promotion_code) + expect_adjustment_creation(adjustable: line_item, promotion:, promotion_code:) end end end end context "with a free-shipping adjustment action" do - let!(:action) { Promotion::Actions::FreeShipping.create!(promotion: promotion) } + let!(:action) { Promotion::Actions::FreeShipping.create!(promotion:) } context "right coupon code given" do let(:order) { create(:order_with_line_items, line_items_count: 3) } @@ -236,9 +236,9 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) subject.apply expect(subject.success).to be_present - expect_order_connection(order: order, promotion: promotion, promotion_code: promotion_code) + expect_order_connection(order:, promotion:, promotion_code:) order.shipments.each do |shipment| - expect_adjustment_creation(adjustable: shipment, promotion: promotion, promotion_code: promotion_code) + expect_adjustment_creation(adjustable: shipment, promotion:, promotion_code:) end end @@ -252,7 +252,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) end context "with a whole-order adjustment action" do - let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) } + let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion:, calculator:) } context "right coupon given" do let(:order) { create(:order) } let(:calculator) { Calculator::FlatRate.new(preferred_amount: 10) } @@ -270,8 +270,8 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) subject.apply expect(subject.success).to be_present expect(order.adjustments.count).to eq(1) - expect_order_connection(order: order, promotion: promotion, promotion_code: promotion_code) - expect_adjustment_creation(adjustable: order, promotion: promotion, promotion_code: promotion_code) + expect_order_connection(order:, promotion:, promotion_code:) + expect_adjustment_creation(adjustable: order, promotion:, promotion_code:) end context "when the coupon is already applied to the order" do @@ -303,7 +303,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) end context "when the promotion exceeds its usage limit" do - let!(:second_order) { FactoryBot.create(:completed_order_with_promotion, promotion: promotion) } + let!(:second_order) { FactoryBot.create(:completed_order_with_promotion, promotion:) } before do promotion.update!(usage_limit: 1) @@ -325,10 +325,10 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) context "for an order with taxable line items" do let(:store) { create(:store) } - let(:order) { create(:order, store: store) } + let(:order) { create(:order, store:) } let(:tax_category) { create(:tax_category, name: "Taxable Foo") } let(:zone) { create(:zone, :with_country) } - let!(:tax_rate) { create(:tax_rate, amount: 0.1, tax_categories: [tax_category], zone: zone ) } + let!(:tax_rate) { create(:tax_rate, amount: 0.1, tax_categories: [tax_category], zone: ) } before(:each) do expect(order).to receive(:tax_address).at_least(:once).and_return(Spree::Tax::TaxLocation.new(country: zone.countries.first)) @@ -339,7 +339,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) order.coupon_code = "10off" 3.times do |_i| - taxable = create(:product, tax_category: tax_category, price: 9.0) + taxable = create(:product, tax_category:, price: 9.0) order.contents.add(taxable.master, 1) end end @@ -361,7 +361,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) order.coupon_code = "10off" 3.times do |_i| - taxable = create(:product, tax_category: tax_category, price: 11.0) + taxable = create(:product, tax_category:, price: 11.0) order.contents.add(taxable.master, 2) end end @@ -388,7 +388,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) order.coupon_code = "20off" 3.times do |_i| - taxable = create(:product, tax_category: tax_category, price: 10.0) + taxable = create(:product, tax_category:, price: 10.0) order.contents.add(taxable.master, 2) end end @@ -410,7 +410,7 @@ def expect_adjustment_creation(adjustable:, promotion:, promotion_code: nil) context 'removing a coupon code from an order' do let!(:promotion) { promotion_code.promotion } let(:promotion_code) { create(:promotion_code, value: '10off') } - let!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) } + let!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion:, calculator:) } let(:calculator) { Calculator::FlatRate.new(preferred_amount: 10) } let(:order) { create(:order_with_line_items, line_items_count: 3) } diff --git a/legacy_promotions/spec/models/spree/promotion_handler/page_spec.rb b/legacy_promotions/spec/models/spree/promotion_handler/page_spec.rb index 19ee14cc82a..ad3c59cd3b6 100644 --- a/legacy_promotions/spec/models/spree/promotion_handler/page_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_handler/page_spec.rb @@ -10,7 +10,7 @@ module PromotionHandler let(:promotion) { Promotion.create(name: "10% off", path: '10off') } before do calculator = Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) - action = Promotion::Actions::CreateItemAdjustments.create(calculator: calculator) + action = Promotion::Actions::CreateItemAdjustments.create(calculator:) promotion.actions << action end diff --git a/legacy_promotions/spec/models/spree/promotion_handler/shipping_spec.rb b/legacy_promotions/spec/models/spree/promotion_handler/shipping_spec.rb index 17bce06b4c8..dc1c08a5d32 100644 --- a/legacy_promotions/spec/models/spree/promotion_handler/shipping_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_handler/shipping_spec.rb @@ -6,7 +6,7 @@ module Spree module PromotionHandler RSpec.describe Shipping, type: :model do let(:order) { create(:order) } - let(:shipment) { create(:shipment, order: order ) } + let(:shipment) { create(:shipment, order: ) } let(:action) { Spree::Promotion::Actions::FreeShipping.new } @@ -41,7 +41,7 @@ module PromotionHandler context 'when already applied' do before do - order.order_promotions.create!(promotion: promotion, promotion_code: promotion.codes.first) + order.order_promotions.create!(promotion:, promotion_code: promotion.codes.first) end it 'adjusts the shipment' do @@ -56,7 +56,7 @@ module PromotionHandler end before do - order.order_promotions.create!(promotion: promotion, promotion_code: promotion.codes.first) + order.order_promotions.create!(promotion:, promotion_code: promotion.codes.first) end it 'does not adjust the shipment' do @@ -82,7 +82,7 @@ module PromotionHandler allow(Spree::Config.promotions).to receive(:shipping_actions) { ['CustomShippingAction'] } - order.order_promotions.create!(promotion: promotion, promotion_code: promotion.codes.first) + order.order_promotions.create!(promotion:, promotion_code: promotion.codes.first) end let(:action) { custom_klass.new } diff --git a/legacy_promotions/spec/models/spree/promotion_integration_spec.rb b/legacy_promotions/spec/models/spree/promotion_integration_spec.rb index 6ed19aba4cb..72b48c1f7ec 100644 --- a/legacy_promotions/spec/models/spree/promotion_integration_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_integration_spec.rb @@ -4,18 +4,18 @@ RSpec.describe "Legacy promotion system" do describe "promotions with a quantity adjustment" do - let(:action) { Spree::Promotion::Actions::CreateQuantityAdjustments.create!(calculator: calculator, promotion: promotion) } + let(:action) { Spree::Promotion::Actions::CreateQuantityAdjustments.create!(calculator:, promotion:) } let(:order) do create( :order_with_line_items, - line_items_attributes: line_items_attributes + line_items_attributes: ) end let(:line_items_attributes) do [ - { price: 10, quantity: quantity } + { price: 10, quantity: } ] end @@ -42,7 +42,7 @@ let(:calculator) { FactoryBot.create :flat_rate_calculator } before do - action.perform(order: order, promotion: promotion) + action.perform(order:, promotion:) order.recalculate end @@ -91,13 +91,13 @@ } let(:order) { create :completed_order_with_promotion, - promotion: promotion, + promotion:, line_items_attributes: [{ price: 20 }, { price: 30 }, { price: 100 }] } before do calculator.preferred_amount = 15 - Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator: calculator, promotion: promotion) + Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator:, promotion:) order.recalculate end @@ -111,7 +111,7 @@ before do rule = Spree::Promotion::Rules::Product.create!( - promotion: promotion, + promotion:, product_promotion_rules: [ Spree::ProductPromotionRule.new(product: first_product), ], @@ -141,8 +141,8 @@ let(:code) { promotion.codes.first } let(:order) do FactoryBot.create(:order_with_line_items, line_items_price: 40, shipment_cost: 0).tap do |order| - FactoryBot.create(:payment, amount: 30, order: order) - promotion.activate(order: order, promotion_code: code) + FactoryBot.create(:payment, amount: 30, order:) + promotion.activate(order:, promotion_code: code) end end let(:promo_adjustment) { order.adjustments.promotion.first } @@ -150,8 +150,8 @@ order.next! until order.can_complete? FactoryBot.create(:order_with_line_items, line_items_price: 40, shipment_cost: 0).tap do |order| - FactoryBot.create(:payment, amount: 30, order: order) - promotion.activate(order: order, promotion_code: code) + FactoryBot.create(:payment, amount: 30, order:) + promotion.activate(order:, promotion_code: code) order.next! until order.can_complete? order.complete! end @@ -184,7 +184,7 @@ describe "adding items to the cart" do let(:order) { create :order } - let(:line_item) { create :line_item, order: order } + let(:line_item) { create :line_item, order: } let(:promo) { create :promotion_with_item_adjustment, adjustment_rate: 5, code: 'promo' } let(:promotion_code) { promo.codes.first } let(:variant) { create :variant } @@ -193,7 +193,7 @@ expect(line_item.adjustments).to be_empty expect(order.adjustment_total).to eq 0 - promo.activate order: order, promotion_code: promotion_code + promo.activate(order:, promotion_code:) order.recalculate expect(line_item.adjustments.size).to eq(1) diff --git a/legacy_promotions/spec/models/spree/promotion_spec.rb b/legacy_promotions/spec/models/spree/promotion_spec.rb index c4b696192fa..f230b11138b 100644 --- a/legacy_promotions/spec/models/spree/promotion_spec.rb +++ b/legacy_promotions/spec/models/spree/promotion_spec.rb @@ -246,7 +246,7 @@ let(:promotion) { promotion_code.promotion } it "assigns the code" do - expect(promotion.activate(order: @order, promotion_code: promotion_code)).to be true + expect(promotion.activate(order: @order, promotion_code:)).to be true expect(promotion.order_promotions.map(&:promotion_code)).to eq [promotion_code] end end @@ -257,7 +257,7 @@ let(:order) { create(:order_with_line_items) } before do - promotion.activate(order: order) + promotion.activate(order:) end it 'removes the promotion' do @@ -286,7 +286,7 @@ before do FactoryBot.create( :completed_order_with_promotion, - promotion: promotion + promotion: ) promotion.actions.first.adjustments.update_all(eligible: true) end @@ -309,13 +309,13 @@ :promotion, :with_order_adjustment, code: "discount", - usage_limit: usage_limit + usage_limit: ) end let(:promotable) do FactoryBot.create( :completed_order_with_promotion, - promotion: promotion + promotion: ) end it_behaves_like "it should" @@ -327,13 +327,13 @@ :promotion, :with_line_item_adjustment, code: "discount", - usage_limit: usage_limit + usage_limit: ) end before do promotion.actions.first.perform({ - order: order, - promotion: promotion, + order:, + promotion:, promotion_code: promotion.codes.first }) end @@ -369,14 +369,14 @@ context "when the code is applied to a non-complete order" do let(:order) { FactoryBot.create(:order_with_line_items) } - before { promotion.activate(order: order, promotion_code: promotion.codes.first) } + before { promotion.activate(order:, promotion_code: promotion.codes.first) } it { is_expected.to eq 0 } end context "when the code is applied to a complete order" do let!(:order) do FactoryBot.create( :completed_order_with_promotion, - promotion: promotion + promotion: ) end context "and the promo is eligible" do @@ -429,7 +429,7 @@ end describe '#not_started?' do - let(:promotion) { Spree::Promotion.new(starts_at: starts_at) } + let(:promotion) { Spree::Promotion.new(starts_at:) } subject { promotion.not_started? } context 'no starts_at date' do @@ -449,7 +449,7 @@ end describe '#started?' do - let(:promotion) { Spree::Promotion.new(starts_at: starts_at) } + let(:promotion) { Spree::Promotion.new(starts_at:) } subject { promotion.started? } context 'when no starts_at date' do @@ -469,7 +469,7 @@ end describe '#expired?' do - let(:promotion) { Spree::Promotion.new(expires_at: expires_at) } + let(:promotion) { Spree::Promotion.new(expires_at:) } subject { promotion.expired? } context 'when no expires_at date' do @@ -489,7 +489,7 @@ end describe '#not_expired?' do - let(:promotion) { Spree::Promotion.new(expires_at: expires_at) } + let(:promotion) { Spree::Promotion.new(expires_at:) } subject { promotion.not_expired? } context 'when no expired_at date' do @@ -569,7 +569,7 @@ let!(:action) do calculator = Spree::Calculator::FlatRate.new - action_params = { promotion: promotion, calculator: calculator } + action_params = { promotion:, calculator: } action = Spree::Promotion::Actions::CreateAdjustment.create(action_params) promotion.actions << action action @@ -578,7 +578,7 @@ let!(:adjustment) do order = create(:order) Spree::Adjustment.create!( - order: order, + order:, adjustable: order, source: action, promotion_code: promotion.codes.first, @@ -642,7 +642,7 @@ context "when promotion's usage limit is exceeded" do before do promotion.usage_limit = 1 - create(:completed_order_with_promotion, promotion: promotion) + create(:completed_order_with_promotion, promotion:) end it { is_expected.to be false } @@ -651,7 +651,7 @@ context "when promotion code's usage limit is exceeded" do before do promotion.per_code_usage_limit = 1 - create(:completed_order_with_promotion, promotion: promotion) + create(:completed_order_with_promotion, promotion:) promotion.codes.first.adjustments.update_all(eligible: true) end @@ -659,7 +659,7 @@ end context "when promotion is at last usage on the same order" do - let(:order) { create(:completed_order_with_promotion, promotion: promotion) } + let(:order) { create(:completed_order_with_promotion, promotion:) } let(:promotable) { order } before do @@ -670,7 +670,7 @@ end context "when promotion code is at last usage on the same order" do - let(:order) { create(:completed_order_with_promotion, promotion: promotion) } + let(:order) { create(:completed_order_with_promotion, promotion:) } let(:promotable) { order } before do @@ -683,7 +683,7 @@ context "when promotable is a Spree::Order" do let(:promotion) { create(:promotion, :with_order_adjustment) } - let(:promotable) { create :order, line_items: line_items } + let(:promotable) { create :order, line_items: } let(:line_items) { [] } it_behaves_like "a promotable" @@ -745,8 +745,8 @@ context "#eligible_rules" do let(:promotable) { double('Promotable') } - let(:rule1) { Spree::PromotionRule.create!(promotion: promotion) } - let(:rule2) { Spree::PromotionRule.create!(promotion: promotion) } + let(:rule1) { Spree::PromotionRule.create!(promotion:) } + let(:rule2) { Spree::PromotionRule.create!(promotion:) } it "true if there are no rules" do expect(promotion.eligible_rules(promotable)).to eq [] @@ -838,9 +838,9 @@ context "due to promotion code not being eligible" do let(:order) { create(:order) } let(:promotion) { create(:promotion, per_code_usage_limit: 0) } - let(:promotion_code) { create(:promotion_code, promotion: promotion) } + let(:promotion_code) { create(:promotion_code, promotion:) } - subject { promotion.line_item_actionable? order, line_item, promotion_code: promotion_code } + subject { promotion.line_item_actionable? order, line_item, promotion_code: } it "returns false" do expect(subject).to eq false @@ -863,8 +863,8 @@ let(:promotion) { create :promotion, :with_order_adjustment } let(:user) { create :user } - let(:order) { create :order_with_line_items, user: user } - let(:excluded_order) { create :order_with_line_items, user: user } + let(:order) { create :order_with_line_items, user: } + let(:excluded_order) { create :order_with_line_items, user: } before do order.user_id = user.id @@ -873,7 +873,7 @@ context 'when the user has used this promo' do before do - promotion.activate(order: order) + promotion.activate(order:) order.recalculate order.completed_at = Time.current order.save! @@ -900,7 +900,7 @@ end context 'when the order is not complete' do - let(:order) { create :order, user: user } + let(:order) { create :order, user: } # The before clause above sets the completed at # value for this order diff --git a/legacy_promotions/spec/models/spree/shipment_spec.rb b/legacy_promotions/spec/models/spree/shipment_spec.rb index e39ca1b85eb..22e24ca8de4 100644 --- a/legacy_promotions/spec/models/spree/shipment_spec.rb +++ b/legacy_promotions/spec/models/spree/shipment_spec.rb @@ -13,12 +13,12 @@ cost: 1, inventory_units: order.inventory_units, shipping_rates: [shipping_rate], - stock_location: stock_location + stock_location: ) end let(:shipping_rate) do Spree::ShippingRate.create!( - shipping_method: shipping_method, + shipping_method:, selected: true ) end diff --git a/legacy_promotions/spec/requests/spree/api/promotion_application_spec.rb b/legacy_promotions/spec/requests/spree/api/promotion_application_spec.rb index eeb618d13ce..e4c5a3ebfe7 100644 --- a/legacy_promotions/spec/requests/spree/api/promotion_application_spec.rb +++ b/legacy_promotions/spec/requests/spree/api/promotion_application_spec.rb @@ -12,7 +12,7 @@ let!(:promotion) do promotion = create(:promotion, name: "10% off", code: "10off") calculator = Spree::Calculator::FlatPercentItemTotal.create(preferred_flat_percent: "10") - action = Spree::Promotion::Actions::CreateItemAdjustments.create(calculator: calculator) + action = Spree::Promotion::Actions::CreateItemAdjustments.create(calculator:) promotion.actions << action promotion end diff --git a/legacy_promotions/spec/subscribers/spree/order_promotion_subscriber_spec.rb b/legacy_promotions/spec/subscribers/spree/order_promotion_subscriber_spec.rb index 131b83a6bd7..0bc6bf16781 100644 --- a/legacy_promotions/spec/subscribers/spree/order_promotion_subscriber_spec.rb +++ b/legacy_promotions/spec/subscribers/spree/order_promotion_subscriber_spec.rb @@ -18,7 +18,7 @@ order.promotions << promotion expect(order.order_promotions).not_to be_empty - bus.publish(:order_emptied, order: order) + bus.publish(:order_emptied, order:) expect(order.order_promotions).to be_empty end end diff --git a/sample/db/samples/orders.rb b/sample/db/samples/orders.rb index 798ff073e06..1f93d855aa6 100644 --- a/sample/db/samples/orders.rb +++ b/sample/db/samples/orders.rb @@ -41,8 +41,8 @@ ) orders.each do |order| - order.payments.create!(payment_method: payment_method) - order.update(store: store) + order.payments.create!(payment_method:) + order.update(store:) order.next! while !order.can_complete? order.complete! diff --git a/sample/db/samples/product_option_types.rb b/sample/db/samples/product_option_types.rb index b1808d7b599..f2637ab7214 100644 --- a/sample/db/samples/product_option_types.rb +++ b/sample/db/samples/product_option_types.rb @@ -15,7 +15,7 @@ ] products_with_variants.each do |name| - product = Spree::Product.find_by!(name: name) + product = Spree::Product.find_by!(name:) product.option_types = [size, color] product.save! end diff --git a/sample/db/samples/product_properties.rb b/sample/db/samples/product_properties.rb index f58aedc9b71..4a4754ec11b 100644 --- a/sample/db/samples/product_properties.rb +++ b/sample/db/samples/product_properties.rb @@ -72,7 +72,7 @@ } products.each do |name, properties| - product = Spree::Product.find_by(name: name) + product = Spree::Product.find_by(name:) properties.each do |prop_name, prop_value| product.set_property(prop_name, prop_value) end diff --git a/sample/db/samples/products.rb b/sample/db/samples/products.rb index 7737c609157..e2245c24b15 100644 --- a/sample/db/samples/products.rb +++ b/sample/db/samples/products.rb @@ -23,8 +23,8 @@ products = [ { name: "Solidus Water Bottle", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 19.99, eur_price: 16, weight: 0.5, @@ -34,8 +34,8 @@ }, { name: "Solidus tote", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 19.99, eur_price: 16, weight: 0.5, @@ -45,8 +45,8 @@ }, { name: "Solidus hoodie", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 29.99, eur_price: 27, weight: 1, @@ -56,8 +56,8 @@ }, { name: "Solidus mug set", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 19.99, eur_price: 16, weight: 0.5, @@ -67,8 +67,8 @@ }, { name: "Solidus winter hat", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 29.99, eur_price: 27, weight: 1, @@ -78,8 +78,8 @@ }, { name: "Solidus circle sticker", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 29.99, eur_price: 27, weight: 0.8, @@ -89,8 +89,8 @@ }, { name: "Solidus notebook", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 26.99, eur_price: 23, weight: 0.5, @@ -100,8 +100,8 @@ }, { name: "Solidus t-shirt", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 9.99, eur_price: 7, weight: 1, @@ -111,8 +111,8 @@ }, { name: "Solidus long sleeve tee", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 15.99, eur_price: 14, weight: 0.5, @@ -122,8 +122,8 @@ }, { name: "Solidus dark tee", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 15.99, eur_price: 14, weight: 0.5, @@ -133,8 +133,8 @@ }, { name: "Solidus canvas tote bag", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 15.99, eur_price: 14, weight: 0.5, @@ -145,8 +145,8 @@ { name: "Solidus cap", description: "Step into style with our signature cap – a perfect blend of comfort and trendsetting flair. Crafted with care and designed for the fashion-forward, this cap adds an instant touch of cool to any outfit. Whether you're hitting the streets or simply seeking shade, our cap is your go-to accessory. Elevate your look today!", - tax_category: tax_category, - shipping_category: shipping_category, + tax_category:, + shipping_category:, price: 24, eur_price: 22, weight: 0.5, diff --git a/sample/db/samples/reimbursements.rb b/sample/db/samples/reimbursements.rb index fce000df514..7445e6c8ac7 100644 --- a/sample/db/samples/reimbursements.rb +++ b/sample/db/samples/reimbursements.rb @@ -22,20 +22,20 @@ # Create a return authorization return_item = Spree::ReturnItem.new( - inventory_unit: inventory_unit, - preferred_reimbursement_type: preferred_reimbursement_type + inventory_unit:, + preferred_reimbursement_type: ) order.return_authorizations.create!( reason: return_reason, return_items: [return_item], - stock_location: stock_location + stock_location: ) # Create a customer return and mark it as received customer_return = Spree::CustomerReturn.create!( return_items: [return_item], - stock_location: stock_location + stock_location: ) return_item.reload return_item.receive! diff --git a/sample/db/samples/shipping_methods.rb b/sample/db/samples/shipping_methods.rb index dfff4dada84..d4cfa51b9cc 100644 --- a/sample/db/samples/shipping_methods.rb +++ b/sample/db/samples/shipping_methods.rb @@ -17,35 +17,35 @@ name: "UPS Ground (USD)", zones: [north_america], calculator: Spree::Calculator::Shipping::FlatRate.create!, - tax_category: tax_category, + tax_category:, shipping_categories: [shipping_category] }, { name: "UPS Two Day (USD)", zones: [north_america], calculator: Spree::Calculator::Shipping::FlatRate.create!, - tax_category: tax_category, + tax_category:, shipping_categories: [shipping_category] }, { name: "UPS One Day (USD)", zones: [north_america], calculator: Spree::Calculator::Shipping::FlatRate.create!, - tax_category: tax_category, + tax_category:, shipping_categories: [shipping_category] }, { name: "UPS Ground (EU)", zones: [europe_vat], calculator: Spree::Calculator::Shipping::FlatRate.create!, - tax_category: tax_category, + tax_category:, shipping_categories: [shipping_category] }, { name: "UPS Ground (EUR)", zones: [europe_vat], calculator: Spree::Calculator::Shipping::FlatRate.create!, - tax_category: tax_category, + tax_category:, shipping_categories: [shipping_category] } ]) @@ -60,7 +60,7 @@ shipping_method = Spree::ShippingMethod.find_by!(name: shipping_method_name) shipping_method.calculator.preferences = { amount: price, - currency: currency + currency: } shipping_method.calculator.save! shipping_method.save! diff --git a/sample/db/samples/stock.rb b/sample/db/samples/stock.rb index 2cc23eee5eb..678e68b5bce 100644 --- a/sample/db/samples/stock.rb +++ b/sample/db/samples/stock.rb @@ -3,12 +3,12 @@ Spree::Sample.load_sample("variants") country = Spree::Country.find_by(iso: 'US') -location = Spree::StockLocation.first_or_create! name: 'default', address1: 'Example Street', city: 'City', zipcode: '12345', country: country, state: country.states.first +location = Spree::StockLocation.first_or_create! name: 'default', address1: 'Example Street', city: 'City', zipcode: '12345', country:, state: country.states.first location.active = true location.save! Spree::Variant.all.find_each do |variant| variant.stock_items.each do |stock_item| - Spree::StockMovement.create(quantity: 10, stock_item: stock_item) + Spree::StockMovement.create(quantity: 10, stock_item:) end end diff --git a/sample/db/samples/tax_rates.rb b/sample/db/samples/tax_rates.rb index 619e4dd3181..d68129c6737 100644 --- a/sample/db/samples/tax_rates.rb +++ b/sample/db/samples/tax_rates.rb @@ -10,6 +10,6 @@ tax_rate.calculator = Spree::Calculator::DefaultTax.create! tax_rate.save! Spree::TaxRateTaxCategory.create!( - tax_rate: tax_rate, + tax_rate:, tax_category: clothing ) diff --git a/sample/db/samples/taxons.rb b/sample/db/samples/taxons.rb index 59176e318f3..8d96e53e3a8 100644 --- a/sample/db/samples/taxons.rb +++ b/sample/db/samples/taxons.rb @@ -21,7 +21,7 @@ } products.each do |key, name| - products[key] = Spree::Product.find_by!(name: name) + products[key] = Spree::Product.find_by!(name:) end taxons = [ diff --git a/sample/solidus_sample.gemspec b/sample/solidus_sample.gemspec index 64243b1b4f8..02895023364 100644 --- a/sample/solidus_sample.gemspec +++ b/sample/solidus_sample.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| f.match(%r{^(spec|script)/}) end - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' s.add_dependency 'solidus_core', s.version diff --git a/solidus.gemspec b/solidus.gemspec index 92d782ec448..41b70ca15c9 100644 --- a/solidus.gemspec +++ b/solidus.gemspec @@ -18,12 +18,12 @@ Gem::Specification.new do |s| s.files = Dir['README.md', 'lib/**/*'] - s.required_ruby_version = '>= 3.0.0' + s.required_ruby_version = '>= 3.1.0' s.required_rubygems_version = '>= 1.8.23' s.add_dependency 'solidus_api', s.version s.add_dependency 'solidus_backend', s.version s.add_dependency 'solidus_core', s.version - s.add_dependency 'solidus_sample', s.version s.add_dependency 'solidus_legacy_promotions', s.version + s.add_dependency 'solidus_sample', s.version end diff --git a/tasks/testing.rake b/tasks/testing.rake index 3d8eca98b26..7dee5cbb90a 100644 --- a/tasks/testing.rake +++ b/tasks/testing.rake @@ -11,7 +11,7 @@ def subproject_task(project, task, title: project, task_name: nil) task_name ||= "#{task}:#{project}" task task_name do print_title(title) - Dir.chdir("#{File.dirname(__FILE__)}/#{project}") do + Dir.chdir(project) do sh "rake #{task}" end end