solidus_core 2.0.0.rc1 → 2.0.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbdfb658bce9038100b17820c195754a991baaa5
4
- data.tar.gz: 08313688df1befda337af2e52baab5149c510940
3
+ metadata.gz: 0a431556798d4e71cf6ddd2705c1e9771a945218
4
+ data.tar.gz: a573024f06b38e92edb6e2ae89d3893a2259d690
5
5
  SHA512:
6
- metadata.gz: f76f20c1fc3ca55a230b8cee008b4a6ffd1c228b07dcb9cc2ab317bd53d995a8a6cb262c39ef54db1bc2e587b68b3ba9b223cbf81a7eb951ecc7a5a89b5b7a7c
7
- data.tar.gz: 6233bcf5c299863d50f6e9f983b6b928af5cd596368a0c86ad956b62f0acc8583a54e61a806891954c91d736499d5799d79721b956ed6e051b78e340a39cefca
6
+ metadata.gz: 81ca409e7263d31ea26aa9aac0c5952bd71d261da44dc0af933bd3257865323f00e528548e1ec9a4957c5fb47aadfd80f498b80a9ca37fdd32810c8cd3d6c9fb
7
+ data.tar.gz: 9ebb33484c741e1cd4631d05d0ed5569ab0c340e9672cb8b66d028379ff7a75eb0f4916b67c9ae3f68e6aa52cd1a318b6c2e80fa80c0531d426b18b6c0a2385f
@@ -64,11 +64,10 @@ module Spree
64
64
  #
65
65
  # @param num [String] the desired credit card number
66
66
  def number=(num)
67
- @number = begin
68
- num.gsub(/[^0-9]/, '')
69
- rescue
70
- nil
71
- end
67
+ @number =
68
+ if num.is_a?(String)
69
+ num.gsub(/[^0-9]/, '')
70
+ end
72
71
  end
73
72
 
74
73
  # Sets the credit card type, converting it to the preferred internal
@@ -89,7 +88,6 @@ module Spree
89
88
 
90
89
  # Sets the last digits field based on the assigned credit card number.
91
90
  def set_last_digits
92
- number.to_s.gsub!(/\s/, '')
93
91
  verification_value.to_s.gsub!(/\s/, '')
94
92
  self.last_digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
95
93
  end
@@ -5,7 +5,7 @@ module Spree
5
5
  end
6
6
 
7
7
  def self.solidus_version
8
- "2.0.0.rc1"
8
+ "2.0.0"
9
9
  end
10
10
 
11
11
  def self.solidus_gem_version
@@ -1,3 +1,3 @@
1
1
  module Spree
2
- Deprecation = ActiveSupport::Deprecation.new('2.0', 'Solidus')
2
+ Deprecation = ActiveSupport::Deprecation.new('2.1', 'Solidus')
3
3
  end
@@ -14,7 +14,8 @@ describe Spree::Adjustment, type: :model do
14
14
  let(:adjustment) { Spree::Adjustment.create(label: "Adjustment", amount: 5, order: order, adjustable: line_item) }
15
15
 
16
16
  it 'touches the adjustable' do
17
- expect { adjustment.save }.to change { line_item.updated_at }
17
+ line_item.update_columns(updated_at: 1.day.ago)
18
+ expect { adjustment.save! }.to change { line_item.updated_at }
18
19
  end
19
20
  end
20
21
 
@@ -35,7 +35,7 @@ describe Spree::CreditCard, type: :model do
35
35
  allow(@payment).to receive_messages payment_method: @payment_gateway
36
36
  end
37
37
 
38
- context "#can_capture?" do
38
+ describe "#can_capture?" do
39
39
  it "should be true if payment is pending" do
40
40
  payment = mock_model(Spree::Payment, pending?: true, created_at: Time.current)
41
41
  expect(credit_card.can_capture?(payment)).to be true
@@ -47,14 +47,14 @@ describe Spree::CreditCard, type: :model do
47
47
  end
48
48
  end
49
49
 
50
- context "#can_void?" do
50
+ describe "#can_void?" do
51
51
  it "should be true if payment is not void" do
52
52
  payment = mock_model(Spree::Payment, failed?: false, void?: false)
53
53
  expect(credit_card.can_void?(payment)).to be true
54
54
  end
55
55
  end
56
56
 
57
- context "#can_credit?" do
57
+ describe "#can_credit?" do
58
58
  it "should be false if payment is not completed" do
59
59
  payment = mock_model(Spree::Payment, completed?: false)
60
60
  expect(credit_card.can_credit?(payment)).to be false
@@ -66,7 +66,7 @@ describe Spree::CreditCard, type: :model do
66
66
  end
