solidus_core 2.8.6 → 2.9.0.rc.1

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/logo/solidus.svg +1 -18
  3. data/app/assets/images/logo/solidus_logo.png +0 -0
  4. data/app/mailers/spree/test_mailer.rb +2 -0
  5. data/app/models/concerns/spree/default_price.rb +1 -1
  6. data/app/models/concerns/spree/ransackable_attributes.rb +1 -1
  7. data/app/models/concerns/spree/user_reporting.rb +1 -1
  8. data/app/models/spree/billing_integration.rb +7 -2
  9. data/app/models/spree/country.rb +2 -0
  10. data/app/models/spree/customer_return.rb +1 -1
  11. data/app/models/spree/image.rb +2 -44
  12. data/app/models/spree/image/paperclip_attachment.rb +55 -0
  13. data/app/models/spree/inventory_unit.rb +0 -1
  14. data/app/models/spree/option_type.rb +2 -0
  15. data/app/models/spree/option_value.rb +1 -1
  16. data/app/models/spree/order.rb +8 -13
  17. data/app/models/spree/payment.rb +1 -1
  18. data/app/models/spree/payment_method.rb +8 -4
  19. data/app/models/spree/product.rb +1 -1
  20. data/app/models/spree/promotion.rb +18 -11
  21. data/app/models/spree/promotion/rules/first_order.rb +1 -3
  22. data/app/models/spree/promotion/rules/item_total.rb +9 -1
  23. data/app/models/spree/promotion/rules/one_use_per_user.rb +2 -2
  24. data/app/models/spree/promotion/rules/product.rb +3 -3
  25. data/app/models/spree/promotion/rules/taxon.rb +5 -8
  26. data/app/models/spree/promotion/rules/user_logged_in.rb +1 -1
  27. data/app/models/spree/promotion_handler/coupon.rb +19 -3
  28. data/app/models/spree/property.rb +2 -0
  29. data/app/models/spree/reimbursement.rb +5 -5
  30. data/app/models/spree/return_item.rb +6 -2
  31. data/app/models/spree/state.rb +6 -0
  32. data/app/models/spree/stock/location_filter/active.rb +14 -0
  33. data/app/models/spree/stock/location_filter/base.rb +43 -0
  34. data/app/models/spree/stock/simple_coordinator.rb +4 -1
  35. data/app/models/spree/stock_location.rb +2 -0
  36. data/app/models/spree/tax_category.rb +11 -0
  37. data/app/models/spree/taxon.rb +4 -11
  38. data/app/models/spree/taxon/paperclip_attachment.rb +21 -0
  39. data/app/models/spree/taxonomy.rb +2 -0
  40. data/app/models/spree/unit_cancel.rb +12 -1
  41. data/app/models/spree/variant.rb +1 -1
  42. data/app/models/spree/variant/pricing_options.rb +10 -0
  43. data/app/models/spree/wallet_payment_source.rb +26 -10
  44. data/app/models/spree/zone.rb +1 -1
  45. data/app/views/spree/order_mailer/inventory_cancellation_email.text.erb +3 -3
  46. data/config/locales/en.yml +26 -53
  47. data/db/default/spree/store_credit.rb +1 -0
  48. data/db/migrate/20161123154034_add_available_to_users_and_remove_display_on_from_shipping_methods.rb +1 -1
  49. data/db/migrate/20170608074534_rename_bogus_gateways.rb +9 -8
  50. data/db/migrate/20190220093635_drop_spree_store_credit_update_reasons.rb +19 -0
  51. data/lib/generators/spree/install/install_generator.rb +0 -3
  52. data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +3 -0
  53. data/lib/solidus/migrations/rename_gateways.rb +2 -0
  54. data/lib/spree/app_configuration.rb +24 -0
  55. data/lib/spree/core.rb +1 -0
  56. data/lib/spree/core/controller_helpers/pricing.rb +1 -4
  57. data/lib/spree/core/controller_helpers/strong_parameters.rb +7 -21
  58. data/lib/spree/core/engine.rb +5 -0
  59. data/lib/spree/core/importer/order.rb +1 -3
  60. data/lib/spree/core/stock_configuration.rb +5 -0
  61. data/lib/spree/core/version.rb +3 -1
  62. data/lib/spree/deprecation.rb +50 -0
  63. data/lib/spree/event.rb +111 -0
  64. data/lib/spree/event/adapters/active_support_notifications.rb +35 -0
  65. data/lib/spree/event/configuration.rb +17 -0
  66. data/lib/spree/event/processors/mailer_processor.rb +27 -0
  67. data/lib/spree/event/subscriber.rb +84 -0
  68. data/lib/spree/permitted_attributes.rb +7 -76
  69. data/lib/spree/testing_support/capybara_ext.rb +15 -0
  70. data/lib/spree/testing_support/common_rake.rb +1 -1
  71. data/lib/spree/testing_support/dummy_app.rb +3 -10
  72. data/lib/spree/testing_support/factories/promotion_factory.rb +10 -0
  73. data/lib/spree/testing_support/factories/return_item_factory.rb +1 -0
  74. data/lib/spree/testing_support/preferences.rb +62 -0
  75. data/lib/tasks/email.rake +2 -0
  76. data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +4 -0
  77. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +2 -0
  78. data/lib/tasks/migrations/migrate_user_addresses.rake +3 -0
  79. data/lib/tasks/migrations/rename_gateways.rake +2 -0
  80. data/lib/tasks/order_capturing.rake +2 -0
  81. data/spec/helpers/base_helper_spec.rb +3 -3
  82. data/spec/helpers/products_helper_spec.rb +2 -2
  83. data/spec/{models → lib}/spree/app_configuration_spec.rb +11 -1
  84. data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +13 -0
  85. data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +1 -8
  86. data/spec/lib/spree/core/testing_support/factories/shipping_method_factory_spec.rb +1 -1
  87. data/spec/lib/spree/core/testing_support/preferences_spec.rb +33 -0
  88. data/spec/lib/spree/event/subscriber_spec.rb +85 -0
  89. data/spec/lib/spree/event_spec.rb +92 -0
  90. data/spec/lib/spree/money_spec.rb +3 -9
  91. data/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb +5 -3
  92. data/spec/mailers/order_mailer_spec.rb +1 -1
  93. data/spec/mailers/test_mailer_spec.rb +3 -1
  94. data/spec/models/spree/address_spec.rb +5 -4
  95. data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
  96. data/spec/models/spree/country_spec.rb +5 -5
  97. data/spec/models/spree/customer_return_spec.rb +1 -1
  98. data/spec/models/spree/order/checkout_spec.rb +3 -7
  99. data/spec/models/spree/order/finalizing_spec.rb +1 -1
  100. data/spec/models/spree/order/payment_spec.rb +3 -3
  101. data/spec/models/spree/order_inventory_spec.rb +1 -1
  102. data/spec/models/spree/order_spec.rb +67 -2
  103. data/spec/models/spree/order_updater_spec.rb +2 -2
  104. data/spec/models/spree/payment_spec.rb +12 -0
  105. data/spec/models/spree/product_spec.rb +3 -3
  106. data/spec/models/spree/promotion/rules/first_order_spec.rb +13 -3
  107. data/spec/models/spree/promotion/rules/item_total_spec.rb +15 -0
  108. data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +10 -0
  109. data/spec/models/spree/promotion/rules/product_spec.rb +15 -0
  110. data/spec/models/spree/promotion/rules/taxon_spec.rb +59 -8
  111. data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +5 -0
  112. data/spec/models/spree/promotion_handler/shipping_spec.rb +1 -1
  113. data/spec/models/spree/promotion_spec.rb +80 -0
  114. data/spec/models/spree/reimbursement_spec.rb +3 -2
  115. data/spec/models/spree/return_item_spec.rb +9 -0
  116. data/spec/models/spree/shipment_spec.rb +3 -3
  117. data/spec/models/spree/stock/availability_spec.rb +1 -1
  118. data/spec/models/spree/stock/estimator_spec.rb +5 -7
  119. data/spec/models/spree/stock/location_filter/active_spec.rb +22 -0
  120. data/spec/models/spree/stock/location_sorter/default_first_spec.rb +4 -2
  121. data/spec/models/spree/stock/location_sorter/unsorted_spec.rb +3 -1
  122. data/spec/models/spree/stock/quantifier_spec.rb +1 -1
  123. data/spec/models/spree/stock/simple_coordinator_spec.rb +5 -0
  124. data/spec/models/spree/stock_item_spec.rb +3 -2
  125. data/spec/models/spree/stock_movement_spec.rb +1 -1
  126. data/spec/models/spree/store_credit_spec.rb +1 -1
  127. data/spec/models/spree/tax/order_adjuster_spec.rb +1 -1
  128. data/spec/models/spree/tax/taxation_integration_spec.rb +1 -1
  129. data/spec/models/spree/tax_category_spec.rb +21 -0
  130. data/spec/models/spree/taxon_spec.rb +28 -0
  131. data/spec/models/spree/unit_cancel_spec.rb +41 -0
  132. data/spec/models/spree/user_spec.rb +3 -3
  133. data/spec/models/spree/variant/pricing_options_spec.rb +23 -0
  134. data/spec/models/spree/variant/vat_price_generator_spec.rb +1 -1
  135. data/spec/models/spree/variant_spec.rb +11 -8
  136. data/spec/models/spree/wallet_payment_source_spec.rb +35 -6
  137. data/spec/models/spree/wallet_spec.rb +1 -1
  138. data/spec/spec_helper.rb +0 -4
  139. data/spec/support/concerns/default_price.rb +8 -0
  140. metadata +18 -5
  141. data/spec/lib/spree/permitted_attributes_spec.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12240271e722fffd557b6ef159c53f8df695472c383200d6869b2634643fd91b
