solidus_core 1.3.0.rc1 → 1.3.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/concerns/spree/user_address_book.rb +8 -1
  3. data/app/models/spree/app_configuration.rb +1 -1
  4. data/app/models/spree/gateway.rb +1 -1
  5. data/app/models/spree/variant.rb +6 -0
  6. data/db/migrate/20140309033438_create_store_from_preferences.rb +1 -0
  7. data/db/migrate/20160608162651_ensure_default_store.rb +13 -0
  8. data/db/migrate/20160608180751_ensure_store_on_orders.rb +12 -0
  9. data/lib/spree/core/price_migrator.rb +0 -2
  10. data/lib/spree/core/version.rb +1 -1
  11. data/lib/tasks/migrations/create_vat_prices.rake +6 -2
  12. data/lib/tasks/migrations/{assure_store_on_orders.rake → ensure_store_on_orders.rake} +5 -5
  13. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +3 -2
  14. data/lib/tasks/upgrade.rake +2 -2
  15. data/spec/lib/tasks/dummy_task.rake +10 -0
  16. data/spec/lib/tasks/dummy_task_spec.rb +28 -0
  17. data/spec/lib/tasks/exchanges_spec.rb +5 -8
  18. data/spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb +5 -8
  19. data/spec/lib/tasks/migrations/create_vat_prices_spec.rb +29 -0
  20. data/spec/lib/tasks/migrations/ensure_store_on_orders_spec.rb +80 -0
  21. data/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb +17 -0
  22. data/spec/lib/tasks/order_capturing_spec.rb +5 -8
  23. data/spec/lib/tasks/upgrade_spec.rb +21 -0
  24. data/spec/models/spree/app_configuration_spec.rb +0 -5
  25. data/spec/models/spree/concerns/user_address_book_spec.rb +17 -0
  26. data/spec/models/spree/promotion_handler/coupon_spec.rb +1 -1
  27. data/spec/models/spree/shipment_spec.rb +1 -1
  28. data/spec/models/spree/store_spec.rb +16 -7
  29. data/spec/models/spree/variant_spec.rb +11 -4
  30. data/spec/support/shared_contexts/rake.rb +30 -0
  31. metadata +12 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9448c7bb96e59ed1cb4f56c29f66060c99a0abd5
4
- data.tar.gz: e0cde0bf71c48efcaece95c384d457b4dd3c59ef
3
+ metadata.gz: f6b5b0a3568fe33572f315e0751a23fac38a4f4e
4
+ data.tar.gz: 9562633f680c89784fc2accad040216d8363759b
5
5
  SHA512:
6
- metadata.gz: a24c63de0a3f6303aa9099fff4340f75c488a830f5a6443eafa9ec3add8a85f7d14f11085d1d7bc567661cd390676fc13c0781514dbc3a7598d31484745a4aa5
7
- data.tar.gz: de47427d22d7d72d347f79347074844cdf87d1e0f3e5f3d8afbb312077c6be5e422bc0733b4bbaf0c6ddf5d3d151f82e3667c8e748eadc66af2862e2c4f7fd0d
6
+ metadata.gz: 917953facff8328caabe7164eda4fd5b42d05b1f5537660580b95f0ad109e2e68e11378d17dbb35651cb2c0809cc863380ec6b5a91065587b4f865bc4b36194a
7
+ data.tar.gz: 195cd6d1cc96d4d3581ed0d433a86685edc030f247b9c4fc76f77ff437820296ce83c4e3ab6279433a7332e9254099eeff42d1a4bc9bceb0ccbadcad03208ac0
@@ -108,7 +108,14 @@ module Spree
108
108
 
109
109
  if persisted?
110
110
  user_address.save!
111
- user_addresses.reset # ensures proper ordering
111
+
112
+ # If these associations have already been accessed, they will be
113
+ # caching the existing values.
114
+ # user_addresses need to be reset to get the new ordering based on any changes
115
+ # {default_,}user_address needs to be reset as its result is likely to have changed.
116
+ user_addresses.reset
117
+ association(:default_user_address).reset
118
+ association(:default_address).reset
112
119
  end
113
120
 
114
121
  user_address.address
@@ -299,7 +299,7 @@ module Spree
299
299
  # @return [variant_price_selector_class] An instance of the pricing options class with default desired
300
300
  # attributes
301
301
  def default_pricing_options
