solidus_core 2.1.1 → 2.2.0.beta1

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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -1
  3. data/app/assets/config/solidus_core_manifest.js +1 -0
  4. data/app/assets/javascripts/spree.js.erb +72 -0
  5. data/app/helpers/spree/store_helper.rb +5 -0
  6. data/app/jobs/spree/promotion_code_batch_job.rb +24 -0
  7. data/app/mailers/spree/promotion_code_batch_mailer.rb +13 -0
  8. data/app/models/concerns/spree/calculated_adjustments.rb +1 -1
  9. data/app/models/concerns/spree/ordered_property_value_list.rb +2 -2
  10. data/app/models/concerns/spree/user_address_book.rb +4 -4
  11. data/app/models/concerns/spree/user_methods.rb +7 -0
  12. data/app/models/concerns/spree/user_payment_source.rb +12 -5
  13. data/app/models/spree/address.rb +14 -3
  14. data/app/models/spree/adjustment.rb +13 -1
  15. data/app/models/spree/app_configuration.rb +0 -19
  16. data/app/models/spree/base.rb +2 -0
  17. data/app/models/spree/credit_card.rb +34 -43
  18. data/app/models/spree/gateway/bogus.rb +1 -1
  19. data/app/models/spree/gateway.rb +6 -4
  20. data/app/models/spree/inventory_unit.rb +3 -2
  21. data/app/models/spree/order/checkout.rb +187 -273
  22. data/app/models/spree/order.rb +137 -71
  23. data/app/models/spree/order_contents.rb +1 -1
  24. data/app/models/spree/order_inventory.rb +11 -11
  25. data/app/models/spree/order_promotion.rb +2 -0
  26. data/app/models/spree/order_update_attributes.rb +1 -8
  27. data/app/models/spree/order_updater.rb +67 -63
  28. data/app/models/spree/payment.rb +0 -1
  29. data/app/models/spree/payment_create.rb +27 -7
  30. data/app/models/spree/payment_method/store_credit.rb +3 -3
  31. data/app/models/spree/payment_method.rb +4 -1
  32. data/app/models/spree/payment_source.rb +45 -0
  33. data/app/models/spree/product/scopes.rb +24 -24
  34. data/app/models/spree/product.rb +4 -4
  35. data/app/models/spree/promotion.rb +2 -0
  36. data/app/models/spree/promotion_code/batch_builder.rb +63 -0
  37. data/app/models/spree/promotion_code.rb +1 -0
  38. data/app/models/spree/promotion_code_batch.rb +25 -0
  39. data/app/models/spree/promotion_handler/cart.rb +2 -2
  40. data/app/models/spree/promotion_handler/coupon.rb +1 -2
  41. data/app/models/spree/promotion_handler/free_shipping.rb +32 -21
  42. data/app/models/spree/promotion_handler/page.rb +1 -1
  43. data/app/models/spree/reimbursement.rb +1 -1
  44. data/app/models/spree/return_authorization.rb +0 -28
  45. data/app/models/spree/return_item.rb +1 -1
  46. data/app/models/spree/shipment.rb +4 -4
  47. data/app/models/spree/shipping_method.rb +2 -2
  48. data/app/models/spree/shipping_rate.rb +1 -1
  49. data/app/models/spree/stock/availability_validator.rb +16 -17
  50. data/app/models/spree/stock/coordinator.rb +3 -3
  51. data/app/models/spree/stock/package.rb +1 -1
  52. data/app/models/spree/stock/quantifier.rb +5 -4
  53. data/app/models/spree/stock_location.rb +2 -2
  54. data/app/models/spree/store.rb +2 -2
  55. data/app/models/spree/store_credit.rb +1 -1
  56. data/app/models/spree/tax/tax_helpers.rb +3 -3
  57. data/app/models/spree/tax_rate.rb +7 -1
  58. data/app/models/spree/taxonomy.rb +1 -1
  59. data/app/models/spree/variant/scopes.rb +5 -5
  60. data/app/models/spree/variant/vat_price_generator.rb +8 -5
  61. data/app/models/spree/variant.rb +1 -0
  62. data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +19 -10
  63. data/app/models/spree/wallet/default_payment_builder.rb +6 -6
  64. data/app/models/spree/wallet.rb +71 -0
  65. data/app/models/spree/wallet_payment_source.rb +17 -0
  66. data/app/models/spree/zone.rb +1 -1
  67. data/app/views/spree/carton_mailer/shipped_email.text.erb +1 -1
  68. data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +2 -0
  69. data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +2 -0
  70. data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +0 -7
  71. data/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb +0 -5
  72. data/app/views/spree/shared/_error_messages.html.erb +1 -1
  73. data/app/views/spree/shipment_mailer/shipped_email.html.erb +1 -1
  74. data/config/initializers/assets.rb +1 -1
  75. data/config/initializers/friendly_id.rb +1 -1
  76. data/config/locales/en.yml +50 -12
  77. data/db/default/spree/store_credit.rb +2 -1
  78. data/db/migrate/20130826062534_add_depth_to_spree_taxons.rb +4 -6
  79. data/db/migrate/20160420044191_create_spree_wallet_payment_sources.rb +23 -0
  80. data/db/migrate/20160420181916_migrate_credit_cards_to_wallet_payment_sources.rb +26 -0
  81. data/db/migrate/20161017102621_create_spree_promotion_code_batch.rb +36 -0
  82. data/db/migrate/20161129035810_add_index_to_spree_payments_number.rb +5 -0
  83. data/db/migrate/20170223235001_remove_spree_store_credits_column.rb +5 -0
  84. data/lib/generators/spree/dummy/templates/rails/application.rb +1 -1
  85. data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
  86. data/lib/generators/spree/install/install_generator.rb +6 -5
  87. data/lib/spree/core/controller_helpers/payment_parameters.rb +54 -0
  88. data/lib/spree/core/engine.rb +6 -9
  89. data/lib/spree/core/version.rb +1 -1
  90. data/lib/spree/core.rb +0 -1
  91. data/lib/spree/money.rb +18 -0
  92. data/lib/spree/permission_sets/default_customer.rb +1 -1
  93. data/lib/spree/permitted_attributes.rb +1 -1
  94. data/lib/spree/testing_support/authorization_helpers.rb +1 -0
  95. data/lib/spree/testing_support/capybara_ext.rb +13 -0
  96. data/lib/spree/testing_support/factories/order_factory.rb +5 -1
  97. data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
  98. data/lib/spree/testing_support/factories/shipment_factory.rb +0 -1
  99. data/solidus_core.gemspec +3 -3
  100. data/spec/jobs/promotion_code_batch_job_spec.rb +65 -0
  101. data/spec/lib/calculated_adjustments_spec.rb +105 -1
  102. data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +4 -1
  103. data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +8 -0
  104. data/spec/lib/spree/money_spec.rb +32 -0
  105. data/spec/lib/spree/permission_sets/default_customer_spec.rb +20 -0
  106. data/spec/mailers/promotion_code_batch_mailer_spec.rb +45 -0
  107. data/spec/models/spree/credit_card_spec.rb +86 -86
  108. data/spec/models/spree/gateway_spec.rb +3 -1
  109. data/spec/models/spree/inventory_unit_spec.rb +12 -4
  110. data/spec/models/spree/order/checkout_spec.rb +11 -32
  111. data/spec/models/spree/order/tax_spec.rb +2 -2
  112. data/spec/models/spree/order_contents_spec.rb +24 -1
  113. data/spec/models/spree/order_inventory_spec.rb +130 -83
  114. data/spec/models/spree/order_spec.rb +15 -117
  115. data/spec/models/spree/order_update_attributes_spec.rb +1 -44
  116. data/spec/models/spree/order_updater_spec.rb +10 -13
  117. data/spec/models/spree/payment_create_spec.rb +5 -1
  118. data/spec/models/spree/payment_method_spec.rb +16 -0
  119. data/spec/models/spree/payment_spec.rb +14 -8
  120. data/spec/models/spree/promotion_code/batch_builder_spec.rb +61 -0
  121. data/spec/models/spree/promotion_code_batch_spec.rb +58 -0
  122. data/spec/models/spree/promotion_code_spec.rb +4 -0
  123. data/spec/models/spree/promotion_spec.rb +3 -6
  124. data/spec/models/spree/return_authorization_spec.rb +0 -59
  125. data/spec/models/spree/shipment_spec.rb +4 -4
  126. data/spec/models/spree/stock/availability_validator_spec.rb +64 -9
  127. data/spec/models/spree/tax/item_adjuster_spec.rb +1 -2
  128. data/spec/models/spree/unit_cancel_spec.rb +0 -85
  129. data/spec/models/spree/user_spec.rb +3 -1
  130. data/spec/models/spree/variant/vat_price_generator_spec.rb +8 -2
  131. data/spec/models/spree/variant_spec.rb +16 -4
  132. data/spec/models/spree/wallet_payment_source_spec.rb +46 -0
  133. data/spec/models/spree/wallet_spec.rb +128 -0
  134. data/spec/support/concerns/payment_source.rb +64 -0
  135. metadata +51 -25
  136. data/app/assets/javascripts/spree.js.coffee.erb +0 -64
  137. data/app/models/spree/promotion_builder.rb +0 -55
  138. data/app/models/spree/promotion_code/code_builder.rb +0 -62
  139. data/config/initializers/premailer_assets.rb +0 -1
  140. data/lib/spree/core/unreturned_item_charger.rb +0 -106
  141. data/lib/tasks/exchanges.rake +0 -47
  142. data/spec/lib/spree/core/unreturned_item_charger_spec.rb +0 -126
  143. data/spec/lib/tasks/exchanges_spec.rb +0 -220
  144. data/spec/models/spree/promotion_builder_spec.rb +0 -120
  145. data/spec/models/spree/promotion_code/code_builder_spec.rb +0 -77