4
- data.tar.gz: 54fa7b31fdc8688eae2146814cb53b0fe95a44e0769dd4c4f601384662458644
3
+ metadata.gz: 71217c9617a1dc11ee7ffa67f022200e9cc9e5e81f0d79fad8712e6264f30d7b
4
+ data.tar.gz: 2a51df897566b8347205712578172e75cb3ea4d5b8852c98c6a99cdb6de5e40c
5
5
  SHA512:
6
- metadata.gz: a42f2ce13d73407b08ee0fa5dc1d86bd3a857cded64d78205e898a3786480239dec54a160de606b35c99e59361792670cef7a241843747b8633a3695511428a2
7
- data.tar.gz: 3a45c91be1329e0f93e6291f8a74d381e477689ecbf2d492d6ccaff7346326bb542197faa04ca8d8b5940bd29df8c7da1a91d902733b9e55fae50177608404e5
6
+ metadata.gz: 713cea25167eb830ff1274b1e2b8ca163342f28ebd89e0d148a963dff83fc94d038def70e4713b255cd5df05448580fba1cfbcbd968d1a80dae3429be1dc90f8
7
+ data.tar.gz: 1b1b5b6321c5df0de1e9bafda1d6cae35b53c8c59671137aefd0cba54a05b457ae1f3ef26b38302dd4ef16780364de0e4591db40b919e370d498c78ee0d990a5
@@ -1,18 +1 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="153px" height="52px" viewBox="0 0 153 52" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <!-- Generator: Sketch 52.5 (67469) - http://www.bohemiancoding.com/sketch -->
4
- <title>solidus</title>
5
- <desc>Created with Sketch.</desc>
6
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7
- <g id="solidus" transform="translate(7.000000, 9.000000)" fill="#000000">
8
- <path d="M3.36538462,26.6135458 C5.12019231,28.501992 8.00480769,29.9601594 10.5528846,29.9601594 C13.3894231,29.9601594 15.0961538,28.3585657 15.0961538,27.0916335 C15.0961538,25.5856574 13.9182692,24.7968127 12.1153846,24.4621514 L9.32692308,23.936255 C2.88461538,22.7410359 1.08173077,20.685259 1.08173077,17.4342629 C1.08173077,13.5856574 4.35096154,10 10.0721154,10 C13.2451923,10 16.0336538,10.9322709 19.1586538,13.1553785 L16.3461538,16.5976096 C13.9423077,14.5657371 11.8028846,14.063745 10.1923077,14.063745 C8.07692308,14.063745 5.98557692,15.0916335 5.98557692,16.9322709 C5.98557692,18.2948207 7.06730769,19.0119522 8.96634615,19.3227092 L13.9423077,20.2549801 C18.0048077,20.9960159 20,22.9322709 20,26.3266932 C20,29.6733068 17.2596154,34 10.3125,34 C6.44230769,34 3.125,32.6374502 0,30.0079681 L3.36538462,26.6135458 Z" id="Path"></path>
9
- <path d="M34.5,10 C42.4047619,10 47,15.988024 47,22 C47,28.011976 42.4047619,34 34.5,34 C26.5952381,34 22,28.011976 22,22 C22,15.988024 26.5714286,10 34.5,10 M34.5,29.4251497 C38.7619048,29.4251497 41.8571429,26.1197605 41.8571429,22.0239521 C41.8571429,17.9281437 38.7619048,14.6227545 34.5,14.6227545 C30.2380952,14.6227545 27.1428571,17.9281437 27.1428571,22.0239521 C27.1428571,26.1197605 30.2380952,29.4251497 34.5,29.4251497" id="Shape" fill-rule="nonzero"></path>
10
- <path d="M64.5,4 C65.8834951,4 67,5.11650485 67,6.5 C67,7.88349515 65.8834951,9 64.5,9 C63.1165049,9 62,7.88349515 62,6.5 C62,5.11650485 63.1165049,4 64.5,4" id="Path"></path>
11
- <rect id="Rectangle" x="62" y="14" width="5" height="20"></rect>
12
- <path d="M89.1428571,4 L89.1428571,12.5273159 C87.1428571,11.0783848 84.5714286,10.1995249 81.5,10.1995249 C73.5952381,10.1995249 69,16.1377672 69,22.0997625 C69,28.0617577 73.5952381,34 81.5,34 C84.5714286,34 87.1428571,33.0973872 89.1428571,31.672209 L89.1428571,34 L94,34 L94,4 L89.1428571,4 Z M81.5,29.4394299 C77.2380952,29.4394299 74.1428571,26.1615202 74.1428571,22.0997625 C74.1428571,18.0380048 77.2380952,14.760095 81.5,14.760095 C85.7619048,14.760095 88.8571429,18.0380048 88.8571429,22.0997625 C88.8571429,26.1615202 85.7619048,29.4394299 81.5,29.4394299 Z" id="Shape" fill-rule="nonzero"></path>
13
- <path d="M97.0482759,10 L101.972414,10 L101.972414,23.3413174 C101.972414,26.6946108 104.434483,29.0898204 107.524138,29.0898204 C110.613793,29.0898204 113.075862,26.6946108 113.075862,23.3413174 L113.075862,10 L118,10 L118,23.7724551 C118,30.1676647 112.97931,34 107.5,34 C102.044828,34 97,30.1916168 97,23.7724551 L97,10 L97.0482759,10 Z" id="Path"></path>
14
- <path d="M122.365385,26.5896414 C124.120192,28.4780876 127.004808,29.936255 129.552885,29.936255 C132.389423,29.936255 134.096154,28.3346614 134.096154,27.0677291 C134.096154,25.561753 132.918269,24.7729084 131.115385,24.438247 L128.326923,23.9123506 C121.908654,22.7410359 120.105769,20.6613546 120.105769,17.4342629 C120.105769,13.5856574 123.375,10 129.096154,10 C132.269231,10 135.057692,10.9322709 138.182692,13.1553785 L135.370192,16.5976096 C132.966346,14.5657371 130.826923,14.063745 129.216346,14.063745 C127.100962,14.063745 125.009615,15.0916335 125.009615,16.9322709 C125.009615,18.2948207 126.091346,19.0119522 127.990385,19.3227092 L132.942308,20.2549801 C137.004808,20.9960159 139,22.9322709 139,26.3266932 C139,29.6733068 136.259615,34 129.3125,34 C125.442308,34 122.125,32.6374502 119,30.0079681 L122.365385,26.5896414 Z" id="Path"></path>
15
- <path d="M56.3986486,28.6315789 C55.0506757,27.8442105 54.5067568,26.9614035 54.4358108,24.6708772 L54.4358108,8.87578947 C54.4358108,4.1277193 52.1182432,2.40982456 47.1283784,0 L45,3.84140351 L47.6013514,5.3445614 C48.9493243,6.13192982 49.4932432,7.01473684 49.5641892,9.30526316 L49.5641892,25.1242105 C49.5641892,29.8722807 51.8817568,31.5901754 56.8716216,34 L59,30.1585965 L56.3986486,28.6315789 Z" id="Path"></path>
16
- </g>
17
- </g>
18
- </svg>
1
+ <svg width="153" height="38" viewBox="0 0 153 38" xmlns="http://www.w3.org/2000/svg"><g fill="#242830" fill-rule="nonzero"><path d="M45.0815035 17.9295775l-4.2797203-.808169c-1.6476923-.2729578-2.5838811-.899155-2.5838811-2.0819719 0-1.6056338 1.8135315-2.4994366 3.6431119-2.4994366 1.3962587 0 3.2472377.4335211 5.3496503 2.2050704l2.4340909-2.9971831c-2.706923-1.93746476-5.1196153-2.75098589-7.863986-2.75098589-4.9537762 0-7.7890909 3.12563379-7.7890909 6.47605629 0 2.8312677 1.5620979 4.6242254 7.1417832 5.6678874l2.4126923.4549295c1.5620979.2943662 2.5838812.9794367 2.5838812 2.2907043 0 1.1025352-1.4818532 2.4994366-3.9373427 2.4994366-2.2040559 0-4.7023426-1.2684507-6.2216433-2.9169014l-2.9637063 2.9597183c2.706923 2.2907042 5.5796853 3.4788732 8.9285664 3.4788732 6.0183566 0 8.3882517-3.7464788 8.3882517-6.6847887s-1.727937-4.6456338-5.2426573-5.2932394zM62.960035 8.99690141c-6.9545455 0-10.9293357 5.20760559-10.9293357 10.43661969 0 5.2290141 4.0175874 10.4312676 10.9293357 10.4312676 6.9117482 0 10.9293356-5.2076056 10.9293356-10.4312676 0-5.2236619-4.0175874-10.43661969-10.9293356-10.43661969zm0 16.89126759c-3.5454364 0-6.4195805-2.8754669-6.4195805-6.4225352 0-3.5470682 2.8741441-6.4225352 6.4195805-6.4225352 3.5454363 0 6.4195804 2.875467 6.4195804 6.4225352.0277543 1.7117236-.6396762 3.3615035-1.8496498 4.572034-1.2099737 1.2105306-2.8589946 1.8782684-4.5699306 1.8505012zM88.5634615 3.58591549c-1.1818121 0-2.1398601.95848899-2.1398601 2.14084507 0 1.18235609.958048 2.14084507 2.1398601 2.14084507 1.1818122 0 2.1398602-.95848898 2.1398602-2.14084507 0-1.18235608-.958048-2.14084507-2.1398602-2.14084507zm-2.1238112 8.53661971h4.2476224v17.763662h-4.2476224v-17.763662zm23.8915387-1.0597183c-1.951059-1.37951017-4.293144-2.09615393-6.681713-2.04450704-6.9063991 0-10.9239865 5.20760564-10.9239865 10.43126764 0 5.2236619 4.0175874 10.4366197 10.9239865 10.4366197 2.388342.0384309 4.727465-.6810542 6.681713-2.0552113v2.0445071h4.247622V3.58591549h-4.247622v7.47690141zm-6.681713 14.8253521c-3.545437 0-6.4195809-2.8754669-6.4195809-6.4225352 0-3.5470682 2.8741439-6.4225352 6.4195809-6.4225352 3.545436 0 6.41958 2.875467 6.41958 6.4225352.027754 1.7117236-.639676 3.3615035-1.84965 4.572034-1.209974 1.2105306-2.858994 1.8782684-4.56993 1.8505012zm26.881993-5.2504225c0 2.9169014-2.139861 4.9988732-4.787938 4.9988732-2.648076 0-4.787937-2.0819718-4.787937-4.9988732V9.03971831h-4.27972V21.0123944c0 5.5822535 4.349266 8.8952112 9.051609 8.8952112 4.702342 0 9.083706-3.3343662 9.083706-8.8952112V9.03971831h-4.27972V20.6377465zm17.118881-2.6439437l-4.279721-.8135211c-1.647692-.2676056-2.583881-.8938028-2.583881-2.0819718 0-1.6056338 1.813532-2.4994367 3.643112-2.4994367 1.396259 0 3.247238.4388733 5.34965 2.2104226l2.434091-2.9971831c-2.701573-1.93746481-5.119615-2.75098594-7.863986-2.75098594-4.953776 0-7.783741 3.12563384-7.783741 6.47605634 0 2.8098592 1.556748 4.6242254 7.115035 5.6411268l2.418042.4602816c1.556748.2890141 2.578532.9794367 2.578532 2.2907043 0 1.1025352-1.476504 2.4994366-3.931993 2.4994366-2.209406 0-4.707693-1.2684507-6.226993-2.9169014l-2.91021 2.9811267c2.680175 2.2907043 5.547587 3.4788733 8.901818 3.4788733 6.013007 0 8.388252-3.7464789 8.388252-6.6847887 0-2.9383099-1.727937-4.6456338-5.248007-5.2932395zm-67.3734969 3.7678873V7.98c0-4.14788732-2.0382167-5.64647887-6.4195804-7.74985916L71.9848951 3.5859155l2.2896504 1.31126761c1.1822727.68507042 1.6637412 1.45577465 1.727937 3.45746479V22.1577465c0 4.1478873 2.0382168 5.6464789 6.4195804 7.7498591l1.8723777-3.3557746-2.2896504-1.3326761c-1.1876224-.6850704-1.6637412-1.4557746-1.7279371-3.4574648zM.20863636 37.8876056H23.6829021V.15521127H.20863636V37.8876056zM3.56821678 3.51633803H20.2698252V34.4729577H3.56821678V3.51633803z"/><path d="M13.5934615 24.2450704V13.6104225c0-3.2112676-1.5727972-4.35126757-4.95912584-5.97295771L7.18993007 10.2225352l1.76538462 1.0169014c.91479021.5352113 1.28391611 1.1239437 1.33206291 2.6760564v10.6507042c0 3.2112676 1.5727972 4.3512676 4.9591259 5.9729577l1.4497552-2.5850704-1.7707342-1.043662c-.9147902-.5298591-1.2839161-1.1239436-1.332063-2.6653521z"/></g></svg>
@@ -3,6 +3,8 @@
3
3
  module Spree
