spree_core 4.2.0.rc1 → 4.2.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
  SHA256:
3
- metadata.gz: 9aaaa7166983682cd10080012ae8c4b54c89808552125eed36bce0345c2ed023
4
- data.tar.gz: b330046bd7a2af73be37cfedc5bae1a591c22e0344d62d1672d5ba84d0cf6f84
3
+ metadata.gz: 3c4aedf602c42650159969df6a8bc7f450fd1c68f6d93d2a40ff8635f691b5be
4
+ data.tar.gz: 41c8433179fb96ecb5ea01dd0b7f35cf600652531f8bdebdb837e24977cf795f
5
5
  SHA512:
6
- metadata.gz: f2faa906d370fd03cb6e477b00e9e52c5a658e051df9cf02d6f19a62f1480a99785e038e3ade796c92b2a8dc1cec4c820602e68dcc3615142c9cfe1a191f33bb
7
- data.tar.gz: 578828b9e6649880bfd6f1029adc1f0b5563ef5c68cda14d5ff1e3237ccc057953f0b30c4cad0984eff273417701c5303f6efe6ef3f13b19dd4cec4bc67358e2
6
+ metadata.gz: 5f3c60e7a972db6b1a2747b06485210904a431959eda4bdf5e9b0948207b5352bbff1b9fca5c414ac68b03d872301fb8aaffdbb1aef8b61777c51c5fa927b0c1
7
+ data.tar.gz: 15fa837cab8e2f12a409ff45432206e01f3d54211545b52c3ae26c0291baa2ee40cd8f49edaccdb9d6914411b8bacff269abc91993968741b959d555b8bdab30
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  module BaseHelper
3
3
  def available_countries
4
- checkout_zone = Spree::Zone.find_by(name: Spree::Config[:checkout_zone])
4
+ checkout_zone = current_store.checkout_zone || Spree::Zone.default_checkout_zone
5
5
 
6
6
  countries = if checkout_zone && checkout_zone.kind == 'country'
7
7
  checkout_zone.country_list
@@ -212,7 +212,7 @@ module Spree
212
212
  def meta_robots
213
213
  return unless current_store.respond_to?(:seo_robots)
214
214
  return if current_store.seo_robots.blank?
215
-
215
+
216
216
  tag('meta', name: 'robots', content: current_store.seo_robots)
217
217
  end
218
218
  end
@@ -27,6 +27,7 @@ module Spree
27
27
  belongs_to :source
28
28
  end
29
29
  belongs_to :order, class_name: 'Spree::Order', inverse_of: :all_adjustments
30
+ belongs_to :promotion_action, class_name: 'Spree::PromotionAction', foreign_key: :source_id, optional: true # created only for has_free_shipping?
30
31
 
31
32
  validates :adjustable, :order, :label, presence: true
32
33
  validates :amount, numericality: true
@@ -69,8 +69,7 @@ module Spree
69
69
  preference :credit_to_new_allocation, :boolean, default: false
70
70
 
71
71
  # Multi currency configurations
72
- preference :allow_currency_change, :boolean, default: false
73
- preference :show_currency_selector, :boolean, default: false
72
+ preference :show_store_currency_selector, :boolean, default: false
74
73
 
75
74
  # searcher_class allows spree extension writers to provide their own Search class
76
75
  def searcher_class
@@ -57,7 +57,7 @@ module Spree
57
57
  end
58
58
 
59
59
  def update_price
