spree_core 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/products_helper.rb +8 -3
  3. data/app/mailers/spree/base_mailer.rb +5 -0
  4. data/app/models/spree/ability.rb +10 -12
  5. data/app/models/spree/app_configuration.rb +2 -0
  6. data/app/models/spree/classification.rb +3 -0
  7. data/app/models/spree/image.rb +1 -1
  8. data/app/models/spree/line_item.rb +2 -0
  9. data/app/models/spree/order.rb +17 -12
  10. data/app/models/spree/order/checkout.rb +1 -1
  11. data/app/models/spree/payment.rb +14 -2
  12. data/app/models/spree/payment/processing.rb +1 -1
  13. data/app/models/spree/preferences/store.rb +1 -1
  14. data/app/models/spree/product.rb +2 -2
  15. data/app/models/spree/product/scopes.rb +5 -8
  16. data/app/models/spree/shipment.rb +4 -1
  17. data/app/models/spree/stock/availability_validator.rb +1 -1
  18. data/app/models/spree/stock/quantifier.rb +1 -1
  19. data/app/models/spree/stock_item.rb +11 -7
  20. data/config/locales/en.yml +8 -2
  21. data/db/default/spree/countries.rb +25 -25
  22. data/db/migrate/20130213191427_create_default_stock.rb +5 -2
  23. data/db/migrate/20130830001033_add_shipping_category_to_shipping_methods_and_products.rb +15 -0
  24. data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +19 -0
  25. data/db/migrate/20130909115621_change_states_required_for_countries.rb +9 -0
  26. data/db/migrate/20131001013410_remove_unused_credit_card_fields.rb +12 -0
  27. data/lib/spree/core/controller_helpers/order.rb +1 -1
  28. data/lib/spree/core/controller_helpers/ssl.rb +22 -29
  29. data/lib/spree/core/preference_rescue.rb +25 -0
  30. data/lib/spree/core/version.rb +1 -1
  31. data/lib/spree/money.rb +4 -0
  32. data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
  33. metadata +13 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4eb6afc84186dd0b46d37daebea561e582412dfb
4
- data.tar.gz: 96ad34a945d823c7f0ce6d17797c183eee5f4261
3
+ metadata.gz: 4b3832f1651011ef4d49aebec92add9c6fc8744d
4
+ data.tar.gz: 0f9032e0a7134479874ddda954c590cee31486a8
5
5
  SHA512:
6
- metadata.gz: 2a990089d87e7ed851394892fe747d8146fdd7992a1f1d70f1cb7447a6471c937dd1faf5380cbec891844f048049b5f8b65312bae912ae69cf46690f235e2dab
7
- data.tar.gz: c13e7f2071ddac220493da65f4407b25e00cf0704a7d205637c67513487f7646e60ab209d43ed3a2365d81d473420c6fb56760331a7598dc2e66c7966837e9e6
6
+ metadata.gz: df88e26ab461edc8b6a6373a708386c359a051aec2e6a1715c26ef6b7318d90fec9be379abb911d2eb0171377076186210565fbd2408e8c6eb112a0eefb5c3f1
7
+ data.tar.gz: d8e1e60bb608201d98d4fcf89344716d4bbdd17347135b3ccad3e8b524d44d22ac515cd3d23a78c1dc5f55262083c63aec0ead934f0202d737ebcf7c845fa651
@@ -40,9 +40,14 @@ module Spree
40
40
  end
41
41
 
42
42
  def line_item_description(variant)
43
- description = variant.product.description
44
- if description.present?
45
- truncate(strip_tags(description.gsub(' ', ' ')), length: 100)
43
+ ActiveSupport::Deprecation.warn "line_item_description(variant) is deprecated and may be removed from future releases, use line_item_description_text(line_item.description) instead.", caller
44
+
45
+ line_item_description_text(variant.product.description)
46
+ end
47
+
48
+ def line_item_description_text description_text
49
+ if description_text.present?
50
+ truncate(strip_tags(description_text.gsub(' ', ' ')), length: 100)
46
51
  else
47
52
  Spree.t(:product_has_no_description)
48
53
  end
@@ -8,5 +8,10 @@ module Spree
8
8
  Spree::Money.new(amount).to_s
9
9
  end
10
10
  helper_method :money
11
+
12
+ def mail(headers={}, &block)
13
+ super if Spree::Config[:send_core_emails]
14
+ end
15
+
11
16
  end
12
17
  end
@@ -47,18 +47,16 @@ module Spree
47
47
  order.user == user || order.token && token == order.token
48
48
  end
49
49
  can :create, Order
50
-
51
- can :read, Address do |address|
52
- address.user == user
53
- end
54
-
55
- #############################
56
- can :read, Product
57
- can :index, Product
58
- #############################
59
- can :read, Taxon
60
- can :index, Taxon
61
- #############################
50
+ can [:index, :read], Product
51
+ can [:index, :read], ProductProperty
52
+ can [:index, :read], Property
53
+ can :create, Spree.user_class
54
+ can [:read, :update, :destroy], Spree.user_class, id: user.id
55
+ can [:index, :read], State
56
+ can [:index, :read], Taxon
57
+ can [:index, :read], Taxonomy
58
+ can [:index, :read], Variant
59
+ can [:index, :read], Zone
62
60
  end
63
61
 
64
62
  #include any abilities registered by extensions, etc.
@@ -32,6 +32,7 @@ module Spree
32
32
  preference :allow_ssl_in_staging, :boolean, default: true
33
33
  preference :alternative_billing_phone, :boolean, default: false # Request extra phone for bill addr
34
34
  preference :alternative_shipping_phone, :boolean, default: false # Request extra phone for ship addr
35
+ preference :always_include_confirm_step, :boolean, default: false # Ensures confirmation step is always in checkout_progress bar, but does not force a confirm step if your payment methods do not support it.
35
36
  preference :always_put_site_name_in_title, :boolean, default: true
36
37
  preference :auto_capture, :boolean, default: false # automatically capture the credit card (as opposed to just authorize and capture later)
37
38
  preference :cache_static_content, :boolean, default: true
@@ -86,6 +87,7 @@ module Spree
86
87
 
87
88
  # Default mail headers settings
88
89
  preference :enable_mail_delivery, :boolean, :default => false
90
+ preference :send_core_emails, :boolean, :default => true
89
91
  preference :mails_from, :string, :default => 'spree@example.com'
90
92
  preference :mail_bcc, :string, :default => 'spree@example.com'
91
93
  preference :intercept_email, :string, :default => nil
@@ -3,5 +3,8 @@ module Spree
3
3
  self.table_name = 'spree_products_taxons'
4
4
  belongs_to :product, class_name: "Spree::Product"
5
5
  belongs_to :taxon, class_name: "Spree::Taxon"
6
+
7
+ # For #3494
8
+ validates_uniqueness_of :taxon_id, :scope => :product_id, :message => :already_linked
6
9
  end
7
10
  end
@@ -10,7 +10,7 @@ module Spree
10
10
  default_style: :product,
11
11
  url: '/spree/products/:id/:style/:basename.:extension',
12
12
  path: ':rails_root/public/spree/products/:id/:style/:basename.:extension',
13
- convert_options: { all: '-strip -auto-orient' }
13
+ convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
14
14
 
15
15
  # save the w,h of the original image (from which others can be calculated)
16
16
  # we need to look at the write-queue for images which have not been saved yet
@@ -27,6 +27,8 @@ module Spree
27
27
  after_save :update_order
28
28
  after_destroy :update_order
29
29
 
30
+ delegate :name, :description, to: :variant
31
+
30
32
  attr_accessor :target_shipment
31
33
 
32
34
  def copy_price
@@ -53,6 +53,7 @@ module Spree
53
53
  has_many :payments, dependent: :destroy
54
54
  has_many :return_authorizations, dependent: :destroy
55
55
  has_many :state_changes, as: :stateful
56
+ has_many :inventory_units
56
57
 
57
58
  has_many :shipments, dependent: :destroy, :class_name => "Shipment" do
58
59
  def states
@@ -153,7 +154,7 @@ module Spree
153
154
  end
154
155
 
155
156
  def completed?
156
- !! completed_at
157
+ completed_at.present? || complete?
157
158
  end
158
159
 
159
160
  # Indicates whether or not the user is allowed to proceed to checkout.
@@ -171,7 +172,11 @@ module Spree
171
172
 
172
173
  # If true, causes the confirmation step to happen during the checkout process
173
174
  def confirmation_required?
