From 3d718d9738170d4c494379a26b2e77eb052cee87 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 6 Sep 2019 11:47:34 +0100 Subject: [PATCH 01/19] Move admin layout body contents to a separate partial --- app/views/spree/layouts/_admin_body.html.haml | 78 ++++++++++++++++++ app/views/spree/layouts/admin.html.haml | 79 +------------------ 2 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 app/views/spree/layouts/_admin_body.html.haml diff --git a/app/views/spree/layouts/_admin_body.html.haml b/app/views/spree/layouts/_admin_body.html.haml new file mode 100644 index 0000000000..a51fc57755 --- /dev/null +++ b/app/views/spree/layouts/_admin_body.html.haml @@ -0,0 +1,78 @@ += admin_inject_currency_config += render "layouts/i18n_script" + +#wrapper{"data-hook" => ""} + - if flash[:error] + .flash.error= flash[:error] + - if notice + .flash.notice= notice + - if flash[:success] + .flash.success= flash[:success] + + #progress + .wrapper + #spinner + .progress-message + = Spree.t(:loading) + \... + + = render :partial => 'spree/admin/shared/alert', :collection => session[:alerts] + + %header#header{"data-hook" => ""} + .container + %figure.columns.five{"data-hook" => "logo-wrapper"} + = link_to image_tag(Spree::Config[:admin_interface_logo], :id => 'logo'), spree.admin_path + %nav.columns.eleven{"data-hook" => "admin_login_navigation_bar"} + = render :partial => 'spree/layouts/admin/login_nav' + + %nav#admin-menu{"data-hook" => ""} + .container + .sixteen.columns.main-menu-wrapper + %ul.inline-menu.fullwidth-menu{"data-hook" => "admin_tabs"} + = render :partial => 'spree/admin/shared/tabs' + + - if content_for?(:sub_menu) + %nav#sub-menu{"data-hook" => ""} + .container + .sixteen.columns + = yield :sub_menu + + - if content_for?(:page_title) || content_for?(:page_actions) + #content-header{"data-hook" => ""} + .container + .sixteen.columns + .block-table + - if content_for?(:page_title) + .table-cell + %h1{:class => "page-title"}= yield :page_title + - if content_for?(:page_actions) + .page-actions.table-cell.toolbar{"data-hook" => "toolbar"} + %ul.inline-menu + = yield :page_actions + + .container + .row + - content_class = content_for?(:sidebar) ? "with-sidebar" : "" + #content{:class => content_class, "data-hook" => ""} + - if content_for?(:table_filter) + - table_filter_class = content_for?(:sidebar) ? 'twelve columns' : 'sixteen columns' + #table-filter{:class => table_filter_class, "data-hook" => ""} + %fieldset + %legend{:align => "center"}= yield :table_filter_title + = yield :table_filter + - div_class = content_for?(:sidebar) ? 'twelve columns' : 'sixteen columns' + %div{:class => div_class} + = yield + - if content_for?(:sidebar) + %aside#sidebar.four.columns{"data-hook" => ""} + - if content_for?(:sidebar_title) + %h5.sidebar-title + %span= yield :sidebar_title + = yield :sidebar + +%div{"data-hook" => "admin_footer_scripts"} + += render 'spree/shared/google_analytics' + +%script + = raw "Spree.api_key = \"#{try_spree_current_user.try(:spree_api_key).to_s}\";" diff --git a/app/views/spree/layouts/admin.html.haml b/app/views/spree/layouts/admin.html.haml index cdf4fbda02..df4c8c011a 100644 --- a/app/views/spree/layouts/admin.html.haml +++ b/app/views/spree/layouts/admin.html.haml @@ -4,81 +4,4 @@ = render :partial => 'spree/admin/shared/head' %body.admin - = admin_inject_currency_config - = render "layouts/i18n_script" - - #wrapper{"data-hook" => ""} - - if flash[:error] - .flash.error= flash[:error] - - if notice - .flash.notice= notice - - if flash[:success] - .flash.success= flash[:success] - - #progress - .wrapper - #spinner - .progress-message - = Spree.t(:loading) - \... - - = render :partial => 'spree/admin/shared/alert', :collection => session[:alerts] - - %header#header{"data-hook" => ""} - .container - %figure.columns.five{"data-hook" => "logo-wrapper"} - = link_to image_tag(Spree::Config[:admin_interface_logo], :id => 'logo'), spree.admin_path - %nav.columns.eleven{"data-hook" => "admin_login_navigation_bar"} - = render :partial => 'spree/layouts/admin/login_nav' - - %nav#admin-menu{"data-hook" => ""} - .container - .sixteen.columns.main-menu-wrapper - %ul.inline-menu.fullwidth-menu{"data-hook" => "admin_tabs"} - = render :partial => 'spree/admin/shared/tabs' - - - if content_for?(:sub_menu) - %nav#sub-menu{"data-hook" => ""} - .container - .sixteen.columns - = yield :sub_menu - - - if content_for?(:page_title) || content_for?(:page_actions) - #content-header{"data-hook" => ""} - .container - .sixteen.columns - .block-table - - if content_for?(:page_title) - .table-cell - %h1{:class => "page-title"}= yield :page_title - - if content_for?(:page_actions) - .page-actions.table-cell.toolbar{"data-hook" => "toolbar"} - %ul.inline-menu - = yield :page_actions - - .container - .row - - content_class = content_for?(:sidebar) ? "with-sidebar" : "" - #content{:class => content_class, "data-hook" => ""} - - if content_for?(:table_filter) - - table_filter_class = content_for?(:sidebar) ? 'twelve columns' : 'sixteen columns' - #table-filter{:class => table_filter_class, "data-hook" => ""} - %fieldset - %legend{:align => "center"}= yield :table_filter_title - = yield :table_filter - - div_class = content_for?(:sidebar) ? 'twelve columns' : 'sixteen columns' - %div{:class => div_class} - = yield - - if content_for?(:sidebar) - %aside#sidebar.four.columns{"data-hook" => ""} - - if content_for?(:sidebar_title) - %h5.sidebar-title - %span= yield :sidebar_title - = yield :sidebar - - %div{"data-hook" => "admin_footer_scripts"} - - = render 'spree/shared/google_analytics' - - %script - = raw "Spree.api_key = \"#{try_spree_current_user.try(:spree_api_key).to_s}\";" + = render :partial => 'spree/layouts/admin_body' From d038c27f1ffc5f3e03ddc4189616d691956fb582 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 19 Aug 2019 19:35:24 +0100 Subject: [PATCH 02/19] Fix app_wrapper_attr code by making the content_for tag be only the name of the ng-app and ng-ctrller --- app/views/admin/customers/index.html.haml | 4 ++-- app/views/admin/enterprises/edit.html.haml | 4 ++-- app/views/admin/enterprises/index.html.haml | 4 ++-- app/views/admin/enterprises/new.html.haml | 4 ++-- app/views/admin/order_cycles/index.html.haml | 4 ++-- app/views/admin/subscriptions/index.html.haml | 4 ++-- app/views/spree/admin/orders/bulk_management.html.haml | 4 ++-- .../spree/admin/orders/customer_details/edit.html.haml | 4 ++-- app/views/spree/admin/orders/index.html.haml | 7 +++++-- app/views/spree/layouts/admin.html.haml | 3 ++- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/views/admin/customers/index.html.haml b/app/views/admin/customers/index.html.haml index 6477357d63..477e609cde 100644 --- a/app/views/admin/customers/index.html.haml +++ b/app/views/admin/customers/index.html.haml @@ -2,8 +2,8 @@ %h1.page-title =t :customers -- content_for :app_wrapper_attrs do - = "ng-app='admin.customers'" +- content_for :main_ng_app_name do + = "admin.customers" - content_for :page_actions do %li diff --git a/app/views/admin/enterprises/edit.html.haml b/app/views/admin/enterprises/edit.html.haml index 61c26b5428..0e6a9162b8 100644 --- a/app/views/admin/enterprises/edit.html.haml +++ b/app/views/admin/enterprises/edit.html.haml @@ -4,8 +4,8 @@ = t('.editing') = @enterprise.name -- content_for :app_wrapper_attrs do - = "ng-app='admin.enterprises'" +- content_for :main_ng_app_name do + = "admin.enterprises" - content_for :page_actions do %li= select :enterprise, :id, options_for_select(editable_enterprises.collect {|e| [e.name, e.id, {:'data-url' => "#{main_app.edit_admin_enterprise_path(e.permalink)}", :'ng-selected' => "selected==#{e.id}"}]}, @enterprise.id ), {}, {:'enterprise-switcher' => '', 'data-initial' => "#{@enterprise.id}", :'ng-init' => "selected='#{@enterprise.id}'", :'ng-model' => 'selected', :id => 'enterprise_switcher', :class => 'select2'} diff --git a/app/views/admin/enterprises/index.html.haml b/app/views/admin/enterprises/index.html.haml index 8ced7bd769..499f8f9db6 100644 --- a/app/views/admin/enterprises/index.html.haml +++ b/app/views/admin/enterprises/index.html.haml @@ -1,8 +1,8 @@ - content_for :page_title do = t('.title') -- content_for :app_wrapper_attrs do - = "ng-app='admin.enterprises'" +- content_for :main_ng_app_name do + = "admin.enterprises" - content_for :page_actions do = render 'admin/shared/user_guide_link' diff --git a/app/views/admin/enterprises/new.html.haml b/app/views/admin/enterprises/new.html.haml index dd830054f5..ec54e17900 100644 --- a/app/views/admin/enterprises/new.html.haml +++ b/app/views/admin/enterprises/new.html.haml @@ -6,8 +6,8 @@ - content_for :page_actions do %li= button_link_to t('.back_link'), main_app.admin_enterprises_path, icon: 'icon-arrow-left' -- content_for :app_wrapper_attrs do - = "ng-app='admin.enterprises'" +- content_for :main_ng_app_name do + = "admin.enterprises" = admin_inject_available_countries(module: 'admin.enterprises') = admin_inject_json "admin.enterprises", "defaultCountryID", Spree::Config[:default_country_id] diff --git a/app/views/admin/order_cycles/index.html.haml b/app/views/admin/order_cycles/index.html.haml index 81cb437940..266d4c36d9 100644 --- a/app/views/admin/order_cycles/index.html.haml +++ b/app/views/admin/order_cycles/index.html.haml @@ -1,8 +1,8 @@ = content_for :page_title do = t :admin_order_cycles -- content_for :app_wrapper_attrs do - = "ng-app='admin.orderCycles'" +- content_for :main_ng_app_name do + = "admin.orderCycles" = content_for :page_actions do - if subscriptions_enabled? diff --git a/app/views/admin/subscriptions/index.html.haml b/app/views/admin/subscriptions/index.html.haml index 096e745627..4dd37c4f75 100644 --- a/app/views/admin/subscriptions/index.html.haml +++ b/app/views/admin/subscriptions/index.html.haml @@ -1,8 +1,8 @@ - content_for :page_title do = t('admin.subscriptions.subscriptions') -- content_for :app_wrapper_attrs do - = "ng-app='admin.subscriptions'" +- content_for :main_ng_app_name do + = "admin.subscriptions" - content_for :page_actions do %li diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index 1d2b5ed70d..1fc72e9a9b 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -1,5 +1,5 @@ -- content_for :app_wrapper_attrs do - = "ng-app='admin.lineItems'" +- content_for :main_ng_app_name do + = "admin.lineItems" - content_for :page_title do %h1.page-title diff --git a/app/views/spree/admin/orders/customer_details/edit.html.haml b/app/views/spree/admin/orders/customer_details/edit.html.haml index 36ecdb70a0..e4fa93ffbb 100644 --- a/app/views/spree/admin/orders/customer_details/edit.html.haml +++ b/app/views/spree/admin/orders/customer_details/edit.html.haml @@ -13,8 +13,8 @@ #select-customer{"data-hook" => ""} %fieldset.no-border-bottom %legend{:align => "center"}= Spree.t(:customer_search) - - content_for :app_wrapper_attrs do - = 'ng-app=admin.orders' + - content_for :main_ng_app_name do + = "admin.orders" = hidden_field_tag :customer_search_override, nil, distributor_id: @order.distributor_id, :class => 'fullwidth title customer-search-override' = render :partial => "spree/admin/orders/customer_details/autocomplete", :formats => :js diff --git a/app/views/spree/admin/orders/index.html.haml b/app/views/spree/admin/orders/index.html.haml index 3f1e087b6e..07c3acd836 100644 --- a/app/views/spree/admin/orders/index.html.haml +++ b/app/views/spree/admin/orders/index.html.haml @@ -7,8 +7,11 @@ = render partial: 'spree/admin/shared/order_sub_menu' -- content_for :app_wrapper_attrs do - = "ng-app='admin.orders' ng-controller='ordersCtrl'" +- content_for :main_ng_app_name do + = "admin.orders" + +- content_for :main_ng_ctrl_name do + = "ordersCtrl" - content_for :table_filter_title do = t(:search) diff --git a/app/views/spree/layouts/admin.html.haml b/app/views/spree/layouts/admin.html.haml index df4c8c011a..fdfb6c0932 100644 --- a/app/views/spree/layouts/admin.html.haml +++ b/app/views/spree/layouts/admin.html.haml @@ -4,4 +4,5 @@ = render :partial => 'spree/admin/shared/head' %body.admin - = render :partial => 'spree/layouts/admin_body' + %div{ "ng-app" => yield(:main_ng_app_name).strip.html_safe, "ng-controller" => yield(:main_ng_ctrl_name).strip.html_safe } + = render :partial => 'spree/layouts/admin_body' From 33472014f173f6d77b202e9e40b0ee31535a9c8b Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 6 Sep 2019 12:23:18 +0100 Subject: [PATCH 03/19] Do not add main_ng_app_name if it is not defined --- app/views/spree/layouts/admin.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/spree/layouts/admin.html.haml b/app/views/spree/layouts/admin.html.haml index fdfb6c0932..2457053ae0 100644 --- a/app/views/spree/layouts/admin.html.haml +++ b/app/views/spree/layouts/admin.html.haml @@ -4,5 +4,8 @@ = render :partial => 'spree/admin/shared/head' %body.admin - %div{ "ng-app" => yield(:main_ng_app_name).strip.html_safe, "ng-controller" => yield(:main_ng_ctrl_name).strip.html_safe } + - if content_for?(:main_ng_app_name) + %div{ "ng-app" => yield(:main_ng_app_name).strip.html_safe, "ng-controller" => yield(:main_ng_ctrl_name).strip.html_safe } + = render :partial => 'spree/layouts/admin_body' + - else = render :partial => 'spree/layouts/admin_body' From 0c809b2911b79bf17466517c8560dc9803ffe5ca Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 6 Sep 2019 12:25:42 +0100 Subject: [PATCH 04/19] Remove now unused override app_wrapper --- .../spree/layouts/admin/add_app_wrapper.html.erb.deface | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 app/overrides/spree/layouts/admin/add_app_wrapper.html.erb.deface diff --git a/app/overrides/spree/layouts/admin/add_app_wrapper.html.erb.deface b/app/overrides/spree/layouts/admin/add_app_wrapper.html.erb.deface deleted file mode 100644 index 9c5e6fcd80..0000000000 --- a/app/overrides/spree/layouts/admin/add_app_wrapper.html.erb.deface +++ /dev/null @@ -1,5 +0,0 @@ - - -
> - <%= render_original %> -
From 377b4a3755e54362bb3fad4f2e9776efc0f0defd Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 6 Sep 2019 12:47:54 +0100 Subject: [PATCH 05/19] Do not add ng-controller if main_ng_ctrl_name is not set --- app/views/spree/layouts/admin.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/spree/layouts/admin.html.haml b/app/views/spree/layouts/admin.html.haml index 2457053ae0..530b83bdb5 100644 --- a/app/views/spree/layouts/admin.html.haml +++ b/app/views/spree/layouts/admin.html.haml @@ -5,7 +5,11 @@ %body.admin - if content_for?(:main_ng_app_name) - %div{ "ng-app" => yield(:main_ng_app_name).strip.html_safe, "ng-controller" => yield(:main_ng_ctrl_name).strip.html_safe } - = render :partial => 'spree/layouts/admin_body' + - if content_for?(:main_ng_ctrl_name) + %div{ "ng-app" => yield(:main_ng_app_name).strip.html_safe, "ng-controller" => yield(:main_ng_ctrl_name).strip.html_safe } + = render :partial => 'spree/layouts/admin_body' + - else + %div{ "ng-app" => yield(:main_ng_app_name).strip.html_safe } + = render :partial => 'spree/layouts/admin_body' - else = render :partial => 'spree/layouts/admin_body' From 07e0951490a480204add4e05c7b98f82c79f9845 Mon Sep 17 00:00:00 2001 From: JASON KNOEPFLER Date: Fri, 20 Sep 2019 10:35:25 -0700 Subject: [PATCH 06/19] Change users#update email change flash alert --- app/controllers/spree/admin/users_controller.rb | 6 +++++- config/locales/en.yml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/spree/admin/users_controller.rb b/app/controllers/spree/admin/users_controller.rb index 17ab1d041d..b2c91611df 100644 --- a/app/controllers/spree/admin/users_controller.rb +++ b/app/controllers/spree/admin/users_controller.rb @@ -46,7 +46,11 @@ module Spree @user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) } end - flash.now[:success] = Spree.t(:account_updated) + if params[:user][:email] != @user.email + flash.now[:success] = Spree.t(:email_updated) + else + flash.now[:success] = Spree.t(:account_updated) + end end render :edit end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9348cd9138..b595cb9da0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2943,6 +2943,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using email: Email # TODO: remove 'account_updated' key once we get to Spree 2.0 account_updated: "Account updated!" + email_updated: "The account will be updated once the new email is confirmed." my_account: "My account" date: "Date" time: "Time" From 62599e8dfc5bf238b4b09ba05adbe231548e921a Mon Sep 17 00:00:00 2001 From: JASON KNOEPFLER Date: Fri, 20 Sep 2019 15:28:25 -0700 Subject: [PATCH 07/19] Edit user email feature spec --- spec/features/admin/users_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index d58ba686a6..4ab504c5a4 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -64,6 +64,13 @@ feature "Managing users" do expect(page).to have_content("Account updated") end + + it "should let me edit the user email" do + fill_in "Email", with: "newemail@example.org" + click_button "Update" + + expect(page).to have_content("The account will be updated once the new email is confirmed.") + end end end From 88893a2968f39b78cf2768b6ba87cee2d55429ba Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Sat, 21 Sep 2019 14:09:27 +0200 Subject: [PATCH 08/19] Enable trace & search analytics in Datadog This will enrich the quality of the reported traces for all web frameworks in our stack. That means not only memcached as we did in https://github.com/openfoodfoundation/openfoodnetwork/pull/4266 but PostgreSQL and Rails too. After enabling, the Trace Search & Analytics page populates which allows us to search traces and add APM queries to dashboards. --- config/initializers/datadog.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/datadog.rb b/config/initializers/datadog.rb index 4029ebb6d0..8494343f93 100644 --- a/config/initializers/datadog.rb +++ b/config/initializers/datadog.rb @@ -2,5 +2,6 @@ if ENV['DATADOG_RAILS_APM'] Datadog.configure do |c| c.use :rails, service_name: 'rails' c.use :delayed_job, service_name: 'delayed_job' + c.analytics_enabled = true end end From 4ec8fcd3a6e2677315e0dd97a61e2d7aff5eb66f Mon Sep 17 00:00:00 2001 From: JASON KNOEPFLER Date: Sat, 21 Sep 2019 08:10:58 -0700 Subject: [PATCH 09/19] Assign flash message var from conditional return --- app/controllers/spree/admin/users_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/spree/admin/users_controller.rb b/app/controllers/spree/admin/users_controller.rb index b2c91611df..b2fe682cb7 100644 --- a/app/controllers/spree/admin/users_controller.rb +++ b/app/controllers/spree/admin/users_controller.rb @@ -46,11 +46,12 @@ module Spree @user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) } end - if params[:user][:email] != @user.email - flash.now[:success] = Spree.t(:email_updated) - else - flash.now[:success] = Spree.t(:account_updated) - end + message = if params[:user][:email] != @user.email + Spree.t(:email_updated) + else + Spree.t(:account_updated) + end + flash.now[:success] = message end render :edit end From c66e5fe1e97917c69621a2e439dafc42333d0c01 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 22 Sep 2019 14:59:59 +0100 Subject: [PATCH 10/19] Make subscription line items handle soft deleted variants This ensures subscription list page works. The variant can be removed from the subscription by the user in the edit subscription page --- app/models/subscription_line_item.rb | 5 ++++ .../subscription_line_item_serializer_spec.rb | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 spec/serializers/api/admin/subscription_line_item_serializer_spec.rb diff --git a/app/models/subscription_line_item.rb b/app/models/subscription_line_item.rb index 38f2694be0..d7d96fedc5 100644 --- a/app/models/subscription_line_item.rb +++ b/app/models/subscription_line_item.rb @@ -10,6 +10,11 @@ class SubscriptionLineItem < ActiveRecord::Base (price_estimate || 0) * (quantity || 0) end + # Ensure SubscriptionLineItem always has access to soft-deleted Variant attribute + def variant + Spree::Variant.unscoped { super } + end + # Used to calculators to estimate fees alias_method :amount, :total_estimate diff --git a/spec/serializers/api/admin/subscription_line_item_serializer_spec.rb b/spec/serializers/api/admin/subscription_line_item_serializer_spec.rb new file mode 100644 index 0000000000..5542c5d482 --- /dev/null +++ b/spec/serializers/api/admin/subscription_line_item_serializer_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +module Api + module Admin + describe SubscriptionLineItemSerializer do + let(:subscription_line_item) { create(:subscription_line_item) } + + it "serializes a subscription line item with the product name" do + serializer = described_class.new(subscription_line_item) + + expect(serializer.to_json).to match subscription_line_item.variant.product.name + end + + context "when the variant of the subscription line item is soft deleted" do + it "serializers the subscription line item with the product name" do + subscription_line_item.variant.update_attribute :deleted_at, Time.zone.now + + serializer = described_class.new(subscription_line_item.reload) + + expect(serializer.to_json).to match subscription_line_item.variant.product.name + end + end + end + end +end From cd6d34663eb5448dc9224b8dc515e31db0348706 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 22 Sep 2019 15:25:24 +0100 Subject: [PATCH 11/19] Remove all usages of Spree Config track_inventory_levels, this is always true in OFN since v2.0.0 --- app/models/concerns/variant_stock.rb | 15 ++------- app/models/spree/shipment_decorator.rb | 2 +- .../spree/admin/products/_form.html.haml | 21 ++++++------- .../spree/admin/variants/_form.html.haml | 23 +++++++------- spec/models/concerns/variant_stock_spec.rb | 31 ++++--------------- 5 files changed, 30 insertions(+), 62 deletions(-) diff --git a/app/models/concerns/variant_stock.rb b/app/models/concerns/variant_stock.rb index 8eac3eb32e..7089674630 100644 --- a/app/models/concerns/variant_stock.rb +++ b/app/models/concerns/variant_stock.rb @@ -31,27 +31,18 @@ module VariantStock end # Sets the stock level of the variant. - # This will only work if `track_inventory_levels` config is set - # and if there is a stock item for the variant. + # This will only work if there is a stock item for the variant. # - # @raise [StandardError] when the track_inventory_levels config key is not set - # and when the variant has no stock item + # @raise [StandardError] when the variant has no stock item def on_hand=(new_level) warn_deprecation(__method__, '#total_on_hand') - error = 'Cannot set on_hand value when Spree::Config[:track_inventory_levels] is false' - raise error unless Spree::Config.track_inventory_levels - raise_error_if_no_stock_item_available overwrite_stock_levels(new_level) end # Checks whether this variant is produced on demand. - # - # In Spree 2.0 this attribute is removed in favour of - # track_inventory_levels only. It was initially introduced in - # https://github.com/openfoodfoundation/spree/commit/20b5ad9835dca7f41a40ad16c7b45f987eea6dcc def on_demand warn_deprecation(__method__, 'StockItem#backorderable?') @@ -89,8 +80,6 @@ module VariantStock # Here we depend only on variant.total_on_hand and variant.on_demand. # This way, variant_overrides only need to override variant.total_on_hand and variant.on_demand. def can_supply?(quantity) - return true unless Spree::Config[:track_inventory_levels] - on_demand || total_on_hand >= quantity end diff --git a/app/models/spree/shipment_decorator.rb b/app/models/spree/shipment_decorator.rb index 735fdb64cd..be80102e5a 100644 --- a/app/models/spree/shipment_decorator.rb +++ b/app/models/spree/shipment_decorator.rb @@ -32,7 +32,7 @@ module Spree # NOTE: This is an override of spree's method, needed to allow orders # without line items (ie. user invoices) to not have inventory units def require_inventory - return false unless Spree::Config[:track_inventory_levels] && line_items.count > 0 # This line altered + return false unless line_items.count > 0 # This line altered order.completed? && !order.canceled? end end diff --git a/app/views/spree/admin/products/_form.html.haml b/app/views/spree/admin/products/_form.html.haml index 0104afceba..cbc7718325 100644 --- a/app/views/spree/admin/products/_form.html.haml +++ b/app/views/spree/admin/products/_form.html.haml @@ -53,18 +53,17 @@ = f.label :sku, t(:sku) = f.text_field :sku, :size => 16 - - if Spree::Config[:track_inventory_levels] - .alpha.two.columns - = f.field_container :on_hand do - = f.label :on_hand, t(:on_hand) - = f.number_field :on_hand, :min => 0 - .omega.two.columns - = f.field_container :on_demand, :class => ['checkbox'] do - %label - = f.check_box :on_demand - = t(:on_demand) + .alpha.two.columns + = f.field_container :on_hand do + = f.label :on_hand, t(:on_hand) + = f.number_field :on_hand, :min => 0 + .omega.two.columns + = f.field_container :on_demand, :class => ['checkbox'] do + %label + = f.check_box :on_demand + = t(:on_demand) - .clear + .clear %ul#shipping_specs %li#shipping_specs_weight_field.field.alpha.two.columns diff --git a/app/views/spree/admin/variants/_form.html.haml b/app/views/spree/admin/variants/_form.html.haml index 00c4b01bfe..acc9c56314 100644 --- a/app/views/spree/admin/variants/_form.html.haml +++ b/app/views/spree/admin/variants/_form.html.haml @@ -38,18 +38,17 @@ = f.label :cost_price, Spree.t(:cost_price) = f.text_field :cost_price, value: number_to_currency(@variant.cost_price, unit: ''), class: 'fullwidth' - - if Spree::Config[:track_inventory_levels] - %div{ 'set-on-demand' => '' } - .field.checkbox - %label - = f.check_box :on_demand - = t(:on_demand) - %div{'ofn-with-tip' => t('admin.products.variants.to_order_tip')} - %a= t('admin.whats_this') - .field - = f.label :on_hand, t(:on_hand) - .fullwidth - = f.text_field :on_hand + %div{ 'set-on-demand' => '' } + .field.checkbox + %label + = f.check_box :on_demand + = t(:on_demand) + %div{'ofn-with-tip' => t('admin.products.variants.to_order_tip')} + %a= t('admin.whats_this') + .field + = f.label :on_hand, t(:on_hand) + .fullwidth + = f.text_field :on_hand .right.six.columns.omega.label-block - if @product.variant_unit != 'weight' diff --git a/spec/models/concerns/variant_stock_spec.rb b/spec/models/concerns/variant_stock_spec.rb index 489737ec18..e417e3a203 100644 --- a/spec/models/concerns/variant_stock_spec.rb +++ b/spec/models/concerns/variant_stock_spec.rb @@ -45,33 +45,14 @@ describe VariantStock do end describe '#on_hand=' do - context 'when track_inventory_levels is set' do - before do - allow(Spree::Config) - .to receive(:track_inventory_levels) { true } - end - - it 'sets the new level as the stock item\'s count_on_hand' do - variant.on_hand = 3 - unique_stock_item = variant.stock_items.first - expect(unique_stock_item.count_on_hand).to eq(3) - end - - context 'when the variant has no stock item' do - let(:variant) { build(:variant) } - - it 'raises' do - expect { variant.on_hand = 3 } - .to raise_error(StandardError) - end - end + it 'sets the new level as the stock item\'s count_on_hand' do + variant.on_hand = 3 + unique_stock_item = variant.stock_items.first + expect(unique_stock_item.count_on_hand).to eq(3) end - context 'when track_inventory_levels is not set' do - before do - allow(Spree::Config) - .to receive(:track_inventory_levels) { false } - end + context 'when the variant has no stock item' do + let(:variant) { build(:variant) } it 'raises' do expect { variant.on_hand = 3 } From efd450606e202e10d6f74b77157bb74cfdb197ac Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 24 Sep 2019 19:16:05 +1000 Subject: [PATCH 12/19] Replace deprecated validates_presence_of This syntax has been deprecated in Rails 3: https://guides.rubyonrails.org/3_0_release_notes.html#patches-and-deprecations --- app/services/subscription_validator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/subscription_validator.rb b/app/services/subscription_validator.rb index 051033dd9f..1ca035dfc7 100644 --- a/app/services/subscription_validator.rb +++ b/app/services/subscription_validator.rb @@ -9,8 +9,8 @@ class SubscriptionValidator attr_reader :subscription - validates_presence_of :shop, :customer, :schedule, :shipping_method, :payment_method - validates_presence_of :bill_address, :ship_address, :begins_at + validates :shop, :customer, :schedule, :shipping_method, :payment_method, presence: true + validates :bill_address, :ship_address, :begins_at, presence: true validate :shipping_method_allowed? validate :payment_method_allowed? validate :payment_method_type_allowed? From e8f9ace8e6a2b9946380805721d62f786cf43dfe Mon Sep 17 00:00:00 2001 From: Dan Ingenthron Date: Mon, 23 Sep 2019 00:56:33 -0500 Subject: [PATCH 13/19] Correct translation key on add card link --- app/views/spree/users/_cards.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/users/_cards.html.haml b/app/views/spree/users/_cards.html.haml index 6f7d13a06a..103bff8578 100644 --- a/app/views/spree/users/_cards.html.haml +++ b/app/views/spree/users/_cards.html.haml @@ -16,7 +16,7 @@ .small-12.medium-6.columns .new_card{ ng: { show: 'CreditCard.visible', class: '{visible: CreditCard.visible}' } } - %h3= t(:add_a_new_card) + %h3= t(:add_new_credit_card) = render 'new_card_form' .authorised_shops{ ng: { controller: 'AuthorisedShopsCtrl', hide: 'CreditCard.visible' } } %h3 From c46fe7b675dfb20a6c6a681b47179d9c5d467e3d Mon Sep 17 00:00:00 2001 From: JASON KNOEPFLER Date: Wed, 25 Sep 2019 19:41:33 -0700 Subject: [PATCH 14/19] encapsulate new unconfirmed email logic --- app/controllers/spree/admin/users_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/spree/admin/users_controller.rb b/app/controllers/spree/admin/users_controller.rb index b2fe682cb7..d941785f01 100644 --- a/app/controllers/spree/admin/users_controller.rb +++ b/app/controllers/spree/admin/users_controller.rb @@ -46,7 +46,7 @@ module Spree @user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) } end - message = if params[:user][:email] != @user.email + message = if new_email_unconfirmed? Spree.t(:email_updated) else Spree.t(:account_updated) @@ -131,6 +131,10 @@ module Spree def load_roles @roles = Spree::Role.scoped end + + def new_email_unconfirmed? + params[:user][:email] != @user.email + end end end end From d0c77a8dc42772510c4565103330eb1b56d1c34d Mon Sep 17 00:00:00 2001 From: Rachel Arnould <6525576+RachL@users.noreply.github.com> Date: Thu, 26 Sep 2019 21:20:50 +0200 Subject: [PATCH 15/19] Update bug template --- .github/ISSUE_TEMPLATE/bug_report.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 76ce58fccf..334d6f2317 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,6 +9,7 @@ assignees: '' ## Description + ## Expected Behavior @@ -22,6 +23,8 @@ assignees: '' ## Steps to Reproduce + + 1. 2. @@ -29,13 +32,8 @@ assignees: '' 4. ## Animated Gif/Screenshot - - - -## Context - - + + ## Severity From d604328bfb9d5674bcc3894e522bf2fce261fb47 Mon Sep 17 00:00:00 2001 From: Rachel Arnould <6525576+RachL@users.noreply.github.com> Date: Thu, 26 Sep 2019 21:25:01 +0200 Subject: [PATCH 16/19] Update story template --- .github/ISSUE_TEMPLATE/story-template.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/story-template.md b/.github/ISSUE_TEMPLATE/story-template.md index f3bfa62f54..d3c25f0e53 100644 --- a/.github/ISSUE_TEMPLATE/story-template.md +++ b/.github/ISSUE_TEMPLATE/story-template.md @@ -14,5 +14,12 @@ assignees: '' **- I want to be able to do:** (specify the desired behavior) (Link to others issues or resources to provide context > only if really necessary). --> -## Acceptance Criteria - +## Acceptance Criteria & Tests + + + +1. +2. +3. +4. From 375d4fbffd11db7f91fd973c059d89698423dc1e Mon Sep 17 00:00:00 2001 From: Rachel Arnould <6525576+RachL@users.noreply.github.com> Date: Mon, 30 Sep 2019 11:02:36 +0200 Subject: [PATCH 17/19] Add workaround item --- .github/ISSUE_TEMPLATE/bug_report.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 334d6f2317..0b39580760 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -35,6 +35,9 @@ assignees: '' +## Workaround + + ## Severity