spree_core 3.4.0.rc1 → 3.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c01ec77a94de597431df6260fdfe18a88817c241
4
- data.tar.gz: 72dcbd2cd49f05b804e3bf427d47899d3f11a3a0
3
+ metadata.gz: 2197427b41a26e477f45fe4ca4440b71c7f51f31
4
+ data.tar.gz: 0cbbda0e9bd9e23d1150a903d678708fe7f8e74d
5
5
  SHA512:
6
- metadata.gz: 95ba01f3578d5bebce43b70a421996ca9b6c7a7493b03b27841fd45a08bddfdabc79eb31e266a8d33a0c870e48962f47f2a34735e8cf1eccac1cd849b239d8ab
7
- data.tar.gz: 1ab924152669666ce1d0e1dd4bbfd6b056b6cd66149d19bdd26b8bb0c8244dbd583a31a7e9aebb8944650e49e00885d9da6fd3c582eb51d49133ff60c48998ab
6
+ metadata.gz: d1164ec3d27a3b434187540f4105fdd7a2d924289f93433bdd4abe28c8bb6e387bc3110a4417e5422bb43343142f3ed2b4defad8b4adb36a21f52500fafa4cf8
7
+ data.tar.gz: 3fb8bd3dca97d2eb69b4d78814a1c0240314180261ec9f3f835b503ad7235438c7fd27322c01a158f8728a0e9504bc391aed4d3c45effc4158bfa224f58db0ed
@@ -1,4 +1,8 @@
1
1
  module Spree
2
+ Paperclip.interpolates :viewable_id do |attachment, _style|
3
+ attachment.instance.viewable_id
4
+ end
5
+
2
6
  class Asset < Spree::Base
3
7
  belongs_to :viewable, polymorphic: true, touch: true
4
8
  acts_as_list scope: [:viewable_id, :viewable_type]
@@ -18,7 +18,7 @@ class Spree::Base < ApplicationRecord
18
18
 
19
19
  self.abstract_class = true
20
20
 
21
- mattr_accessor :belongs_to_required_by_default, instance_accessor: false do
21
+ def self.belongs_to_required_by_default
22
22
  false
23
23
  end
24
24
 
@@ -58,7 +58,7 @@ module Spree
58
58
 
59
59
  event :return do
60
60
  transition to: :returned,
61
- from: [:complete, :awaiting_return, :canceled, :resumed],
61
+ from: [:complete, :awaiting_return, :canceled, :returned, :resumed],
62
62
  if: :all_inventory_units_returned?
63
63
  end
64
64
 
@@ -20,9 +20,9 @@ module Spree
20
20
  def perform
21
21
  @shipment.inventory_units.each &:ship!
22
22
  @shipment.process_order_payments if Spree::Config[:auto_capture_on_dispatch]
23
- send_shipped_email
24
23
  @shipment.touch :shipped_at
25
24
  update_order_shipment_state
25
+ send_shipped_email
26
26
  end
27
27
 
28
28
  private
@@ -30,15 +30,7 @@ module Spree
30
30
  after_save :touch_ancestors_and_taxonomy
31
31
  after_touch :touch_ancestors_and_taxonomy
32
32
 
33
- has_attached_file :icon,
34
- styles: { mini: '32x32>', normal: '128x128>' },
35
- default_style: :mini,
36
- url: '/spree/taxons/:id/:style/:basename.:extension',
37
- path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
38
- default_url: '/assets/default_taxon.png'
39
-
40
- validates_attachment :icon,
41
- content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] }
33
+ has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::TaxonIcon'
42
34
 
43
35
  self.whitelisted_ransackable_associations = %w[taxonomy]
44
36
 
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ class TaxonIcon < Asset
3
+ has_attached_file :attachment,
4
+ styles: { mini: '32x32>', normal: '128x128>' },
5
+ default_style: :mini,
6
+ url: '/spree/taxons/:viewable_id/:style/:basename.:extension',
7
+ path: ':rails_root/public/spree/taxons/:viewable_id/:style/:basename.:extension',
8
+ default_url: '/assets/default_taxon.png'
9
+
10
+ validates_attachment :attachment,
11
+ content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] }
12
+ end
13
+ end
@@ -1,31 +1,16 @@
1
1
  require 'carmen'
2
2
 