60
- if Spree::Config.allow_currency_change == true
60
+ if Spree::Config.show_store_currency_selector == true
61
61
  currency_price = Spree::Price.where(
62
62
  currency: order.currency,
63
63
  variant_id: variant_id
@@ -11,7 +11,7 @@ module Spree
11
11
  end
12
12
 
13
13
  def parsed_details
14
- @details ||= YAML.load(details)
14
+ @details ||= YAML.safe_load(details, [ActiveMerchant::Billing::Response])
15
15
  end
16
16
  end
17
17
  end
@@ -19,6 +19,8 @@ module Spree
19
19
 
20
20
  default_scope { order(:position) }
21
21
 
22
+ scope :filterable, -> { where(filterable: true) }
23
+
22
24
  accepts_nested_attributes_for :option_values, reject_if: ->(ov) { ov[:name].blank? || ov[:presentation].blank? }, allow_destroy: true
23
25
 
24
26
  after_touch :touch_all_products
@@ -649,10 +649,10 @@ module Spree
649
649
  end
650
650
 
651
651
  def has_free_shipping?
652
- promotions.
653
- joins(:promotion_actions).
654
- where(spree_promotion_actions: { type: 'Spree::Promotion::Actions::FreeShipping' }).
655
- exists?
652
+ shipment_adjustments.
653
+ joins(:promotion_action).
654
+ where(spree_adjustments: { eligible: true, source_type: 'Spree::PromotionAction' },
655
+ spree_promotion_actions: { type: 'Spree::Promotion::Actions::FreeShipping' }).exists?
656
656
  end
657
657
 
658
658
  private
@@ -55,31 +55,18 @@ module Spree
55
55
  def update_or_create_address(attributes = {})
56
56
  return if attributes.blank?
57
57
 
58
- attributes = attributes.select { |_k, v| v.present? }
58
+ attributes.transform_values! { |v| v == '' ? nil : v }
59
59
 
60
- if user
61
- address = user.addresses.build(attributes.except(:id)).check
62
- return address if address.id
63
- end
64
-
65
- if attributes[:id]
66
- address = Spree::Address.find(attributes[:id])
67
- attributes.delete(:id)
60
+ default_address_scope = user ? user.addresses : ::Spree::Address
61
+ default_address = default_address_scope.find_by(id: attributes[:id])
68
62
 
69
- if address&.editable?
70
- address.update(attributes)
71
- return address
72
- else
73
- attributes.delete(:id)
74
- end
75
- end
63
+ if default_address&.editable?
64
+ default_address.update(attributes)
76
65
 
77
- unless attributes[:id]
78
- address = Spree::Address.new(attributes)
79
- address.save
66
+ return default_address
80
67
  end
81
68
 
82
- address
69
+ ::Spree::Address.find_or_create_by(attributes.except(:id, :updated_at, :created_at))
83
70
  end
84
71
  end
85
72
  end
@@ -194,21 +194,10 @@ module Spree
194
194
  end
195
195
 
196
196
  def used_by?(user, excluded_orders = [])
197
- [
198
- :adjustments,
199
- :line_item_adjustments,
200
- :shipment_adjustments
201
- ].any? do |adjustment_type|
202
- user.orders.complete.joins(adjustment_type).where(
203
- spree_adjustments: {
204
- source_type: 'Spree::PromotionAction',
205
- source_id: actions.map(&:id),
206
- eligible: true
207
- }
208
- ).where.not(
209
- id: excluded_orders.map(&:id)
210
- ).any?
211
- end
197
+ user.orders.complete.joins(:promotions).joins(:all_adjustments).
198
+ where.not(spree_orders: { id: excluded_orders.map(&:id) }).
199
+ where(spree_promotions: { id: id }).
200
+ where(spree_adjustments: { source_type: 'Spree::PromotionAction', eligible: true }).any?
212
201
  end
213
202
 
214
203
  private
@@ -25,7 +25,6 @@ module Spree
25
25
 
26
26
  def remove(coupon_code)
27
27
  promotion = order.promotions.with_coupon_code(coupon_code)
28
-
29
28
  if promotion.present?
30
29
  # Order promotion has to be destroyed before line item removing
31
30
  order.order_promotions.where(promotion_id: promotion.id).destroy_all
@@ -76,7 +75,7 @@ module Spree
76
75
  line_item = order.find_line_item_by_variant(item.variant)
77
76
  next if line_item.blank?
78
77
 
79
- Spree::Dependencies.cart_remove_item_service(order: order, item: item.variant, quantity: item.quantity)
78
+ Spree::Dependencies.cart_remove_item_service.constantize.call(order: order, item: item.variant, quantity: item.quantity)
80
79
  end
81
80
  end
82
81
 
@@ -3,6 +3,7 @@ module Spree
3
3
  has_many :orders, class_name: 'Spree::Order'
4
4
  has_many :payment_methods, class_name: 'Spree::PaymentMethod'
5
5
  belongs_to :default_country, class_name: 'Spree::Country'
6
+ belongs_to :checkout_zone, class_name: 'Spree::Zone'
6
7
 
7
8
  with_options presence: true do
8
9
  validates :name, :url, :mail_from_address, :default_currency, :code
@@ -46,6 +47,10 @@ module Spree
46
47
  end.uniq.compact
47
48
  end
48
49
 
50
+ def unique_name
51
+ "#{name} (#{code})"
52
+ end
53
+
49
54
  private
50
55
 
51
56
  def ensure_default_exists_and_is_unique
@@ -70,6 +70,10 @@ module Spree
70
70
  matches.first
71
71
  end
72
72
 
73
+ def self.default_checkout_zone
74
+ find_by(name: Spree::Config[:checkout_zone])
75
+ end
76
+
73
77
  def kind
74
78
  if self[:kind].present?
75
79
  self[:kind]
@@ -52,6 +52,7 @@ en:
52
52
  spree/option_type:
53
53
  name: Name
54
54
  presentation: Presentation
55
+ filterable: Filterable
55
56
  spree/order:
56
57
  checkout_complete: Checkout Complete
57
58
  completed_at: Completed At
@@ -574,9 +575,6 @@ en:
574
575
  agree_to_privacy_policy: Agree to Privacy Policy
575
576
  agree_to_terms_of_service: Agree to Terms of Service
576
577
  all: All
577
- allow_currency_change:
578
- short: Allow Currency Change
579
- long: Allow users to change their currency via the currency picker.
580
578
  all_adjustments_closed: All adjustments successfully closed!
581
579
  all_adjustments_opened: All adjustments successfully opened!
582
580
  all_departments: All departments
@@ -889,6 +887,7 @@ en:
889
887
  filename: Filename
890
888
  fill_in_customer_info: Please fill in customer info
891
889
  filter: Filter
890
+ filterable: Filterable
892
891
  filter_results: Filter Results
893
892
  finalize: Finalize
894
893
  find_a_taxon: Find a Taxon
@@ -959,6 +958,8 @@ en:
959
958
  supported_locales: Supported Locales
960
959
  this_file_language: English (US)
961
960
  translations: Translations
961
+ checkout_zone_warning_html: "Selecting a Zone will limit customers on Checkout to Addresses in Countries in that Zone. <br />
962
+ Please see documentation: <a href='https://guides.spreecommerce.org/user/configuration/configuring_geography.html#zones' target='_blank' class='alert-link'>https://guides.spreecommerce.org/user/configuration/configuring_geography.html#zones</a>"
962
963
  icon: Icon
963
964
  image: Image
964
965
  images: Images
@@ -1570,15 +1571,15 @@ en:
1570
1571
  shopping_cart: Shopping Cart
1571
1572
  show: Show
1572
1573
  show_active: Show Active
1573
- show_currency_selector:
1574
- short: Show Currency Selector
1575
- long_html: Display the currency picker in the main nav bar. This will only display if there are multiple supported currencies, and <strong>Allow currency change</strong> option is enabled.
1576
1574
  show_deleted: Show Deleted
1577
1575
  show_discontinued: Show Discontinued
1578
1576
  show_only_complete_orders: Only show complete orders
1579
1577
  show_only_considered_risky: Only show risky orders
1580
1578
  show_property: Show Property
1581
1579
  show_rate_in_label: Show rate in label
1580
+ show_store_currency_selector:
1581
+ short: Show Store selector
1582
+ long: Display the Store selector in the main nav bar of Storefront and allow users to change Store and Currency
1582
1583
  sign_up: Sign Up
1583
1584
  sku: SKU
1584
1585
  skus: SKUs
@@ -1811,3 +1812,4 @@ en:
1811
1812
  zipcode_required: Zip Code Required
1812
1813
  zone: Zone
1813
1814
  zones: Zones
1815
+ no_limits_zone: No Limits
@@ -0,0 +1,12 @@
1
+ class AddCheckoutZoneFieldToStore < ActiveRecord::Migration[6.0]
2
+ def change
3
+ unless column_exists?(:spree_stores, :checkout_zone_id)
4
+ add_column :spree_stores, :checkout_zone_id, :integer
5
+
6
+ Spree::Store.reset_column_information
7
+
8
+ default_zone = Spree::Zone.default_checkout_zone
9
+ Spree::Store.update_all(checkout_zone_id: default_zone.id) if default_zone.present?
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ class AddFilterableColumnToSpreeOptionTypes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :spree_option_types, :filterable, :boolean, default: true, null: false
4
+ add_index :spree_option_types, :filterable
5
+ end
6
+ end
@@ -38,7 +38,7 @@ module Spree
38
38
  end
39
39
  end
40
40
  order.reload
41
- rescue Exception => e
41
+ rescue StandardError => e
42
42
  order.destroy if order&.persisted?
43
43
  raise e.message
44
44
  end
@@ -80,7 +80,7 @@ module Spree
80
80
 
81
81
  adjustments = s.delete(:adjustments_attributes)
82
82
  create_adjustments_from_params(adjustments, order, shipment)
83
- rescue Exception => e
83
+ rescue StandardError => e
84
84
  raise "Order import shipments: #{e.message} #{s}"
85
85
  end
86
86
  end
@@ -115,7 +115,7 @@ module Spree
115
115
  line_item.save!
116
116
  end
117
117
  create_adjustments_from_params(adjustments, order, line_item)
118
- rescue Exception => e
118
+ rescue StandardError => e
119
119
  raise "Order import line items: #{e.message} #{line_item}"
120
120
  end
121
121
  end
@@ -132,7 +132,7 @@ module Spree
132
132
  )
