Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rubocop violations after the latest release #5535

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/app/views/spree/api/images/_image.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

json.(image, *image_attributes)
json.(image, :viewable_type, :viewable_id)
Spree::Image.attachment_definitions[:attachment][:styles].each do |key, _value|

Spree::Image.attachment_definitions[:attachment][:styles].each_key do |key|
json.set! "#{key}_url", image.url(key)
end
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update
invoke_callbacks(:update, :before)

attributes = payment_method_params
attributes.each do |key, _value|
attributes.each_key do |key|
if key.include?("password") && attributes[key].blank?
attributes.delete(key)
end
Expand Down
4 changes: 2 additions & 2 deletions backend/app/controllers/spree/admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def location_after_save
if updating_variant_property_rules?
url_params = {}
url_params[:ovi] = []
params[:product][:variant_property_rules_attributes].each do |_index, param_attrs|
params[:product][:variant_property_rules_attributes].each_value do |param_attrs|
url_params[:ovi] += param_attrs[:option_value_ids]
end
spree.admin_product_product_properties_url(@product, url_params)
Expand Down Expand Up @@ -133,7 +133,7 @@ def render_after_update_error
def normalize_variant_property_rules
return unless updating_variant_property_rules?

params[:product][:variant_property_rules_attributes].each do |_index, param_attrs|
params[:product][:variant_property_rules_attributes].each_value do |param_attrs|
param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(',')
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ 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: currency) || 0.0].min
end
end

Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/promotion_handler/coupon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def handle_present_promotion(promotion)

unless promotion.eligible?(order, promotion_code: promotion_code)
set_promotion_eligibility_error_code(promotion)
return (error || ineligible_for_this_order)
return error || ineligible_for_this_order
end

# If any of the actions for the promotion return `true`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def split_by_category(package)

def hash_to_packages(categories)
packages = []
categories.each do |_id, contents|
categories.each_value do |contents|
packages << build_package(contents)
end
packages
Expand Down
6 changes: 5 additions & 1 deletion core/lib/spree/core/state_machines/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def define_state_machine!

# Persist the state on the order
after_transition do |order, transition|
order.state = order.state
# Hard to say if this is really necessary, it was introduced in this commit:
# https://github.com/mamhoff/solidus/commit/fa1d66c42e4c04ee7cd1c20d87e4cdb74a226d3d
# But it seems to be harmless, so we'll keep it for now.
order.state = order.state # rubocop:disable Lint/SelfAssignment

order.state_changes.create(
previous_state: transition.from,
next_state: transition.to,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(amount, options = {})
if amount.is_a?(::Money)
@money = amount
else
currency = (options[:currency] || Spree::Config[:currency])
currency = options[:currency] || Spree::Config[:currency]

@money = Monetize.from_string(amount, currency)
end
Expand Down
3 changes: 2 additions & 1 deletion sample/db/samples/shipping_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
}
])

{
# The just below rubocop:disable directive will be removed once https://github.com/rubocop/rubocop/issues/12441 is resolved.
{ # rubocop:disable Style/HashEachMethods
"UPS Ground (USD)" => [5, "USD"],
"UPS Ground (EU)" => [5, "USD"],
"UPS One Day (USD)" => [15, "USD"],
Expand Down
Loading