@@ -29,6 +29,8 @@ en:
29
29
  code: Code
30
30
  name: Name
31
31
  state: State
32
+ spree/calculator/flat_rate:
33
+ preferred_amount: Amount
32
34
  spree/calculator/tiered_flat_rate:
33
35
  preferred_base_amount: Base Amount
34
36
  preferred_tiers: Tiers
@@ -166,12 +168,12 @@ en:
166
168
  code: Code
167
169
  description: Description
168
170
  event_name: Event Name
169
- expires_at: Expiration
171
+ expires_at: Expiration date
170
172
  name: Name
171
173
  path: Path
172
174
  per_code_usage_limit: Per Code Usage Limit
173
175
  promotion_uses: Promotion Uses
174
- starts_at: Starts
176
+ starts_at: Start date
175
177
  usage_limit: Overall Usage Limit
176
178
  spree/promotion_category:
177
179
  name: Name
@@ -468,6 +470,12 @@ en:
468
470
  spree/promotion_category:
469
471
  one: Promotion Category
470
472
  other: Promotion Categories
473
+ spree/promotion_code_batch:
474
+ one: Promotion Code Batch
475
+ other: Promotion Code Batches
476
+ spree/promotion_code:
477
+ one: Promotion Code
478
+ other: Promotion Codes
471
479
  spree/property:
472
480
  one: Property Type
473
481
  other: Property Types
@@ -517,6 +525,9 @@ en:
517
525
  spree/stock_transfer:
518
526
  one: Stock Transfer
519
527
  other: Stock Transfers
528
+ spree/store:
529
+ one: Store
530
+ other: Stores
520
531
  spree/store_credit:
521
532
  one: Store Credit
522
533
  other: Store Credits
@@ -621,6 +632,10 @@ en:
621
632
  attributes:
622
633
  user_id:
623
634
  default_address_exists: "already has a default address"
635
+ spree/wallet_payment_source:
636
+ attributes:
637
+ payment_source:
638
+ has_to_be_payment_source_class: "has to be a Spree::PaymentSource"
624
639
 
625
640
  devise:
626
641
  confirmations:
@@ -642,7 +657,7 @@ en:
642
657
  unlock_instructions:
643
658
  subject: Unlock Instructions
644
659
  oauth_callbacks:
645
- failure: Could not authorize you from %{kind} because "%{reason}".
660
+ failure: "Could not authorize you from %{kind} because %{reason}."
646
661
  success: Successfully authorized from %{kind} account.
647
662
  unlocks:
648
663
  send_instructions: You will receive an email with instructions about how to unlock your account in a few minutes.
@@ -688,14 +703,13 @@ en:
688
703
  list: List
689
704
  listing: Listing
690
705
  new: New
691
- refund: Refund
692
706
  receive: Receive
707
+ refund: Refund
693
708
  remove: Remove
694
709
  save: Save
695
- ship: ship
696
- update: Update
710
+ ship: Ship
697
711
  split: Split
698
- ship: ship
712
+ update: Update
699
713
  activate: Activate
700
714
  active: Active
701
715
  add: Add