67
67
  end
68
68
 
69
- context "#valid?" do
69
+ describe "#valid?" do
70
70
  it "should validate presence of number" do
71
71
  credit_card.attributes = valid_credit_card_attributes.except(:number)
72
72
  expect(credit_card).not_to be_valid
@@ -109,7 +109,7 @@ describe Spree::CreditCard, type: :model do
109
109
  end
110
110
  end
111
111
 
112
- context "#save" do
112
+ describe "#save" do
113
113
  before do
114
114
  credit_card.attributes = valid_credit_card_attributes
115
115
  credit_card.save!
@@ -145,7 +145,7 @@ describe Spree::CreditCard, type: :model do
145
145
  end
146
146
  end
147
147
 
148
- context "#number=" do
148
+ describe "#number=" do
149
149
  it "should strip non-numeric characters from card input" do
150
150
  credit_card.number = "6011000990139424"
151
151
  expect(credit_card.number).to eq("6011000990139424")
@@ -161,7 +161,7 @@ describe Spree::CreditCard, type: :model do
161
161
  end
162
162
 
163
163
  # Regression test for https://github.com/spree/spree/issues/3847 and https://github.com/spree/spree/issues/3896
164
- context "#expiry=" do
164
+ describe "#expiry=" do
165
165
  it "can set with a 2-digit month and year" do
166
166
  credit_card.expiry = '04 / 15'
167
167
  expect(credit_card.month).to eq('4')
@@ -208,7 +208,7 @@ describe Spree::CreditCard, type: :model do
208
208
  end
209
209
  end
210
210
 
211
- context "#cc_type=" do
211
+ describe "#cc_type=" do
212
212
  it "converts between the different types" do
213
213
  credit_card.cc_type = 'mastercard'
214
214
  expect(credit_card.cc_type).to eq('master')
@@ -257,13 +257,13 @@ describe Spree::CreditCard, type: :model do
257
257
  end
258
258
  end
259
259
 
260
- context "#associations" do
260
+ describe "#associations" do
261
261
  it "should be able to access its payments" do
262
262
  credit_card.payments.to_a
263
263
  end
264
264
  end
265
265
 
266
- context "#first_name" do
266
+ describe "#first_name" do
267
267
  before do
268
268
  credit_card.name = "Ludwig van Beethoven"
269
269
  end
@@ -273,7 +273,7 @@ describe Spree::CreditCard, type: :model do
273
273
  end
274
274
  end
275
275
 
276
- context "#last_name" do
276
+ describe "#last_name" do
277
277
  before do
278
278
  credit_card.name = "Ludwig van Beethoven"
279
279
  end
@@ -283,7 +283,7 @@ describe Spree::CreditCard, type: :model do
283
283
  end
284
284
  end
285
285
 
286
- context "#to_active_merchant" do
286
+ describe "#to_active_merchant" do
287
287
  before do
288
288
  credit_card.number = "4111111111111111"
289
289
  credit_card.year = Time.current.year
@@ -30,7 +30,7 @@ describe Spree::OrderShipping do
30
30
 
31
31
  it "updates shipment.shipped_at" do
32
32
  Timecop.freeze do |now|
33
- expect { subject }.to change { shipment.shipped_at }.from(nil).to(now)
33
+ expect { subject }.to change { shipment.shipped_at }.from(nil).to be_within(1.second).of(now)
34
34
  end
35
35
  end
36
36
 
@@ -40,7 +40,7 @@ describe Spree::OrderShipping do
40
40
  Timecop.freeze(future) do
41
41
  subject
42
42
  end
43
- end.to change { order.updated_at }.from(order.updated_at).to(future)
43
+ end.to change { order.updated_at }.to be_within(1.second).of(future)
44
44
  end
45
45
  end
46
46
 
@@ -97,6 +97,7 @@ describe Spree::Product, type: :model do
97
97
  master = product.master
98
98
  master.default_price.price = 11
99
99
  master.save!
100
+ product.update_columns(updated_at: 1.day.ago)
100
101
  product.master.default_price.price = 12
101
102
  end
102
103
 
@@ -342,19 +343,27 @@ describe Spree::Product, type: :model do
342
343
 
343
344
  context "associations" do
344
345
  describe "product_option_types" do
345
- it "touches the product instance when an option type is added" do
346
- expect {
347
- product.product_option_types.create(option_type: create(:option_type, name: 'new-option-type'))
348
- product.reload
349
- }.to change { product.updated_at }
346
+ context "with no existing option types" do
347
+ before { product.update_columns(updated_at: 1.day.ago) }
348
+
349
+ it "touches the product instance when an option type is added" do
350
+ expect {
351
+ product.product_option_types.create(option_type: create(:option_type, name: 'new-option-type'))
352
+ }.to change { product.reload.updated_at }
353
+ end
350
354
  end
