Removing redundant curly braces

This commit is contained in:
Hugo Daniel
2018-04-13 11:58:13 +02:00
committed by Pau Perez
parent abe5d3596c
commit d9f451b6fe
18 changed files with 26 additions and 26 deletions

View File

@@ -37,7 +37,7 @@ class BaseController < ApplicationController
# And default to the only order cycle if there's only the one
if @order_cycles.count == 1
current_order({ create_order_if_necessary: true }).set_order_cycle! @order_cycles.first
current_order( create_order_if_necessary: true ).set_order_cycle! @order_cycles.first
end
end
end

View File

@@ -49,14 +49,14 @@ class EnterprisesController < BaseController
end
def check_stock_levels
if current_order({ create_order_if_necessary: true }).insufficient_stock_lines.present?
if current_order(create_order_if_necessary: true).insufficient_stock_lines.present?
redirect_to spree.cart_path
end
end
def reset_order
distributor = Enterprise.is_distributor.find_by_permalink(params[:id]) || Enterprise.is_distributor.find(params[:id])
order = current_order({ create_order_if_necessary: true })
order = current_order(create_order_if_necessary: true)
reset_distributor(order, distributor)

View File

@@ -26,7 +26,7 @@ class ShopController < BaseController
def order_cycle
if request.post?
if oc = OrderCycle.with_distributor(@distributor).active.find_by_id(params[:order_cycle_id])
current_order({ create_order_if_necessary: true }).set_order_cycle! oc
current_order(create_order_if_necessary: true).set_order_cycle! oc
render partial: "json/order_cycle"
else
render status: 404, json: ""

View File

@@ -18,7 +18,7 @@ Spree::OrdersController.class_eval do
# Patching to redirect to shop if order is empty
def edit
@order = current_order({ create_order_if_necessary: true })
@order = current_order( create_order_if_necessary: true )
@insufficient_stock_lines = @order.insufficient_stock_lines
if @order.line_items.empty?
@@ -78,7 +78,7 @@ Spree::OrdersController.class_eval do
# callbacks on Spree::Adjustment and then manually invoke Spree::Order#update! on success.
Spree::Adjustment.without_callbacks do
populator = Spree::OrderPopulator.new(current_order({ create_order_if_necessary: true }), current_currency)
populator = Spree::OrderPopulator.new(current_order( create_order_if_necessary: true ), current_currency)
if populator.populate(params.slice(:products, :variants, :quantity), true)
fire_event('spree.cart.add')
@@ -127,7 +127,7 @@ Spree::OrdersController.class_eval do
end
def update_distribution
@order = current_order({ create_order_if_necessary: true })
@order = current_order( create_order_if_necessary: true )
if params[:commit] == 'Choose Hub'
distributor = Enterprise.is_distributor.find params[:order][:distributor_id]
@@ -159,7 +159,7 @@ Spree::OrdersController.class_eval do
end
def clear
@order = current_order({ create_order_if_necessary: true })
@order = current_order( create_order_if_necessary: true )
@order.empty!
@order.set_order_cycle! nil
redirect_to main_app.enterprise_path(@order.distributor.id)

View File

@@ -2,7 +2,7 @@ require 'open_food_network/available_payment_method_filter'
module EnterprisesHelper
def current_distributor
@current_distributor ||= current_order({ create_order_if_necessary: false }).andand.distributor
@current_distributor ||= current_order( create_order_if_necessary: false ).andand.distributor
end
def current_customer

View File

@@ -1,6 +1,6 @@
module OrderCyclesHelper
def current_order_cycle
@current_order_cycle ||= current_order({ create_order_if_necessary: false }).andand.order_cycle
@current_order_cycle ||= current_order( create_order_if_necessary: false ).andand.order_cycle
end
def permitted_enterprises_for(order_cycle)

View File

@@ -1,6 +1,6 @@
module SharedHelper
def distributor_link_class(distributor)
cart = current_order({ create_order_if_necessary: true })
cart = current_order( create_order_if_necessary: true )
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
klass = "shop-distributor"

View File

@@ -1,7 +1,7 @@
module Spree
module OrdersHelper
def cart_is_empty
order = current_order({ create_order_if_necessary: false })
order = current_order( create_order_if_necessary: false )
order.nil? || order.line_items.empty?
end

View File

@@ -23,7 +23,7 @@ class ResetOrderService
# Builds an order setting the token and distributor of the one specified
def build_new_order
new_order = controller.current_order({ create_order_if_necessary: true })
new_order = controller.current_order( create_order_if_necessary: true )
new_order.set_distributor!(distributor)
new_order.tokenized_permission.token = token
new_order.tokenized_permission.save!

View File

@@ -1,5 +1,5 @@
.add-to-cart
- order = current_order({ create_order_if_necessary: false })
- order = current_order( create_order_if_necessary: false )
- if product_out_of_stock
= content_tag('strong', t(:out_of_stock))