302
- @default_pricing_options ||= pricing_options_class.new
302
+ pricing_options_class.new
303
303
  end
304
304
 
305
305
  attr_writer :variant_search_class
@@ -15,7 +15,7 @@ module Spree
15
15
  gateway_options = options
16
16
  gateway_options.delete :login if gateway_options.key?(:login) && gateway_options[:login].nil?
17
17
  if gateway_options[:server]
18
- ActiveMerchant::Billing::Base.gateway_mode = gateway_options[:server].to_sym
18
+ ActiveMerchant::Billing::Base.mode = gateway_options[:server].to_sym
19
19
  end
20
20
  @provider ||= provider_class.new(gateway_options)
21
21
  end
@@ -94,9 +94,11 @@ module Spree
94
94
  # Returns variants that are not deleted and have a price in the given
95
95
  # currency.
96
96
  #
97
+ # @deprecated Please use the .with_prices scope instead
97
98
  # @param currency [String] the currency to filter by; defaults to Spree's default
98
99
  # @return [ActiveRecord::Relation]
99
100
  def self.active(currency = nil)
101
+ Spree::Deprecation.warn("`Variant.active(currency)` is deprecated. Please use `Variant.with_prices(pricing_options)` instead.", caller)
100
102
  joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL')
101
103
  end
102
104
 
@@ -264,19 +266,23 @@ module Spree
264
266
 
265
267
  # Converts the variant's price to the given currency.
266
268
  #
269
+ # @deprecated Please use #price_for(pricing_options) instead
267
270
  # @param currency [String] the desired currency
268
271
  # @return [Spree::Price] the price in the desired currency
269
272
  def price_in(currency)
270
273
  prices.currently_valid.find_by(currency: currency)
271
274
  end
275
+ deprecate price_in: :price_for, deprecator: Spree::Deprecation
272
276
 
273
277
  # Fetches the price amount in the specified currency.
274
278
  #
279
+ # @deprecated Please use #price_for instead and use a money object rathern than a BigDecimal.
275
280
  # @param currency (see #price)
276
281
  # @return [Float] the amount in the specified currency.
277
282
  def amount_in(currency)
278
283
  price_in(currency).try(:amount)
279
284
  end
285
+ deprecate amount_in: :price_for, deprecator: Spree::Deprecation
280
286
 
281
287
  # Generates a friendly name and sku string.
282
288
  #
@@ -27,6 +27,7 @@ class CreateStoreFromPreferences < ActiveRecord::Migration
27
27
  s.seo_title = preference_store.get('spree/app_configuration/default_seo_title') {}
28
28
  s.default_currency = preference_store.get('spree/app_configuration/currency') {}
29
29
  s.code = 'spree'
30
+ s.default = true
30
31
  end.save!
31
32
  end
32
33
  end
@@ -0,0 +1,13 @@
1
+ class EnsureDefaultStore < ActiveRecord::Migration
2
+ class Store < ActiveRecord::Base
3
+ self.table_name = 'spree_stores'
4
+ end
5
+
6
+ def up
7
+ unless Store.where(default: true).exists?
8
+ store = Store.first
9
+ raise "Database has no stores. One should have been created in a previous migration." unless store
10
+ store.update_column(:default, true)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class EnsureStoreOnOrders < ActiveRecord::Migration
2
+ class Store < ActiveRecord::Base
3
+ self.table_name = 'spree_stores'
4
+ end
5
+ class Order < ActiveRecord::Base
6
+ self.table_name = 'spree_orders'
7
+ end
8
+ def up
9
+ default_store = Store.find_by(default: true)
10
+ Order.where(store_id: nil).update_all(store_id: default_store.id)
11
+ end
12
+ end
@@ -7,8 +7,6 @@ module Spree
7
7
  # We need to tag the exisiting prices as "default", so that the VatPriceGenerator knows
8
8
  # that they include the default zone's VAT.
9
9
  Spree::Config.admin_vat_country_iso = Spree::Zone.default_tax.countries.first.iso
10
- # If we don't remove this ivar, the above line stays without effect because of caching.
11
- Spree::Config.remove_instance_variable(:@default_pricing_options)
12
10
  Spree::Variant.find_each do |variant|
13
11
  new(variant).migrate_vat_prices
14
12
  end
@@ -5,7 +5,7 @@ module Spree
5
5
  end
6
6
 