174
- payments.map(&:payment_method).compact.any?(&:payment_profiles_supported?)
175
+ if payments.empty? and Spree::Config[:always_include_confirm_step]
176
+ true
177
+ else
178
+ payments.map(&:payment_method).compact.any?(&:payment_profiles_supported?)
179
+ end
175
180
  end
176
181
 
177
182
  # Indicates the number of items in the order
@@ -244,13 +249,6 @@ module Spree
244
249
  shipment_state.nil? || %w{ready backorder pending}.include?(shipment_state)
245
250
  end
246
251
 
247
- def allow_resume?
248
- # we shouldn't allow resume for legacy orders b/c we lack the information
249
- # necessary to restore to a previous state
250
- return false if state_changes.empty? || state_changes.last.previous_state.nil?
251
- true
252
- end
253
-
254
252
  def awaiting_returns?
255
253
  return_authorizations.any? { |return_authorization| return_authorization.authorized? }
256
254
  end
@@ -462,7 +460,7 @@ module Spree
462
460
  @insufficient_stock_lines ||= line_items.select(&:insufficient_stock?)
463
461
  end
464
462
 
465
- def merge!(order)
463
+ def merge!(order, user = nil)
466
464
  order.line_items.each do |line_item|
467
465
  next unless line_item.currency == currency
468
466
  current_line_item = self.line_items.find_by_variant_id(line_item.variant_id)
@@ -474,14 +472,17 @@ module Spree
474
472
  line_item.save
475
473
  end
476
474
  end
475
+
476
+ self.associate_user!(user) if !self.user && !user.blank?
477
+
477
478
  # So that the destroy doesn't take out line items which may have been re-assigned
478
479
  order.line_items.reload
479
480
  order.destroy
480
481
  end
481
482
 
482
483
  def empty!
483
- line_items.destroy_all
484
484
  adjustments.destroy_all
485
+ line_items.destroy_all
485
486
  end
486
487
 
487
488
  def clear_adjustments!
@@ -594,10 +595,14 @@ module Spree
594
595
  def after_cancel
595
596
  shipments.each { |shipment| shipment.cancel! }
596
597
 
597
- OrderMailer.cancel_email(self.id).deliver
598
+ send_cancel_email
598
599
  self.payment_state = 'credit_owed' unless shipped?
599
600
  end
600
601
 
602
+ def send_cancel_email
603
+ OrderMailer.cancel_email(self.id).deliver
604
+ end
605
+
601
606
  def after_resume
602
607
  shipments.each { |shipment| shipment.resume! }
603
608
  end
@@ -56,7 +56,7 @@ module Spree
56
56
  end
57
57
 
58
58
  event :resume do
59
- transition :to => :resumed, :from => :canceled, :if => :allow_resume?
59
+ transition :to => :resumed, :from => :canceled, :if => :canceled?
60
60
  end
61
61
 
62
62
  event :authorize_return do
@@ -12,7 +12,7 @@ module Spree
12
12
  has_many :log_entries, as: :source
13
13
 
14
14
  before_validation :validate_source
15
- before_save :set_unique_identifier
15
+ before_create :set_unique_identifier
16
16
 
17
17
  after_save :create_payment_profile, if: :profiles_supported?
18
18
 
@@ -35,10 +35,12 @@ module Spree
35
35
 
36
36
  after_rollback :persist_invalid
37
37
 
38
+ validates :amount, numericality: true
39
+
38
40
  def persist_invalid
39
41
  return unless ['failed', 'invalid'].include?(state)
40
42
  state_will_change!
41
- save
43
+ save
42
44
  end
43
45
 
44
46
  # order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
@@ -77,6 +79,16 @@ module Spree
77
79
  end
78
80
  alias display_amount money
79
81
 
82
+ def amount=(amount)
83
+ self[:amount] =
84
+ case amount
85
+ when String
86
+ separator = I18n.t('number.currency.format.separator')
87
+ number = amount.delete("^0-9-#{separator}").tr(separator, '.')
88
+ number.to_d if number.present?
89
+ end || amount
90
+ end
91
+
80
92
  def offsets_total
81
93
  offsets.pluck(:amount).sum
82
94
  end
@@ -205,4 +205,4 @@ module Spree
205
205
  end
206
206
  end
207
207
  end
208
- end
208
+ end
@@ -86,7 +86,7 @@ module Spree::Preferences
86
86
  end
87
87
 
88
88
  def should_persist?
89
- @persistence && Spree::Preference.connected? && Spree::Preference.table_exists?
89
+ @persistence and Spree::Preference.table_exists?
90
90
  end
91
91
 
92
92
  end
@@ -49,7 +49,7 @@ module Spree
49
49
  order: "#{::Spree::Variant.quoted_table_name}.position ASC"
50
50
 
51
51
  has_many :prices, through: :variants, order: 'spree_variants.position, spree_variants.id, currency'
52
- has_many :stock_items, through: :variants
52
+ has_many :stock_items, through: :variants_including_master
53
53
 
54
54
  delegate_belongs_to :master, :sku, :price, :currency, :display_amount, :display_price, :weight, :height, :width, :depth, :is_master, :has_default_price?, :cost_currency, :price_in, :amount_in
55
55
  delegate_belongs_to :master, :cost_price if Variant.table_exists? && Variant.column_names.include?('cost_price')
@@ -260,7 +260,7 @@ module Spree
260
260
  # there's a weird quirk with the delegate stuff that does not automatically save the delegate object
261
261
  # when saving so we force a save using a hook.
262
262
  def save_master
263
- master.save if master && (master.changed? || master.new_record? || (master.default_price && (master.default_price.changed || master.default_price.new_record)))
263
+ master.save if master && (master.changed? || master.new_record? || (master.default_price && (master.default_price.changed? || master.default_price.new_record?)))
264
264
  end
265
265
 
266
266
  def ensure_master
@@ -68,14 +68,11 @@ module Spree
68
68
  #
69
69
  # SELECT COUNT(*) ...
70
70
  add_search_scope :in_taxon do |taxon|
71
- if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
72
- scope = select("DISTINCT ON (spree_products.id) spree_products.*")
73
- else
74
- scope = select("DISTINCT(spree_products.id), spree_products.*")
75
- end
76
-
77
- scope.joins(:taxons).
78
- where(Taxon.table_name => { :id => taxon.self_and_descendants.map(&:id) })
71
+ select("spree_products.id, spree_products.*").
72
+ where(id: Classification.select('spree_products_taxons.product_id').
73
+ joins(:taxon).
74
+ where(Taxon.table_name => { :id => taxon.self_and_descendants.pluck(:id) })
75
+ )
79
76
  end
80
77
 
81
78
  # This scope selects products in all taxons AND all its descendants
@@ -105,11 +105,14 @@ module Spree
105
105
  def refresh_rates
106
106
  return shipping_rates if shipped?
107
107
 
108
+ # StockEstimator.new assigment below will replace the current shipping_method
109
+ original_shipping_method_id = shipping_method.try(:id)
110
+
108
111
  self.shipping_rates = Stock::Estimator.new(order).shipping_rates(to_package)
109
112
 
110
113
  if shipping_method
111
114
  selected_rate = shipping_rates.detect { |rate|
112
- rate.shipping_method_id == shipping_method.id
115
+ rate.shipping_method_id == original_shipping_method_id
113
116
  }
114
117
  self.selected_shipping_rate_id = selected_rate.id if selected_rate
115
118
  end