4
4
  class TestMailer < BaseMailer
5
5
  def test_email(email)
6
+ Spree::Deprecation.warn("Spree::TestMailer has been deprecated and will be removed with Solidus 3.0")
7
+
6
8
  store = Spree::Store.default
7
9
  subject = "#{store.name} #{t('.subject')}"
8
10
  mail(to: email, from: from_address(store), subject: subject)
@@ -21,7 +21,7 @@ module Spree
21
21
  delegate :price=, to: :find_or_build_default_price
22
22
 
23
23
  def has_default_price?
24
- !default_price.nil?
24
+ default_price.present? && !default_price.discarded?
25
25
  end
26
26
  end
27
27
  end
@@ -7,7 +7,7 @@ module Spree::RansackableAttributes
7
7
  class_attribute :whitelisted_ransackable_attributes
8
8
 
9
9
  class_attribute :default_ransackable_attributes
10
- self.default_ransackable_attributes = %w[id name]
10
+ self.default_ransackable_attributes = %w[id]
11
11
  end
12
12
 
13
13
  class_methods do
@@ -10,7 +10,7 @@ module Spree
10
10
  end
11
11
 
12
12
  def order_count
13
- BigDecimal(spree_orders.complete.count)
13
+ spree_orders.complete.count
14
14
  end
