spree_core 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/base_helper.rb +1 -1
  3. data/app/helpers/spree/products_helper.rb +7 -8
  4. data/app/models/spree/adjustment.rb +3 -1
  5. data/app/models/spree/asset.rb +1 -1
  6. data/app/models/spree/classification.rb +1 -1
  7. data/app/models/spree/credit_card.rb +2 -2
  8. data/app/models/spree/gateway/bogus.rb +3 -2
  9. data/app/models/spree/inventory_unit.rb +1 -1
  10. data/app/models/spree/item_adjustments.rb +8 -4
  11. data/app/models/spree/line_item.rb +5 -0
  12. data/app/models/spree/order.rb +8 -4
  13. data/app/models/spree/order/checkout.rb +2 -0
  14. data/app/models/spree/payment.rb +6 -3
  15. data/app/models/spree/payment_method.rb +7 -3
  16. data/app/models/spree/payment_method/check.rb +2 -0
  17. data/app/models/spree/price.rb +1 -13
  18. data/app/models/spree/product.rb +26 -24
  19. data/app/models/spree/promotion.rb +2 -2
  20. data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -3
  21. data/app/models/spree/promotion/actions/create_line_items.rb +1 -0
  22. data/app/models/spree/promotion_handler/coupon.rb +5 -1
  23. data/app/models/spree/return_authorization.rb +2 -2
  24. data/app/models/spree/shipping_category.rb +2 -2
  25. data/app/models/spree/shipping_method_category.rb +1 -1
  26. data/app/models/spree/stock_item.rb +1 -1
  27. data/app/models/spree/stock_location.rb +1 -1
  28. data/app/models/spree/store.rb +1 -1
  29. data/app/models/spree/tax_category.rb +2 -2
  30. data/app/models/spree/tax_rate.rb +7 -4
  31. data/app/models/spree/variant.rb +18 -17
  32. data/app/models/spree/zone.rb +15 -17
  33. data/app/models/spree/zone_member.rb +1 -1
  34. data/config/initializers/user_class_extensions.rb +10 -9
  35. data/config/locales/en.yml +4 -1
  36. data/db/migrate/20140530024945_move_order_token_from_tokenized_permission.rb +1 -1
  37. data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +3 -5
  38. data/db/migrate/20141021194502_add_state_lock_version_to_order.rb +5 -0
  39. data/db/migrate/20141101231208_fix_adjustment_order_presence.rb +13 -0
  40. data/db/migrate/20141105213646_update_classifications_positions.rb +9 -0
  41. data/lib/generators/spree/install/install_generator.rb +3 -7
  42. data/lib/spree/core.rb +3 -3
  43. data/lib/spree/core/controller_helpers/order.rb +8 -7
  44. data/lib/spree/core/importer/order.rb +16 -3
  45. data/lib/spree/core/search/base.rb +1 -1
  46. data/lib/spree/core/validators/email.rb +1 -1
  47. data/lib/spree/core/version.rb +1 -1
  48. data/lib/spree/localized_number.rb +20 -0
  49. data/lib/spree/migrations.rb +7 -3
  50. data/lib/spree/money.rb +2 -2
  51. data/lib/spree/permitted_attributes.rb +3 -1
  52. data/lib/spree/testing_support/ability_helpers.rb +25 -25
  53. data/lib/spree/testing_support/capybara_ext.rb +2 -2
  54. data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
  55. data/lib/spree/testing_support/factories/order_factory.rb +1 -1
  56. data/lib/spree/testing_support/factories/promotion_factory.rb +4 -4
  57. data/lib/spree/testing_support/factories/stock_factory.rb +2 -2
  58. data/lib/spree/testing_support/flash.rb +2 -2
  59. metadata +16 -19
  60. data/vendor/assets/javascripts/jquery.validate/localization/messages_et.js +0 -23
  61. data/vendor/assets/javascripts/jquery.validate/localization/messages_eu.js +0 -25
  62. data/vendor/assets/javascripts/jquery.validate/localization/messages_hr.js +0 -25
  63. data/vendor/assets/javascripts/jquery.validate/localization/messages_ka.js +0 -25
  64. data/vendor/assets/javascripts/jquery.validate/localization/messages_ko.js +0 -25
  65. data/vendor/assets/javascripts/jquery.validate/localization/messages_my.js +0 -25
  66. data/vendor/assets/javascripts/jquery.validate/localization/messages_pt_BR.js +0 -26
  67. data/vendor/assets/javascripts/jquery.validate/localization/messages_pt_PT.js +0 -26
  68. data/vendor/assets/javascripts/jquery.validate/localization/messages_sl.js +0 -25
  69. data/vendor/assets/javascripts/jquery.validate/localization/messages_sv.js +0 -23
  70. data/vendor/assets/javascripts/jquery.validate/localization/messages_uk.js +0 -25
  71. data/vendor/assets/javascripts/jquery.validate/localization/messages_zh.js +0 -25
  72. data/vendor/assets/javascripts/jquery.validate/localization/messages_zh_TW.js +0 -26