7
7
  def self.solidus_version
8
- "1.3.0.rc1"
8
+ "1.3.0.rc2"
9
9
  end
10
10
 
11
11
  def self.solidus_gem_version
@@ -3,8 +3,12 @@ namespace :solidus do
3
3
  namespace :create_vat_prices do
4
4
  task up: :environment do
5
5
  print "Creating differentiated prices for VAT countries ... "
6
- Spree::PriceMigrator.migrate_default_vat_prices
7
- puts "Success."
6
+ if Spree::Zone.default_tax
7
+ Spree::PriceMigrator.migrate_default_vat_prices
8
+ puts "Success."
9
+ else
10
+ puts "No Zone set as default_tax. Skipping."
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -1,6 +1,6 @@
1
1
  namespace :solidus do
2
2
  namespace :migrations do
3
- namespace :assure_store_on_orders do
3
+ namespace :ensure_store_on_orders do
4
4
  desc "Makes sure every order in the system has a store attached"
5
5
  task up: :environment do
6
6
 
@@ -16,18 +16,18 @@ namespace :solidus do
16
16
 
17
17
  spree_store_count = Spree::Store.count
18
18
  if spree_store_count == 0
19
- abort "You do not have a store set up. Please create a store instance for your installation."
19
+ raise "You do not have a store set up. Please create a store instance for your installation."
20
20
  elsif spree_store_count > 1
21
- abort(<<-TEXT.squish)
21
+ raise(<<-TEXT.squish)
22
22
  You have more than one store set up. We can not be sure which store to attach your
23
23
  orders to. Please attach store ids to all your orders, and run this task again
24
24
  when you're finished.
25
25
  TEXT
26
26
  end
27
27
 
28
- default_store = Store.where(default: true).first
28
+ default_store = Spree::Store.where(default: true).first
29
29
  unless default_store
30
- abort "Your store is not marked as default. Please mark your one store as the default store and run this task again."
30
+ raise "Your store is not marked as default. Please mark your one store as the default store and run this task again."
31
31
  end
32
32
 
33
33
  Spree::Order.where(store_id: nil).update_all(store_id: Spree::Store.default.id)
@@ -2,7 +2,7 @@ namespace :solidus do
2
2
  namespace :migrations do
3
3
  namespace :migrate_shipping_rate_taxes do
4
4
  task up: :environment do
5
- puts "Adding persisted tax notes to historic shipping rates"
5
+ print "Adding persisted tax notes to historic shipping rates ... "
6
6
  Spree::ShippingRate.where.not(tax_rate_id: nil).find_each do |shipping_rate|
7
7
  tax_rate = Spree::TaxRate.unscoped.find(shipping_rate.tax_rate_id)
8
8
  shipping_rate.taxes.find_or_create_by!(
@@ -10,7 +10,8 @@ namespace :solidus do
10
10
  amount: tax_rate.compute_amount(shipping_rate)
11
11
  )
12
12
  end
13
- Spree::ShippingRate.where.not(tax_rate_id: nil).update_all(tax_rate: nil)
13
+ Spree::ShippingRate.where.not(tax_rate_id: nil).update_all(tax_rate_id: nil)
14
+ puts "Success."
14
15
  end
15
16
  end
16
17
  end
@@ -2,9 +2,9 @@ namespace :solidus do
2
2
  namespace :upgrade do
3
3
  desc "Upgrade Solidus to version 1.3"
4
4
  task one_point_three: [
5
- 'solidus:migrations:assure_store_on_orders:up',
5
+ 'solidus:migrations:ensure_store_on_orders:up',
6
6
  'solidus:migrations:migrate_shipping_rate_taxes:up',
7
- 'solidus:migrations:create_vat_prices'
7
+ 'solidus:migrations:create_vat_prices:up'
8
8
  ] do
9
9
  puts "Your Solidus install is ready for Solidus 1.3."
10
10
  end