@@ -17,7 +17,7 @@ module Spree
17
17
  display_name = %Q{#{variant.name}}
18
18
  display_name += %Q{ (#{variant.options_text})} unless variant.options_text.blank?
19
19
 
20
- line_item.errors[:quantity] << Spree.t(:out_of_stock, :scope => :order_populator, :item => display_name.inspect)
20
+ line_item.errors[:quantity] << Spree.t(:selected_quantity_not_available, :scope => :order_populator, :item => display_name.inspect)
21
21
  end
22
22
  end
23
23
  end
@@ -10,7 +10,7 @@ module Spree
10
10
 
11
11
  def total_on_hand
12
12
  if Spree::Config.track_inventory_levels
13
- stock_items.sum(&:count_on_hand)
13
+ stock_items.sum(:count_on_hand)
14
14
  else
15
15
  Float::INFINITY
16
16
  end
@@ -7,7 +7,7 @@ module Spree
7
7
  has_many :stock_movements
8
8
 
9
9
  validates_presence_of :stock_location, :variant
10
- validates_uniqueness_of :variant_id, scope: :stock_location_id
10
+ validates_uniqueness_of :variant_id, scope: [:stock_location_id, :deleted_at]
11
11
 
12
12
  attr_accessible :count_on_hand, :variant, :stock_location, :backorderable, :variant_id
13
13
 
@@ -24,7 +24,7 @@ module Spree
24
24
  def adjust_count_on_hand(value)
25
25
  self.with_lock do
26
26
  self.count_on_hand = self.count_on_hand + value
27
- process_backorders if in_stock?
27
+ process_backorders(count_on_hand - count_on_hand_was)
28
28
 
29
29
  self.save!
30
30
  end
@@ -32,7 +32,7 @@ module Spree
32
32
 
33
33
  def set_count_on_hand(value)
34
34
  self.count_on_hand = value
35
- process_backorders if in_stock?
35
+ process_backorders(count_on_hand - count_on_hand_was)
36
36
 
37
37
  self.save!
38
38
  end
@@ -51,10 +51,14 @@ module Spree
51
51
  write_attribute(:count_on_hand, value)
52
52
  end
53
53
 
54
- def process_backorders
55
- backordered_inventory_units.each do |unit|
56
- return unless in_stock?
57
- unit.fill_backorder
54
+ # Process backorders based on amount of stock received
55
+ # If stock was -20 and is now -15 (increase of 5 units), then we should process 5 inventory orders.
56
+ # If stock was -20 but then was -25 (decrease of 5 units), do nothing.
57
+ def process_backorders(number)
58
+ if number > 0
59
+ backordered_inventory_units.first(number).each do |unit|
60
+ unit.fill_backorder
61
+ end
58
62
  end
59
63
  end
60
64
  end
@@ -214,6 +214,10 @@ en:
214
214
  other: Zones
215
215
  errors:
216
216
  models:
217
+ spree/classification:
218
+ attributes:
219
+ taxon_id:
220
+ already_linked: "is already linked to this product"
217
221
  spree/credit_card:
218
222
  attributes:
219
223
  base:
@@ -395,6 +399,7 @@ en:
395
399
  capture: Capture
396
400
  card_code: Card Code
397
401
  card_number: Card Number
402
+ card_type: Brand
398
403
  card_type_is: Card type is
399
404
  cart: Cart
400
405
  categories: Categories
@@ -639,7 +644,6 @@ en:
639
644
  login_name: Login
640
645
  logout: Logout
641
646
  look_for_similar_items: Look for similar items
642
- maestro_or_solo_cards: Maestro/Solo cards
643
647
  mail_method_settings: Mail Method Settings
644
648
  mail_methods: Mail Methods
645
649
  make_refund: Make refund
@@ -751,6 +755,7 @@ en:
751
755
  order_number: Order
752
756
  order_populator:
753
757
  out_of_stock: ! '%{item} is out of stock.'
758
+ selected_quantity_not_available: ! 'Selected quantity of %{item} is not available.'
754
759
  please_enter_reasonable_quantity: Please enter a reasonable quantity.
755
760
  order_processed_successfully: Your order has been processed successfully
756
761
  order_state:
@@ -988,8 +993,9 @@ en:
988
993
  special_instructions: Special Instructions
989
994
  split: Split
990
995
  spree_gateway_error_flash_for_checkout: There was a problem with your payment information. Please check your information and try again.
996
+ ssl:
997
+ change_protocol: "Please switch to using HTTP (rather than HTTPS) and retry this request."
991
998
  start: Start
992
- start_date: Valid from
993
999
  state: State
994
1000
  state_based: State Based
995
1001
  states: States
@@ -1,6 +1,6 @@
1
1
  Spree::Country.create!({"name"=>"Chad", "iso3"=>"TCD", "iso"=>"TD", "iso_name"=>"CHAD", "numcode"=>"148"}, :without_protection => true)
2
2
  Spree::Country.create!({"name"=>"Faroe Islands", "iso3"=>"FRO", "iso"=>"FO", "iso_name"=>"FAROE ISLANDS", "numcode"=>"234"}, :without_protection => true)
3
- Spree::Country.create!({"name"=>"India", "iso3"=>"IND", "iso"=>"IN", "iso_name"=>"INDIA", "numcode"=>"356"}, :without_protection => true)
3
+ Spree::Country.create!({"name"=>"India", "iso3"=>"IND", "iso"=>"IN", "iso_name"=>"INDIA", "numcode"=>"356", "states_required"=>true}, :without_protection => true)
4
4
  Spree::Country.create!({"name"=>"Nicaragua", "iso3"=>"NIC", "iso"=>"NI", "iso_name"=>"NICARAGUA", "numcode"=>"558"}, :without_protection => true)
5
5
  Spree::Country.create!({"name"=>"Saint Lucia", "iso3"=>"LCA", "iso"=>"LC", "iso_name"=>"SAINT LUCIA", "numcode"=>"662"}, :without_protection => true)
6
6
  Spree::Country.create!({"name"=>"Fiji", "iso3"=>"FJI", "iso"=>"FJ", "iso_name"=>"FIJI", "numcode"=>"242"}, :without_protection => true)
@@ -8,14 +8,14 @@ Spree::Country.create!({"name"=>"Indonesia", "iso3"=>"IDN", "iso"=>"ID", "iso_na
8
8
  Spree::Country.create!({"name"=>"Niger", "iso3"=>"NER", "iso"=>"NE", "iso_name"=>"NIGER", "numcode"=>"562"}, :without_protection => true)
9
9
  Spree::Country.create!({"name"=>"Saint Pierre and Miquelon", "iso3"=>"SPM", "iso"=>"PM", "iso_name"=>"SAINT PIERRE AND MIQUELON", "numcode"=>"666"}, :without_protection => true)
10
10
  Spree::Country.create!({"name"=>"Finland", "iso3"=>"FIN", "iso"=>"FI", "iso_name"=>"FINLAND", "numcode"=>"246"}, :without_protection => true)
11
- Spree::Country.create!({"name"=>"Nigeria", "iso3"=>"NGA", "iso"=>"NG", "iso_name"=>"NIGERIA", "numcode"=>"566"}, :without_protection => true)
11
+ Spree::Country.create!({"name"=>"Nigeria", "iso3"=>"NGA", "iso"=>"NG", "iso_name"=>"NIGERIA", "numcode"=>"566", "states_required"=>true}, :without_protection => true)
12
12
  Spree::Country.create!({"name"=>"Saint Vincent and the Grenadines", "iso3"=>"VCT", "iso"=>"VC", "iso_name"=>"SAINT VINCENT AND THE GRENADINES", "numcode"=>"670"}, :without_protection => true)
13
13
  Spree::Country.create!({"name"=>"France", "iso3"=>"FRA", "iso"=>"FR", "iso_name"=>"FRANCE", "numcode"=>"250"}, :without_protection => true)
14
14
  Spree::Country.create!({"name"=>"Iran, Islamic Republic of", "iso3"=>"IRN", "iso"=>"IR", "iso_name"=>"IRAN, ISLAMIC REPUBLIC OF", "numcode"=>"364"}, :without_protection => true)
15
15
  Spree::Country.create!({"name"=>"Niue", "iso3"=>"NIU", "iso"=>"NU", "iso_name"=>"NIUE", "numcode"=>"570"}, :without_protection => true)
16
16
  Spree::Country.create!({"name"=>"Samoa", "iso3"=>"WSM", "iso"=>"WS", "iso_name"=>"SAMOA", "numcode"=>"882"}, :without_protection => true)
17
17
  Spree::Country.create!({"name"=>"French Guiana", "iso3"=>"GUF", "iso"=>"GF", "iso_name"=>"FRENCH GUIANA", "numcode"=>"254"}, :without_protection => true)
18
- Spree::Country.create!({"name"=>"Iraq", "iso3"=>"IRQ", "iso"=>"IQ", "iso_name"=>"IRAQ", "numcode"=>"368"}, :without_protection => true)
18
+ Spree::Country.create!({"name"=>"Iraq", "iso3"=>"IRQ", "iso"=>"IQ", "iso_name"=>"IRAQ", "numcode"=>"368", "states_required"=>true}, :without_protection => true)
19
19
  Spree::Country.create!({"name"=>"San Marino", "iso3"=>"SMR", "iso"=>"SM", "iso_name"=>"SAN MARINO", "numcode"=>"674"}, :without_protection => true)
20
20
  Spree::Country.create!({"name"=>"Ireland", "iso3"=>"IRL", "iso"=>"IE", "iso_name"=>"IRELAND", "numcode"=>"372"}, :without_protection => true)
21
21
  Spree::Country.create!({"name"=>"Sao Tome and Principe", "iso3"=>"STP", "iso"=>"ST", "iso_name"=>"SAO TOME AND PRINCIPE", "numcode"=>"678"}, :without_protection => true)
@@ -26,7 +26,7 @@ Spree::Country.create!({"name"=>"Senegal", "iso3"=>"SEN", "iso"=>"SN", "iso_name
26
26
  Spree::Country.create!({"name"=>"Jamaica", "iso3"=>"JAM", "iso"=>"JM", "iso_name"=>"JAMAICA", "numcode"=>"388"}, :without_protection => true)
27
27
  Spree::Country.create!({"name"=>"Japan", "iso3"=>"JPN", "iso"=>"JP", "iso_name"=>"JAPAN", "numcode"=>"392"}, :without_protection => true)
28
28
  Spree::Country.create!({"name"=>"Jordan", "iso3"=>"JOR", "iso"=>"JO", "iso_name"=>"JORDAN", "numcode"=>"400"}, :without_protection => true)
29
- Spree::Country.create!({"name"=>"Belgium", "iso3"=>"BEL", "iso"=>"BE", "iso_name"=>"BELGIUM", "numcode"=>"56"}, :without_protection => true)
29
+ Spree::Country.create!({"name"=>"Belgium", "iso3"=>"BEL", "iso"=>"BE", "iso_name"=>"BELGIUM", "numcode"=>"56", "states_required"=>true}, :without_protection => true)
30
30
  Spree::Country.create!({"name"=>"Belize", "iso3"=>"BLZ", "iso"=>"BZ", "iso_name"=>"BELIZE", "numcode"=>"84"}, :without_protection => true)
31
31
  Spree::Country.create!({"name"=>"Kazakhstan", "iso3"=>"KAZ", "iso"=>"KZ", "iso_name"=>"KAZAKHSTAN", "numcode"=>"398"}, :without_protection => true)
32
32
  Spree::Country.create!({"name"=>"Uganda", "iso3"=>"UGA", "iso"=>"UG", "iso_name"=>"UGANDA", "numcode"=>"800"}, :without_protection => true)
@@ -35,19 +35,19 @@ Spree::Country.create!({"name"=>"Kenya", "iso3"=>"KEN", "iso"=>"KE", "iso_name"=
35
35
  Spree::Country.create!({"name"=>"Ukraine", "iso3"=>"UKR", "iso"=>"UA", "iso_name"=>"UKRAINE", "numcode"=>"804"}, :without_protection => true)
36
36
  Spree::Country.create!({"name"=>"Bermuda", "iso3"=>"BMU", "iso"=>"BM", "iso_name"=>"BERMUDA", "numcode"=>"60"}, :without_protection => true)
37
37
  Spree::Country.create!({"name"=>"Kiribati", "iso3"=>"KIR", "iso"=>"KI", "iso_name"=>"KIRIBATI", "numcode"=>"296"}, :without_protection => true)
38
- Spree::Country.create!({"name"=>"Mexico", "iso3"=>"MEX", "iso"=>"MX", "iso_name"=>"MEXICO", "numcode"=>"484"}, :without_protection => true)
39
- Spree::Country.create!({"name"=>"United Arab Emirates", "iso3"=>"ARE", "iso"=>"AE", "iso_name"=>"UNITED ARAB EMIRATES", "numcode"=>"784"}, :without_protection => true)
38
+ Spree::Country.create!({"name"=>"Mexico", "iso3"=>"MEX", "iso"=>"MX", "iso_name"=>"MEXICO", "numcode"=>"484", "states_required"=>true}, :without_protection => true)
39
+ Spree::Country.create!({"name"=>"United Arab Emirates", "iso3"=>"ARE", "iso"=>"AE", "iso_name"=>"UNITED ARAB EMIRATES", "numcode"=>"784", "states_required"=>true}, :without_protection => true)
40
40
  Spree::Country.create!({"name"=>"Bhutan", "iso3"=>"BTN", "iso"=>"BT", "iso_name"=>"BHUTAN", "numcode"=>"64"}, :without_protection => true)
41
41
  Spree::Country.create!({"name"=>"Cuba", "iso3"=>"CUB", "iso"=>"CU", "iso_name"=>"CUBA", "numcode"=>"192"}, :without_protection => true)
42
42
  Spree::Country.create!({"name"=>"North Korea", "iso3"=>"PRK", "iso"=>"KP", "iso_name"=>"KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF", "numcode"=>"408"}, :without_protection => true)
43
- Spree::Country.create!({"name"=>"Micronesia, Federated States of", "iso3"=>"FSM", "iso"=>"FM", "iso_name"=>"MICRONESIA, FEDERATED STATES OF", "numcode"=>"583"}, :without_protection => true)
43
+ Spree::Country.create!({"name"=>"Micronesia, Federated States of", "iso3"=>"FSM", "iso"=>"FM", "iso_name"=>"MICRONESIA, FEDERATED STATES OF", "numcode"=>"583", "states_required"=>true}, :without_protection => true)
44
44
  Spree::Country.create!({"name"=>"United Kingdom", "iso3"=>"GBR", "iso"=>"GB", "iso_name"=>"UNITED KINGDOM", "numcode"=>"826"}, :without_protection => true)
45
45
  Spree::Country.create!({"name"=>"Bolivia", "iso3"=>"BOL", "iso"=>"BO", "iso_name"=>"BOLIVIA", "numcode"=>"68"}, :without_protection => true)
46
46
  Spree::Country.create!({"name"=>"Cyprus", "iso3"=>"CYP", "iso"=>"CY", "iso_name"=>"CYPRUS", "numcode"=>"196"}, :without_protection => true)
47
47
  Spree::Country.create!({"name"=>"South Korea", "iso3"=>"KOR", "iso"=>"KR", "iso_name"=>"KOREA, REPUBLIC OF", "numcode"=>"410"}, :without_protection => true)
48
48
  Spree::Country.create!({"name"=>"Moldova, Republic of", "iso3"=>"MDA", "iso"=>"MD", "iso_name"=>"MOLDOVA, REPUBLIC OF", "numcode"=>"498"}, :without_protection => true)
49
- Spree::Country.create!({"name"=>"United States", "iso3"=>"USA", "iso"=>"US", "iso_name"=>"UNITED STATES", "numcode"=>"840"}, :without_protection => true)
50
- Spree::Country.create!({"name"=>"Bosnia and Herzegovina", "iso3"=>"BIH", "iso"=>"BA", "iso_name"=>"BOSNIA AND HERZEGOVINA", "numcode"=>"70"}, :without_protection => true)
49
+ Spree::Country.create!({"name"=>"United States", "iso3"=>"USA", "iso"=>"US", "iso_name"=>"UNITED STATES", "numcode"=>"840", "states_required"=>true}, :without_protection => true)
50
+ Spree::Country.create!({"name"=>"Bosnia and Herzegovina", "iso3"=>"BIH", "iso"=>"BA", "iso_name"=>"BOSNIA AND HERZEGOVINA", "numcode"=>"70", "states_required"=>true}, :without_protection => true)
51
51
  Spree::Country.create!({"name"=>"Czech Republic", "iso3"=>"CZE", "iso"=>"CZ", "iso_name"=>"CZECH REPUBLIC", "numcode"=>"203"}, :without_protection => true)
52
52
  Spree::Country.create!({"name"=>"Kuwait", "iso3"=>"KWT", "iso"=>"KW", "iso_name"=>"KUWAIT", "numcode"=>"414"}, :without_protection => true)
53
53
  Spree::Country.create!({"name"=>"Monaco", "iso3"=>"MCO", "iso"=>"MC", "iso_name"=>"MONACO", "numcode"=>"492"}, :without_protection => true)
@@ -58,7 +58,7 @@ Spree::Country.create!({"name"=>"Guadeloupe", "iso3"=>"GLP", "iso"=>"GP", "iso_n
58
58
  Spree::Country.create!({"name"=>"Kyrgyzstan", "iso3"=>"KGZ", "iso"=>"KG", "iso_name"=>"KYRGYZSTAN", "numcode"=>"417"}, :without_protection => true)
59
59
  Spree::Country.create!({"name"=>"Mongolia", "iso3"=>"MNG", "iso"=>"MN", "iso_name"=>"MONGOLIA", "numcode"=>"496"}, :without_protection => true)
60
60
  Spree::Country.create!({"name"=>"Philippines", "iso3"=>"PHL", "iso"=>"PH", "iso_name"=>"PHILIPPINES", "numcode"=>"608"}, :without_protection => true)
61
- Spree::Country.create!({"name"=>"Brazil", "iso3"=>"BRA", "iso"=>"BR", "iso_name"=>"BRAZIL", "numcode"=>"76"}, :without_protection => true)
61
+ Spree::Country.create!({"name"=>"Brazil", "iso3"=>"BRA", "iso"=>"BR", "iso_name"=>"BRAZIL", "numcode"=>"76", "states_required"=>true}, :without_protection => true)
62
62
  Spree::Country.create!({"name"=>"Djibouti", "iso3"=>"DJI", "iso"=>"DJ", "iso_name"=>"DJIBOUTI", "numcode"=>"262"}, :without_protection => true)
63
63
  Spree::Country.create!({"name"=>"Guam", "iso3"=>"GUM", "iso"=>"GU", "iso_name"=>"GUAM", "numcode"=>"316"}, :without_protection => true)
64
64
  Spree::Country.create!({"name"=>"Lao People's Democratic Republic", "iso3"=>"LAO", "iso"=>"LA", "iso_name"=>"LAO PEOPLE'S DEMOCRATIC REPUBLIC", "numcode"=>"418"}, :without_protection => true)
@@ -74,8 +74,8 @@ Spree::Country.create!({"name"=>"Vanuatu", "iso3"=>"VUT", "iso"=>"VU", "iso_name
74
74
  Spree::Country.create!({"name"=>"Dominican Republic", "iso3"=>"DOM", "iso"=>"DO", "iso_name"=>"DOMINICAN REPUBLIC", "numcode"=>"214"}, :without_protection => true)
75
75
  Spree::Country.create!({"name"=>"Mozambique", "iso3"=>"MOZ", "iso"=>"MZ", "iso_name"=>"MOZAMBIQUE", "numcode"=>"508"}, :without_protection => true)
76
76
  Spree::Country.create!({"name"=>"Portugal", "iso3"=>"PRT", "iso"=>"PT", "iso_name"=>"PORTUGAL", "numcode"=>"620"}, :without_protection => true)
77
- Spree::Country.create!({"name"=>"Sudan", "iso3"=>"SDN", "iso"=>"SD", "iso_name"=>"SUDAN", "numcode"=>"736"}, :without_protection => true)
78
- Spree::Country.create!({"name"=>"Venezuela", "iso3"=>"VEN", "iso"=>"VE", "iso_name"=>"VENEZUELA", "numcode"=>"862"}, :without_protection => true)
77
+ Spree::Country.create!({"name"=>"Sudan", "iso3"=>"SDN", "iso"=>"SD", "iso_name"=>"SUDAN", "numcode"=>"736", "states_required"=>true}, :without_protection => true)
78
+ Spree::Country.create!({"name"=>"Venezuela", "iso3"=>"VEN", "iso"=>"VE", "iso_name"=>"VENEZUELA", "numcode"=>"862", "states_required"=>true}, :without_protection => true)
79
79
  Spree::Country.create!({"name"=>"Ecuador", "iso3"=>"ECU", "iso"=>"EC", "iso_name"=>"ECUADOR", "numcode"=>"218"}, :without_protection => true)
80
80
  Spree::Country.create!({"name"=>"Guinea", "iso3"=>"GIN", "iso"=>"GN", "iso_name"=>"GUINEA", "numcode"=>"324"}, :without_protection => true)
81
81
  Spree::Country.create!({"name"=>"Myanmar", "iso3"=>"MMR", "iso"=>"MM", "iso_name"=>"MYANMAR", "numcode"=>"104"}, :without_protection => true)
@@ -94,11 +94,11 @@ Spree::Country.create!({"name"=>"Haiti", "iso3"=>"HTI", "iso"=>"HT", "iso_name"=
94
94
  Spree::Country.create!({"name"=>"Romania", "iso3"=>"ROM", "iso"=>"RO", "iso_name"=>"ROMANIA", "numcode"=>"642"}, :without_protection => true)
95
95
  Spree::Country.create!({"name"=>"Swaziland", "iso3"=>"SWZ", "iso"=>"SZ", "iso_name"=>"SWAZILAND", "numcode"=>"748"}, :without_protection => true)
96
96
  Spree::Country.create!({"name"=>"Holy See (Vatican City State)", "iso3"=>"VAT", "iso"=>"VA", "iso_name"=>"HOLY SEE (VATICAN CITY STATE)", "numcode"=>"336"}, :without_protection => true)
97
- Spree::Country.create!({"name"=>"Russian Federation", "iso3"=>"RUS", "iso"=>"RU", "iso_name"=>"RUSSIAN FEDERATION", "numcode"=>"643"}, :without_protection => true)
97
+ Spree::Country.create!({"name"=>"Russian Federation", "iso3"=>"RUS", "iso"=>"RU", "iso_name"=>"RUSSIAN FEDERATION", "numcode"=>"643", "states_required"=>true}, :without_protection => true)
98
98
  Spree::Country.create!({"name"=>"Sweden", "iso3"=>"SWE", "iso"=>"SE", "iso_name"=>"SWEDEN", "numcode"=>"752"}, :without_protection => true)
99
99
  Spree::Country.create!({"name"=>"Honduras", "iso3"=>"HND", "iso"=>"HN", "iso_name"=>"HONDURAS", "numcode"=>"340"}, :without_protection => true)
100
100
  Spree::Country.create!({"name"=>"Rwanda", "iso3"=>"RWA", "iso"=>"RW", "iso_name"=>"RWANDA", "numcode"=>"646"}, :without_protection => true)
101
- Spree::Country.create!({"name"=>"Switzerland", "iso3"=>"CHE", "iso"=>"CH", "iso_name"=>"SWITZERLAND", "numcode"=>"756"}, :without_protection => true)
101
+ Spree::Country.create!({"name"=>"Switzerland", "iso3"=>"CHE", "iso"=>"CH", "iso_name"=>"SWITZERLAND", "numcode"=>"756", "states_required"=>true}, :without_protection => true)
102
102
  Spree::Country.create!({"name"=>"Hong Kong", "iso3"=>"HKG", "iso"=>"HK", "iso_name"=>"HONG KONG", "numcode"=>"344"}, :without_protection => true)
103
103
  Spree::Country.create!({"name"=>"Syrian Arab Republic", "iso3"=>"SYR", "iso"=>"SY", "iso_name"=>"SYRIAN ARAB REPUBLIC", "numcode"=>"760"}, :without_protection => true)
104
104
  Spree::Country.create!({"name"=>"Taiwan", "iso3"=>"TWN", "iso"=>"TW", "iso_name"=>"TAIWAN, PROVINCE OF CHINA", "numcode"=>"158"}, :without_protection => true)
@@ -106,9 +106,9 @@ Spree::Country.create!({"name"=>"Tajikistan", "iso3"=>"TJK", "iso"=>"TJ", "iso_n
106
106
  Spree::Country.create!({"name"=>"Tanzania, United Republic of", "iso3"=>"TZA", "iso"=>"TZ", "iso_name"=>"TANZANIA, UNITED REPUBLIC OF", "numcode"=>"834"}, :without_protection => true)
107
107
  Spree::Country.create!({"name"=>"Armenia", "iso3"=>"ARM", "iso"=>"AM", "iso_name"=>"ARMENIA", "numcode"=>"51"}, :without_protection => true)
108
108
  Spree::Country.create!({"name"=>"Aruba", "iso3"=>"ABW", "iso"=>"AW", "iso_name"=>"ARUBA", "numcode"=>"533"}, :without_protection => true)
109
- Spree::Country.create!({"name"=>"Australia", "iso3"=>"AUS", "iso"=>"AU", "iso_name"=>"AUSTRALIA", "numcode"=>"36"}, :without_protection => true)
109
+ Spree::Country.create!({"name"=>"Australia", "iso3"=>"AUS", "iso"=>"AU", "iso_name"=>"AUSTRALIA", "numcode"=>"36", "states_required"=>true}, :without_protection => true)
110
110
  Spree::Country.create!({"name"=>"Thailand", "iso3"=>"THA", "iso"=>"TH", "iso_name"=>"THAILAND", "numcode"=>"764"}, :without_protection => true)
111
- Spree::Country.create!({"name"=>"Austria", "iso3"=>"AUT", "iso"=>"AT", "iso_name"=>"AUSTRIA", "numcode"=>"40"}, :without_protection => true)
111
+ Spree::Country.create!({"name"=>"Austria", "iso3"=>"AUT", "iso"=>"AT", "iso_name"=>"AUSTRIA", "numcode"=>"40", "states_required"=>true}, :without_protection => true)
112
112
  Spree::Country.create!({"name"=>"Madagascar", "iso3"=>"MDG", "iso"=>"MG", "iso_name"=>"MADAGASCAR", "numcode"=>"450"}, :without_protection => true)
113
113
  Spree::Country.create!({"name"=>"Togo", "iso3"=>"TGO", "iso"=>"TG", "iso_name"=>"TOGO", "numcode"=>"768"}, :without_protection => true)
114
114
  Spree::Country.create!({"name"=>"Azerbaijan", "iso3"=>"AZE", "iso"=>"AZ", "iso_name"=>"AZERBAIJAN", "numcode"=>"31"}, :without_protection => true)
@@ -117,14 +117,14 @@ Spree::Country.create!({"name"=>"Malawi", "iso3"=>"MWI", "iso"=>"MW", "iso_name"
117
117
  Spree::Country.create!({"name"=>"Tokelau", "iso3"=>"TKL", "iso"=>"TK", "iso_name"=>"TOKELAU", "numcode"=>"772"}, :without_protection => true)
118
118
  Spree::Country.create!({"name"=>"Bahamas", "iso3"=>"BHS", "iso"=>"BS", "iso_name"=>"BAHAMAS", "numcode"=>"44"}, :without_protection => true)
119
119
  Spree::Country.create!({"name"=>"China", "iso3"=>"CHN", "iso"=>"CN", "iso_name"=>"CHINA", "numcode"=>"156"}, :without_protection => true)
120
- Spree::Country.create!({"name"=>"Malaysia", "iso3"=>"MYS", "iso"=>"MY", "iso_name"=>"MALAYSIA", "numcode"=>"458"}, :without_protection => true)
120
+ Spree::Country.create!({"name"=>"Malaysia", "iso3"=>"MYS", "iso"=>"MY", "iso_name"=>"MALAYSIA", "numcode"=>"458", "states_required"=>true}, :without_protection => true)
121
121
  Spree::Country.create!({"name"=>"Tonga", "iso3"=>"TON", "iso"=>"TO", "iso_name"=>"TONGA", "numcode"=>"776"}, :without_protection => true)
122
122
  Spree::Country.create!({"name"=>"Bahrain", "iso3"=>"BHR", "iso"=>"BH", "iso_name"=>"BAHRAIN", "numcode"=>"48"}, :without_protection => true)
123
123
  Spree::Country.create!({"name"=>"Colombia", "iso3"=>"COL", "iso"=>"CO", "iso_name"=>"COLOMBIA", "numcode"=>"170"}, :without_protection => true)
124
124
  Spree::Country.create!({"name"=>"Maldives", "iso3"=>"MDV", "iso"=>"MV", "iso_name"=>"MALDIVES", "numcode"=>"462"}, :without_protection => true)
125
125
  Spree::Country.create!({"name"=>"Trinidad and Tobago", "iso3"=>"TTO", "iso"=>"TT", "iso_name"=>"TRINIDAD AND TOBAGO", "numcode"=>"780"}, :without_protection => true)
126
126
  Spree::Country.create!({"name"=>"Bangladesh", "iso3"=>"BGD", "iso"=>"BD", "iso_name"=>"BANGLADESH", "numcode"=>"50"}, :without_protection => true)
127
- Spree::Country.create!({"name"=>"Comoros", "iso3"=>"COM", "iso"=>"KM", "iso_name"=>"COMOROS", "numcode"=>"174"}, :without_protection => true)
127
+ Spree::Country.create!({"name"=>"Comoros", "iso3"=>"COM", "iso"=>"KM", "iso_name"=>"COMOROS", "numcode"=>"174", "states_required"=>true}, :without_protection => true)
128
128
  Spree::Country.create!({"name"=>"French Polynesia", "iso3"=>"PYF", "iso"=>"PF", "iso_name"=>"FRENCH POLYNESIA", "numcode"=>"258"}, :without_protection => true)
129
129
  Spree::Country.create!({"name"=>"Mali", "iso3"=>"MLI", "iso"=>"ML", "iso_name"=>"MALI", "numcode"=>"466"}, :without_protection => true)
130
130
  Spree::Country.create!({"name"=>"Norfolk Island", "iso3"=>"NFK", "iso"=>"NF", "iso_name"=>"NORFOLK ISLAND", "numcode"=>"574"}, :without_protection => true)
@@ -148,7 +148,7 @@ Spree::Country.create!({"name"=>"Seychelles", "iso3"=>"SYC", "iso"=>"SC", "iso_n
148
148
  Spree::Country.create!({"name"=>"Turks and Caicos Islands", "iso3"=>"TCA", "iso"=>"TC", "iso_name"=>"TURKS AND CAICOS ISLANDS", "numcode"=>"796"}, :without_protection => true)
149
149
  Spree::Country.create!({"name"=>"Georgia", "iso3"=>"GEO", "iso"=>"GE", "iso_name"=>"GEORGIA", "numcode"=>"268"}, :without_protection => true)
150
150
  Spree::Country.create!({"name"=>"Mauritania", "iso3"=>"MRT", "iso"=>"MR", "iso_name"=>"MAURITANIA", "numcode"=>"478"}, :without_protection => true)
151
- Spree::Country.create!({"name"=>"Pakistan", "iso3"=>"PAK", "iso"=>"PK", "iso_name"=>"PAKISTAN", "numcode"=>"586"}, :without_protection => true)
151
+ Spree::Country.create!({"name"=>"Pakistan", "iso3"=>"PAK", "iso"=>"PK", "iso_name"=>"PAKISTAN", "numcode"=>"586", "states_required"=>true}, :without_protection => true)
152
152
  Spree::Country.create!({"name"=>"Sierra Leone", "iso3"=>"SLE", "iso"=>"SL", "iso_name"=>"SIERRA LEONE", "numcode"=>"694"}, :without_protection => true)
153
153
  Spree::Country.create!({"name"=>"Tuvalu", "iso3"=>"TUV", "iso"=>"TV", "iso_name"=>"TUVALU", "numcode"=>"798"}, :without_protection => true)
154
154
  Spree::Country.create!({"name"=>"Costa Rica", "iso3"=>"CRI", "iso"=>"CR", "iso_name"=>"COSTA RICA", "numcode"=>"188"}, :without_protection => true)
@@ -169,7 +169,7 @@ Spree::Country.create!({"name"=>"Greece", "iso3"=>"GRC", "iso"=>"GR", "iso_name"
169
169
  Spree::Country.create!({"name"=>"Peru", "iso3"=>"PER", "iso"=>"PE", "iso_name"=>"PERU", "numcode"=>"604"}, :without_protection => true)
170
170
  Spree::Country.create!({"name"=>"Solomon Islands", "iso3"=>"SLB", "iso"=>"SB", "iso_name"=>"SOLOMON ISLANDS", "numcode"=>"90"}, :without_protection => true)
171
171
  Spree::Country.create!({"name"=>"Greenland", "iso3"=>"GRL", "iso"=>"GL", "iso_name"=>"GREENLAND", "numcode"=>"304"}, :without_protection => true)
172
- Spree::Country.create!({"name"=>"Somalia", "iso3"=>"SOM", "iso"=>"SO", "iso_name"=>"SOMALIA", "numcode"=>"706"}, :without_protection => true)
172
+ Spree::Country.create!({"name"=>"Somalia", "iso3"=>"SOM", "iso"=>"SO", "iso_name"=>"SOMALIA", "numcode"=>"706", "states_required"=>true}, :without_protection => true)
173
173
  Spree::Country.create!({"name"=>"Grenada", "iso3"=>"GRD", "iso"=>"GD", "iso_name"=>"GRENADA", "numcode"=>"308"}, :without_protection => true)
174
174
  Spree::Country.create!({"name"=>"South Africa", "iso3"=>"ZAF", "iso"=>"ZA", "iso_name"=>"SOUTH AFRICA", "numcode"=>"710"}, :without_protection => true)
175
175
  Spree::Country.create!({"name"=>"Spain", "iso3"=>"ESP", "iso"=>"ES", "iso_name"=>"SPAIN", "numcode"=>"724"}, :without_protection => true)
@@ -197,11 +197,11 @@ Spree::Country.create!({"name"=>"Virgin Islands, U.S.", "iso3"=>"VIR", "iso"=>"V
197
197
  Spree::Country.create!({"name"=>"Antigua and Barbuda", "iso3"=>"ATG", "iso"=>"AG", "iso_name"=>"ANTIGUA AND BARBUDA", "numcode"=>"28"}, :without_protection => true)
198
198
  Spree::Country.create!({"name"=>"Cameroon", "iso3"=>"CMR", "iso"=>"CM", "iso_name"=>"CAMEROON", "numcode"=>"120"}, :without_protection => true)
199
199
  Spree::Country.create!({"name"=>"Liechtenstein", "iso3"=>"LIE", "iso"=>"LI", "iso_name"=>"LIECHTENSTEIN", "numcode"=>"438"}, :without_protection => true)
200
- Spree::Country.create!({"name"=>"Nepal", "iso3"=>"NPL", "iso"=>"NP", "iso_name"=>"NEPAL", "numcode"=>"524"}, :without_protection => true)
200
+ Spree::Country.create!({"name"=>"Nepal", "iso3"=>"NPL", "iso"=>"NP", "iso_name"=>"NEPAL", "numcode"=>"524", "states_required"=>true}, :without_protection => true)
201
201
  Spree::Country.create!({"name"=>"Wallis and Futuna", "iso3"=>"WLF", "iso"=>"WF", "iso_name"=>"WALLIS AND FUTUNA", "numcode"=>"876"}, :without_protection => true)
202
202
  Spree::Country.create!({"name"=>"Western Sahara", "iso3"=>"ESH", "iso"=>"EH", "iso_name"=>"WESTERN SAHARA", "numcode"=>"732"}, :without_protection => true)
203
- Spree::Country.create!({"name"=>"Argentina", "iso3"=>"ARG", "iso"=>"AR", "iso_name"=>"ARGENTINA", "numcode"=>"32"}, :without_protection => true)
204
- Spree::Country.create!({"name"=>"Canada", "iso3"=>"CAN", "iso"=>"CA", "iso_name"=>"CANADA", "numcode"=>"124"}, :without_protection => true)
203
+ Spree::Country.create!({"name"=>"Argentina", "iso3"=>"ARG", "iso"=>"AR", "iso_name"=>"ARGENTINA", "numcode"=>"32", "states_required"=>true}, :without_protection => true)
204
+ Spree::Country.create!({"name"=>"Canada", "iso3"=>"CAN", "iso"=>"CA", "iso_name"=>"CANADA", "numcode"=>"124", "states_required"=>true}, :without_protection => true)
205
205
  Spree::Country.create!({"name"=>"Eritrea", "iso3"=>"ERI", "iso"=>"ER", "iso_name"=>"ERITREA", "numcode"=>"232"}, :without_protection => true)
206
206
  Spree::Country.create!({"name"=>"Lithuania", "iso3"=>"LTU", "iso"=>"LT", "iso_name"=>"LITHUANIA", "numcode"=>"440"}, :without_protection => true)
207
207
  Spree::Country.create!({"name"=>"Netherlands", "iso3"=>"NLD", "iso"=>"NL", "iso_name"=>"NETHERLANDS", "numcode"=>"528"}, :without_protection => true)
@@ -213,7 +213,7 @@ Spree::Country.create!({"name"=>"Netherlands Antilles", "iso3"=>"ANT", "iso"=>"A
213
213
  Spree::Country.create!({"name"=>"Saint Helena", "iso3"=>"SHN", "iso"=>"SH", "iso_name"=>"SAINT HELENA", "numcode"=>"654"}, :without_protection => true)
214
214
  Spree::Country.create!({"name"=>"Zambia", "iso3"=>"ZMB", "iso"=>"ZM", "iso_name"=>"ZAMBIA", "numcode"=>"894"}, :without_protection => true)
215
215
  Spree::Country.create!({"name"=>"Cayman Islands", "iso3"=>"CYM", "iso"=>"KY", "iso_name"=>"CAYMAN ISLANDS", "numcode"=>"136"}, :without_protection => true)
216
- Spree::Country.create!({"name"=>"Ethiopia", "iso3"=>"ETH", "iso"=>"ET", "iso_name"=>"ETHIOPIA", "numcode"=>"231"}, :without_protection => true)
216
+ Spree::Country.create!({"name"=>"Ethiopia", "iso3"=>"ETH", "iso"=>"ET", "iso_name"=>"ETHIOPIA", "numcode"=>"231", "states_required"=>true}, :without_protection => true)
217
217
  Spree::Country.create!({"name"=>"Hungary", "iso3"=>"HUN", "iso"=>"HU", "iso_name"=>"HUNGARY", "numcode"=>"348"}, :without_protection => true)
218
218
  Spree::Country.create!({"name"=>"Macao", "iso3"=>"MAC", "iso"=>"MO", "iso_name"=>"MACAO", "numcode"=>"446"}, :without_protection => true)
219
219
  Spree::Country.create!({"name"=>"New Caledonia", "iso3"=>"NCL", "iso"=>"NC", "iso_name"=>"NEW CALEDONIA", "numcode"=>"540"}, :without_protection => true)
@@ -223,7 +223,7 @@ Spree::Country.create!({"name"=>"Falkland Islands (Malvinas)", "iso3"=>"FLK", "i
223
223
  Spree::Country.create!({"name"=>"Iceland", "iso3"=>"ISL", "iso"=>"IS", "iso_name"=>"ICELAND", "numcode"=>"352"}, :without_protection => true)
224
224
  Spree::Country.create!({"name"=>"Macedonia", "iso3"=>"MKD", "iso"=>"MK", "iso_name"=>"MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF", "numcode"=>"807"}, :without_protection => true)
225
225
  Spree::Country.create!({"name"=>"New Zealand", "iso3"=>"NZL", "iso"=>"NZ", "iso_name"=>"NEW ZEALAND", "numcode"=>"554"}, :without_protection => true)
226
- Spree::Country.create!({"name"=>"Saint Kitts and Nevis", "iso3"=>"KNA", "iso"=>"KN", "iso_name"=>"SAINT KITTS AND NEVIS", "numcode"=>"659"}, :without_protection => true)
226
+ Spree::Country.create!({"name"=>"Saint Kitts and Nevis", "iso3"=>"KNA", "iso"=>"KN", "iso_name"=>"SAINT KITTS AND NEVIS", "numcode"=>"659", "states_required"=>true}, :without_protection => true)
227
227
  Spree::Country.create!({"name"=>"Serbia", "iso3"=>"SRB", "iso"=>"RS", "iso_name" => "SERBIA", "numcode"=>"999"}, :without_protection => true)
228
228
 
229
229
  Spree::Config[:default_country_id] = Spree::Country.find_by_name("United States").id
@@ -4,10 +4,13 @@ class CreateDefaultStock < ActiveRecord::Migration
4
4
  Spree::StockItem.skip_callback(:save, :after, :process_backorders)
5
5
  location = Spree::StockLocation.new(name: 'default')
6
6
  location.save(validate: false)
7
+
7
8
  Spree::Variant.all.each do |variant|
8
- stock_item = location.stock_items.build(variant: variant)
9
+ stock_item = Spree::StockItem.unscoped.build(stock_location: location, variant: variant)
9
10
  stock_item.send(:count_on_hand=, variant.count_on_hand)
10
- stock_item.save!
11
+ # Avoid running default_scope defined by acts_as_paranoid, related to #3805,
12
+ # validations would run a query with a delete_at column tha might not be present yet
13
+ stock_item.save! validate: false
11
14
  end
12
15
 
13
16
  remove_column :spree_variants, :count_on_hand
@@ -0,0 +1,15 @@
1
+ class AddShippingCategoryToShippingMethodsAndProducts < ActiveRecord::Migration
2
+ def up
3
+ default_category = Spree::ShippingCategory.first
4
+ default_category ||= Spree::ShippingCategory.create!(:name => "Default")
5
+
6
+ Spree::ShippingMethod.all.each do |method|
7
+ method.shipping_categories << default_category if method.shipping_categories.blank?
8
+ end
9
+
10
+ Spree::Product.where(shipping_category_id: nil).update_all(shipping_category_id: default_category.id)
11
+ end
12
+
13
+ def down
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ class MigrateOldShippingCalculators < ActiveRecord::Migration
2
+ def up
3
+ Spree::ShippingMethod.all.each do |shipping_method|
4
+ old_calculator = shipping_method.calculator
5
+ next if old_calculator.class < Spree::ShippingCalculator # We don't want to mess with new shipping calculators
6
+ new_calculator = eval("Spree::Calculator::Shipping::#{old_calculator.class.name.demodulize}").new
7
+ new_calculator.preferences.keys.each do |pref|
8
+ # Preferences can't be read/set by name, you have to prefix preferred_
9
+ pref_method = "preferred_#{pref}"
10
+ new_calculator.send("#{pref_method}=", old_calculator.send(pref_method))
11
+ end
12
+ new_calculator.calculable = old_calculator.calculable
13
+ new_calculator.save
14
+ end
15
+ end
16
+
17
+ def down
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ class ChangeStatesRequiredForCountries < ActiveRecord::Migration
2
+ def up
3
+ change_column_default :spree_countries, :states_required, false
4
+ end
5
+
6
+ def down
7
+ change_column_default :spree_countries, :states_required, true
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ class RemoveUnusedCreditCardFields < ActiveRecord::Migration
2
+ def up
3
+ remove_column :spree_credit_cards, :start_month
4
+ remove_column :spree_credit_cards, :start_year
5
+ remove_column :spree_credit_cards, :issue_number
6
+ end
7
+ def down
8
+ add_column :spree_credit_cards, :start_month, :string
9
+ add_column :spree_credit_cards, :start_year, :string
10
+ add_column :spree_credit_cards, :issue_number, :string
11
+ end
12
+ end
@@ -61,7 +61,7 @@ module Spree
61
61
  if session[:order_id].nil? && last_incomplete_order
62
62
  session[:order_id] = last_incomplete_order.id
63
63
  elsif current_order(true) && last_incomplete_order && current_order != last_incomplete_order
64
- current_order.merge!(last_incomplete_order)
64
+ current_order.merge!(last_incomplete_order, user)
65
65
  end
66
66
  end
67
67
  end
@@ -6,21 +6,20 @@ module Spree
6
6
 
7
7
  included do
8
8
  before_filter :force_non_ssl_redirect, :if => Proc.new { Spree::Config[:redirect_https_to_http] }
9
- before_filter :force_ssl_redirect, :if => Proc.new { Rails.application.config.force_ssl }
9
+ class_attribute :ssl_allowed_actions
10
10
 
11
11
  def self.ssl_allowed(*actions)
12
- class_attribute :ssl_allowed_actions
13
- self.ssl_allowed_actions = actions
12
+ self.ssl_allowed_actions ||= []
13
+ self.ssl_allowed_actions.concat actions
14
14
  end
15
15
 
16
16
  def self.ssl_required(*actions)
17
- class_attribute :ssl_required_actions
18
- self.ssl_required_actions = actions
17
+ ssl_allowed *actions
19
18
  if ssl_supported?
20
- if ssl_required_actions.empty? or Rails.application.config.force_ssl
19
+ if actions.empty? or Rails.application.config.force_ssl
21
20
  force_ssl
22
21
  else
23
- force_ssl :only => ssl_required_actions
22
+ force_ssl :only => actions
24
23
  end
25
24
  end
26
25
  end
@@ -32,36 +31,30 @@ module Spree
32
31
  end
33
32
 
34
33
  private
34
+ def ssl_allowed?
35
+ (!ssl_allowed_actions.nil? && (ssl_allowed_actions.empty? || ssl_allowed_actions.include?(action_name.to_sym)))
36
+ end
35
37
 
36
38
  # Redirect the existing request to use the HTTP protocol.
37
39
  #
38
40
  # ==== Parameters
39
41
  # * <tt>host</tt> - Redirect to a different host name
40
42
  def force_non_ssl_redirect(host = nil)
41
- return true if defined?(ssl_allowed_actions) and ssl_allowed_actions.include?(action_name.to_sym)
42
- if request.ssl? and (!defined?(ssl_required_actions) or !ssl_required_actions.include?(action_name.to_sym))
43
- redirect_options = {:protocol => 'http://', :status => :moved_permanently}
44
- redirect_options.merge!(:host => host) if host
45
- redirect_options.merge!(:params => request.query_parameters)
46
- flash.keep if respond_to?(:flash)
47
- redirect_to redirect_options
48
- end
49
- end
50
-
51
- # Redirect the existing request to use the HTTPS protocol.
52
- #
53
- # ==== Parameters
54
- # * <tt>host</tt> - Redirect to a different host name
55
- def force_ssl_redirect(host = nil)
56
- unless request.ssl?
57
- redirect_options = {:protocol => 'https://', :status => :moved_permanently}
58
- redirect_options.merge!(:host => host) if host
59
- redirect_options.merge!(:params => request.query_parameters)
60
- flash.keep if respond_to?(:flash)
61
- redirect_to redirect_options
43
+ if request.ssl? && !ssl_allowed?
44
+ if request.get?
45
+ redirect_options = {
46
+ :protocol => 'http://',
47
+ :host => host || request.host,
48
+ :path => request.fullpath,
49
+ }
50
+ flash.keep if respond_to?(:flash)
51
+ insecure_url = ActionDispatch::Http::URL.url_for(redirect_options)
52
+ redirect_to insecure_url, :status => :moved_permanently
53
+ else
54
+ render :text => Spree.t(:change_protocol, :scope => :ssl), :status => :upgrade_required
55
+ end
62
56
  end
63
57
  end
64
-
65
58
  end
66
59
  end
67
60
  end
@@ -0,0 +1,25 @@
1
+ module Spree
2
+ class OldPrefs < ActiveRecord::Base
3
+ self.table_name = "spree_preferences"
4
+ belongs_to :owner, :polymorphic => true
5
+ attr_accessor :owner_klass
6
+ end
7
+
8
+ class PreferenceRescue
9
+ def self.try
10
+ OldPrefs.where(:key => nil).each do |old_pref|
11
+ next unless owner = (old_pref.owner rescue nil)
12
+ unless old_pref.owner_type == "Spree::Activator" || old_pref.owner_type == "Spree::Configuration"
13
+ begin
14
+ old_pref.key = [owner.class.name, old_pref.name, owner.id].join('::').underscore
15
+ old_pref.value_type = owner.preference_type(old_pref.name)
16
+ puts "Migrating Preference: #{old_pref.key}"
17
+ old_pref.save
18
+ rescue NoMethodError => ex
19
+ puts ex.message
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.0.5"
3
+ "2.0.6"
4
4
  end
5
5
  end
data/lib/spree/money.rb CHANGED
@@ -33,6 +33,10 @@ module Spree
33
33
  output
34
34
  end
35
35
 
36
+ def as_json(*)
37
+ to_s
38
+ end
39
+
36
40
  def ==(obj)
37
41
  @money == obj.money
38
42
  end
@@ -7,7 +7,7 @@ FactoryGirl.define do
7
7
  factory :credit_card, class: TestCard do
8
8
  verification_value 123
9
9
  month 12
10
- year 2013
10
+ year { Time.now.year }
11
11
  number '4111111111111111'
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.34'
19
+ version: 1.39.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.34'
26
+ version: 1.39.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: acts_as_list
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -168,14 +168,14 @@ dependencies:
168
168
  name: money
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '='
171
+ - - '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: 5.1.1
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '='
178
+ - - '>='
179
179
  - !ruby/object:Gem::Version
180
180
  version: 5.1.1
181
181
  - !ruby/object:Gem::Dependency
@@ -459,6 +459,7 @@ files:
459
459
  - lib/spree/core/mail_interceptor.rb
460
460
  - lib/spree/core/mail_settings.rb
461
461
  - lib/spree/core/permalinks.rb
462
+ - lib/spree/core/preference_rescue.rb
462
463
  - lib/spree/core/product_duplicator.rb
463
464
  - lib/spree/core/product_filters.rb
464
465
  - lib/spree/core/s3_support.rb
@@ -613,7 +614,11 @@ files:
613
614
  - db/migrate/20130809164330_add_admin_name_column_to_spree_stock_locations.rb
614
615
  - db/migrate/20130813140619_expand_order_number_size.rb
615
616
  - db/migrate/20130826062534_add_depth_to_spree_taxons.rb
617
+ - db/migrate/20130830001033_add_shipping_category_to_shipping_methods_and_products.rb
618
+ - db/migrate/20130830001159_migrate_old_shipping_calculators.rb
619
+ - db/migrate/20130909115621_change_states_required_for_countries.rb
616
620
  - db/migrate/20130915032339_add_deleted_at_to_spree_stock_items.rb
621
+ - db/migrate/20131001013410_remove_unused_credit_card_fields.rb
617
622
  - db/seeds.rb
618
623
  - vendor/assets/javascripts/jquery-migrate-1.0.0.js
619
624
  - vendor/assets/javascripts/jquery.validate/localization/messages_et.js