15
15
 
16
16
  def average_order_value
@@ -9,8 +9,13 @@ module Spree
9
9
 
10
10
  def gateway
11
11
  integration_options = options
12
- ActiveMerchant::Billing::Base.integration_mode = integration_options[:server].to_sym
13
- integration_options[:test] = true if integration_options[:test_mode]
12
+
13
+ # All environments except production considered to be test
14
+ test_server = integration_options[:server] != 'production'
15
+ test_mode = integration_options[:test_mode]
16
+
17
+ integration_options[:test] = (test_server || test_mode)
18
+
14
19
  @gateway ||= gateway_class.new(integration_options)
15
20
  end
16
21
 
@@ -8,6 +8,8 @@ module Spree
8
8
 
9
9
  validates :name, :iso_name, presence: true
10
10
 
11
+ self.whitelisted_ransackable_attributes = %w[name]
12
+
11
13
  def self.default
12
14
  if Spree::Config.default_country_id
13
15
  Spree::Deprecation.warn("Setting your default country via its ID is deprecated. Please set your default country via the `default_country_iso` setting.", caller)
@@ -53,7 +53,7 @@ module Spree
53
53
  end
54
54
 
55
55
  def process_return!
56
- order.return! if order.all_inventory_units_returned?
56
+ order.return! if order.can_return?
57
57
  end