@@ -0,0 +1,10 @@
1
+ # This is a dummy task used for generic rake task testing
2
+
3
+ task dummy_task: :environment do
4
+ DummyTaskRunner.run
5
+ end
6
+
7
+ class DummyTaskRunner
8
+ def self.run
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy_task' do
4
+ include_context(
5
+ 'rake',
6
+ task_name: 'dummy_task',
7
+ task_path: Spree::Core::Engine.root.join('spec/lib/tasks/dummy_task.rake'),
8
+ )
9
+
10
+ it 'calls the dummy task exactly once' do
11
+ expect(DummyTaskRunner).to receive(:run).once
12
+ task.invoke
13
+ end
14
+
15
+ # This tests:
16
+ # 1) that tasks get reenabled between examples
17
+ # 2) that tasks aren't loaded in the wrong way, causing them to execute
18
+ # an extra time for every example that's defined.
19
+ # We need at least two specs to trigger the error conditions and spec order is
20
+ # random so we just create the same spec twice. We could probably combine this
21
+ # with the generic spec above but this seems clearer.
22
+ 2.times do |i|
23
+ it "still calls the dummy task exactly once when more than one example is defined - #{i}" do
24
+ expect(DummyTaskRunner).to receive(:run).once
25
+ task.invoke
26
+ end
27
+ end
28
+ end
@@ -1,14 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "exchanges:charge_unreturned_items" do
4
- let(:task) do
5
- Rake::Task['exchanges:charge_unreturned_items']
6
- end
7
-
8
- before do
9
- Rails.application.load_tasks
10
- task.reenable
11
- end
4
+ include_context(
5
+ 'rake',
6
+ task_name: 'exchanges:charge_unreturned_items',
7
+ task_path: Spree::Core::Engine.root.join('lib/tasks/exchanges.rake'),
8
+ )
12
9
 
13
10
  subject { task }
14
11
 
@@ -1,16 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'spree:migrations:copy_shipped_shipments_to_cartons' do
4
- before do
5
- Rails.application.load_tasks
6
- task.reenable
7
- end
4
+ include_context(
5
+ 'rake',
6
+ task_name: 'spree:migrations:copy_shipped_shipments_to_cartons:up',
7
+ task_path: Spree::Core::Engine.root.join('lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake'),
8
+ )
8
9
 
9
10
  describe 'up' do
10
- let(:task) do
11
- Rake::Task['spree:migrations:copy_shipped_shipments_to_cartons:up']
12
- end
13
-
14
11
  # should generate a carton
15
12
  let!(:shipped_shipment) { shipped_order.shipments.first }