@@ -13,6 +13,9 @@ module Spree
13
13
  order = Spree::Order.create!
14
14
  order.associate_user!(user)
15
15
 
16
+ shipments_attrs = params.delete(:shipments_attributes)
17
+
18
+ create_shipments_from_params(shipments_attrs, order)
16
19
  create_line_items_from_params(params.delete(:line_items_attributes),order)
17
20
  create_shipments_from_params(params.delete(:shipments_attributes), order)
18
21
  create_adjustments_from_params(params.delete(:adjustments_attributes), order)
@@ -27,8 +30,15 @@ module Spree
27
30
 
28
31
  order.update_attributes!(params)
29
32
 
33
+ order.create_proposed_shipments unless shipments_attrs.present?
34
+
30
35
  # Really ensure that the order totals & states are correct
31
36
  order.updater.update
37
+ if shipments_attrs.present?
38
+ order.shipments.each_with_index do |shipment, index|
39
+ shipment.update_columns(cost: shipments_attrs[index][:cost].to_f) if shipments_attrs[index][:cost].present?
40
+ end
41
+ end
32
42
  order.reload
33
43
  rescue Exception => e
34
44
  order.destroy if order && order.persisted?
@@ -44,7 +54,7 @@ module Spree
44
54
  begin
45
55
  shipment = order.shipments.build
46
56
  shipment.tracking = s[:tracking]
47
- shipment.stock_location = Spree::StockLocation.find_by_name!(s[:stock_location])
57
+ shipment.stock_location = Spree::StockLocation.find_by_admin_name(s[:stock_location]) || Spree::StockLocation.find_by_name!(s[:stock_location])
48
58
 
49
59
  inventory_units = s[:inventory_units] || []
50
60
  inventory_units.each do |iu|
@@ -109,8 +119,11 @@ module Spree
109
119
  return [] unless adjustments
110
120
  adjustments.each do |a|
111
121
  begin
112
- adjustment = order.adjustments.build(:amount => a[:amount].to_f,
113
- :label => a[:label])
122
+ adjustment = order.adjustments.build(
123
+ order: order,
124
+ amount: a[:amount].to_f,
125
+ label: a[:label]
126
+ )
114
127
  adjustment.save!
115
128
  adjustment.close!
116
129
  rescue Exception => e
@@ -42,7 +42,7 @@ module Spree
42
42
 
43
43
  def add_eagerload_scopes scope
44
44
  if include_images
45
- scope.eager_load({master: [:prices, :images]})
45
+ scope.includes({master: [:prices, :images]})
46
46
  else
47
47
  scope.includes(master: :prices)
48
48
  end
@@ -1,6 +1,6 @@
1
1
  class EmailValidator < ActiveModel::EachValidator
2
2
  def validate_each(record,attribute,value)
3
- unless value =~ /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
3
+ unless value =~ /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/
4
4
  record.errors.add(attribute, :invalid, {:value => value}.merge!(options))
