diff --git a/Gemfile b/Gemfile index 0e2d21d89c6..feb780db3be 100644 --- a/Gemfile +++ b/Gemfile @@ -11,17 +11,17 @@ gem 'i18n-js', '~> 3.0.0' gem 'nokogiri', '>= 1.6.7.1' gem 'pg' -gem 'spree', github: 'openfoodfoundation/spree', branch: 'step-6a', ref: '86bf87f1b1e1b299edc8cd10a2486e44ba0a3987' +gem 'spree', '2.0.13' gem 'spree_i18n', github: 'spree/spree_i18n', branch: '1-3-stable' -gem 'spree_auth_devise', github: 'openfoodfoundation/spree_auth_devise', branch: 'spree-upgrade-intermediate' +gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable' # Our branch contains two changes # - Pass customer email and phone number to PayPal (merged to upstream master) # - Change type of password from string to password to hide it in the form -gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "spree-upgrade-intermediate" -#gem 'spree_paypal_express', github: "spree-contrib/better_spree_paypal_express", branch: "1-3-stable" +# gem 'spree_paypal_express' +gem 'spree_paypal_express', github: "spree-contrib/better_spree_paypal_express", branch: "2-0-stable" gem 'stripe', '~> 3.3.1' -gem 'activemerchant', '~> 1.71.0' +gem 'activemerchant' gem 'oauth2', '~> 1.2.0' # Used for Stripe Connect gem 'jwt', '~> 1.5' @@ -49,8 +49,8 @@ gem 'representative_view' gem 'rabl' gem "active_model_serializers" gem 'oj' -gem 'deface', github: 'spree/deface', ref: '1110a13' -gem 'paperclip' +gem 'deface', '1.0.0' +gem 'paperclip', '~> 3.4.1' gem 'dalli' gem 'geocoder' gem 'gmaps4rails' @@ -95,7 +95,7 @@ end gem "foundation-rails" gem 'foundation_rails_helper', github: 'willrjmarshall/foundation_rails_helper', branch: "rails3" -gem 'jquery-rails' +gem 'jquery-rails', '3.0.0' gem 'jquery-migrate-rails' gem 'css_splitter' diff --git a/Gemfile.lock b/Gemfile.lock index d6adb99a3d5..63749a3b283 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,15 +12,6 @@ GIT specs: custom_error_message (1.1.1) -GIT - remote: https://github.com/openfoodfoundation/better_spree_paypal_express.git - revision: 8d95f4544c682634812becaf50999fba0cd04df0 - branch: spree-upgrade-intermediate - specs: - spree_paypal_express (2.0.3) - paypal-sdk-merchant (= 1.106.1) - spree_core (~> 1.3.99) - GIT remote: https://github.com/openfoodfoundation/ofn-qz.git revision: 60da2ae4c44cbb4c8d602f59fb5fff8d0f21db3c @@ -30,88 +21,25 @@ GIT railties (~> 3.1) GIT - remote: https://github.com/openfoodfoundation/spree.git - revision: 86bf87f1b1e1b299edc8cd10a2486e44ba0a3987 - ref: 86bf87f1b1e1b299edc8cd10a2486e44ba0a3987 - branch: step-6a + remote: https://github.com/spree-contrib/better_spree_paypal_express.git + revision: 1206925d1c85bdc4b68b728d6676150ab0785486 + branch: 2-0-stable specs: - spree (1.3.99) - spree_api (= 1.3.99) - spree_backend (= 1.3.99) - spree_cmd (= 1.3.99) - spree_core (= 1.3.99) - spree_dash (= 1.3.99) - spree_frontend (= 1.3.99) - spree_sample (= 1.3.99) - spree_api (1.3.99) - rabl (= 0.7.2) - spree_core (= 1.3.99) - versioncake (= 0.4.0) - spree_backend (1.3.99) - deface (>= 0.9.0) - jquery-rails (~> 2.0) - rails (~> 3.2.8) - select2-rails (~> 3.2) - spree_api (= 1.3.99) - spree_core (= 1.3.99) - stringex (~> 1.3.2) - spree_cmd (1.3.99) - thor (>= 0.14.6) - spree_core (1.3.99) - activemerchant (~> 1.50) - acts_as_list (= 0.1.9) - awesome_nested_set (= 2.1.5) - aws-sdk (~> 1.11.1) - cancan (= 1.6.8) - deface (>= 0.9.0) - ffaker (~> 1.15.0) - highline (= 1.6.15) - httparty (= 0.9.0) - json (>= 1.5.5) - kaminari (= 0.13.0) - money (= 5.1.0) - paperclip (~> 3.0) - rails (~> 3.2.13) - ransack (= 0.7.2) - state_machine (= 1.2.0) - stringex (~> 1.3.2) - truncate_html (= 0.9.2) - spree_dash (1.3.99) - httparty (~> 0.9.0) - spree_backend (= 1.3.99) - spree_frontend (= 1.3.99) - spree_frontend (1.3.99) - deface (>= 0.9.0) - jquery-rails (~> 2.2.1) - rails (~> 3.2.8) - select2-rails (~> 3.2) - spree_api (= 1.3.99) - spree_core (= 1.3.99) - stringex (~> 1.3.2) - spree_sample (1.3.99) - spree_core (= 1.3.99) + spree_paypal_express (2.0.3) + paypal-sdk-merchant (= 1.106.1) + spree_core (~> 2.0.3) GIT - remote: https://github.com/openfoodfoundation/spree_auth_devise.git - revision: da9eecefc6fe13dedf4c6f3febec79caad839ec3 - branch: spree-upgrade-intermediate + remote: https://github.com/spree/spree_auth_devise.git + revision: 0181835fb6ac77a05191d26f6f32a0f4a548d851 + branch: 2-0-stable specs: spree_auth_devise (2.0.0) devise (~> 2.2.5) devise-encryptable (= 0.1.2) - spree_backend (~> 1.3.6) - spree_core (~> 1.3.6) - spree_frontend (~> 1.3.6) - -GIT - remote: https://github.com/spree/deface.git - revision: 1110a1336252109bce7f98f9182042e0bc2930ae - ref: 1110a13 - specs: - deface (1.0.0.rc3) - colorize (>= 0.5.8) - nokogiri (~> 1.6.0) - rails (>= 3.1) + spree_backend (~> 2.0.0) + spree_core (~> 2.0.0) + spree_frontend (~> 2.0.0) GIT remote: https://github.com/spree/spree_i18n.git @@ -152,10 +80,16 @@ GEM sprockets (~> 2.2.1) active_model_serializers (0.8.3) activemodel (>= 3.0) - activemerchant (1.71.0) - activesupport (>= 3.2.14, < 6.x) + active_utils (2.2.3) + activesupport (>= 2.3.11) + i18n + activemerchant (1.43.3) + active_utils (~> 2.0, >= 2.0.1) + activesupport (>= 2.3.14, < 5.0.0) builder (>= 2.1.2, < 4.0.0) - i18n (>= 0.6.9) + i18n (~> 0.5) + json (~> 1.7) + money (< 7.0.0) nokogiri (~> 1.4) activemodel (3.2.21) activesupport (= 3.2.21) @@ -173,7 +107,8 @@ GEM multi_json (~> 1.0) acts-as-taggable-on (3.5.0) activerecord (>= 3.2, < 5) - acts_as_list (0.1.9) + acts_as_list (0.3.0) + activerecord (>= 3.0) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) andand (1.3.3) @@ -186,10 +121,10 @@ GEM arel (3.0.3) ast (2.3.0) atomic (1.1.99) - awesome_nested_set (2.1.5) + awesome_nested_set (2.1.6) activerecord (>= 3.0.0) awesome_print (1.0.2) - aws-sdk (1.11.1) + aws-sdk (1.31.3) json (~> 1.4) nokogiri (>= 1.4.4) uuidtools (~> 2.1) @@ -200,7 +135,9 @@ GEM bugsnag (4.1.0) builder (3.0.4) byebug (9.0.6) - cancan (1.6.8) + cancan (1.6.10) + canonical-rails (0.1.0) + rails (>= 3.1, < 5.1) capybara (2.18.0) addressable mini_mime (>= 0.1.3) @@ -210,7 +147,7 @@ GEM xpath (>= 2.0, < 4.0) chronic (0.10.2) chunky_png (1.3.4) - climate_control (0.1.0) + climate_control (0.2.0) cliver (0.3.2) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) @@ -253,6 +190,10 @@ GEM fog (~> 1.0) rails (~> 3.0) debugger-linecache (1.2.0) + deface (1.0.0) + colorize (>= 0.5.8) + nokogiri (~> 1.6.0) + rails (>= 3.1) delayed_job (4.1.4) activesupport (>= 3.0, < 5.2) delayed_job_active_record (4.1.2) @@ -281,7 +222,7 @@ GEM railties (>= 3.0.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - ffaker (1.15.0) + ffaker (1.22.1) ffi (1.9.18) figaro (0.7.0) bundler (~> 1.0) @@ -432,12 +373,11 @@ GEM rspec (>= 2.99.0, < 4.0) haml (4.0.4) tilt - highline (1.6.15) + highline (1.6.21) hike (1.2.3) http_parser.rb (0.6.0) - httparty (0.9.0) - multi_json (~> 1.0) - multi_xml + httparty (0.16.2) + multi_xml (>= 0.5.2) i18n (0.6.11) i18n-js (3.0.0) i18n (~> 0.6, >= 0.6.6) @@ -448,18 +388,19 @@ GEM ipaddress (0.8.0) journey (1.0.4) jquery-migrate-rails (1.2.1) - jquery-rails (2.2.2) + jquery-rails (3.0.0) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) + jquery-ui-rails (4.0.5) + railties (>= 3.1.0) json (1.8.6) json_spec (1.1.5) multi_json (~> 1.0) rspec (>= 2.0, < 4.0) jwt (1.5.4) - kaminari (0.13.0) + kaminari (0.15.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - railties (>= 3.0.0) kgio (2.9.3) knapsack (1.16.0) rake @@ -481,8 +422,10 @@ GEM mini_portile2 (2.1.0) momentjs-rails (2.5.1) railties (>= 3.1) - money (5.1.0) - i18n (~> 0.6.0) + monetize (1.7.0) + money (~> 6.9) + money (6.11.0) + i18n (>= 0.6.4, < 1.1) multi_json (1.12.1) multi_xml (0.6.0) multipart-post (2.0.0) @@ -504,14 +447,17 @@ GEM paper_trail (3.0.8) activerecord (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0) - paperclip (3.5.4) + paperclip (3.4.2) activemodel (>= 3.0.0) + activerecord (>= 3.0.0) activesupport (>= 3.0.0) - cocaine (~> 0.5.3) + cocaine (~> 0.5.0) mime-types parallel (1.11.2) parallel_tests (2.14.1) parallel + paranoia (1.3.4) + activerecord (~> 3.1) parser (2.4.0.0) ast (~> 2.2) paypal-sdk-core (0.2.10) @@ -524,8 +470,8 @@ GEM capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - polyamorous (0.5.0) - activerecord (~> 3.0) + polyamorous (0.6.4) + activerecord (>= 3.0) polyglot (0.3.5) powerpack (0.1.1) pry (0.11.2) @@ -535,9 +481,8 @@ GEM byebug (>= 9.0, < 9.1) pry (~> 0.10) public_suffix (3.0.0) - rabl (0.7.2) + rabl (0.9.3) activesupport (>= 2.3.14) - multi_json (~> 1.0) rack (1.4.7) rack-cache (1.7.0) rack (>= 0.4) @@ -569,10 +514,10 @@ GEM rake raindrops (0.13.0) rake (10.5.0) - ransack (0.7.2) - actionpack (~> 3.0) - activerecord (~> 3.0) - polyamorous (~> 0.5.0) + ransack (1.1.0) + actionpack (>= 3.0) + activerecord (>= 3.0) + polyamorous (~> 0.6.0) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) @@ -635,7 +580,8 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - select2-rails (3.5.10) + select2-rails (3.4.9) + sass-rails thor (~> 0.14) shellany (0.0.1) shoulda-matchers (2.8.0) @@ -644,13 +590,62 @@ GEM activesupport (>= 3.0.0) spinjs-rails (1.3) rails (>= 3.1) + spree (2.0.13) + spree_api (= 2.0.13) + spree_backend (= 2.0.13) + spree_cmd (= 2.0.13) + spree_core (= 2.0.13) + spree_frontend (= 2.0.13) + spree_sample (= 2.0.13) + spree_api (2.0.13) + rabl (= 0.9.3) + spree_core (= 2.0.13) + versioncake (~> 1.2.0) + spree_backend (2.0.13) + jquery-rails (~> 3.0.0) + jquery-ui-rails (~> 4.0.0) + select2-rails (~> 3.4.7) + spree_api (= 2.0.13) + spree_core (= 2.0.13) + spree_cmd (2.0.13) + thor (~> 0.14) + spree_core (2.0.13) + activemerchant (~> 1.43.1) + acts_as_list (= 0.3.0) + awesome_nested_set (= 2.1.6) + aws-sdk (= 1.31.3) + cancan (~> 1.6.10) + deface (= 1.0.0) + ffaker (~> 1.22.0) + highline (~> 1.6.18) + httparty (~> 0.11) + json (~> 1.7) + kaminari (~> 0.15.0) + monetize + paperclip (~> 3.4.1) + paranoia (~> 1.3) + rails (~> 3.2.21) + ransack (~> 1.1.0) + state_machine (= 1.2.0) + stringex (~> 1.5.1) + truncate_html (= 0.9.2) + spree_frontend (2.0.13) + canonical-rails + deface (>= 0.9.0) + jquery-rails (~> 3.0.0) + rails (~> 3.2.13) + spree_api (= 2.0.13) + spree_core (= 2.0.13) + stringex (~> 1.5.1) + spree_sample (2.0.13) + spree_core (= 2.0.13) sprockets (2.2.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) state_machine (1.2.0) - stringex (1.3.3) + stringex (1.5.1) stripe (3.3.1) faraday (~> 0.9) therubyracer (0.12.0) @@ -679,10 +674,11 @@ GEM rack unicorn uuidtools (2.1.5) - versioncake (0.4.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) + versioncake (1.2.0) + actionpack (>= 3.2) + activesupport (>= 3.2) + railties (>= 3.2) + tzinfo warden (1.2.7) rack (>= 1.0) webmock (1.8.11) @@ -705,7 +701,7 @@ PLATFORMS DEPENDENCIES active_model_serializers - activemerchant (~> 1.71.0) + activemerchant acts-as-taggable-on (~> 3.4) andand angular-rails-templates (~> 0.2.0) @@ -727,7 +723,7 @@ DEPENDENCIES database_cleaner (= 0.7.1) db2fog debugger-linecache - deface! + deface (= 1.0.0) delayed_job_active_record diffy eventmachine (>= 1.2.3) @@ -749,7 +745,7 @@ DEPENDENCIES i18n-js (~> 3.0.0) immigrant jquery-migrate-rails - jquery-rails + jquery-rails (= 3.0.0) json_spec (~> 1.1.4) jwt (~> 1.5) knapsack @@ -762,7 +758,7 @@ DEPENDENCIES ofn-qz! oj paper_trail (~> 3.0.8) - paperclip + paperclip (~> 3.4.1) parallel_tests pg poltergeist (>= 1.16.0) @@ -785,7 +781,7 @@ DEPENDENCIES simple_form! skylight (< 2.0) spinjs-rails - spree! + spree (= 2.0.13) spree_auth_devise! spree_i18n! spree_paypal_express! diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 36bf72fd9c1..14f7e52371d 100644 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -37,7 +37,7 @@ def set_order_cycles # And default to the only order cycle if there's only the one if @order_cycles.count == 1 - current_order(true).set_order_cycle! @order_cycles.first + current_order(create_order_if_necessary: true).set_order_cycle! @order_cycles.first end end end diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 451e60ceb4b..e201f8177f8 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -50,14 +50,14 @@ def clean_permalink end def check_stock_levels - if current_order(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(true) + order = current_order(create_order_if_necessary: true) reset_distributor(order, distributor) diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index 4634536766e..fe410c1b6b3 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -27,7 +27,7 @@ def products def order_cycle if request.post? if oc = OrderCycle.with_distributor(@distributor).active.find_by_id(params[:order_cycle_id]) - current_order(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: "" diff --git a/app/controllers/spree/orders_controller_decorator.rb b/app/controllers/spree/orders_controller_decorator.rb index 47425bcbf2c..739aad3a7de 100644 --- a/app/controllers/spree/orders_controller_decorator.rb +++ b/app/controllers/spree/orders_controller_decorator.rb @@ -18,7 +18,7 @@ # Patching to redirect to shop if order is empty def edit - @order = current_order(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 @@ def populate # callbacks on Spree::Adjustment and then manually invoke Spree::Order#update! on success. Spree::Adjustment.without_callbacks do - populator = Spree::OrderPopulator.new(current_order(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 @@ def li_stock_levels(order) end def update_distribution - @order = current_order(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 @@ def remove_missing_line_items(attrs) end def clear - @order = current_order(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) diff --git a/app/helpers/enterprises_helper.rb b/app/helpers/enterprises_helper.rb index 8cef0281b19..549c86f5730 100644 --- a/app/helpers/enterprises_helper.rb +++ b/app/helpers/enterprises_helper.rb @@ -2,7 +2,7 @@ module EnterprisesHelper def current_distributor - @current_distributor ||= current_order(false).andand.distributor + @current_distributor ||= current_order(create_order_if_necessary: false).andand.distributor end def current_customer diff --git a/app/helpers/order_cycles_helper.rb b/app/helpers/order_cycles_helper.rb index 8afca2b9491..064582aba50 100644 --- a/app/helpers/order_cycles_helper.rb +++ b/app/helpers/order_cycles_helper.rb @@ -1,6 +1,6 @@ module OrderCyclesHelper def current_order_cycle - @current_order_cycle ||= current_order(false).andand.order_cycle + @current_order_cycle ||= current_order(create_order_if_necessary: false).andand.order_cycle end def permitted_enterprises_for(order_cycle) diff --git a/app/helpers/shared_helper.rb b/app/helpers/shared_helper.rb index a1e1f84ec25..bacf123814c 100644 --- a/app/helpers/shared_helper.rb +++ b/app/helpers/shared_helper.rb @@ -1,6 +1,6 @@ module SharedHelper def distributor_link_class(distributor) - cart = current_order(true) + cart = current_order(create_order_if_necessary: true) @active_distributors ||= Enterprise.distributors_with_active_order_cycles klass = "shop-distributor" diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index 99540f6ed45..a37f4091994 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -1,7 +1,7 @@ module Spree module OrdersHelper def cart_is_empty - order = current_order(false) + order = current_order(create_order_if_necessary: false) order.nil? || order.line_items.empty? end diff --git a/app/services/reset_order_service.rb b/app/services/reset_order_service.rb index 402c377eb74..95e73290c91 100644 --- a/app/services/reset_order_service.rb +++ b/app/services/reset_order_service.rb @@ -23,7 +23,7 @@ def call # Builds an order setting the token and distributor of the one specified def build_new_order - new_order = controller.current_order(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! diff --git a/app/views/spree/products/_add_to_cart.html.haml b/app/views/spree/products/_add_to_cart.html.haml index dd406ff50ba..dbc09929b70 100644 --- a/app/views/spree/products/_add_to_cart.html.haml +++ b/app/views/spree/products/_add_to_cart.html.haml @@ -1,5 +1,5 @@ .add-to-cart - - order = current_order(false) + - order = current_order(create_order_if_necessary: false) - if product_out_of_stock = content_tag('strong', t(:out_of_stock)) diff --git a/app/views/spree/products/_distributor_details.html.haml b/app/views/spree/products/_distributor_details.html.haml index e91c0ea6e57..1329a03f8a1 100644 --- a/app/views/spree/products/_distributor_details.html.haml +++ b/app/views/spree/products/_distributor_details.html.haml @@ -2,7 +2,7 @@ %legend = t :products_distributor .distributor-details - - order = current_order(false) + - order = current_order(create_order_if_necessary: false) - if order.andand.distributor.present? = render 'enterprises/distributor_details', :distributor => order.distributor - else diff --git a/app/views/spree/products/_source.html.haml b/app/views/spree/products/_source.html.haml index 7751ba36ef0..461a4dc6c97 100644 --- a/app/views/spree/products/_source.html.haml +++ b/app/views/spree/products/_source.html.haml @@ -10,7 +10,7 @@ %h6.product-section-title= t(:distributors) %table#product-source.table-display{:width => "100%"} %tbody - - order = current_order(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 diff --git a/config/initializers/spree.rb b/config/initializers/spree.rb index 9b62e3ad6e3..8495ec38241 100644 --- a/config/initializers/spree.rb +++ b/config/initializers/spree.rb @@ -27,14 +27,3 @@ # unless the empty module is explicity 'registered' here. Something to do with autoloading? module OpenFoodNetwork end - -# Forcing spree to always allow SSL connections -# Since we are using config.force_ssl = true -# Without this we get a redirect loop: see https://groups.google.com/forum/#!topic/spree-user/NwpqGxJ4klk -SslRequirement.module_eval do - protected - - def ssl_allowed? - true - end -end diff --git a/lib/spree/core/controller_helpers/order_decorator.rb b/lib/spree/core/controller_helpers/order_decorator.rb index dc38e861e64..d72fc7b22f3 100644 --- a/lib/spree/core/controller_helpers/order_decorator.rb +++ b/lib/spree/core/controller_helpers/order_decorator.rb @@ -1,6 +1,6 @@ Spree::Core::ControllerHelpers::Order.class_eval do - def current_order_with_scoped_variants(create_order_if_necessary = false) - order = current_order_without_scoped_variants(create_order_if_necessary) + def current_order_with_scoped_variants(options = {}) + order = current_order_without_scoped_variants(options) if order scoper = OpenFoodNetwork::ScopeVariantToHub.new(order.distributor) diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index b373ae64b5f..5335b1f3871 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -94,7 +94,7 @@ end it "sets the new order's token to the same as the old order" do - order = controller.current_order(true) + order = controller.current_order(create_order_if_necessary: true) spree_post :update, order: {} expect(controller.current_order.token).to eq order.token end diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index eedcb5ad160..bcd434302ec 100644 --- a/spec/controllers/enterprises_controller_spec.rb +++ b/spec/controllers/enterprises_controller_spec.rb @@ -2,7 +2,7 @@ describe EnterprisesController, type: :controller do describe "shopping for a distributor" do - let(:order) { controller.current_order(true) } + let(:order) { controller.current_order(create_order_if_necessary: true) } let!(:current_distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) } diff --git a/spec/controllers/spree/checkout_controller_spec.rb b/spec/controllers/spree/checkout_controller_spec.rb index b91c19f7444..37bd483d559 100644 --- a/spec/controllers/spree/checkout_controller_spec.rb +++ b/spec/controllers/spree/checkout_controller_spec.rb @@ -5,7 +5,7 @@ describe Spree::CheckoutController, type: :controller do context 'rendering edit from within spree for the current checkout state' do - let(:order) { controller.current_order(true) } + let(:order) { controller.current_order(create_order_if_necessary: true) } let(:user) { create(:user) } before do diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb index fbcd5ec1078..ce15c8cacca 100644 --- a/spec/controllers/spree/orders_controller_spec.rb +++ b/spec/controllers/spree/orders_controller_spec.rb @@ -30,7 +30,7 @@ it "redirects home with message if hub is not ready for checkout" do VariantOverride.stub(:indexed).and_return({}) - order = subject.current_order(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 @@ end describe "when an item has insufficient stock" do - let(:order) { subject.current_order(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 @@ distributor_product = create(:distributor_enterprise) p = create(:product, :distributors => [distributor_product], :group_buy => true) - order = subject.current_order(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 "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(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 @@ end it "filters line items that are missing from params" do - order = subject.current_order(true) + order = subject.current_order(create_order_if_necessary: true) li = order.add_variant(create(:simple_product).master) attrs = { diff --git a/spec/controllers/spree/paypal_controller_spec.rb b/spec/controllers/spree/paypal_controller_spec.rb index 90f97fcb7d7..4843eef98df 100644 --- a/spec/controllers/spree/paypal_controller_spec.rb +++ b/spec/controllers/spree/paypal_controller_spec.rb @@ -9,7 +9,7 @@ module Spree end context 'when confirming' do - let(:previous_order) { controller.current_order(true) } + let(:previous_order) { controller.current_order(create_order_if_necessary: true) } let(:payment_method) { create(:payment_method) } before do diff --git a/spec/performance/orders_controller_spec.rb b/spec/performance/orders_controller_spec.rb index e151e4f506f..ee856901217 100644 --- a/spec/performance/orders_controller_spec.rb +++ b/spec/performance/orders_controller_spec.rb @@ -4,7 +4,7 @@ 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(true) } + let(:order) { subject.current_order(create_order_if_necessary: true) } let(:num_products) { 20 } before do