58
58
 
59
59
  private
@@ -2,55 +2,13 @@
2
2
 
3
3
  module Spree
4
4
  class Image < Asset
5
- validate :no_attachment_errors
6
-
7
- has_attached_file :attachment,
8
- styles: { mini: '48x48>', small: '100x100>', product: '240x240>', large: '600x600>' },
9
- default_style: :product,
10
- default_url: 'noimage/:style.png',
11
- url: '/spree/products/:id/:style/:basename.:extension',
12
- path: ':rails_root/public/spree/products/:id/:style/:basename.:extension',
13
- convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
14
- validates_attachment :attachment,
15
- presence: true,
16
- content_type: { content_type: %w(image/jpeg image/jpg image/png image/gif) }
17
-
18
- # save the w,h of the original image (from which others can be calculated)
19
- # we need to look at the write-queue for images which have not been saved yet
20
- after_post_process :find_dimensions, if: :valid?
5
+ include ::Spree::Config.image_attachment_module
21
6
 
22
7
  def mini_url
23
8
  Spree::Deprecation.warn(
24
9
  'Spree::Image#mini_url is DEPRECATED. Use Spree::Image#url(:mini) instead.'
25
10
  )
26
- attachment.url(:mini, false)
27
- end
28
-
29
- def url(size)
30
- attachment.url(size)
31
- end
32
-
33
- def filename
34
- attachment_file_name
35
- end
36
-
37
- def find_dimensions
38
- temporary = attachment.queued_for_write[:original]
39
- filename = temporary.path unless temporary.nil?
40
- filename = attachment.path if filename.blank?
41
- geometry = Paperclip::Geometry.from_file(filename)
42
- self.attachment_width = geometry.width
43
- self.attachment_height = geometry.height
44
- end
45
-
46
- # if there are errors from the plugin, then add a more meaningful message
47
- def no_attachment_errors
48
- unless attachment.errors.empty?
49
- # uncomment this to get rid of the less-than-useful interim messages
50
- # errors.clear
51
- errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
52
- false
53
- end
11
+ url(:mini)
54
12
  end