5
5
  end
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '2.3.4'
3
+ '2.3.5'
4
4
  end
5
5
  end
@@ -0,0 +1,20 @@
1
+ module Spree
2
+ class LocalizedNumber
3
+
4
+ # Strips all non-price-like characters from the number, taking into account locale settings.
5
+ def self.parse(number)
6
+ return number unless number.is_a?(String)
7
+
8
+ separator, delimiter = I18n.t([:'number.currency.format.separator', :'number.currency.format.delimiter'])
9
+ non_number_characters = /[^0-9\-#{separator}]/
10
+
11
+ # strip everything else first
12
+ number.gsub!(non_number_characters, '')
13
+ # then replace the locale-specific decimal separator with the standard separator if necessary
14
+ number.gsub!(separator, '.') unless separator == '.'
15
+
16
+ number.to_d
17
+ end
18
+
19
+ end
20
+ end
@@ -28,9 +28,13 @@ module Spree
28
28
  name
29
29
  end.compact! || []
30
30
 
31
- unless (engine_migrations.sort - engine_in_app.sort).empty?
32
- puts "[#{engine_name.capitalize} WARNING] Missing migrations." \
33
- " Run `bundle exec rake railties:install:migrations` to get them.\n\n"
31
+ missing_migrations = engine_migrations.sort - engine_in_app.sort
32
+ unless missing_migrations.empty?
33
+ puts "[#{engine_name.capitalize} WARNING] Missing migrations."
34
+ missing_migrations.each do |migration|
35
+ puts "[#{engine_name.capitalize} WARNING] #{migration} from #{engine_name} is missing."
36
+ end
37
+ puts "[#{engine_name.capitalize} WARNING] Run `bundle exec rake railties:install:migrations` to get them.\n\n"
34
38
  true
35
39
  end
36
40
  end
@@ -6,7 +6,7 @@ module Spree
6
6
  class Money
7
7
  attr_reader :money
8
8
 
9
- delegate :cents, :to => :money
9
+ delegate :cents, to: :money
10
10
 
11
11
  def initialize(amount, options={})
12
12
  @money = Monetize.parse([amount, (options[:currency] || Spree::Config[:currency])].join)
@@ -26,7 +26,7 @@ module Spree
26
26
  @money.format(@options)
27
27
  end
28
28
 
29
- def to_html(options = { :html => true })
29
+ def to_html(options = { html: true })
30
30
  output = @money.format(@options.merge(options))
31
31
  if options[:html]
32
32
  # 1) prevent blank, breaking spaces
@@ -35,7 +35,9 @@ module Spree
35
35
  :state => [:name, :abbr]
36
36
  ]
37
37
 
38
- @@checkout_attributes = [:email, :use_billing, :shipping_method_id, :coupon_code, :special_instructions]
38
+ @@checkout_attributes = [
39
+ :coupon_code, :email, :shipping_method_id, :special_instructions, :use_billing
40
+ ]
39
41
 
40
42
  @@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
41
43
 
@@ -1,105 +1,105 @@
1
1
  shared_examples_for 'access granted' do
2
2
  it 'should allow read' do
3
- ability.should be_able_to(:read, resource, token) if token
4
- ability.should be_able_to(:read, resource) unless token
3
+ expect(ability).to be_able_to(:read, resource, token) if token
4
+ expect(ability).to be_able_to(:read, resource) unless token
5
5
  end
6
6
 
7
7
  it 'should allow create' do
8
- ability.should be_able_to(:create, resource, token) if token
9
- ability.should be_able_to(:create, resource) unless token
8
+ expect(ability).to be_able_to(:create, resource, token) if token
9
+ expect(ability).to be_able_to(:create, resource) unless token
10
10
  end
11
11
 
12
12
  it 'should allow update' do