16
13
  # should not generate a carton because it's not shipped
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'solidus:migrations:create_vat_prices' do
4
+ describe 'up' do
5
+ include_context(
6
+ 'rake',
7
+ task_path: Spree::Core::Engine.root.join('lib/tasks/migrations/create_vat_prices.rake'),
8
+ task_name: 'solidus:migrations:create_vat_prices:up',
9
+ )
10
+
11
+ context "without a zone" do
12
+ it 'skips' do
13
+ expect { task.invoke }.to output(
14
+ "Creating differentiated prices for VAT countries ... No Zone set as default_tax. Skipping.\n"
15
+ ).to_stdout
16
+ end
17
+ end
18
+
19
+ context "with a zone" do
20
+ let!(:zone) { create(:zone, :with_country, default_tax: true) }
21
+
22
+ it 'runs' do
23
+ expect { task.invoke }.to output(
24
+ "Creating differentiated prices for VAT countries ... Success.\n"
25
+ ).to_stdout
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'solidus:migrations:ensure_store_on_orders' do
4
+ describe 'up' do
5
+ include_context(
6
+ 'rake',
7
+ task_path: Spree::Core::Engine.root.join('lib/tasks/migrations/ensure_store_on_orders.rake'),
8
+ task_name: 'solidus:migrations:ensure_store_on_orders:up',
9
+ )
10
+
11
+ context 'with no orders' do
12
+ it 'succeeds' do
13
+ expect { task.invoke }.to output(
14
+ "Everything is good, all orders in your database have a store attached.\n"
15
+ ).to_stdout
16
+ end
17
+ end
18
+
19
+ context 'when all orders have store_ids' do
20
+ let!(:order) { create(:order, store: create(:store)) }
21
+
22
+ it 'succeeds' do
23
+ expect { task.invoke }.to output(
24
+ "Everything is good, all orders in your database have a store attached.\n"
25
+ ).to_stdout
26
+ end
27
+ end
28
+
29
+ context 'when some orders do not have store_ids' do
30
+ let!(:order_with_store) { create(:order, store: store) }
31
+ let!(:order_without_store) do
32
+ # due to a before_validation that adds a store when one is missing,
33
+ # we can't simply specify `store: nil`
34
+ create(:order, store: store).tap do |o|
35
+ o.update_columns(store_id: nil)
36
+ end
37
+ end
38
+ let!(:store) { create(:store) }
39
+
40
+ it 'succeeds' do
41
+ expect { task.invoke }.to output(
42
+ "All orders updated with the default store.\n"
43
+ ).to_stdout
44
+ end
45
+
46
+ context 'when there are no stores' do
47
+ before do
48
+ order_with_store.update_columns(store_id: nil)
49
+ # due to a before_validation that adds a store when one is missing,
50
+ # we can't simply specify `store: nil`
51
+ store.destroy
52
+ end
53
+
54
+ it 'raises' do
55
+ expect { task.invoke }.to raise_error(/You do not have a store set up/)
56
+ end
57
+ end
58
+
59
+ context 'when there are multiple stores' do
60
+ let!(:extra_store) { create(:store) }
61
+
62
+ it 'raises' do
63
+ expect { task.invoke }.to raise_error(/You have more than one store set up/)
64
+ end
65
+ end
66
+
67
+ context 'when there is no default store' do
68
+ before do
69
+ # The before_save 'ensure_default_exists_and_is_unique' means that we
70
+ # need to use update_columns to set up this scenario.
71
+ store.update_columns(default: false)
72
+ end
73
+
74
+ it 'raises' do
75
+ expect { task.invoke }.to raise_error(/Your store is not marked as default/)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'solidus:migrations:migrate_shipping_rate_taxes' do
4
+ describe 'up' do
5
+ include_context(
6
+ 'rake',
7
+ task_path: Spree::Core::Engine.root.join('lib/tasks/migrations/migrate_shipping_rate_taxes.rake'),
8
+ task_name: 'solidus:migrations:migrate_shipping_rate_taxes:up',
9
+ )
10
+
11
+ it 'runs' do
12
+ expect { task.invoke }.to output(
13
+ "Adding persisted tax notes to historic shipping rates ... Success.\n"
14
+ ).to_stdout
15
+ end
16
+ end
17
+ end
@@ -1,14 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "order_capturing:capture_payments" do
4
- let(:task) do
5
- Rake::Task['order_capturing:capture_payments']
6
- end
7
-
8
- before do
9
- Rails.application.load_tasks
10
- task.reenable
11
- end
4
+ include_context(
5
+ 'rake',
6
+ task_name: 'order_capturing:capture_payments',
7
+ task_path: Spree::Core::Engine.root.join('lib/tasks/order_capturing.rake'),
8
+ )
12
9
 
13
10
  subject { task }
14
11
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'solidus:upgrade:one_point_three' do
4
+ include_context(
5
+ 'rake',
6
+ task_path: Spree::Core::Engine.root.join('lib/tasks/upgrade.rake'),
7
+ task_name: 'solidus:upgrade:one_point_three',
8
+ )
9
+
10
+ before do
11
+ load Spree::Core::Engine.root.join('lib/tasks/migrations/ensure_store_on_orders.rake')
12
+ load Spree::Core::Engine.root.join('lib/tasks/migrations/migrate_shipping_rate_taxes.rake')
13
+ load Spree::Core::Engine.root.join('lib/tasks/migrations/create_vat_prices.rake')
14
+ end
15
+
16
+ it 'runs' do
17
+ expect { task.invoke }.to output(
18
+ /Your Solidus install is ready for Solidus 1.3./
19
+ ).to_stdout
20
+ end
21
+ end
@@ -28,11 +28,6 @@ describe Spree::AppConfiguration, type: :model do
28
28
  expect(prefs.pricing_options_class).to eq Spree::Variant::PriceSelector.pricing_options_class
29
29
  end
30
30
 
31
- it "has an instacached getter for the default pricing options" do
32
- expect(prefs.default_pricing_options).to be_a Spree::Variant::PriceSelector.pricing_options_class
33
- expect(prefs.default_pricing_options.object_id).to eq prefs.default_pricing_options.object_id
34
- end
35
-
36
31
  describe '#stock' do
37
32
  subject { prefs.stock }
38
33
  it { is_expected.to be_a Spree::Core::StockConfiguration }
@@ -336,4 +336,21 @@ module Spree
336
336
  expect(subject.default_address).to eq ship_address
337
337
  end
338
338
  end