@@ -703,6 +717,7 @@ en:
703
717
  add_action_of_type: Add action of type
704
718
  add_country: Add Country
705
719
  add_coupon_code: Add Coupon Code
720
+ add_line_item: Add Item
706
721
  add_new_header: Add New Header
707
722
  add_new_style: Add New Style
708
723
  add_one: Add One
@@ -743,8 +758,8 @@ en:
743
758
  adjustment_total: Adjustment Total
744
759
  adjustments: Adjustments
745
760
  admin:
746
- general_settings:
747
- edit:
761
+ stores:
762
+ form:
748
763
  no_cart_tax_country: "No taxes on carts without address"
749
764
  images:
750
765
  index:
@@ -770,6 +785,17 @@ en:
770
785
  form:
771
786
  starts_at_placeholder: Immediately
772
787
  expires_at_placeholder: Never
788
+ activation: Activation
789
+ general: General
790
+ activations_new:
791
+ auto: Apply to all orders
792
+ multiple_codes: Multiple promotion codes
793
+ path: URL Path
794
+ single_code: Single promotion code
795
+ activations_edit:
796
+ auto: All orders will attempt to use this promotion
797
+ single_code_html: "This promotion uses the promotion code: <code>%{code}</code>"
798
+ multiple_codes_html: "This promotion uses %{count} promotion codes"
773
799
  store_credits:
774
800
  add: "Add store credit"
775
801
  amount_authorized: "Amount Authorized"
@@ -816,7 +842,6 @@ en:
816
842
  checkout: Refunds and Returns
817
843
  configuration: Configuration
818
844
  display_order: Display Order
819
- general: Store
820
845
  option_types: Option Types
821
846
  orders: Orders
822
847
  overview: Overview
@@ -832,6 +857,7 @@ en:
832
857
  stock: Stock
833
858
  stock_items: Store Stock
834
859
  stock_transfers: Stock Transfers
860
+ stores: Stores
835
861
  taxes: Taxes
836
862
  taxonomies: Taxonomies
837
863
  taxons: Taxons
@@ -1168,7 +1194,6 @@ en:
1168
1194
  exceptions:
1169
1195
  count_on_hand_setter: Cannot set count_on_hand manually, as it is set automatically by the recalculate_count_on_hand callback. Please use `update_column(:count_on_hand, value)` instead.
1170
1196
  exchange_for: Exchange for
1171
- expedited_exchanges_warning: "Any specified exchanges will ship to the customer immediately upon saving. The customer will be charged the full amount of the item if they do not return the original item within %{days_window} days."
1172
1197
  excl: excl.
1173
1198
  expected: Expected
1174
1199
  expected_items: Expected Items
@@ -1280,7 +1305,7 @@ en:
1280
1305
  inventory: Inventory
1281
1306
  inventory_adjustment: Inventory Adjustment
1282
1307
  inventory_canceled: Inventory canceled
1283
- inventory_error_flash_for_insufficient_quantity: An item in your cart has become unavailable.
1308
+ inventory_error_flash_for_insufficient_quantity: "#{names} became unavailable."
1284
1309
  inventory_not_available: Inventory not available for %{item}.
1285
1310
  inventory_state: Inventory State
1286
1311
  inventory_states:
@@ -1376,6 +1401,7 @@ en:
1376
1401
  new_product: New Product
1377
1402
  new_promotion: New Promotion
1378
1403
  new_promotion_category: New Promotion Category
1404
+ new_promotion_code_batch: New Promotion Code Batch
1379
1405
  new_property: New Property Type
1380
1406
  new_refund: New Refund
1381
1407
  new_refund_reason: New Refund Reason
@@ -1389,6 +1415,7 @@ en:
1389
1415
  new_stock_movement: New Stock Movement
1390
1416
  new_stock_transfer: New Stock Transfer
1391
1417
  new_store_credit: New Store Credit
1418
+ new_store: New Store
1392
1419
  new_tax_category: New Tax Category
1393
1420
  new_tax_rate: New Tax Rate
1394
1421
  new_taxon: New Taxon
@@ -1599,6 +1626,17 @@ en:
1599
1626
  description: Makes all shipments for the order free
1600
1627
  name: Free shipping
1601
1628
  promotion_actions: Actions