13
- ability.should be_able_to(:update, resource, token) if token
14
- ability.should be_able_to(:update, resource) unless token
13
+ expect(ability).to be_able_to(:update, resource, token) if token
14
+ expect(ability).to be_able_to(:update, resource) unless token
15
15
  end
16
16
  end
17
17
 
18
18
  shared_examples_for 'access denied' do
19
19
  it 'should not allow read' do
20
- ability.should_not be_able_to(:read, resource)
20
+ expect(ability).to_not be_able_to(:read, resource)
21
21
  end
22
22
 
23
23
  it 'should not allow create' do
24
- ability.should_not be_able_to(:create, resource)
24
+ expect(ability).to_not be_able_to(:create, resource)
25
25
  end
26
26
 
27
27
  it 'should not allow update' do
28
- ability.should_not be_able_to(:update, resource)
28
+ expect(ability).to_not be_able_to(:update, resource)
29
29
  end
30
30
  end
31
31
 
32
32
  shared_examples_for 'admin granted' do
33
33
  it 'should allow admin' do
34
- ability.should be_able_to(:admin, resource, token) if token
35
- ability.should be_able_to(:admin, resource) unless token
34
+ expect(ability).to be_able_to(:admin, resource, token) if token
35
+ expect(ability).to be_able_to(:admin, resource) unless token
36
36
  end
37
37
  end
38
38
 
39
39
  shared_examples_for 'admin denied' do
40
40
  it 'should not allow admin' do
41
- ability.should_not be_able_to(:admin, resource)
41
+ expect(ability).to_not be_able_to(:admin, resource)
42
42
  end
43
43
  end
44
44
 
45
45
  shared_examples_for 'index allowed' do
46
46
  it 'should allow index' do
47
- ability.should be_able_to(:index, resource)
47
+ expect(ability).to be_able_to(:index, resource)
48
48
  end
49
49
  end
50
50
 
51
51
  shared_examples_for 'no index allowed' do
52
52
  it 'should not allow index' do
53
- ability.should_not be_able_to(:index, resource)
53
+ expect(ability).to_not be_able_to(:index, resource)
54
54
  end
55
55
  end
56
56
 
57
57
  shared_examples_for 'create only' do
58
58
  it 'should allow create' do
59
- ability.should be_able_to(:create, resource)
59
+ expect(ability).to be_able_to(:create, resource)
60
60
  end
61
61
 
62
62
  it 'should not allow read' do
63
- ability.should_not be_able_to(:read, resource)
63
+ expect(ability).to_not be_able_to(:read, resource)
64
64
  end
65
65
 
66
66
  it 'should not allow update' do
67
- ability.should_not be_able_to(:update, resource)
67
+ expect(ability).to_not be_able_to(:update, resource)
68
68
  end
69
69
 
70
70
  it 'should not allow index' do
71
- ability.should_not be_able_to(:index, resource)
71
+ expect(ability).to_not be_able_to(:index, resource)
72
72
  end
73
73
  end
74
74
 
75
75
  shared_examples_for 'read only' do
76
76
  it 'should not allow create' do
77
- ability.should_not be_able_to(:create, resource)
77
+ expect(ability).to_not be_able_to(:create, resource)
78
78
  end
79
79
 
80
80
  it 'should not allow update' do
81
- ability.should_not be_able_to(:update, resource)
81
+ expect(ability).to_not be_able_to(:update, resource)
82
82
  end
83
83
 
84
84
  it 'should allow index' do
85
- ability.should be_able_to(:index, resource)
85
+ expect(ability).to be_able_to(:index, resource)
86
86
  end
87
87
  end
88
88
 
89
89
  shared_examples_for 'update only' do
90
90
  it 'should not allow create' do
91
- ability.should_not be_able_to(:create, resource)
91
+ expect(ability).to_not be_able_to(:create, resource)
92
92
  end
93
93
 
94
94
  it 'should not allow read' do
95
- ability.should_not be_able_to(:read, resource)
95
+ expect(ability).to_not be_able_to(:read, resource)
96
96
  end
97
97
 