55
13
  end
56
14
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree::Image::PaperclipAttachment
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ validate :no_attachment_errors
8
+
9
+ has_attached_file :attachment,
10
+ styles: { mini: '48x48>', small: '100x100>', product: '240x240>', large: '600x600>' },
11
+ default_style: :product,
12
+ default_url: 'noimage/:style.png',
13
+ url: '/spree/products/:id/:style/:basename.:extension',
14
+ path: ':rails_root/public/spree/products/:id/:style/:basename.:extension',
15
+ convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
16
+ validates_attachment :attachment,
17
+ presence: true,
18
+ content_type: { content_type: %w[image/jpeg image/jpg image/png image/gif] }
19
+
20
+ # save the w,h of the original image (from which others can be calculated)
21
+ # we need to look at the write-queue for images which have not been saved yet
22
+ after_post_process :find_dimensions, if: :valid?
23
+ end
24
+
25
+ def url(size)
26
+ attachment.url(size)
27
+ end
28
+
29
+ def filename
30
+ attachment_file_name
31
+ end
32
+
33
+ def attachment_present?
34
+ attachment.present?
35
+ end
36
+
37
+ def find_dimensions
38
+ temporary = attachment.queued_for_write[:original]
39
+ filename = temporary.path unless temporary.nil?
40
+ filename = attachment.path if filename.blank?
41
+ geometry = Paperclip::Geometry.from_file(filename)
42
+ self.attachment_width = geometry.width
43
+ self.attachment_height = geometry.height
44
+ end
45
+
46
+ # if there are errors from the plugin, then add a more meaningful message
47
+ def no_attachment_errors
48
+ unless attachment.errors.empty?
49
+ # uncomment this to get rid of the less-than-useful interim messages
50
+ # errors.clear
51
+ errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
52
+ false
53
+ end
54
+ end
55
+ end
@@ -10,7 +10,6 @@ module Spree
10
10
 