3
- connection = ApplicationRecord.connection
4
- country_inserts = []
5
-
6
- country_values = -> do
7
- Carmen::Country.all.each do |country|
8
- name = connection.quote country.name
9
- iso3 = connection.quote country.alpha_3_code
10
- iso = connection.quote country.alpha_2_code
11
- iso_name = connection.quote country.name.upcase
12
- numcode = connection.quote country.numeric_code
13
- states_required = connection.quote country.subregions?
14
-
15
- country_inserts << [name, iso3, iso, iso_name, numcode, states_required].join(", ")
16
- end
17
-
18
- country_inserts.join("), (")
3
+ Carmen::Country.all.each do |country|
4
+ Spree::Country.where(
5
+ name: country.name,
6
+ iso3: country.alpha_3_code,
7
+ iso: country.alpha_2_code,
8
+ iso_name: country.name.upcase,
9
+ numcode: country.numeric_code,
10
+ states_required: country.subregions?
11
+ ).first_or_create
19
12
  end
20
13
 
21
- columns = ["name", "iso3", "iso", "iso_name", "numcode", "states_required"]
22
- columns = connection.adapter_name =~ /MySQL/i ? columns.join(", ") : "\"#{columns.join('", "')}\""
23
-
24
- connection.execute <<-SQL
25
- INSERT INTO spree_countries (#{columns})
26
- VALUES (#{country_values.call});
27
- SQL
28
-
29
14
  Spree::Config[:default_country_id] = Spree::Country.find_by(iso: "US").id
30
15
 
31
16
  # find countries that do not use postal codes (by iso) and set 'zipcode_required' to false for them.
@@ -0,0 +1,11 @@
1
+ # Temporary fix to FriendlyId in Rails5, so that we don't
2
+ # encounter any validation errors when creating slugs via
3
+ # FriendlyId::History on a paranoid model.
4
+ # See: https://github.com/norman/friendly_id/issues/822
5
+ if Rails::VERSION::STRING >= '5.0'
6
+ module FriendlyId
7
+ class Slug < ActiveRecord::Base
8
+ belongs_to :sluggable, polymorphic: true, optional: true
9
+ end
10
+ end
11
+ end
@@ -21,11 +21,11 @@ StateMachines::Machine.ignore_method_conflicts = true
21
21
  module Spree
22
22
  mattr_accessor :user_class
23
23
 
24
- def self.user_class
24
+ def self.user_class(constantize: true)
25
25
  if @@user_class.is_a?(Class)
26
26
  raise 'Spree.user_class MUST be a String or Symbol object, not a Class object.'
27
27
  elsif @@user_class.is_a?(String) || @@user_class.is_a?(Symbol)
28
- @@user_class.to_s.constantize
28
+ constantize ? @@user_class.to_s.constantize : @@user_class.to_s
29
29
  end
30
30
  end
31
31
 
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '3.4.0.rc1'
3
+ '3.4.0.rc2'
4
4
  end
5
5
  end
@@ -1 +1,2 @@
1
+ require 'friendly_id/slug_rails5_patch'
1
2
  require 'spree/core'
@@ -157,4 +157,14 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
157
157
  puts 'DONE ! Your database should no longer have line items that are associated with deleted variants.'
158
158
  end
159
159
  end
160
+
161
+ desc 'Migrates taxon icons to spree assets after upgrading to Spree 3.4: only needed if you used taxons icons.'
162
+ task migrate_taxon_icons: :environment do |_t, _args|
163
+ Spree::Taxon.where.not(icon_file_name: nil).find_each do |taxon|
164
+ taxon.create_icon(attachment_file_name: taxon.icon_file_name,
165
+ attachment_content_type: taxon.icon_content_type,
166
+ attachment_file_size: taxon.icon_file_size,
167
+ attachment_updated_at: taxon.icon_updated_at)
168
+ end
169
+ end
160
170
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0.rc1
4
+ version: 3.4.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -536,6 +536,7 @@ files:
536
536
  - app/models/spree/tax_category.rb
537
537
  - app/models/spree/tax_rate.rb
538
538
  - app/models/spree/taxon.rb
539
+ - app/models/spree/taxon_icon.rb
539
540
  - app/models/spree/taxonomy.rb
540
541
  - app/models/spree/tracker.rb
541
542
  - app/models/spree/validations/db_maximum_length_validator.rb
@@ -835,6 +836,7 @@ files:
835
836
  - db/migrate/20170722102643_add_analytics_kind_to_spree_trackers.rb
836
837
  - db/migrate/20170727103056_rename_tracker_kind_field.rb
837
838
  - db/seeds.rb
839
+ - lib/friendly_id/slug_rails5_patch.rb
838
840
  - lib/generators/spree/custom_user/custom_user_generator.rb
839
841
  - lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
840
842
  - lib/generators/spree/custom_user/templates/initializer.rb.tt