1629
+ promotion_code_batch_mailer:
1630
+ promotion_code_batch_finished:
1631
+ subject: Promotion code batch finished
1632
+ message: "All %{number_of_codes} codes have been created for promotion: "
1633
+ promotion_code_batch_errored:
1634
+ subject: Promotion code batch errored
1635
+ message: "Promotion code batch errored (%{error}) for promotion: "
1636
+ promotion_code_batches:
1637
+ errored: "Errored: %{error}"
1638
+ finished: "All %{number_of_codes} codes have been created."
1639
+ processing: "Processing: %{number_of_codes_processed} / %{number_of_codes}"
1602
1640
  promotion_form:
1603
1641
  match_policies:
1604
1642
  all: Match all of these rules
@@ -4,7 +4,8 @@ Spree::PaymentMethod.create_with(
4
4
  name: "Store Credit",
5
5
  description: "Store credit",
6
6
  active: true,
7
- display_on: 'none'
7
+ available_to_admin: false,
8
+ available_to_users: false
8
9
  ).find_or_create_by!(
9
10
  type: "Spree::PaymentMethod::StoreCredit"
10
11
  )
@@ -1,12 +1,10 @@
1
1
  class AddDepthToSpreeTaxons < ActiveRecord::Migration[4.2]
2
2
  def up
3
- if !Spree::Taxon.column_names.include?('depth')
4
- add_column :spree_taxons, :depth, :integer
3
+ add_column :spree_taxons, :depth, :integer
5
4
 
6
- say_with_time 'Update depth on all taxons' do
7
- Spree::Taxon.reset_column_information
8
- Spree::Taxon.all.each(&:save)
9
- end
5
+ say_with_time 'Update depth on all taxons' do
6
+ Spree::Taxon.reset_column_information
7
+ Spree::Taxon.all.each(&:save)
10
8
  end
11
9
  end
12
10
 
@@ -0,0 +1,23 @@
1
+ class CreateSpreeWalletPaymentSources < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :spree_wallet_payment_sources do |t|
4
+ t.references(
5
+ :user,
6
+ foreign_key: { to_table: Spree.user_class.table_name },
7
+ index: true,
8
+ null: false,
9
+ )
10
+ t.references :payment_source, polymorphic: true, null: false
11
+ t.boolean :default, default: false, null: false
12
+
13
+ t.timestamps null: false
14
+ end
15
+
16
+ add_index(
17
+ :spree_wallet_payment_sources,
18
+ [:user_id, :payment_source_id, :payment_source_type],
19
+ unique: true,
20
+ name: 'index_spree_wallet_payment_sources_on_source_and_user',
21
+ )
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ class MigrateCreditCardsToWalletPaymentSources < ActiveRecord::Migration[4.2]
2
+ class CreditCard < ActiveRecord::Base
3
+ self.table_name = 'spree_credit_cards'
4
+ end
5
+ class WalletPaymentSource < ActiveRecord::Base
6
+ self.table_name = 'spree_wallet_payment_sources'
7
+ end
8
+
9
+ def up
10
+ credit_cards = CreditCard.
11
+ where.not(gateway_customer_profile_id: nil).
12
+ where.not(user_id: nil)
13
+
14
+ credit_cards.find_each do |credit_card|
15
+ WalletPaymentSource.find_or_create_by!(
16
+ user_id: credit_card.user_id,
17
+ payment_source: credit_card
18
+ ) do |wallet_source|
19
+ wallet_source.default = credit_card.default
20
+ end
21
+ end
22
+ end
23
+
24
+ def down
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ class CreateSpreePromotionCodeBatch < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :spree_promotion_code_batches do |t|
4
+ t.references :promotion, null: false, index: true
5
+ t.string :base_code, null: false
6
+ t.integer :number_of_codes, null: false
7
+ t.string :email
8
+ t.string :error
9
+ t.string :state, default: "pending"
10
+ t.timestamps
11
+ end
12
+
13
+ add_foreign_key(
14
+ :spree_promotion_code_batches,
15
+ :spree_promotions,
16
+ column: :promotion_id
17
+ )
18
+
19
+ add_column(
20
+ :spree_promotion_codes,
21
+ :promotion_code_batch_id,
22
+ :integer
23
+ )
24
+
25
+ add_foreign_key(
26
+ :spree_promotion_codes,
27
+ :spree_promotion_code_batches,
28
+ column: :promotion_code_batch_id
29
+ )
30
+
31
+ add_index(
32
+ :spree_promotion_codes,
33
+ :promotion_code_batch_id
34
+ )
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ class AddIndexToSpreePaymentsNumber < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_index 'spree_payments', ['number'], unique: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveSpreeStoreCreditsColumn < ActiveRecord::Migration[5.0]
2
+ def change
3
+ remove_column :spree_store_credits, :spree_store_credits, :datetime
4
+ end
5
+ end
@@ -2,7 +2,7 @@ require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  require 'rails/all'
4
4
 