11
11
  belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :inventory_units
12
12
  belongs_to :shipment, class_name: "Spree::Shipment", touch: true, inverse_of: :inventory_units
13
- belongs_to :return_authorization, class_name: "Spree::ReturnAuthorization", inverse_of: :inventory_units
14
13
  belongs_to :carton, class_name: "Spree::Carton", inverse_of: :inventory_units
15
14
  belongs_to :line_item, class_name: "Spree::LineItem", inverse_of: :inventory_units
16
15
 
@@ -25,6 +25,8 @@ module Spree
25
25
  after_touch :touch_all_products
26
26
  after_save :touch_all_products
27
27
 
28
+ self.whitelisted_ransackable_attributes = %w[name]
29
+
28
30
  def touch_all_products
29
31
  products.find_each(&:touch)
30
32
  end
@@ -16,7 +16,7 @@ module Spree
16
16
 
17
17
  delegate :name, :presentation, to: :option_type, prefix: :option_type
18
18
 
19
- self.whitelisted_ransackable_attributes = ['presentation']
19
+ self.whitelisted_ransackable_attributes = %w[name presentation]
20
20
 
21
21
  # Updates the updated_at column on all the variants associated with this
22
22
  # option value.
@@ -366,11 +366,11 @@ module Spree
366
366
 
367
367
  # Creates new tax charges if there are any applicable rates. If prices already
368
368
  # include taxes then price adjustments are created instead.
369
- # @deprecated This now happens during #update!
369
+ # @deprecated This now happens during #recalculate
370
370
  def create_tax_charge!
371
- Spree::Config.tax_adjuster_class.new(self).adjust!
371
+ recalculate
372
372
  end
373
- deprecate create_tax_charge!: :update!, deprecator: Spree::Deprecation
373
+ deprecate create_tax_charge!: :recalculate, deprecator: Spree::Deprecation
374
374
 
375
375
  def reimbursement_total
376
376
  reimbursements.sum(:total)
@@ -392,7 +392,7 @@ module Spree
392
392
  end
393
393
 
394
394
  def refund_total
395
- payments.flat_map(&:refunds).sum(&:amount)
395
+ refunds.sum(&:amount)
396
396
  end
397
397
 
398
398
  def name
@@ -434,7 +434,7 @@ module Spree
434
434
 
435
435
  touch :completed_at
436
436
 
437
- deliver_order_confirmation_email unless confirmation_delivered?
437
+ Spree::Event.fire 'order_finalized', order: self
438
438
  end
439
439
 
440
440
  def fulfill!
@@ -443,11 +443,6 @@ module Spree
443
443
  save!
444
444
  end
445
445
 
446
- def deliver_order_confirmation_email
447
- Spree::Config.order_mailer_class.confirm_email(self).deliver_later
448
- update_column(:confirmation_delivered, true)
449
- end
450
-
451
446
  # Helper methods for checkout steps
452
447
  def paid?
453
448
  %w(paid credit_owed).include?(payment_state)
@@ -582,11 +577,11 @@ module Spree
582
577
  bill_address == ship_address
583
578
  end
584
579
 
580
+ # @deprecated This now happens during #recalculate
585
581
  def set_shipments_cost
586
- shipments.each(&:update_amounts)
587
582
  recalculate
588
583
  end
589
- deprecate set_shipments_cost: :update!, deprecator: Spree::Deprecation
584
+ deprecate set_shipments_cost: :recalculate, deprecator: Spree::Deprecation
590
585
 
591
586
  def is_risky?
592
587
  payments.risky.count > 0
@@ -765,7 +760,7 @@ module Spree
765
760
 
766
761
  def record_ip_address(ip_address)
767
762
  if last_ip_address != ip_address
768
- update_attributes!(last_ip_address: ip_address)
763
+ update_column(:last_ip_address, ip_address)
769
764
  end
770
765
  end
771
766
 
@@ -58,7 +58,7 @@ module Spree
58
58
  scope :failed, -> { with_state('failed') }
59
59
 
60
60
  scope :risky, -> { where("avs_response IN (?) OR (cvv_response_code IS NOT NULL and cvv_response_code != 'M') OR state = 'failed'", RISKY_AVS_CODES) }
61
- scope :valid, -> { where.not(state: %w(failed invalid)) }
61
+ scope :valid, -> { where.not(state: %w(failed invalid void)) }
62
62
 
63
63
  scope :store_credits, -> { where(source_type: Spree::StoreCredit.to_s) }