View File

@@ -2,7 +2,7 @@
%legend
= t :products_distributor
.distributor-details
- order = current_order({ create_order_if_necessary: false })
- order = current_order( create_order_if_necessary: false )
- if order.andand.distributor.present?
= render 'enterprises/distributor_details', :distributor => order.distributor
- else

View File

@@ -10,7 +10,7 @@
%h6.product-section-title= t(:distributors)
%table#product-source.table-display{:width => "100%"}
%tbody
- order = current_order({ create_order_if_necessary: false })
- order = current_order( create_order_if_necessary: false )
- validator = DistributionChangeValidator.new(order)
- Enterprise.distributing_products(@product).each do |distributor|
- if !order.nil? && distributor == order.distributor

View File

@@ -94,7 +94,7 @@ describe CheckoutController, type: :controller do
end
it "sets the new order's token to the same as the old order" do
order = controller.current_order({ create_order_if_necessary: true })
order = controller.current_order( create_order_if_necessary: true )
spree_post :update, order: {}
expect(controller.current_order.token).to eq order.token
end

View File

@@ -2,7 +2,7 @@ require 'spec_helper'
describe EnterprisesController, type: :controller do
describe "shopping for a distributor" do
let(:order) { controller.current_order({ create_order_if_necessary: true }) }
let(:order) { controller.current_order( create_order_if_necessary: true ) }
let!(:current_distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) }

View File

@@ -5,7 +5,7 @@ require 'support/request/authentication_workflow'
describe Spree::CheckoutController, type: :controller do
context 'rendering edit from within spree for the current checkout state' do
let(:order) { controller.current_order({ create_order_if_necessary: true }) }
let(:order) { controller.current_order( create_order_if_necessary: true ) }
let(:user) { create(:user) }
before do

View File

@@ -30,7 +30,7 @@ describe Spree::OrdersController, type: :controller do
it "redirects home with message if hub is not ready for checkout" do
VariantOverride.stub(:indexed).and_return({})
order = subject.current_order({ create_order_if_necessary: true })
order = subject.current_order( create_order_if_necessary: true )
distributor.stub(:ready_for_checkout?) { false }
order.stub(distributor: distributor, order_cycle: order_cycle)
@@ -44,7 +44,7 @@ describe Spree::OrdersController, type: :controller do
end
describe "when an item has insufficient stock" do
let(:order) { subject.current_order({ create_order_if_necessary: true }) }
let(:order) { subject.current_order( create_order_if_necessary: true ) }
let(:oc) { create(:simple_order_cycle, distributors: [d], variants: [variant]) }
let(:d) { create(:distributor_enterprise, shipping_methods: [create(:shipping_method)], payment_methods: [create(:payment_method)]) }
let(:variant) { create(:variant, on_demand: false, on_hand: 5) }
@@ -129,7 +129,7 @@ describe Spree::OrdersController, type: :controller do
distributor_product = create(:distributor_enterprise)
p = create(:product, :distributors => [distributor_product], :group_buy => true)
order = subject.current_order({ create_order_if_necessary: true })
order = subject.current_order( create_order_if_necessary: true )
order.stub(:distributor) { distributor_product }
order.should_receive(:set_variant_attributes).with(p.master, {'max_quantity' => '3'})
controller.stub(:current_order).and_return(order)
@@ -164,7 +164,7 @@ describe Spree::OrdersController, type: :controller do
describe "removing line items from cart" do
describe "when I pass params that includes a line item no longer in our cart" do
it "should silently ignore the missing line item" do
order = subject.current_order({ create_order_if_necessary: true })
order = subject.current_order( create_order_if_necessary: true )
li = order.add_variant(create(:simple_product, on_hand: 110).variants.first)
spree_get :update, order: { line_items_attributes: {
"0" => {quantity: "0", id: "9999"},
@@ -176,7 +176,7 @@ describe Spree::OrdersController, type: :controller do
end
it "filters line items that are missing from params" do
order = subject.current_order({ create_order_if_necessary: true })
order = subject.current_order( create_order_if_necessary: true )
li = order.add_variant(create(:simple_product).master)
attrs = {

View File

@@ -9,7 +9,7 @@ module Spree
end
context 'when confirming' do
let(:previous_order) { controller.current_order({ create_order_if_necessary: true }) }
let(:previous_order) { controller.current_order( create_order_if_necessary: true ) }
let(:payment_method) { create(:payment_method) }
before do

View File

@@ -4,7 +4,7 @@ describe Spree::OrdersController, type: :controller, performance: true do
let(:distributor) { create(:distributor_enterprise) }
let(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], variants: products.map { |p| p.variants.first }) }
let(:products) { (0...num_products).map { create(:product) } }
let(:order) { subject.current_order({ create_order_if_necessary: true }) }
let(:order) { subject.current_order( create_order_if_necessary: true ) }
let(:num_products) { 20 }
before do