Rubocop: Autocorrect

Now, with Ruby 3.1 we need to address some code style
This commit is contained in:
Thomas von Deyen 2024-09-12 14:00:28 +02:00
parent 1595c52497
commit 273e5bd54e
No known key found for this signature in database
GPG Key ID: F2548C2CBA04A848
391 changed files with 1373 additions and 1373 deletions

View File

@ -10,7 +10,7 @@ module SolidusAdmin
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)

View File

@ -11,7 +11,7 @@ class SolidusAdmin::Layout::Navigation::Account::Component < SolidusAdmin::BaseC
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 @@ class SolidusAdmin::Layout::Navigation::Account::Component < SolidusAdmin::BaseC
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"),
])

View File

@ -9,7 +9,7 @@ class SolidusAdmin::Layout::Navigation::Component < SolidusAdmin::BaseComponent
@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

View File

@ -124,7 +124,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::UI::Pages::Index::C
'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

View File

@ -10,7 +10,7 @@ class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component < So
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

View File

@ -10,7 +10,7 @@ class SolidusAdmin::Orders::Show::Adjustments::Index::Source::Component < Solidu
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

View File

@ -20,7 +20,7 @@ class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent
:unavailable
end
new(status: status)
new(status:)
end
def initialize(status:)

View File

@ -138,7 +138,7 @@ class SolidusAdmin::StockItems::Index::Component < SolidusAdmin::UI::Pages::Inde
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 },

View File

@ -57,7 +57,7 @@ class SolidusAdmin::StockLocations::Index::Component < SolidusAdmin::Shipping::C
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 @@ class SolidusAdmin::StockLocations::Index::Component < SolidusAdmin::Shipping::C
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'
)

View File

@ -18,14 +18,14 @@ class SolidusAdmin::UI::Forms::Field::Component < SolidusAdmin::BaseComponent
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 @@ class SolidusAdmin::UI::Forms::Field::Component < SolidusAdmin::BaseComponent
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 @@ class SolidusAdmin::UI::Forms::Field::Component < SolidusAdmin::BaseComponent
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 @@ class SolidusAdmin::UI::Forms::Field::Component < SolidusAdmin::BaseComponent
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,

View File

@ -61,8 +61,8 @@ class SolidusAdmin::UI::Pages::Index::Component < SolidusAdmin::BaseComponent
value: search_params,
url: search_url,
searchbar_key: search_key,
filters: filters,
scopes: scopes,
filters:,
scopes:,
}
end
@ -80,12 +80,12 @@ class SolidusAdmin::UI::Pages::Index::Component < SolidusAdmin::BaseComponent
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,

View File

@ -138,7 +138,7 @@ class SolidusAdmin::UI::Table::Component < SolidusAdmin::BaseComponent
predicate: filter.predicate,
options: filter.options,
form: search_form_id,
index: index,
index:,
)
end

View File

@ -10,6 +10,6 @@ class SolidusAdmin::UI::ThumbnailWithCaption::Component < SolidusAdmin::BaseComp
end
def icon_thumbnail
render component("ui/thumbnail").new(icon: icon)
render component("ui/thumbnail").new(icon:)
end
end

View File

@ -77,7 +77,7 @@ class SolidusAdmin::Users::Index::Component < SolidusAdmin::UsersAndRoles::Compo
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,
},

View File

@ -7,8 +7,8 @@ module SolidusAdmin::ControllerHelpers::Search
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 @@ module SolidusAdmin::ControllerHelpers::Search
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:)

View File

@ -28,7 +28,7 @@ module SolidusAdmin
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)}",

View File

@ -169,10 +169,10 @@ module SolidusAdmin
{
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

View File

@ -19,7 +19,7 @@ module SolidusAdmin
end
def find_row(text)
find('table tbody tr', text: text)
find('table tbody tr', text:)
end
def find_row_checkbox(text)

View File

@ -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

View File

@ -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 @@ class SolidusAdmin::UI::Button::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -14,11 +14,11 @@ class SolidusAdmin::UI::Dropdown::ComponentPreview < ViewComponent::Preview
# @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"),
)

View File

@ -13,7 +13,7 @@ class SolidusAdmin::UI::Forms::Address::ComponentPreview < ViewComponent::Previe
render component("ui/forms/address").new(
name: "",
address: fake_address,
disabled: disabled
disabled:
)
end
@ -21,6 +21,6 @@ class SolidusAdmin::UI::Forms::Address::ComponentPreview < ViewComponent::Previe
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

View File

@ -53,6 +53,6 @@ class SolidusAdmin::UI::Forms::Checkbox::ComponentPreview < ViewComponent::Previ
# @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

View File

@ -12,8 +12,8 @@ class SolidusAdmin::UI::Forms::Field::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -18,7 +18,7 @@ class SolidusAdmin::UI::Forms::Input::ComponentPreview < ViewComponent::Preview
type: type.to_sym,
error: error ? "There is an error" : nil,
size: size.to_sym,
value: value,
value:,
)
end
@ -38,7 +38,7 @@ class SolidusAdmin::UI::Forms::Input::ComponentPreview < ViewComponent::Preview
"size" => rows > 1 ? rows : nil,
error: error ? "There is an error" : nil,
size: size.to_sym,
multiple: multiple,
multiple:,
).with_content(options.reduce(:+))
end

View File