339
+
340
+ describe "ship_address=" do
341
+ let!(:user) { create(:user) }
342
+ let!(:address) { create(:address) }
343
+
344
+ # https://github.com/solidusio/solidus/issues/1241
345
+ it "resets the association and persists" do
346
+ # Load (which will cache) the has_one association
347
+ expect(user.ship_address).to be_nil
348
+
349
+ user.update!(ship_address: address)
350
+ expect(user.ship_address).to eq(address)
351
+
352
+ user.reload
353
+ expect(user.ship_address).to eq(address)
354
+ end
355
+ end
339
356
  end
@@ -128,7 +128,7 @@ module Spree
128
128
  end
129
129
 
130
130
  context "coexists with a non coupon code promo" do
131
- let!(:order) { Order.create }
131
+ let!(:order) { create(:order) }
132
132
 
133
133
  before do
134
134
  allow(order).to receive_messages coupon_code: "10off"
@@ -135,7 +135,7 @@ describe Spree::Shipment, type: :model do
135
135
  end
136
136
 
137
137
  context "manifest" do
138
- let(:order) { Spree::Order.create }
138
+ let(:order) { create(:order) }
139
139
  let(:variant) { create(:variant) }
140
140
  let!(:line_item) { order.contents.add variant }
141
141
  let!(:shipment) { order.create_proposed_shipments.first }
@@ -37,19 +37,28 @@ describe Spree::Store, type: :model do
37
37
  end
38
38
 
39
39
  describe ".default" do
40
- let!(:store) { create(:store) }
41
- let!(:store_2) { create(:store, default: true) }
40
+ it "should ensure saved store becomes default if one doesn't exist yet" do
41
+ expect(Spree::Store.where(default: true).count).to eq(0)
42
+ store = build(:store)
43
+ expect(store.default).not_to be true
44
+
45
+ store.save!
42
46
 
43
- it "should ensure there is a default if one doesn't exist yet" do
44
- expect(store_2.default).to be true
47
+ expect(store.default).to be true
45
48
  end
46
49
 
47
50
  it "should ensure there is only one default" do
48
- [store, store_2].each(&:reload)
51
+ orig_default_store = create(:store, default: true)
52
+ expect(orig_default_store.reload.default).to be true
53
+
54
+ new_default_store = create(:store, default: true)
49
55
 
50
56
  expect(Spree::Store.where(default: true).count).to eq(1)
51
- expect(store_2.default).to be true
52
- expect(store.default).not_to be true
57
+
58
+ [orig_default_store, new_default_store].each(&:reload)
59
+
60
+ expect(new_default_store.default).to be true
61
+ expect(orig_default_store.default).not_to be true
53
62
  end
54
63
  end
55
64
 
@@ -205,6 +205,8 @@ describe Spree::Variant, type: :model do
205
205
 
206
206
  context "#default_price" do
207
207
  context "when multiple prices are present in addition to a default price" do
208
+ let(:pricing_options_germany) { Spree::Config.pricing_options_class.new(currency: "EUR") }
209
+ let(:pricing_options_united_states) { Spree::Config.pricing_options_class.new(currency: "USD") }
208
210
  before do
209
211
  variant.prices << create(:price, variant: variant, currency: "USD", amount: 12.12, is_default: false)
210
212
  variant.prices << create(:price, variant: variant, currency: "EUR", amount: 29.99)
@@ -217,8 +219,8 @@ describe Spree::Variant, type: :model do
217
219
  end
218
220
 
219
221
  it "displays default price" do
220
- expect(variant.price_in("USD").display_amount.to_s).to eq("$19.99")
221
- expect(variant.price_in("EUR").display_amount.to_s).to eq("€29.99")
222
+ expect(variant.price_for(pricing_options_united_states).to_s).to eq("$19.99")
223
+ expect(variant.price_for(pricing_options_germany).to_s).to eq("€29.99")
222
224
  end
223
225
  end
224
226
 
@@ -347,7 +349,10 @@ describe Spree::Variant, type: :model do
347
349
  before do
348
350
  variant.prices << create(:price, variant: variant, currency: "EUR", amount: 33.33)
349
351
  end
350
- subject { variant.price_in(currency) }
352
+
353
+ subject do
354
+ Spree::Deprecation.silence { variant.price_in(currency) }
355
+ end
351
356
 
352
357
  context "when currency is not specified" do
353
358
  let(:currency) { nil }
