From 068b72e41a343f4d168a4ae133ed56ba5ce320b8 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 21 Jan 2021 21:51:55 +0000 Subject: [PATCH 1/8] Update Gemfile_next.log by running bundle install --- Gemfile_next.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Gemfile_next.lock b/Gemfile_next.lock index 70dbeba73b..924af7c46a 100644 --- a/Gemfile_next.lock +++ b/Gemfile_next.lock @@ -100,8 +100,8 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) andand (1.3.3) - angular-rails-templates (1.1.0) - railties (>= 4.2, < 7) + angular-rails-templates (1.0.2) + railties (>= 4.2, < 6) sprockets (>= 3.0, < 5) tilt angular_rails_csrf (4.2.0) @@ -163,7 +163,7 @@ GEM sass (>= 3.2, < 3.5) compass-rails (2.0.1) compass (~> 1.0.0) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.8) crack (0.4.4) crass (1.0.6) css_parser (1.7.1) @@ -230,7 +230,7 @@ GEM tilt hashdiff (1.0.1) highline (2.0.3) - i18n (1.8.5) + i18n (1.8.7) concurrent-ruby (~> 1.0) i18n-js (3.8.0) i18n (>= 0.6.6) @@ -271,7 +271,7 @@ GEM letter_opener (1.7.0) launchy (~> 2.2) libv8 (7.3.492.27.1) - loofah (2.7.0) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -284,10 +284,10 @@ GEM mini_portile2 (2.4.0) mini_racer (0.2.15) libv8 (> 7.3) - minitest (5.14.2) - monetize (1.9.4) + minitest (5.14.3) + monetize (1.10.0) money (~> 6.12) - money (6.13.8) + money (6.14.0) i18n (>= 0.6.4, <= 2) msgpack (1.3.3) multi_json (1.15.0) @@ -319,11 +319,11 @@ GEM activerecord (>= 4.0, < 6.1) parser (2.7.2.0) ast (~> 2.4.1) - paypal-sdk-core (0.2.10) + paypal-sdk-core (0.3.4) multi_json (~> 1.0) xml-simple - paypal-sdk-merchant (1.106.1) - paypal-sdk-core (~> 0.2.3) + paypal-sdk-merchant (1.117.2) + paypal-sdk-core (~> 0.3.0) pg (0.21.0) polyamorous (2.3.0) activerecord (>= 5.0) @@ -374,7 +374,7 @@ GEM thor (>= 0.18.1, < 2.0) rainbow (3.0.0) raindrops (0.19.1) - rake (13.0.1) + rake (13.0.3) ransack (2.3.0) actionpack (>= 5.0) activerecord (>= 5.0) @@ -506,7 +506,7 @@ GEM thread_safe (0.3.6) tilt (2.0.10) timecop (0.9.2) - tzinfo (1.2.8) + tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) @@ -538,7 +538,7 @@ GEM wicked_pdf (2.1.0) activesupport wkhtmltopdf-binary (0.12.6.5) - xml-simple (1.1.5) + xml-simple (1.1.8) xpath (3.2.0) nokogiri (~> 1.8) @@ -608,14 +608,14 @@ DEPENDENCIES letter_opener (>= 1.4.1) libv8 (< 8) mini_racer (= 0.2.15) - monetize (~> 1.1) + monetize (~> 1.10) oauth2 (~> 1.4.4) ofn-qz! order_management! paper_trail (~> 10.3.1) paperclip (~> 3.4.1) paranoia (~> 2.4) - paypal-sdk-merchant (= 1.106.1) + paypal-sdk-merchant (= 1.117.2) pg (~> 0.21.0) pry pry-byebug From 08d5a82627978aac01334e6a025ed6391c322ea1 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 21 Jan 2021 21:52:45 +0000 Subject: [PATCH 2/8] Move some entries in Gemfile to general part, no need to keep these as rails 5 exceptions as a general rule works well --- Gemfile | 9 ++++----- Gemfile.lock | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index aaefa0a822..b985918078 100644 --- a/Gemfile +++ b/Gemfile @@ -19,9 +19,6 @@ if ENV['DEPENDENCIES_NEXT'] gem 'awesome_nested_set' gem 'ransack', '2.3.0' gem 'responders' - gem 'sass', '<= 4.7.1' - gem 'sass-rails', '< 6.0.0' - gem 'libv8', '< 8' else gem 'rails', '~> 4.2' @@ -30,8 +27,6 @@ else gem 'awesome_nested_set', '~> 3.3.1' gem 'ransack', '~> 1.8.10' gem 'responders', '~> 2.0' - gem 'sass' - gem 'sass-rails' gem 'db2fog' gem 'unicorn' @@ -120,12 +115,16 @@ gem 'test-unit', '~> 3.3' gem 'coffee-rails', '~> 4.2.2' gem 'compass-rails' +gem 'libv8', '< 8' gem 'mini_racer', '0.2.15' gem 'uglifier', '>= 1.0.3' gem 'angular_rails_csrf' gem 'foundation-icons-sass-rails' +gem 'sass', '<= 4.7.1' +gem 'sass-rails', '< 6.0.0' + gem 'foundation-rails', '= 5.5.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 7e09549d40..d3e83d10b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -785,6 +785,7 @@ DEPENDENCIES kaminari (~> 1.2.1) knapsack letter_opener (>= 1.4.1) + libv8 (< 8) mini_racer (= 0.2.15) monetize (~> 1.10) oauth2 (~> 1.4.4) @@ -813,8 +814,8 @@ DEPENDENCIES rswag rubocop rubocop-rails - sass - sass-rails + sass (<= 4.7.1) + sass-rails (< 6.0.0) select2-rails (~> 3.4.7) selenium-webdriver shoulda-matchers From c171441b6ce1df28c6a01bedc24dfcf7da270b26 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 21 Jan 2021 21:53:51 +0000 Subject: [PATCH 3/8] Add rails-controller-testing to rails 5 --- Gemfile | 1 + Gemfile_next.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index b985918078..a2d6b0fb86 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ if ENV['DEPENDENCIES_NEXT'] gem 'activemerchant', '>= 1.78.0' gem 'angular-rails-templates', '>= 0.3.0' gem 'awesome_nested_set' + gem 'rails-controller-testing' gem 'ransack', '2.3.0' gem 'responders' else diff --git a/Gemfile_next.lock b/Gemfile_next.lock index 924af7c46a..586685067b 100644 --- a/Gemfile_next.lock +++ b/Gemfile_next.lock @@ -357,6 +357,10 @@ GEM bundler (>= 1.3.0) railties (= 5.0.7.2) sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.5) + actionpack (>= 5.0.1.rc1) + actionview (>= 5.0.1.rc1) + activesupport (>= 5.0.1.rc1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -623,6 +627,7 @@ DEPENDENCIES rack-rewrite rack-ssl rails (> 5.0, < 5.1) + rails-controller-testing rails-i18n rails_safe_tasks (~> 1.0) ransack (= 2.3.0) From bb91d372703179fbd3d5c14bfc2ed88127f1d8fd Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 21 Jan 2021 21:54:59 +0000 Subject: [PATCH 4/8] Force angular-rails-templates to be below 1.1.0 --- Gemfile | 2 +- Gemfile_next.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a2d6b0fb86..7a789df658 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ if ENV['DEPENDENCIES_NEXT'] gem 'rails', '> 5.0', '< 5.1' gem 'activemerchant', '>= 1.78.0' - gem 'angular-rails-templates', '>= 0.3.0' + gem 'angular-rails-templates', '>= 0.3.0', '< 1.1.0' gem 'awesome_nested_set' gem 'rails-controller-testing' gem 'ransack', '2.3.0' diff --git a/Gemfile_next.lock b/Gemfile_next.lock index 586685067b..3f9065b3b1 100644 --- a/Gemfile_next.lock +++ b/Gemfile_next.lock @@ -559,7 +559,7 @@ DEPENDENCIES acts-as-taggable-on (~> 4.0) acts_as_list (= 0.9.19) andand - angular-rails-templates (>= 0.3.0) + angular-rails-templates (>= 0.3.0, < 1.1.0) angular_rails_csrf angularjs-file-upload-rails (~> 2.4.1) angularjs-rails (= 1.5.5) From 886888c2a88ad5006cf9793fa5b0e4d21e5c4225 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 21 Jan 2021 22:01:23 +0000 Subject: [PATCH 5/8] Workaround to get where_values to work in rails 5 --- app/services/permissions/order.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/permissions/order.rb b/app/services/permissions/order.rb index 0059088874..8dbbca41be 100644 --- a/app/services/permissions/order.rb +++ b/app/services/permissions/order.rb @@ -65,7 +65,7 @@ module Permissions def managed_orders_where_values Spree::Order. where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")). - where_values. + where_clause.__send__(:predicates). reduce(:and) end @@ -73,7 +73,7 @@ module Permissions def coordinated_orders_where_values Spree::Order. where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)). - where_values. + where_clause.__send__(:predicates). reduce(:and) end @@ -83,7 +83,7 @@ module Permissions distributor_id: granted_distributor_ids, spree_products: { supplier_id: enterprises_with_associated_orders } ). - where_values. + where_clause.__send__(:predicates). reduce(:and) end From eb56d1ff281bdf5c8d77c8449a6803570b6bdf9e Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Tue, 2 Feb 2021 23:00:21 +0000 Subject: [PATCH 6/8] Put the workaround inside a if clause on rails version so it works in both rails 4 and rails 5 --- app/services/permissions/order.rb | 32 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/app/services/permissions/order.rb b/app/services/permissions/order.rb index 8dbbca41be..94ec900e0c 100644 --- a/app/services/permissions/order.rb +++ b/app/services/permissions/order.rb @@ -63,28 +63,36 @@ module Permissions # Any orders placed through any hub that I manage def managed_orders_where_values - Spree::Order. - where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")). - where_clause.__send__(:predicates). - reduce(:and) + query = Spree::Order. + where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")) + + apply_where_clause(query).reduce(:and) end # Any order that is placed through an order cycle one of my managed enterprises coordinates def coordinated_orders_where_values - Spree::Order. - where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)). - where_clause.__send__(:predicates). - reduce(:and) + query = Spree::Order. + where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)) + + apply_where_clause(query).reduce(:and) end def produced_orders_where_values - Spree::Order.with_line_items_variants_and_products_outer. + query = Spree::Order.with_line_items_variants_and_products_outer. where( distributor_id: granted_distributor_ids, spree_products: { supplier_id: enterprises_with_associated_orders } - ). - where_clause.__send__(:predicates). - reduce(:and) + ) + + apply_where_clause(query).reduce(:and) + end + + def apply_where_clause(query) + if ENV['DEPENDENCIES_NEXT'] + query = query.where_clause.__send__(:predicates) + else + query = query.where_values + end end def enterprises_with_associated_orders From 54489948b903ec4829ed19c895daf4f7f94b5a30 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Tue, 2 Feb 2021 23:04:12 +0000 Subject: [PATCH 7/8] Remove useless assignment --- app/services/permissions/order.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/permissions/order.rb b/app/services/permissions/order.rb index 94ec900e0c..f71e46024f 100644 --- a/app/services/permissions/order.rb +++ b/app/services/permissions/order.rb @@ -89,9 +89,9 @@ module Permissions def apply_where_clause(query) if ENV['DEPENDENCIES_NEXT'] - query = query.where_clause.__send__(:predicates) + query.where_clause.__send__(:predicates) else - query = query.where_values + query.where_values end end From 0a1863aa2d9714eccf343c989b51da11050916e2 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Tue, 2 Feb 2021 23:05:11 +0000 Subject: [PATCH 8/8] Remove extra empty line --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7a789df658..c483fdf4cc 100644 --- a/Gemfile +++ b/Gemfile @@ -126,7 +126,6 @@ gem 'foundation-icons-sass-rails' gem 'sass', '<= 4.7.1' gem 'sass-rails', '< 6.0.0' - gem 'foundation-rails', '= 5.5.2.1' gem 'jquery-migrate-rails'