133
133
  adjustment.save!
134
134
  adjustment.close!
135
- rescue Exception => e
135
+ rescue StandardError => e
136
136
  raise "Order import adjustments: #{e.message} #{a}"
137
137
  end
138
138
  end
@@ -150,7 +150,7 @@ module Spree
150
150
  payment.payment_method = Spree::PaymentMethod.find_by!(name: p[:payment_method])
151
151
  payment.source = create_source_payment_from_params(p[:source], payment) if p[:source]
152
152
  payment.save!
153
- rescue Exception => e
153
+ rescue StandardError => e
154
154
  raise "Order import payments: #{e.message} #{p}"
155
155
  end
156
156
  end
@@ -167,7 +167,7 @@ module Spree
167
167
  gateway_payment_profile_id: source_hash[:gateway_payment_profile_id],
168
168
  imported: true
169
169
  )
170
- rescue Exception => e
170
+ rescue StandardError => e
171
171
  raise "Order import source payments: #{e.message} #{source_hash}"
172
172
  end
173
173
 
@@ -179,7 +179,7 @@ module Spree
179
179
  hash
180
180
  rescue ActiveRecord::RecordNotFound => e
181
181
  raise "Ensure order import variant: Variant w/SKU #{sku} not found."
182
- rescue Exception => e
182
+ rescue StandardError => e
183
183
  raise "Ensure order import variant: #{e.message} #{hash}"