@@ -379,7 +384,9 @@ describe Spree::Variant, type: :model do
379
384
  variant.prices << create(:price, variant: variant, currency: "EUR", amount: 33.33)
380
385
  end
381
386
 
382
- subject { variant.amount_in(currency) }
387
+ subject do
388
+ Spree::Deprecation.silence { variant.amount_in(currency) }
389
+ end
383
390
 
384
391
  context "when currency is not specified" do
385
392
  let(:currency) { nil }
@@ -0,0 +1,30 @@
1
+ #
2
+ # Rake task spec setup.
3
+ #
4
+ shared_context "rake" do |task_path:, task_name:|
5
+ require 'rake'
6
+
7
+ let(:task) do
8
+ Rake::Task[task_name]
9
+ end
10
+
11
+ before(:each) do
12
+ # we need to reenable the task or else `task.invoke` will only run the task
13
+ # for the first example that runs.
14
+ task.reenable
15
+ end
16
+
17
+ before(:all) do
18
+ Rake::Task.clear
19
+ # Note: Using `Rails.application.load_tasks` doesn't seem to work correctly
20
+ # in the specs. The tasks each run twice when invoked instead of once.
21
+ load task_path
22
+ # Many tasks require the 'environment' task, which isn't needed in specs
23
+ # since the environment is already loaded. So generate a fake one.
24
+ Rake::Task.define_task(:environment)
25
+ end
26
+
27
+ after(:all) do
28
+ Rake::Task.clear
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.rc1
4
+ version: 1.3.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -881,6 +881,8 @@ files:
881
881
  - db/migrate/20160318145302_add_timestamps_to_prices.rb
882
882
  - db/migrate/20160330204846_add_missing_timestamp_columns.rb
883
883
  - db/migrate/20160509181311_add_country_iso_to_prices.rb
884
+ - db/migrate/20160608162651_ensure_default_store.rb
885
+ - db/migrate/20160608180751_ensure_store_on_orders.rb
884
886
  - db/seeds.rb
885
887
  - lib/generators/spree/custom_user/custom_user_generator.rb
886
888
  - lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
@@ -1049,10 +1051,10 @@ files:
1049
1051
  - lib/tasks/core.rake
1050
1052
  - lib/tasks/email.rake
1051
1053
  - lib/tasks/exchanges.rake
1052
- - lib/tasks/migrations/assure_store_on_orders.rake
1053
1054
  - lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake
1054
1055
  - lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake
1055
1056
  - lib/tasks/migrations/create_vat_prices.rake
1057
+ - lib/tasks/migrations/ensure_store_on_orders.rake
1056
1058
  - lib/tasks/migrations/migrate_shipping_rate_taxes.rake
1057
1059
  - lib/tasks/migrations/migrate_user_addresses.rake
1058
1060
  - lib/tasks/order_capturing.rake
@@ -1152,9 +1154,15 @@ files:
1152
1154
  - spec/lib/spree/localized_number_spec.rb
1153
1155
  - spec/lib/spree/migrations_spec.rb
1154
1156
  - spec/lib/spree/money_spec.rb
1157
+ - spec/lib/tasks/dummy_task.rake
1158
+ - spec/lib/tasks/dummy_task_spec.rb
1155
1159
  - spec/lib/tasks/exchanges_spec.rb
1156
1160
  - spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb
1161
+ - spec/lib/tasks/migrations/create_vat_prices_spec.rb
1162
+ - spec/lib/tasks/migrations/ensure_store_on_orders_spec.rb
1163
+ - spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb
1157
1164
  - spec/lib/tasks/order_capturing_spec.rb
1165
+ - spec/lib/tasks/upgrade_spec.rb
1158
1166
  - spec/mailers/carton_mailer_spec.rb
1159
1167
  - spec/mailers/order_mailer_spec.rb
1160
1168
  - spec/mailers/reimbursement_mailer_spec.rb
@@ -1364,6 +1372,7 @@ files:
1364
1372
  - spec/support/concerns/default_price.rb
1365
1373
  - spec/support/concerns/working_factories.rb
1366
1374
  - spec/support/dummy_ability.rb
1375
+ - spec/support/shared_contexts/rake.rb
1367
1376
  - spec/support/test_gateway.rb
1368
1377
  - vendor/assets/javascripts/jquery.payment.js
1369
1378
  - vendor/assets/javascripts/jsuri.js