5
- Bundler.require(*Rails.groups(:assets => %w(development test)))
5
+ Bundler.require(*Rails.groups(assets: %w(development test)))
6
6
 
7
7
  require '<%= lib_name %>'
8
8
 
@@ -27,7 +27,7 @@ Dummy::Application.configure do
27
27
  # The :test delivery method accumulates sent emails in the
28
28
  # ActionMailer::Base.deliveries array.
29
29
  config.action_mailer.delivery_method = :test
30
- ActionMailer::Base.default :from => "spree@example.com"
30
+ ActionMailer::Base.default from: "spree@example.com"
31
31
 
32
32
  # Raise on deprecation warnings
33
33
  if ENV['SOLIDUS_RAISE_DEPRECATIONS'].present?
@@ -149,23 +149,24 @@ Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
149
149
  end
150
150
  end
151
151
 
152
- def notify_about_routes
152
+ def install_routes
153
153
  insert_into_file File.join('config', 'routes.rb'), after: "Rails.application.routes.draw do\n" do
154
- %{
154
+ <<-ROUTES
155
155
  # This line mounts Spree's routes at the root of your application.
156
156
  # This means, any requests to URLs such as /products, will go to Spree::ProductsController.
157
157
  # If you would like to change where this engine is mounted, simply change the :at option to something different.
158
158
  #
159
159
  # We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
160
- mount Spree::Core::Engine, :at => '/'
161
- }
160
+ mount Spree::Core::Engine, at: '/'
161
+
162
+ ROUTES
162
163
  end
163
164
 
164
165
  unless options[:quiet]
165
166
  puts "*" * 50
166
167
  puts "We added the following line to your application's config/routes.rb file:"
167
168
  puts " "
168
- puts " mount Spree::Core::Engine, :at => '/'"
169
+ puts " mount Spree::Core::Engine, at: '/'"
169
170
  end
170
171
  end
171
172
 
@@ -116,6 +116,60 @@ module Spree
116
116
  params
117
117
  end
118
118
 
119
+ # This method handles the awkwardness of how the html forms are currently
120
+ # set up for frontend.
121
+ #
122
+ # This method expects a params hash in the format of:
123
+ #
124
+ # {
125
+ # order: {
126
+ # wallet_payment_source_id: '123',
127
+ # ...other params...
128
+ # },
129
+ # cvc_confirm: '456', # optional
130
+ # ...other params...
131
+ # }
132
+ #
133
+ # And this method modifies the params into the format of:
134
+ #
135
+ # {
136
+ # order: {
137
+ # payments_attributes: [
138
+ # {
139
+ # source_attributes: {
140
+ # wallet_payment_source_id: '123',
141
+ # verification_value: '456',
142
+ # },
143
+ # },
144
+ # ]
145
+ # ...other params...
146
+ # },
147
+ # ...other params...
148
+ # }
149
+ #
150
+ def move_wallet_payment_source_id_into_payments_attributes(params)
151
+ return params if params[:order].blank?
152
+
153
+ wallet_payment_source_id = params[:order][:wallet_payment_source_id].presence
154
+ cvc_confirm = params[:cvc_confirm].presence
155
+
156
+ return params if wallet_payment_source_id.nil?
157
+
158
+ params[:order][:payments_attributes] = [
159
+ {
160
+ source_attributes: {
161
+ wallet_payment_source_id: wallet_payment_source_id,
162
+ verification_value: cvc_confirm
163
+ }
164
+ }
165
+ ]
166
+
167
+ params[:order].delete(:wallet_payment_source_id)
168
+ params.delete(:cvc_confirm)
169
+
170
+ params
171
+ end
172
+
119
173
  # This is a strange thing to do since an order can have multiple payments
120
174
  # but we always assume that it only has a single payment and that its
121
175
  # amount should be the current order total. Also, this is pretty much
@@ -4,10 +4,6 @@ module Spree
4
4
  isolate_namespace Spree
5
5
  engine_name 'spree'