184
184
  end
185
185
 
@@ -200,7 +200,7 @@ module Spree
200
200
 
201
201
  address.delete(:country)
202
202
  address[:country_id] = Spree::Country.where(search).first!.id
203
- rescue Exception => e
203
+ rescue StandardError => e
204
204
  raise "Ensure order import address country: #{e.message} #{search}"
205
205
  end
206
206
  end
@@ -224,7 +224,7 @@ module Spree
224
224
  else
225
225
  address[:state_name] = search[:name] || search[:abbr]
226
226
  end
227
- rescue Exception => e
227
+ rescue StandardError => e
228
228
  raise "Ensure order import address state: #{e.message} #{search}"
229
229
  end
230
230
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '4.2.0.rc1'
3
+ '4.2.0.rc2'
4
4
  end
5
5
  end
@@ -101,7 +101,7 @@ module Spree
101
101
  :customer_support_email, :facebook, :twitter, :instagram,
102
102
  :description, :address, :contact_email, :contact_phone,
103
103
  :default_locale, :default_country_id, :supported_currencies,
104
- :new_order_notifications_email, :mailer_logo]
104
+ :new_order_notifications_email, :mailer_logo, :checkout_zone_id]
105
105
 
106
106
  @@store_credit_attributes = %i[amount currency category_id memo]