98
98
  it 'should allow update' do
99
- ability.should be_able_to(:update, resource)
99
+ expect(ability).to be_able_to(:update, resource)
100
100
  end
101
101
 
102
102
  it 'should not allow index' do
103
- ability.should_not be_able_to(:index, resource)
103
+ expect(ability).to_not be_able_to(:index, resource)
104
104
  end
105
105
  end
@@ -8,7 +8,7 @@ module CapybaraExt
8
8
  end
9
9
 
10
10
  def eventually_fill_in(field, options={})
11
- page.should have_css('#' + field)
11
+ expect(page).to have_css('#' + field)
12
12
  fill_in field, options
13
13
  end
14
14
 
@@ -145,7 +145,7 @@ end
145
145
 
146
146
  RSpec::Matchers.define :have_title do |expected|
147
147
  match do |actual|
148
- has_css?("title", :text => expected, visible: false)
148
+ has_css?("title", text: expected, visible: false)
149
149
  end
150
150
 
151
151
  failure_message do |actual|
@@ -3,7 +3,7 @@ FactoryGirl.define do
3
3
  quantity 1
4
4
  price { BigDecimal.new('10.00') }
5
5
  order
6
- ignore do
6
+ transient do
7
7
  association :product
8
8
  end
9
9
  variant{ product.master }
@@ -16,7 +16,7 @@ FactoryGirl.define do
16
16
  bill_address
17
17
  ship_address
18
18
 
19
- ignore do
19
+ transient do
20
20
  line_items_count 5
21
21
  end
22
22
 
@@ -3,7 +3,7 @@ FactoryGirl.define do
3
3
  name 'Promo'
4
4
 
5
5
  trait :with_line_item_adjustment do
6
- ignore do
6
+ transient do
7
7
  adjustment_rate 10
8
8
  end
9
9
 
@@ -16,7 +16,7 @@ FactoryGirl.define do
16
16
  factory :promotion_with_item_adjustment, traits: [:with_line_item_adjustment]
17
17
 
18
18
  trait :with_order_adjustment do
19
- ignore do
19
+ transient do
20
20
  order_adjustment_amount 10
21
21
  end
22
22
 
@@ -30,13 +30,13 @@ FactoryGirl.define do
30
30
  end
31
31
 
32
32
  trait :with_item_total_rule do
33
- ignore do
33
+ transient do
34
34
  item_total_threshold_amount 10
35
35
  end
36
36
 
37
37
  after(:create) do |promotion, evaluator|
38
38
  rule = Spree::Promotion::Rules::ItemTotal.create!(
39
- preferred_operator: 'gte',
39
+ preferred_operator: 'gte',
40
40
  preferred_amount: evaluator.item_total_threshold_amount
41
41
  )
42
42
  promotion.rules << rule
@@ -1,7 +1,7 @@
1
1
  FactoryGirl.define do
2
2
  # must use build()
3
3
  factory :stock_packer, class: Spree::Stock::Packer do
4
- ignore do
4
+ transient do
5
5
  stock_location { build(:stock_location) }
6
6
  contents []
7
7
  end
@@ -10,7 +10,7 @@ FactoryGirl.define do
10
10
  end
11
11
 
12
12
  factory :stock_package, class: Spree::Stock::Package do
13
- ignore do
13
+ transient do
14
14
  stock_location { build(:stock_location) }
15
15
  order { create(:order_with_line_items, line_items_count: 2) }
16
16
  contents []
@@ -5,12 +5,12 @@ module Spree
5
5
  flash = convert_flash(flash)
6
6
 
7
7
  within("[class='flash success']") do
8
- page.should have_content(flash)
8
+ expect(page).to have_content(flash)
9
9
  end
10
10
  end
11
11
 
12
12
  def assert_successful_update_message(resource)
13
- flash = Spree.t(:successfully_updated, :resource => Spree.t(resource))
13
+ flash = Spree.t(:successfully_updated, resource: Spree.t(resource))
14
14
  assert_flash_success(flash)