64
64
  scope :not_store_credits, -> { where(arel_table[:source_type].not_eq(Spree::StoreCredit.to_s).or(arel_table[:source_type].eq(nil))) }
@@ -130,9 +130,13 @@ module Spree
130
130
  def gateway
131
131
  gateway_options = options
132
132
  gateway_options.delete :login if gateway_options.key?(:login) && gateway_options[:login].nil?
133
- if gateway_options[:server]
134
- ActiveMerchant::Billing::Base.mode = gateway_options[:server].to_sym
135
- end
133
+
134
+ # All environments except production considered to be test
135
+ test_server = gateway_options[:server] != 'production'
136
+ test_mode = gateway_options[:test_mode]
137
+
138
+ gateway_options[:test] = (test_server || test_mode)
139
+
136
140
  @gateway ||= gateway_class.new(gateway_options)
137
141
  end
138
142
  alias_method :provider, :gateway
@@ -196,7 +200,7 @@ module Spree
196
200
  # The view that represents your payment method on orders in the backend
197
201
  #
198
202
  def partial_name
199
- deprecated_method_type_override || type.demodulize.downcase
203
+ deprecated_method_type_override || type.demodulize.underscore
200
204
  end
201
205
 
202
206
  # :nodoc:
@@ -131,7 +131,7 @@ module Spree
131
131
  alias :options :product_option_types
132
132
 
133
133
  self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants]
134
- self.whitelisted_ransackable_attributes = %w[slug]
134
+ self.whitelisted_ransackable_attributes = %w[name slug]
135
135
 
136
136
  def self.ransackable_scopes(_auth_object = nil)
137
137
  %i(with_deleted with_variant_sku_cont)
@@ -47,20 +47,12 @@ module Spree
47
47
  scope :applied, -> { joins(:order_promotions).distinct }
48
48
 
49
49
  self.whitelisted_ransackable_associations = ['codes']
50
- self.whitelisted_ransackable_attributes = ['path', 'promotion_category_id']
50
+ self.whitelisted_ransackable_attributes = %w[name path promotion_category_id]
51
51
 
52
52
  def self.order_activatable?(order)
53
53
  order && !UNACTIVATABLE_ORDER_STATES.include?(order.state)
54
54
  end
55
55
 
56
- def code
57
- raise "Attempted to call code on a Spree::Promotion. Promotions are now tied to multiple code records"
58
- end
59
-
60
- def code=(_val)
61
- raise "Attempted to call code= on a Spree::Promotion. Promotions are now tied to multiple code records"
62
- end
63
-
64
56
  def self.with_coupon_code(val)
65
57
  joins(:codes).where(
66
58
  PromotionCode.arel_table[:value].eq(val.downcase)
@@ -72,9 +64,24 @@ module Spree
72
64
  super
73
65
  end
74
66
 
67
+ def not_started?
68
+ !started?
69
+ end
70
+
71
+ def started?
72
+ starts_at.nil? || starts_at < Time.current
73
+ end
74
+
75
+ def expired?
76
+ expires_at.present? && expires_at < Time.current
77
+ end
78
+
79
+ def not_expired?
80
+ !expired?
81
+ end
82
+
75
83
  def active?
76
- (starts_at.nil? || starts_at < Time.current) &&
77
- (expires_at.nil? || expires_at > Time.current)
84
+ started? && not_expired?
78
85
  end
79
86
 
80
87
  def inactive?
@@ -16,10 +16,8 @@ module Spree
16
16
 
17
17
  if user || email
18
18
  if !completed_orders.blank? && completed_orders.first != order
19
- eligibility_errors.add(:base, eligibility_error_message(:not_first_order))
19
+ eligibility_errors.add(:base, eligibility_error_message(:not_first_order), error_code: :not_first_order)
20
20
  end
21
- else
22
- eligibility_errors.add(:base, eligibility_error_message(:no_user_or_email_specified))
23
21
  end
24
22
 
25
23
  eligibility_errors.empty?
@@ -20,7 +20,7 @@ module Spree
20
20
  return false unless order.currency == preferred_currency
21
21
  item_total = order.item_total
22
22
  unless item_total.send(preferred_operator == 'gte' ? :>= : :>, BigDecimal(preferred_amount.to_s))
23
- eligibility_errors.add(:base, ineligible_message)
23
+ eligibility_errors.add(:base, ineligible_message, error_code: ineligible_error_code)
24
24
  end
25
25
 
26
26
  eligibility_errors.empty?
@@ -39,6 +39,14 @@ module Spree
39
39
  eligibility_error_message(:item_total_less_than_or_equal, amount: formatted_amount)
40
40
  end
41
41
  end
42
+
43
+ def ineligible_error_code
44
+ if preferred_operator == 'gte'
45
+ :item_total_less_than
46
+ else
47
+ :item_total_less_than_or_equal
48
+ end
49
+ end
42
50
  end
43
51
  end
44
52
  end