@ -29,6 +29,6 @@ class SolidusAdmin::UI::Forms::Switch::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -25,14 +25,14 @@ class SolidusAdmin::UI::Forms::SwitchField::ComponentPreview < ViewComponent::Pr
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

View File

@ -10,7 +10,7 @@ class SolidusAdmin::UI::Icon::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -46,6 +46,6 @@ class SolidusAdmin::UI::Pages::Index::ComponentPreview < ViewComponent::Preview
end
end
render component_subclcass.new(page: page)
render component_subclcass.new(page:)
end
end

View File

@ -13,9 +13,9 @@ class SolidusAdmin::UI::ResourceItem::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -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 @@ class SolidusAdmin::UI::Tab::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -45,7 +45,7 @@ class SolidusAdmin::UI::Table::ComponentPreview < ViewComponent::Preview
{
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|

View File

@ -12,7 +12,7 @@ class SolidusAdmin::UI::Table::RansackFilter::ComponentPreview < ViewComponent::
# @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",

View File

@ -11,6 +11,6 @@ class SolidusAdmin::UI::Thumbnail::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -12,6 +12,6 @@ class SolidusAdmin::UI::Toast::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -13,9 +13,9 @@ class SolidusAdmin::UI::Toggletip::ComponentPreview < ViewComponent::Preview
# @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

View File

@ -13,7 +13,7 @@ describe "Order", :js, type: :feature do
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 @@ describe "Order", :js, type: :feature do
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 @@ describe "Order", :js, type: :feature do
before do
order.shipments.first.adjustments.create!(
order: order,
order:,
label: "Manual shipping discount",
amount: -2,
source: nil

View File

@ -39,9 +39,9 @@ RSpec.describe SolidusAdmin::PermissionSetsHelper, :helper do
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 @@ RSpec.describe SolidusAdmin::PermissionSetsHelper, :helper do
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 @@ RSpec.describe SolidusAdmin::PermissionSetsHelper, :helper do
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 @@ RSpec.describe SolidusAdmin::PermissionSetsHelper, :helper do
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({})

View File

@ -28,7 +28,7 @@ module Spree
@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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -55,7 +55,7 @@ module Spree
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

View File

@ -4,7 +4,7 @@ require 'spec_helper'
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 @@ describe "Ransackable Attributes" do
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 }

View File

@ -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 } }

View File

@ -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

View File

@ -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 }

View File

@ -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

View File

@ -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)

View File

@ -5,7 +5,7 @@ require 'spec_helper'
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)

View File

@ -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: [

View File

@ -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!

View File

@ -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 }

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -5,13 +5,13 @@ require 'spec_helper'
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

View File

@ -5,9 +5,9 @@ require 'spec_helper'
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] }

View File

@ -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." })

View File

@ -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

View File

@ -29,10 +29,10 @@ module ControllerHacks
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

View File

@ -20,7 +20,7 @@ module Spree
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)

View File

@ -7,7 +7,7 @@ module Spree
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|

View File

@ -15,8 +15,8 @@ module Spree
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?

View File

@ -88,7 +88,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
#
# 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

View File

@ -25,7 +25,7 @@ module Spree
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 @@ module Spree
t('spree.date_picker.format', default: '%Y/%m/%d')
end
l(date, format: format)
l(date, format:)
end
def spree_dom_id(record)

View File

@ -114,7 +114,7 @@ module Spree
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

View File

@ -61,7 +61,7 @@ module Spree
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 Spree
{
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:
}
}
}

View File

@ -16,7 +16,7 @@ RSpec.describe Spree::Admin::LocaleController, type: :controller do
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

View File

@ -324,7 +324,7 @@ describe Spree::Admin::OrdersController, type: :controller do
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 @@ describe Spree::Admin::OrdersController, type: :controller do
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 }

View File

@ -99,7 +99,7 @@ module Spree
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)

View File

@ -131,7 +131,7 @@ module Spree
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

View File

@ -31,7 +31,7 @@ describe Spree::Admin::PricesController do
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 } }

View File

@ -33,7 +33,7 @@ module Spree
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

View File

@ -25,7 +25,7 @@ describe Spree::Admin::ProductsController, type: :controller do
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 @@ describe Spree::Admin::ProductsController, type: :controller do
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 @@ describe Spree::Admin::ProductsController, type: :controller do
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 @@ describe Spree::Admin::ProductsController, type: :controller do
context "destroying a product" do
let(:product) do
product = create(:product)
create(:variant, product: product)
create(:variant, product:)
product
end

View File

@ -101,7 +101,7 @@ describe Spree::Admin::WidgetsController, type: :controller do
{ 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 @@ describe Spree::Admin::WidgetsController, type: :controller do
}
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 @@ describe Spree::Admin::WidgetsController, type: :controller do
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 @@ describe Spree::Admin::WidgetsController, type: :controller do
let(:params) { { id: widget.id } }
subject {
delete :destroy, params: params
delete :destroy, params:
}
it 'destroys the resource' do
@ -190,7 +190,7 @@ describe Spree::Admin::WidgetsController, type: :controller do
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 @@ describe Spree::Admin::WidgetsController, type: :controller do
end
context 'html format' do
subject { delete :destroy, params: params }
subject { delete :destroy, params: }
it 'responds with error message' do
subject

Some files were not shown because too many files have changed in this diff Show More