15
15
  end
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -184,14 +184,20 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 0.16.1
187
+ version: '0.15'
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: 0.15.1
188
191
  type: :runtime
189
192
  prerelease: false
190
193
  version_requirements: !ruby/object:Gem::Requirement
191
194
  requirements:
192
195
  - - "~>"
193
196
  - !ruby/object:Gem::Version
194
- version: 0.16.1
197
+ version: '0.15'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 0.15.1
195
201
  - !ruby/object:Gem::Dependency
196
202
  name: monetize
197
203
  requirement: !ruby/object:Gem::Requirement
@@ -240,14 +246,14 @@ dependencies:
240
246
  requirements:
241
247
  - - "~>"
242
248
  - !ruby/object:Gem::Version
243
- version: 4.1.6
249
+ version: 4.1.8
244
250
  type: :runtime
245
251
  prerelease: false
246
252
  version_requirements: !ruby/object:Gem::Requirement
247
253
  requirements:
248
254
  - - "~>"
249
255
  - !ruby/object:Gem::Version
250
- version: 4.1.6
256
+ version: 4.1.8
251
257
  - !ruby/object:Gem::Dependency
252
258
  name: ransack
253
259
  requirement: !ruby/object:Gem::Requirement
@@ -612,6 +618,9 @@ files:
612
618
  - db/migrate/20140616202624_remove_uncaptured_amount_from_spree_payments.rb
613
619
  - db/migrate/20140804185157_add_default_to_shipment_cost.rb
614
620
  - db/migrate/20140927193717_default_pre_tax_amount_should_be_zero.rb
621
+ - db/migrate/20141021194502_add_state_lock_version_to_order.rb
622
+ - db/migrate/20141101231208_fix_adjustment_order_presence.rb
623
+ - db/migrate/20141105213646_update_classifications_positions.rb
615
624
  - db/seeds.rb
616
625
  - lib/generators/spree/custom_user/custom_user_generator.rb
617
626
  - lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
@@ -664,6 +673,7 @@ files:
664
673
  - lib/spree/i18n.rb
665
674
  - lib/spree/i18n/base.rb
666
675
  - lib/spree/i18n/initializer.rb
676
+ - lib/spree/localized_number.rb
667
677
  - lib/spree/migrations.rb
668
678
  - lib/spree/money.rb
669
679
  - lib/spree/permitted_attributes.rb
@@ -725,19 +735,6 @@ files:
725
735
  - lib/tasks/core.rake
726
736
  - vendor/assets/javascripts/jquery-migrate-1.0.0.js
727
737
  - vendor/assets/javascripts/jquery.payment.js
728
- - vendor/assets/javascripts/jquery.validate/localization/messages_et.js
729
- - vendor/assets/javascripts/jquery.validate/localization/messages_eu.js
730
- - vendor/assets/javascripts/jquery.validate/localization/messages_hr.js
731
- - vendor/assets/javascripts/jquery.validate/localization/messages_ka.js
732
- - vendor/assets/javascripts/jquery.validate/localization/messages_ko.js
733
- - vendor/assets/javascripts/jquery.validate/localization/messages_my.js
734
- - vendor/assets/javascripts/jquery.validate/localization/messages_pt_BR.js
735
- - vendor/assets/javascripts/jquery.validate/localization/messages_pt_PT.js
736
- - vendor/assets/javascripts/jquery.validate/localization/messages_sl.js
737
- - vendor/assets/javascripts/jquery.validate/localization/messages_sv.js
738
- - vendor/assets/javascripts/jquery.validate/localization/messages_uk.js
739
- - vendor/assets/javascripts/jquery.validate/localization/messages_zh.js
740
- - vendor/assets/javascripts/jquery.validate/localization/messages_zh_TW.js
741
738
  - vendor/assets/javascripts/jsuri.js
742
739
  - vendor/assets/stylesheets/normalize.css
743
740
  - vendor/assets/stylesheets/skeleton.css