mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Removing a few rubocop warnings
This commit is contained in:
@@ -41,10 +41,7 @@ Metrics/LineLength:
|
||||
- app/controllers/api/enterprise_attachment_controller.rb
|
||||
- app/controllers/api/product_images_controller.rb
|
||||
- app/controllers/application_controller.rb
|
||||
- app/controllers/base_controller.rb
|
||||
- app/controllers/cart_controller.rb
|
||||
- app/controllers/checkout_controller.rb
|
||||
- app/controllers/shop_controller.rb
|
||||
- app/controllers/spree/admin/adjustments_controller_decorator.rb
|
||||
- app/controllers/spree/admin/base_controller_decorator.rb
|
||||
- app/controllers/spree/admin/line_items_controller_decorator.rb
|
||||
@@ -58,7 +55,6 @@ Metrics/LineLength:
|
||||
- app/controllers/spree/orders_controller_decorator.rb
|
||||
- app/controllers/spree/paypal_controller_decorator.rb
|
||||
- app/controllers/stripe/callbacks_controller.rb
|
||||
- app/controllers/user_confirmations_controller.rb
|
||||
- app/helpers/admin/account_helper.rb
|
||||
- app/helpers/admin/injection_helper.rb
|
||||
- app/helpers/angular_form_builder.rb
|
||||
|
||||
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
prepend_before_filter :restrict_iframes
|
||||
before_filter :set_cache_headers # Issue #1213, prevent cart emptying via cache when using back button
|
||||
before_filter :set_cache_headers # prevent cart emptying via cache when using back button #1213
|
||||
|
||||
include EnterprisesHelper
|
||||
|
||||
@@ -16,7 +16,8 @@ class ApplicationController < ActionController::Base
|
||||
def set_checkout_redirect
|
||||
referer_path = OpenFoodNetwork::RefererParser::path(request.referer)
|
||||
if referer_path
|
||||
session["spree_user_return_to"] = [main_app.checkout_path].include?(referer_path) ? referer_path : root_path
|
||||
is_checkout_path_the_referer = [main_app.checkout_path].include?(referer_path)
|
||||
session["spree_user_return_to"] = is_checkout_path_the_referer ? referer_path : root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ class BaseController < ApplicationController
|
||||
@order_cycles = OrderCycle.with_distributor(@distributor).active
|
||||
.order(@distributor.preferred_shopfront_order_cycle_order)
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor, "FilterOrderCycles", current_customer.andand.tag_list)
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor,
|
||||
"FilterOrderCycles",
|
||||
current_customer.andand.tag_list)
|
||||
applicator.filter!(@order_cycles)
|
||||
|
||||
# And default to the only order cycle if there's only the one
|
||||
|
||||
@@ -82,10 +82,14 @@ class CheckoutController < Spree::CheckoutController
|
||||
new_bill_address = @order.bill_address.clone.attributes
|
||||
|
||||
user_bill_address_id = spree_current_user.bill_address.andand.id
|
||||
spree_current_user.update_attributes(bill_address_attributes: new_bill_address.merge('id' => user_bill_address_id))
|
||||
spree_current_user.update_attributes(
|
||||
bill_address_attributes: new_bill_address.merge('id' => user_bill_address_id)
|
||||
)
|
||||
|
||||
customer_bill_address_id = @order.customer.bill_address.andand.id
|
||||
@order.customer.update_attributes(bill_address_attributes: new_bill_address.merge('id' => customer_bill_address_id))
|
||||
@order.customer.update_attributes(
|
||||
bill_address_attributes: new_bill_address.merge('id' => customer_bill_address_id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -94,16 +98,23 @@ class CheckoutController < Spree::CheckoutController
|
||||
new_ship_address = @order.ship_address.clone.attributes
|
||||
|
||||
user_ship_address_id = spree_current_user.ship_address.andand.id
|
||||
spree_current_user.update_attributes(ship_address_attributes: new_ship_address.merge('id' => user_ship_address_id))
|
||||
spree_current_user.update_attributes(
|
||||
ship_address_attributes: new_ship_address.merge('id' => user_ship_address_id)
|
||||
)
|
||||
|
||||
customer_ship_address_id = @order.customer.ship_address.andand.id
|
||||
@order.customer.update_attributes(ship_address_attributes: new_ship_address.merge('id' => customer_ship_address_id))
|
||||
@order.customer.update_attributes(
|
||||
ship_address_attributes: new_ship_address.merge('id' => customer_ship_address_id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def check_order_for_phantom_fees
|
||||
phantom_fees = @order.adjustments.joins('LEFT OUTER JOIN spree_line_items ON spree_line_items.id = spree_adjustments.source_id').
|
||||
where("originator_type = 'EnterpriseFee' AND source_type = 'Spree::LineItem' AND spree_line_items.id IS NULL")
|
||||
phantom_fees = @order.adjustments.
|
||||
joins("LEFT OUTER JOIN spree_line_items"\
|
||||
" ON spree_line_items.id = spree_adjustments.source_id").
|
||||
where("originator_type = 'EnterpriseFee'"\
|
||||
" AND source_type = 'Spree::LineItem' AND spree_line_items.id IS NULL")
|
||||
|
||||
if phantom_fees.any?
|
||||
Bugsnag.notify(RuntimeError.new("Phantom Fees"), {
|
||||
@@ -118,7 +129,9 @@ class CheckoutController < Spree::CheckoutController
|
||||
# Copied and modified from spree. Remove check for order state, since the state machine is
|
||||
# progressed all the way in one go with the one page checkout.
|
||||
def object_params
|
||||
# For payment step, filter order parameters to produce the expected nested attributes for a single payment and its source, discarding attributes for payment methods other than the one selected
|
||||
# For payment step, filter order parameters to produce the expected
|
||||
# nested attributes for a single payment and its source,
|
||||
# discarding attributes for payment methods other than the one selected
|
||||
if params[:payment_source].present? && source_params = params.delete(:payment_source)[params[:order][:payments_attributes].first[:payment_method_id].underscore]
|
||||
params[:order][:payments_attributes].first[:source_attributes] = source_params
|
||||
end
|
||||
@@ -154,7 +167,8 @@ class CheckoutController < Spree::CheckoutController
|
||||
end
|
||||
end
|
||||
|
||||
# When we have a pickup Shipping Method, we clone the distributor address into ship_address before_save
|
||||
# When we have a pickup Shipping Method,
|
||||
# we clone the distributor address into ship_address before_save
|
||||
# We don't want this data in the form, so we clear it out
|
||||
def clear_ship_address
|
||||
unless current_order.shipping_method.andand.require_ship_address
|
||||
@@ -185,7 +199,9 @@ class CheckoutController < Spree::CheckoutController
|
||||
end
|
||||
|
||||
def valid_order_line_items?
|
||||
@order.insufficient_stock_lines.empty? && OrderCycleDistributedVariants.new(@order.order_cycle, @order.distributor).distributes_order_variants?(@order)
|
||||
@order.insufficient_stock_lines.empty? &&
|
||||
OrderCycleDistributedVariants.new(@order.order_cycle, @order.distributor).
|
||||
distributes_order_variants?(@order)
|
||||
end
|
||||
|
||||
def redirect_to_cart_path
|
||||
@@ -203,10 +219,12 @@ class CheckoutController < Spree::CheckoutController
|
||||
def redirect_to_paypal_express_form_if_needed
|
||||
return unless params[:order][:payments_attributes]
|
||||
|
||||
payment_method = Spree::PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id])
|
||||
payment_method_id = params[:order][:payments_attributes].first[:payment_method_id]
|
||||
payment_method = Spree::PaymentMethod.find(payment_method_id)
|
||||
return unless payment_method.kind_of?(Spree::Gateway::PayPalExpress)
|
||||
|
||||
render json: {path: spree.paypal_express_path(payment_method_id: payment_method.id)}, status: 200
|
||||
render json: {path: spree.paypal_express_path(payment_method_id: payment_method.id)},
|
||||
status: 200
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ class EnterprisesController < BaseController
|
||||
end
|
||||
|
||||
def check_permalink
|
||||
render text: params[:permalink], status: 409 and return if Enterprise.find_by_permalink params[:permalink]
|
||||
if Enterprise.find_by_permalink params[:permalink]
|
||||
render text: params[:permalink], status: 409 and return
|
||||
end
|
||||
|
||||
begin
|
||||
Rails.application.routes.recognize_path( "/#{ params[:permalink].to_s }" )
|
||||
@@ -67,7 +69,8 @@ class EnterprisesController < BaseController
|
||||
end
|
||||
|
||||
def reset_order
|
||||
distributor = Enterprise.is_distributor.find_by_permalink(params[:id]) || Enterprise.is_distributor.find(params[:id])
|
||||
distributor = Enterprise.is_distributor.find_by_permalink(params[:id]) ||
|
||||
Enterprise.is_distributor.find(params[:id])
|
||||
order = current_order(true)
|
||||
|
||||
reset_distributor(order, distributor)
|
||||
|
||||
@@ -11,7 +11,8 @@ class ShopController < BaseController
|
||||
|
||||
def products
|
||||
begin
|
||||
renderer = OpenFoodNetwork::CachedProductsRenderer.new(current_distributor, current_order_cycle)
|
||||
renderer = OpenFoodNetwork::CachedProductsRenderer.new(current_distributor,
|
||||
current_order_cycle)
|
||||
|
||||
# If we add any more filtering logic, we should probably
|
||||
# move it all to a lib class like 'CachedProductsFilterer'
|
||||
@@ -59,6 +60,8 @@ class ShopController < BaseController
|
||||
|
||||
def applicator
|
||||
return @applicator unless @applicator.nil?
|
||||
@applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor, "FilterProducts", current_customer.andand.tag_list)
|
||||
@applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
|
||||
"FilterProducts",
|
||||
current_customer.andand.tag_list)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class UserConfirmationsController < DeviseController
|
||||
include Spree::Core::ControllerHelpers::Auth # Needed for access to current_ability, so we can authorize! actions
|
||||
# Needed for access to current_ability, so we can authorize! actions
|
||||
include Spree::Core::ControllerHelpers::Auth
|
||||
|
||||
# GET /resource/confirmation/new
|
||||
def new
|
||||
@@ -44,7 +45,9 @@ class UserConfirmationsController < DeviseController
|
||||
end
|
||||
|
||||
if resource.reset_password_token.present?
|
||||
return spree.edit_spree_user_password_path(reset_password_token: resource.reset_password_token)
|
||||
return spree.edit_spree_user_password_path(
|
||||
reset_password_token: resource.reset_password_token
|
||||
)
|
||||
end
|
||||
|
||||
path = (session[:confirmation_return_url] || login_path).to_s
|
||||
|
||||
Reference in New Issue
Block a user