From 73fc19be1cab53bd2f356bee37b42543230ad28b Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Mon, 24 Dec 2018 07:52:46 +0100 Subject: [PATCH 1/4] Lock FactoryBot to v4.10 for Solidus versions lower than v2.5 --- Gemfile | 6 ++++++ solidus_product_assembly.gemspec | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d0de8c7..3253087 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,12 @@ else gem "rails", "~> 4.2.7" end +if branch < 'v2.5' + gem 'factory_bot', '4.10.0' +else + gem 'factory_bot', '> 4.10.0' +end + gem 'pg', '~> 0.21' gem 'mysql2', '~> 0.4.10' diff --git a/solidus_product_assembly.gemspec b/solidus_product_assembly.gemspec index aa1e20f..dbafa83 100644 --- a/solidus_product_assembly.gemspec +++ b/solidus_product_assembly.gemspec @@ -27,7 +27,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'rspec-rails', '~> 3.4' s.add_development_dependency 'sqlite3' s.add_development_dependency 'ffaker' - s.add_development_dependency 'factory_bot', '~> 4.4' s.add_development_dependency 'capybara', '~> 2.7' s.add_development_dependency 'poltergeist', '~> 1.9' s.add_development_dependency 'database_cleaner', '~> 1.3' From 06056037fd0b1b3ae279d9740e2ba7acc990b105 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Mon, 24 Dec 2018 09:44:53 +0100 Subject: [PATCH 2/4] Replace Spree.t -> I18n.t to fix deprecation warnings --- app/models/spree/product_decorator.rb | 2 +- .../spree/stock/availability_validator.rb | 4 ++-- .../stock/inventory_validator_decorator.rb | 4 ++-- .../spree/admin/orders/_assemblies.html.erb | 10 ++++----- .../admin/orders/_stock_contents.html.erb | 22 +++++++++---------- .../spree/admin/orders/_stock_item.html.erb | 12 +++++----- .../spree/admin/parts/_parts_table.html.erb | 14 ++++++------ .../spree/admin/parts/available.html.erb | 14 ++++++------ app/views/spree/admin/parts/available.js.erb | 14 ++++++------ app/views/spree/admin/parts/index.html.erb | 2 +- .../_product_assembly_fields.html.erb | 4 ++-- .../_product_assembly_product_tabs.html.erb | 2 +- 12 files changed, 52 insertions(+), 52 deletions(-) diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 7e5f86e..5cad9d4 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -46,7 +46,7 @@ def count_of(variant) end def assembly_cannot_be_part - errors.add(:can_be_part, Spree.t(:assembly_cannot_be_part)) if can_be_part + errors.add(:can_be_part, I18n.t('spree.assembly_cannot_be_part')) if can_be_part end private diff --git a/app/models/spree/stock/availability_validator.rb b/app/models/spree/stock/availability_validator.rb index b0188f8..108e95f 100644 --- a/app/models/spree/stock/availability_validator.rb +++ b/app/models/spree/stock/availability_validator.rb @@ -16,8 +16,8 @@ def validate(line_item) display_name = %Q{#{variant.name}} display_name += %Q{ (#{variant.options_text})} unless variant.options_text.blank? - line_item.errors[:quantity] << Spree.t( - :selected_quantity_not_available, + line_item.errors[:quantity] << I18n.t( + 'spree.selected_quantity_not_available', item: display_name.inspect ) end diff --git a/app/models/spree/stock/inventory_validator_decorator.rb b/app/models/spree/stock/inventory_validator_decorator.rb index 42ee0d4..f788e9e 100644 --- a/app/models/spree/stock/inventory_validator_decorator.rb +++ b/app/models/spree/stock/inventory_validator_decorator.rb @@ -3,8 +3,8 @@ def validate(line_item) total_quantity = line_item.quantity_by_variant.values.sum if line_item.inventory_units.count != total_quantity - line_item.errors[:inventory] << Spree.t( - :inventory_not_available, + line_item.errors[:inventory] << I18n.t( + 'spree.inventory_not_available', item: line_item.variant.name ) end diff --git a/app/views/spree/admin/orders/_assemblies.html.erb b/app/views/spree/admin/orders/_assemblies.html.erb index d9b1e4b..bf373dd 100644 --- a/app/views/spree/admin/orders/_assemblies.html.erb +++ b/app/views/spree/admin/orders/_assemblies.html.erb @@ -1,7 +1,7 @@ <% if order.line_items.assemblies.any? %>
- <%= Spree.t(:product_bundles) %> + <%= I18n.t('spree.product_bundles') %>
@@ -43,10 +43,10 @@ <%= line_item_shipment_price(item, item.quantity) %> <% if can? :update, item %> - <%= link_to '', '#', :class => 'save-line-item fa fa-ok no-text with-tip', :title => Spree.t('actions.save') %> - <%= link_to '', '#', :class => 'cancel-line-item fa fa-cancel no-text with-tip', :title => Spree.t('actions.cancel') %> - <%= link_to '', '#', :class => 'edit-line-item fa fa-edit no-text with-tip', :title => Spree.t('actions.edit') %> - <%= link_to '', '#', :class => 'delete-line-item fa fa-trash no-text with-tip', :title => Spree.t('actions.delete') %> + <%= link_to '', '#', :class => 'save-line-item fa fa-ok no-text with-tip', :title => I18n.t('spree.actions.save') %> + <%= link_to '', '#', :class => 'cancel-line-item fa fa-cancel no-text with-tip', :title => I18n.t('spree.actions.cancel') %> + <%= link_to '', '#', :class => 'edit-line-item fa fa-edit no-text with-tip', :title => I18n.t('spree.actions.edit') %> + <%= link_to '', '#', :class => 'delete-line-item fa fa-trash no-text with-tip', :title => I18n.t('spree.actions.delete') %> <% end %> <% end %> diff --git a/app/views/spree/admin/orders/_stock_contents.html.erb b/app/views/spree/admin/orders/_stock_contents.html.erb index be15ace..15e58ca 100644 --- a/app/views/spree/admin/orders/_stock_contents.html.erb +++ b/app/views/spree/admin/orders/_stock_contents.html.erb @@ -4,7 +4,7 @@
- <%= label_tag 'selected_shipping_rate_id', Spree.t(:shipping_method) %> + <%= label_tag 'selected_shipping_rate_id', I18n.t('spree.shipping_method') %> <%= select_tag :selected_shipping_rate_id, options_for_select(shipment.shipping_rates.map {|sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id), {:class => 'select2 fullwidth', :data => {'shipment-number' => shipment.number } } %> @@ -13,9 +13,9 @@ <% if can? :update, shipment %> <%= link_to '', '#', :class => 'save-method fa fa-ok no-text with-tip', - :data => {'shipment-number' => shipment.number, :action => 'save'}, title: Spree.t('actions.save') %> + :data => {'shipment-number' => shipment.number, :action => 'save'}, title: I18n.t('spree.actions.save') %> <%= link_to '', '#', :class => 'cancel-method fa fa-cancel no-text with-tip', - :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel') %> + :data => {:action => 'cancel'}, :title => I18n.t('spree.actions.cancel') %> <% end %> @@ -30,25 +30,25 @@ <%= shipment.display_cost %> <% else %> - <%= Spree.t(:no_shipping_method_selected) %> + <%= I18n.t('spree.no_shipping_method_selected') %> <% end %> <% if can? :update, shipment %> - <%= link_to '', '#', :class => 'edit-method fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> + <%= link_to '', '#', :class => 'edit-method fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => I18n.t('spree.actions.edit') %> <% end %> - + <%= text_field_tag :tracking, shipment.tracking %> <% if can? :update, shipment %> - <%= link_to '', '#', :class => 'save-tracking fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, :action => 'save'}, :title => Spree.t('actions.save') %> - <%= link_to '', '#', :class => 'cancel-tracking fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel') %> + <%= link_to '', '#', :class => 'save-tracking fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, :action => 'save'}, :title => I18n.t('spree.actions.save') %> + <%= link_to '', '#', :class => 'cancel-tracking fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => I18n.t('spree.actions.cancel') %> <% end %> @@ -56,14 +56,14 @@ <% if shipment.tracking.present? %> - <%= Spree.t(:tracking) %>: <%= shipment.tracking %> + <%= I18n.t('spree.tracking') %>: <%= shipment.tracking %> <% else %> - <%= Spree.t(:no_tracking_present) %> + <%= I18n.t('spree.no_tracking_present') %> <% end %> <% if can? :update, shipment %> - <%= link_to '', '#', :class => 'edit-tracking fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> + <%= link_to '', '#', :class => 'edit-tracking fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => I18n.t('spree.actions.edit') %> <% end %> diff --git a/app/views/spree/admin/orders/_stock_item.html.erb b/app/views/spree/admin/orders/_stock_item.html.erb index 9ac2c12..8097526 100644 --- a/app/views/spree/admin/orders/_stock_item.html.erb +++ b/app/views/spree/admin/orders/_stock_item.html.erb @@ -4,7 +4,7 @@ <%= item.variant.product.name %>
<%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %> <% if item.part && item.line_item %> - <%= Spree.t(:part_of_bundle, sku: item.product.sku) %> + <%= I18n.t('spree.part_of_bundle', sku: item.product.sku) %> <% end %> @@ -34,11 +34,11 @@ <% if !shipment.shipped? && !item.part %> <% if can? :update, item %> - <%= link_to '', '#', :class => 'save-item fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %> - <%= link_to '', '#', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %> - <%= link_to '', '#', :class => 'edit-item fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> - <%= link_to '', '#', :class => 'split-item fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %> - <%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => Spree.t('actions.delete') %> + <%= link_to '', '#', :class => 'save-item fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => I18n.t('spree.actions.save'), :style => 'display: none' %> + <%= link_to '', '#', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => I18n.t('spree.actions.cancel'), :style => 'display: none' %> + <%= link_to '', '#', :class => 'edit-item fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => I18n.t('spree.actions.edit') %> + <%= link_to '', '#', :class => 'split-item fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => I18n.t('spree.actions.split') %> + <%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => I18n.t('spree.actions.delete') %> <% end %> <% end %> diff --git a/app/views/spree/admin/parts/_parts_table.html.erb b/app/views/spree/admin/parts/_parts_table.html.erb index 8dea53b..d1d535c 100644 --- a/app/views/spree/admin/parts/_parts_table.html.erb +++ b/app/views/spree/admin/parts/_parts_table.html.erb @@ -1,10 +1,10 @@ - - - - + + + + @@ -17,20 +17,20 @@ <% end %> <% if parts.empty? %> - + <% end %>
<%= Spree.t(:sku) %><%= Spree.t(:name) %><%= Spree.t(:options) %><%= Spree.t(:qty) %><%= I18n.t('spree.sku') %><%= I18n.t('spree.name') %><%= I18n.t('spree.options') %><%= I18n.t('spree.qty') %>
<%= link_to_with_icon( 'edit', - Spree.t('actions.edit'), + I18n.t('spree.actions.edit'), set_count_admin_product_part_url(@product, part), :class => "set_count_admin_product_part_link save-line-item") %> <%= link_to_with_icon( 'delete', - Spree.t('actions.delete'), + I18n.t('spree.actions.delete'), remove_admin_product_part_url(@product, part), class: "remove_admin_product_part_link delete-line-item") %>
<%= Spree.t(:none) %>.
<%= I18n.t('spree.none') %>.
diff --git a/app/views/spree/admin/parts/available.html.erb b/app/views/spree/admin/parts/available.html.erb index 4997c1f..75b6281 100644 --- a/app/views/spree/admin/parts/available.html.erb +++ b/app/views/spree/admin/parts/available.html.erb @@ -6,13 +6,13 @@ } -

<%= Spree.t(:available_parts) %>

+

<%= I18n.t('spree.available_parts') %>

- - - + + + @@ -27,19 +27,19 @@ options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %> <% else %> <%= hidden_field_tag "part[id]", product.master.id %> - <%= Spree.t(:no_variants) %> + <%= I18n.t(:no_variants) %> <% end %> <% end %> <% if @available_products.empty? %> - + <% end %>
<%= Spree.t(:name) %><%= Spree.t(:options) %><%= Spree.t(:qty) %><%= I18n.t('spree.name') %><%= I18n.t('spree.options') %><%= I18n.t('spree.qty') %>
<%= text_field_tag "part[count]", 1 %> - <%= link_to(Spree.t(:select), + <%= link_to(I18n.t('spree.select'), admin_product_parts_path(@product), :class => "add_product_part_link btn btn-primary") %>
<%= Spree.t(:no_match_found) %>.
<%= I18n.t('spree.no_match_found') %>.
diff --git a/app/views/spree/admin/parts/available.js.erb b/app/views/spree/admin/parts/available.js.erb index 4eb80c8..4da6ae1 100644 --- a/app/views/spree/admin/parts/available.js.erb +++ b/app/views/spree/admin/parts/available.js.erb @@ -5,13 +5,13 @@ else row.style.display = ''; } -

<%= Spree.t(:available_parts) %>

+

<%= I18n.t('spree.available_parts') %>

- - - + + + @@ -26,19 +26,19 @@ options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %> <% else %> <%= hidden_field_tag "part[id]", product.master.id %> - <%= Spree.t(:no_variants) %> + <%= I18n.t('spree.no_variants') %> <% end %> <% end %> <% if @available_products.empty? %> - + <% end %>
<%= Spree.t(:name) %><%= Spree.t(:options) %><%= Spree.t(:qty) %><%= I18n.t('spree.name') %><%= I18n.t('spree.options') %><%= I18n.t('spree.qty') %>
<%= text_field_tag "part[count]", 1 %> - <%= link_to(icon('add') + ' ' + Spree.t(:select), + <%= link_to(icon('add') + ' ' + I18n.t('spree.select'), admin_product_parts_path(@product), :class => "add_product_part_link") %>
<%= Spree.t(:no_match_found) %>.
<%= I18n.t('spree.no_match_found') %>.
diff --git a/app/views/spree/admin/parts/index.html.erb b/app/views/spree/admin/parts/index.html.erb index 63c568d..a9fd4c3 100644 --- a/app/views/spree/admin/parts/index.html.erb +++ b/app/views/spree/admin/parts/index.html.erb @@ -7,7 +7,7 @@
<%= form_tag('#') do %> - + <% end %> diff --git a/app/views/spree/admin/products/_product_assembly_fields.html.erb b/app/views/spree/admin/products/_product_assembly_fields.html.erb index b80d79d..0423f45 100644 --- a/app/views/spree/admin/products/_product_assembly_fields.html.erb +++ b/app/views/spree/admin/products/_product_assembly_fields.html.erb @@ -1,12 +1,12 @@
- <%= f.label :can_be_part, Spree.t(:can_be_part)%> + <%= f.label :can_be_part, I18n.t('spree.can_be_part')%> <%= f.check_box(:can_be_part) %>
- <%= f.label :individual_sale, Spree.t(:individual_sale)%> + <%= f.label :individual_sale, I18n.t('spree.individual_sale')%> <%= f.check_box(:individual_sale) %>
diff --git a/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb b/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb index 4a4f0e1..6aef55e 100644 --- a/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb +++ b/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb @@ -1,3 +1,3 @@ > - <%= link_to_with_icon 'sitemap', Spree.t(:parts), admin_product_parts_url(@product) %> + <%= link_to_with_icon 'sitemap', I18n.t('spree.parts'), admin_product_parts_url(@product) %> From 169bcc8ff2d3d5ec90de202842b34fd2f7831d9f Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Mon, 24 Dec 2018 10:43:10 +0100 Subject: [PATCH 3/4] Replace table_exists? -> data_source_exists? --- ...91029165620_add_parts_fields_to_products.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/db/migrate/20091029165620_add_parts_fields_to_products.rb b/db/migrate/20091029165620_add_parts_fields_to_products.rb index 495b4e6..2dbbbb5 100644 --- a/db/migrate/20091029165620_add_parts_fields_to_products.rb +++ b/db/migrate/20091029165620_add_parts_fields_to_products.rb @@ -1,24 +1,24 @@ class AddPartsFieldsToProducts < SolidusSupport::Migration[4.2] def self.up - table = if table_exists?(:products) + table = if data_source_exists?(:products) 'products' - elsif table_exists?(:spree_products) + elsif data_source_exists?(:spree_products) 'spree_products' - end - + end + change_table(table) do |t| t.column :can_be_part, :boolean, :default => false, :null => false t.column :individual_sale, :boolean, :default => true, :null => false - end + end end def self.down - table = if table_exists?(:products) + table = if data_source_exists?(:products) 'products' - elsif table_exists?(:spree_products) + elsif data_source_exists?(:spree_products) 'spree_products' - end - + end + change_table(table) do |t| t.remove :can_be_part t.remove :individual_sale From 1e4934d9cbe2f2e3e0ecf6c41eb156e82388b66b Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Mon, 24 Dec 2018 13:30:41 +0100 Subject: [PATCH 4/4] Gemfile maintenance This patch provides the following changes: * Install database adapter based on DB ENV variable * Fix Git insecure data fetching warning --- Gemfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 3253087..5067265 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" branch = ENV.fetch('SOLIDUS_BRANCH', 'master') -gem "solidus", github: "solidusio/solidus", branch: branch +gem 'solidus', git: 'https://github.com/solidusio/solidus.git', branch: branch gem 'solidus_auth_devise' gem 'deface' @@ -19,8 +19,11 @@ else gem 'factory_bot', '> 4.10.0' end -gem 'pg', '~> 0.21' -gem 'mysql2', '~> 0.4.10' +if ENV['DB'] == 'mysql' + gem 'mysql2', '~> 0.4.10' +else + gem 'pg', '~> 0.21' +end group :development, :test do gem "pry-rails"