6
6
 
7
- rake_tasks do
8
- load File.join(root, "lib", "tasks", "exchanges.rake")
9
- end
10
-
11
7
  config.generators do |g|
12
8
  g.test_framework :rspec
13
9
  end
@@ -108,13 +104,14 @@ module Spree
108
104
  ]
109
105
  end
110
106
 
111
- # filter sensitive information during logging
107
+ # Filter sensitive information during logging
112
108
  initializer "spree.params.filter", before: :load_config_initializers do |app|
113
109
  app.config.filter_parameters += [
114
- :password,
115
- :password_confirmation,
116
- :number,
117
- :verification_value]
110
+ %r{^password$},
111
+ %r{^password_confirmation$},
112
+ %r{^number$}, # Credit Card number
113
+ %r{^verification_value$} # Credit Card verification value
114
+ ]
118
115
  end
119
116
 
120
117
  initializer "spree.core.checking_migrations", before: :load_config_initializers do |_app|
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  def self.solidus_version
3
- "2.1.1"
3
+ "2.2.0.beta1"
4
4
  end
5
5
 
6
6
  def self.solidus_gem_version
data/lib/spree/core.rb CHANGED
@@ -80,7 +80,6 @@ require 'spree/core/controller_helpers/respond_with'
80
80
  require 'spree/core/controller_helpers/search'
81
81
  require 'spree/core/controller_helpers/store'
82
82
  require 'spree/core/controller_helpers/strong_parameters'
83
- require 'spree/core/unreturned_item_charger'
84
83
  require 'spree/core/role_configuration'
85
84
  require 'spree/core/stock_configuration'
86
85
  require 'spree/permission_sets'
data/lib/spree/money.rb CHANGED
@@ -6,6 +6,8 @@ module Spree
6
6
  # Spree::Money is a relatively thin wrapper around Monetize which handles
7
7
  # formatting via Spree::Config.
8
8
  class Money
9
+ include Comparable
10
+ DifferentCurrencyError = Class.new(StandardError)
9
11
  RUBY_NUMERIC_STRING = /\A-?\d+(\.\d+)?\z/
10
12
 
11
13
  class <<self
@@ -92,6 +94,22 @@ module Spree
92
94
  to_s
93
95
  end
94
96
 
97
+ def <=>(other)
98
+ if !other.respond_to?(:money)
99
+ raise TypeError, "Can't compare #{other.class} to Spree::Money"
100
+ end
101
+ if self.currency != other.currency
102
+ # By default, ::Money will try to run a conversion on `other.money` and
103
+ # try a comparison on that. We do not want any currency conversion to
104
+ # take place so we'll catch this here and raise an error.
105
+ raise(
106
+ DifferentCurrencyError,
107
+ "Can't compare #{self.currency} with #{other.currency}"
108
+ )
109
+ end
110
+ @money <=> other.money
111
+ end
112
+
95
113
  # Delegates comparison to the internal ruby money instance.
96
114
  #
97
115
  # @see http://www.rubydoc.info/gems/money/Money/Arithmetic#%3D%3D-instance_method
@@ -7,7 +7,7 @@ module Spree
7
7
  can :display, OptionValue
8
8
  can :create, Order
9
9
  can [:read, :update], Order do |order, token|
10
- order.user == user || order.guest_token && token == order.guest_token
10
+ order.user == user || (order.guest_token.present? && token == order.guest_token)
11
11
  end
12
12
  can :create, ReturnAuthorization do |return_authorization|
13
13
  return_authorization.order.user == user
@@ -88,7 +88,7 @@ module Spree
88
88
  :number, :month, :year, :expiry, :verification_value,
89
89
  :first_name, :last_name, :cc_type, :gateway_customer_profile_id,
90
90
  :gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
91
- :existing_card_id
91
+ :existing_card_id, :wallet_payment_source_id
92
92
  ]
93
93
 
94
94
  @@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
@@ -60,4 +60,5 @@ end
60
60
  RSpec.configure do |config|
61
61
  config.extend Spree::TestingSupport::AuthorizationHelpers::Controller, type: :controller
62
62
  config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :feature
63
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :request
63
64
  end
@@ -20,6 +20,12 @@ module CapybaraExt
20
20
  end
21
21
 
22
22
  def fill_in_quantity(table_column, selector, quantity)