107
107
 
@@ -1,4 +1,21 @@
1
1
  FactoryBot.define do
2
+ trait :with_item_total_rule do
3
+ transient do
4
+ item_total_threshold_amount { 10 }
5
+ end
6
+
7
+ after(:create) do |promotion, evaluator|
8
+ rule = Spree::Promotion::Rules::ItemTotal.create!(
9
+ preferred_operator_min: 'gte',
10
+ preferred_operator_max: 'lte',
11
+ preferred_amount_min: evaluator.item_total_threshold_amount,
12
+ preferred_amount_max: evaluator.item_total_threshold_amount + 100
13
+ )
14
+ promotion.rules << rule
15
+ promotion.save!
16
+ end
17
+ end
18
+
2
19
  factory :promotion, class: Spree::Promotion do
3
20
  name { 'Promo' }
4
21
 
@@ -13,7 +30,16 @@ FactoryBot.define do
13
30
  Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator: calculator, promotion: promotion)
14
31
  end
15
32
  end
33
+
34
+ trait :with_one_use_per_user_rule do
35
+ after(:create) do |promotion|
36
+ rule = Spree::Promotion::Rules::OneUsePerUser.create!
37
+ promotion.rules << rule
38
+ end
39
+ end
40
+
16
41
  factory :promotion_with_item_adjustment, traits: [:with_line_item_adjustment]
42
+ factory :promotion_with_one_use_per_user_rule, traits: [:with_line_item_adjustment, :with_one_use_per_user_rule]
17
43
 
18
44
  trait :with_order_adjustment do
19
45
  transient do
@@ -28,24 +54,8 @@ FactoryBot.define do
28
54
  promotion.save!
29
55
  end
30
56
  end
31
- factory :promotion_with_order_adjustment, traits: [:with_order_adjustment]
32
57
 
33
- trait :with_item_total_rule do
34
- transient do
35
- item_total_threshold_amount { 10 }
36
- end
37
-
38
- after(:create) do |promotion, evaluator|
39
- rule = Spree::Promotion::Rules::ItemTotal.create!(
40
- preferred_operator_min: 'gte',
41
- preferred_operator_max: 'lte',
42
- preferred_amount_min: evaluator.item_total_threshold_amount,
43
- preferred_amount_max: evaluator.item_total_threshold_amount + 100
44
- )
45
- promotion.rules << rule
46
- promotion.save!
47
- end
48
- end
58
+ factory :promotion_with_order_adjustment, traits: [:with_order_adjustment]
49
59
  factory :promotion_with_item_total_rule, traits: [:with_item_total_rule]
50
60
  end
51
61
 
@@ -57,5 +67,7 @@ FactoryBot.define do
57
67
  action.promotion = promotion
58
68
  action.save
59
69
  end
70
+
71
+ factory :free_shipping_promotion_with_item_total_rule, traits: [:with_item_total_rule]
60
72
  end