351
355
 
352
- it "touches product instance when an option type is removed" do
353
- product.product_option_types.create(option_type: create(:option_type, name: 'new-option-type'))
354
- expect {
355
- product.product_option_types = []
356
- product.reload
357
- }.to change { product.updated_at }
356
+ context "with an existing option type" do
357
+ before do
358
+ product.product_option_types.create(option_type: create(:option_type, name: 'new-option-type'))
359
+ product.update_columns(updated_at: 1.day.ago)
360
+ end
361
+
362
+ it "touches product instance when an option type is removed" do
363
+ expect {
364
+ product.product_option_types = []
365
+ }.to change { product.reload.updated_at }
366
+ end
358
367
  end
359
368
  end
360
369
  end
@@ -199,30 +199,41 @@ describe Spree::StockItem, type: :model do
199
199
 
200
200
  let(:inventory_cache_threshold) { 5 }
201
201
 
202
- it "count on hand falls below threshold" do
203
- expect do
204
- subject.set_count_on_hand(3)
205
- end.to change { subject.variant.updated_at }
202
+ before do
203
+ subject.set_count_on_hand(existing_count_on_hand)
204
+ subject.variant.update_column(:updated_at, 1.day.ago)
206
205
  end
207
206
 
208
- it "count on hand rises above threshold" do
209
- subject.set_count_on_hand(2)
210
- expect do
211
- subject.set_count_on_hand(7)
212
- end.to change { subject.variant.updated_at }
213
- end
207
+ context "beginning above threshold" do
208
+ let(:existing_count_on_hand) { 10 }
214
209
 
215
- it "count on hand stays below threshold" do
216
- subject.set_count_on_hand(2)
217
- expect do
218
- subject.set_count_on_hand(3)
219
- end.to change { subject.variant.updated_at }
210
+ it "count on hand falls below threshold" do
211
+ expect do
212
+ subject.set_count_on_hand(3)
213
+ end.to change { subject.variant.updated_at }
214
+ end
215
+
216
+ it "count on hand stays above threshold" do
217
+ expect do
218
+ subject.set_count_on_hand(8)
219
+ end.not_to change { subject.variant.updated_at }
220
+ end
220
221
  end
221
222
 
222
- it "count on hand stays above threshold" do
223
- expect do
224
- subject.set_count_on_hand(8)
225
- end.not_to change { subject.variant.updated_at }
223
+ context "beginning below threshold" do
224
+ let(:existing_count_on_hand) { 2 }
225
+
226
+ it "count on hand rises above threshold" do
227
+ expect do
228
+ subject.set_count_on_hand(7)
229
+ end.to change { subject.variant.updated_at }
230
+ end
231
+
232
+ it "count on hand stays below threshold" do
233
+ expect do
234
+ subject.set_count_on_hand(3)
235
+ end.to change { subject.variant.updated_at }
236
+ end
226
237
  end
227
238
  end
228
239
 
@@ -255,6 +266,8 @@ describe Spree::StockItem, type: :model do
255
266
  end
256
267
 
257
268
  describe "#after_touch" do
269
+ before { subject.variant.update_column(:updated_at, 1.day.ago) }
270
+
258
271
  it "touches its variant" do
259
272
  expect do
260
273
  subject.touch
@@ -838,10 +838,10 @@ describe Spree::StoreCredit do
838
838
  subject { store_credit.invalidate(invalidation_reason, invalidation_user) }
839
839
 
840
840
  it "sets the invalidated_at field to the current time" do
841
- invalidated_at = Time.current
841
+ invalidated_at = 2.minutes.from_now
842
842
  Timecop.freeze(invalidated_at) do
843
843
  subject
844
- expect(store_credit.invalidated_at).to eq invalidated_at
844
+ expect(store_credit.invalidated_at).to be_within(1.second).of invalidated_at
845
845
  end
846
846
  end
847
847
 
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: 2.0.0.rc1
4
+ version: 2.0.0
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-09-07 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -1404,9 +1404,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1404
1404
  version: 2.1.0
1405
1405
  required_rubygems_version: !ruby/object:Gem::Requirement
1406
1406
  requirements:
1407
- - - ">"
1407
+ - - ">="
1408
1408
  - !ruby/object:Gem::Version
1409
- version: 1.3.1
1409
+ version: '0'
1410
1410
  requirements: []
1411
1411
  rubyforge_project:
1412
1412
  rubygems_version: 2.5.1