23
+ Spree::Deprecation.warn <<-WARN.strip_heredoc
24
+ fill_in_quantity is deprecated. Instead use:
25
+ within(#{table_column.inspect}) do
26
+ fill_in #{selector.inspect}, with: #{quantity.inspect}
27
+ end
28
+ WARN
23
29
  within(table_column) do
24
30
  fill_in selector, with: quantity
25
31
  end
@@ -100,6 +106,13 @@ module CapybaraExt
100
106
  end
101
107
 
102
108
  def wait_for_ajax
109
+
110
+ Spree::Deprecation.warn <<-WARN.squish, caller
111
+ wait_for_ajax has been deprecated.
112
+ Please refer to the capybara documentation on how to properly wait for asyncronous behavior:
113
+ https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends
114
+ WARN
115
+
103
116
  counter = 0
104
117
  while page.evaluate_script("typeof($) === 'undefined' || $.active > 0")
105
118
  counter += 1
@@ -76,6 +76,9 @@ FactoryGirl.define do
76
76
 
77
77
  after(:create) do |order|
78
78
  order.refresh_shipment_rates
79
+ order.shipments.each do |shipment|
80
+ shipment.inventory_units.update_all state: 'on_hand', pending: false
81
+ end
79
82
  order.update_column(:completed_at, Time.current)
80
83
  end
81
84
 
@@ -96,7 +99,6 @@ FactoryGirl.define do
96
99
  after(:create) do |order, evaluator|
97
100
  create(evaluator.payment_type, amount: order.total, order: order, state: 'completed')
98
101
  order.shipments.each do |shipment|
99
- shipment.inventory_units.update_all state: 'on_hand'
100
102
  shipment.update_column('state', 'ready')
101
103
  end
102
104
  order.reload
@@ -119,6 +121,8 @@ FactoryGirl.define do
119
121
  shipped_at: Time.current
120
122
  )
121
123
  end
124
+ # We need to update the shipment_state after all callbacks have run
125
+ order.update_columns(shipment_state: 'shipped')
122
126
  order.reload
123
127
  end
124
128
  end
@@ -6,7 +6,7 @@ require 'spree/testing_support/factories/store_credit_factory'
6
6
  FactoryGirl.define do
7
7
  factory :payment, aliases: [:credit_card_payment], class: Spree::Payment do
8
8
  association(:payment_method, factory: :credit_card_payment_method)
9
- source { create(:credit_card, user: order.user) }
9
+ source { create(:credit_card, user: order.user, address: order.bill_address) }
10
10
  order
11
11
  state 'checkout'
12
12
  response_code '12345'
@@ -1,7 +1,6 @@
1
1
  require 'spree/testing_support/factories/order_factory'
2
2
  require 'spree/testing_support/factories/stock_location_factory'
3
3
  require 'spree/testing_support/factories/shipping_method_factory'
4
- require 'spree/testing_support/factories/stock_location_factory'
5
4
 
6
5
  FactoryGirl.define do
7
6
  factory :shipment, class: Spree::Shipment do
data/solidus_core.gemspec CHANGED
@@ -28,9 +28,9 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency 'ffaker', '~> 2.0'
29
29
  s.add_dependency 'friendly_id', '~> 5.0'
30
30
  s.add_dependency 'highline', '~> 1.7' # Necessary for the install generator
31
- s.add_dependency 'kaminari', '~> 0.15', '>= 0.15.1'
31
+ s.add_dependency 'kaminari', '>= 0.17', '< 2.0'
32
32
  s.add_dependency 'monetize', '~> 1.1'
33
- s.add_dependency 'paperclip', '~> 4.2'
33
+ s.add_dependency 'paperclip', ['>= 4.2', '< 6']
34
34
  s.add_dependency 'paranoia', '~> 2.2.0.pre'
35
35
  s.add_dependency 'premailer-rails'
36
36
  s.add_dependency 'rails', '~> 5.0.0'
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
  s.add_dependency 'state_machines-activerecord', '~> 0.4'
40
40
  s.add_dependency 'stringex', '~> 1.5.1'
41
41
  s.add_dependency 'truncate_html', '~> 0.9', '>= 0.9.2'
42
- s.add_dependency 'twitter_cldr', '~> 3.0'
42
+ s.add_dependency 'twitter_cldr', '>= 3.0', '< 5'
43
43
 
44
44
  s.add_development_dependency 'email_spec', '~> 1.6'
45
45
  end