61
73
  end
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :global_zone, class: Spree::Zone do
3
- name { 'GlobalZone' }
3
+ sequence(:name) { |n| "GlobalZone_#{n}" }
4
4
  description { generate(:random_string) }
5
5
  zone_members do |proxy|
6
6
  zone = proxy.instance_eval { @instance }
@@ -84,7 +84,7 @@ RSpec.configure do |config|
84
84
  end
85
85
 
86
86
  Spree.check_unused_translations
87
- if false && Spree.unused_translation_messages.any?
87
+ if Spree.unused_translation_messages.any?
88
88
  puts "\nThere are unused translations within Spree:"
89
89
  puts Spree.unused_translation_messages.sort
90
90
  exit(1)
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
48
48
  s.add_dependency 'twitter_cldr', '>= 4.3', '< 7.0'
49
49
  s.add_dependency 'sprockets', '~> 3.7'
50
50
  s.add_dependency 'sprockets-rails'
51
- s.add_dependency 'mini_magick', '>= 4.9.4', '< 4.11.0'
51
+ s.add_dependency 'mini_magick', '>= 4.9.4', '< 4.12.0'
52
52
  s.add_dependency 'image_processing', '~> 1.2'
53
53
  s.add_dependency 'active_storage_validations', '~> 0.9'
54
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.rc1
4
+ version: 4.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-15 00:00:00.000000000 Z
12
+ date: 2020-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemerchant
@@ -352,7 +352,7 @@ dependencies:
352
352
  version: 4.9.4
353
353
  - - "<"
354
354
  - !ruby/object:Gem::Version
355
- version: 4.11.0
355
+ version: 4.12.0
356
356
  type: :runtime
357
357
  prerelease: false
358
358
  version_requirements: !ruby/object:Gem::Requirement
@@ -362,7 +362,7 @@ dependencies:
362
362
  version: 4.9.4
363
363
  - - "<"
364
364
  - !ruby/object:Gem::Version
365
- version: 4.11.0
365
+ version: 4.12.0
366
366
  - !ruby/object:Gem::Dependency
367
367
  name: image_processing
368
368
  requirement: !ruby/object:Gem::Requirement
@@ -976,6 +976,8 @@ files:
976
976
  - db/migrate/20200607161222_add_new_order_notifications_email_to_spree_stores.rb
977
977
  - db/migrate/20200610113542_add_label_to_spree_addresses.rb
978
978
  - db/migrate/20200826075557_add_unique_index_on_taxon_id_and_product_id_to_spree_products_taxons.rb
979
+ - db/migrate/20201006110150_add_checkout_zone_field_to_store.rb
980
+ - db/migrate/20201012091259_add_filterable_column_to_spree_option_types.rb
979
981
  - db/migrate/20201013084504_add_seo_robots_to_spree_stores.rb
980
982
  - db/seeds.rb
981
983
  - lib/friendly_id/slug_rails5_patch.rb
@@ -1128,9 +1130,9 @@ licenses:
1128
1130
  - BSD-3-Clause
1129
1131
  metadata:
1130
1132
  bug_tracker_uri: https://github.com/spree/spree/issues
1131
- changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.rc1
1133
+ changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.rc2
1132
1134
  documentation_uri: https://guides.spreecommerce.org/
1133
- source_code_uri: https://github.com/spree/spree/tree/v4.2.0.rc1
1135
+ source_code_uri: https://github.com/spree/spree/tree/v4.2.0.rc2
1134
1136
  post_install_message:
1135
1137
  rdoc_options: []
1136
1138
  require_paths:
@@ -1146,7 +1148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1146
1148
  - !ruby/object:Gem::Version
1147
1149
  version: 1.8.23
1148
1150
  requirements: []
1149
- rubygems_version: 3.1.4
1151
+ rubygems_version: 3.1.2
1150
1152
  signing_key:
1151
1153
  specification_version: 4
1152
1154
  summary: The bare bones necessary for Spree.