solidus_core 1.1.4 → 1.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 (296) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/logo/solidus_logo.png +0 -0
  3. data/app/helpers/spree/base_helper.rb +2 -3
  4. data/app/models/concerns/spree/adjustment_source.rb +1 -1
  5. data/app/models/concerns/spree/default_price.rb +3 -1
  6. data/app/models/concerns/spree/named_type.rb +1 -1
  7. data/app/models/concerns/spree/user_methods.rb +10 -0
  8. data/app/models/spree/adjustment.rb +1 -1
  9. data/app/models/spree/adjustment_reason.rb +2 -4
  10. data/app/models/spree/app_configuration.rb +36 -0
  11. data/app/models/spree/base.rb +10 -1
  12. data/app/models/spree/calculator/tiered_percent.rb +2 -1
  13. data/app/models/spree/classification.rb +1 -1
  14. data/app/models/spree/country.rb +3 -3
  15. data/app/models/spree/credit_card.rb +2 -2
  16. data/app/models/spree/customer_return.rb +3 -4
  17. data/app/models/spree/inventory_unit.rb +13 -24
  18. data/app/models/spree/item_adjustments.rb +5 -5
  19. data/app/models/spree/line_item.rb +6 -15
  20. data/app/models/spree/log_entry.rb +1 -1
  21. data/app/models/spree/option_type.rb +4 -2
  22. data/app/models/spree/option_type_prototype.rb +6 -0
  23. data/app/models/spree/option_value.rb +1 -1
  24. data/app/models/spree/order.rb +18 -63
  25. data/app/models/spree/order/checkout.rb +4 -2
  26. data/app/models/spree/order_cancellations.rb +52 -1
  27. data/app/models/spree/order_contents.rb +1 -1
  28. data/app/models/spree/order_merger.rb +143 -0
  29. data/app/models/spree/order_shipping.rb +3 -3
  30. data/app/models/spree/order_update_attributes.rb +42 -0
  31. data/app/models/spree/order_updater.rb +1 -1
  32. data/app/models/spree/payment.rb +16 -10
  33. data/app/models/spree/payment_create.rb +68 -0
  34. data/app/models/spree/payment_method.rb +0 -1
  35. data/app/models/spree/preference.rb +1 -1
  36. data/app/models/spree/price.rb +1 -8
  37. data/app/models/spree/product.rb +9 -44
  38. data/app/models/spree/product/scopes.rb +9 -7
  39. data/app/models/spree/promotion/rules/nth_order.rb +1 -1
  40. data/app/models/spree/promotion/rules/taxon.rb +2 -1
  41. data/app/models/spree/promotion_chooser.rb +1 -0
  42. data/app/models/spree/promotion_code.rb +1 -1
  43. data/app/models/spree/promotion_rule_taxon.rb +6 -0
  44. data/app/models/spree/property.rb +2 -1
  45. data/app/models/spree/property_prototype.rb +6 -0
  46. data/app/models/spree/prototype.rb +6 -2
  47. data/app/models/spree/reimbursement.rb +10 -0
  48. data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +1 -1
  49. data/app/models/spree/return_reason.rb +1 -7
  50. data/app/models/spree/role_user.rb +3 -5
  51. data/app/models/spree/shipment.rb +6 -11
  52. data/app/models/spree/shipping_method.rb +1 -7
  53. data/app/models/spree/shipping_rate.rb +3 -14
  54. data/app/models/spree/stock/coordinator.rb +48 -4
  55. data/app/models/spree/stock/estimator.rb +3 -6
  56. data/app/models/spree/stock/packer.rb +18 -2
  57. data/app/models/spree/stock/shipping_rate_selector.rb +16 -0
  58. data/app/models/spree/stock/shipping_rate_sorter.rb +16 -0
  59. data/app/models/spree/stock_item.rb +19 -15
  60. data/app/models/spree/stock_location.rb +2 -12
  61. data/app/models/spree/stock_transfer.rb +3 -3
  62. data/app/models/spree/store_credit.rb +2 -2
  63. data/app/models/spree/tax_category.rb +3 -2
  64. data/app/models/spree/tax_rate.rb +7 -14
  65. data/app/models/spree/taxon.rb +4 -1
  66. data/app/models/spree/taxonomy.rb +1 -1
  67. data/app/models/spree/transfer_item.rb +2 -2
  68. data/app/models/spree/unit_cancel.rb +2 -0
  69. data/app/models/spree/variant.rb +9 -14
  70. data/app/models/spree/zone.rb +6 -0
  71. data/app/models/spree/zone_member.rb +1 -4
  72. data/app/views/spree/order_mailer/cancel_email.text.erb +0 -0
  73. data/config/locales/en.yml +7 -5
  74. data/db/default/spree/countries.rb +1 -1
  75. data/db/default/spree/zones.rb +5 -11
  76. data/db/migrate/20130213191427_create_default_stock.rb +1 -1
  77. data/db/migrate/20130306181701_add_address_fields_to_stock_location.rb +1 -1
  78. data/db/migrate/20140309033438_create_store_from_preferences.rb +5 -2
  79. data/db/migrate/20141009204607_add_store_id_to_orders.rb +6 -2
  80. data/db/migrate/20141215235502_remove_extra_products_slug_index.rb +5 -0
  81. data/db/migrate/20141217215630_update_product_slug_index.rb +6 -0
  82. data/db/migrate/20150225205344_move_promotion_code_to_promotion_code_value.rb +2 -2
  83. data/db/migrate/20150609093816_increase_scale_on_pre_tax_amounts.rb +10 -0
  84. data/db/migrate/20151117063249_convert_habtm_to_hmt_for_properties_prototypes.rb +17 -0
  85. data/db/migrate/20151124062500_convert_habtm_to_hmt_for_option_type_prototypes.rb +17 -0
  86. data/db/migrate/20151126063028_convert_habtm_to_hmt_for_taxons_promotion_rules.rb +15 -0
  87. data/db/migrate/20151219020209_add_stock_item_unique_index.rb +9 -0
  88. data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
  89. data/lib/generators/spree/dummy/templates/rails/database.yml +1 -1
  90. data/lib/generators/spree/install/templates/config/initializers/spree.rb +25 -1
  91. data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/backend/all.js +3 -0
  92. data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/frontend/all.js +3 -0
  93. data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/backend/all.css +3 -0
  94. data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +3 -0
  95. data/lib/spree/core/controller_helpers/common.rb +1 -1
  96. data/lib/spree/core/controller_helpers/order.rb +1 -1
  97. data/lib/spree/core/controller_helpers/payment_parameters.rb +104 -5
  98. data/lib/spree/core/engine.rb +3 -2
  99. data/lib/spree/core/stock_configuration.rb +11 -0
  100. data/lib/spree/core/unreturned_item_charger.rb +4 -4
  101. data/lib/spree/core/version.rb +9 -1
  102. data/lib/spree/permission_sets/restricted_stock_transfer_management.rb +15 -24
  103. data/lib/spree/permitted_attributes.rb +3 -1
  104. data/lib/spree/testing_support/capybara_ext.rb +14 -40
  105. data/lib/spree/testing_support/factories.rb +0 -15
  106. data/lib/spree/testing_support/factories/address_factory.rb +3 -0
  107. data/lib/spree/testing_support/factories/adjustment_factory.rb +9 -1
  108. data/lib/spree/testing_support/factories/carton_factory.rb +4 -1
  109. data/lib/spree/testing_support/factories/customer_return_factory.rb +4 -0
  110. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +5 -0
  111. data/lib/spree/testing_support/factories/line_item_factory.rb +3 -0
  112. data/lib/spree/testing_support/factories/option_type_factory.rb +6 -0
  113. data/lib/spree/testing_support/factories/{options_factory.rb → option_value_factory.rb} +0 -5
  114. data/lib/spree/testing_support/factories/order_factory.rb +13 -3
  115. data/lib/spree/testing_support/factories/order_promotion_factory.rb +3 -0
  116. data/lib/spree/testing_support/factories/payment_factory.rb +13 -5
  117. data/lib/spree/testing_support/factories/price_factory.rb +2 -0
  118. data/lib/spree/testing_support/factories/product_factory.rb +7 -1
  119. data/lib/spree/testing_support/factories/product_option_type_factory.rb +3 -0
  120. data/lib/spree/testing_support/factories/product_property_factory.rb +3 -0
  121. data/lib/spree/testing_support/factories/promotion_code_factory.rb +3 -0
  122. data/lib/spree/testing_support/factories/promotion_factory.rb +3 -0
  123. data/lib/spree/testing_support/factories/prototype_factory.rb +2 -0
  124. data/lib/spree/testing_support/factories/refund_factory.rb +10 -5
  125. data/lib/spree/testing_support/factories/refund_reason_factory.rb +5 -0
  126. data/lib/spree/testing_support/factories/reimbursement_factory.rb +2 -0
  127. data/lib/spree/testing_support/factories/return_authorization_factory.rb +4 -4
  128. data/lib/spree/testing_support/factories/return_item_factory.rb +4 -0
  129. data/lib/spree/testing_support/factories/return_reason_factory.rb +5 -0
  130. data/lib/spree/testing_support/factories/shipment_factory.rb +6 -1
  131. data/lib/spree/testing_support/factories/shipping_method_factory.rb +22 -10
  132. data/lib/spree/testing_support/factories/shipping_rate_factory.rb +9 -0
  133. data/lib/spree/testing_support/factories/state_factory.rb +2 -0
  134. data/lib/spree/testing_support/factories/stock_item_factory.rb +4 -1
  135. data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -0
  136. data/lib/spree/testing_support/factories/stock_movement_factory.rb +2 -0
  137. data/lib/spree/testing_support/factories/{stock_factory.rb → stock_package_factory.rb} +5 -10
  138. data/lib/spree/testing_support/factories/stock_packer_factory.rb +13 -0
  139. data/lib/spree/testing_support/factories/stock_transfer_factory.rb +2 -2
  140. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +4 -1
  141. data/lib/spree/testing_support/factories/store_credit_factory.rb +10 -6
  142. data/lib/spree/testing_support/factories/tax_category_factory.rb +2 -0
  143. data/lib/spree/testing_support/factories/tax_rate_factory.rb +4 -0
  144. data/lib/spree/testing_support/factories/taxon_factory.rb +2 -0
  145. data/lib/spree/testing_support/factories/user_factory.rb +6 -2
  146. data/lib/spree/testing_support/factories/variant_factory.rb +5 -0
  147. data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +3 -0
  148. data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +4 -0
  149. data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +3 -0
  150. data/lib/spree/testing_support/factories/zone_factory.rb +6 -0
  151. data/lib/spree/testing_support/sequences.rb +9 -0
  152. data/lib/tasks/exchanges.rake +4 -3
  153. data/lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake +2 -2
  154. data/solidus_core.gemspec +4 -5
  155. data/spec/helpers/base_helper_spec.rb +6 -6
  156. data/spec/helpers/order_helper_spec.rb +1 -1
  157. data/spec/helpers/products_helper_spec.rb +2 -2
  158. data/spec/helpers/taxons_helper_spec.rb +1 -1
  159. data/spec/lib/spree/core/controller_helpers/payment_parameters_spec.rb +107 -7
  160. data/spec/lib/spree/core/importer/order_spec.rb +1 -1
  161. data/spec/lib/spree/core/stock_configuration_spec.rb +16 -0
  162. data/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb +24 -0
  163. data/spec/lib/spree/core/testing_support/factories/adjustment_factory_spec.rb +18 -0
  164. data/spec/lib/spree/core/testing_support/factories/adjustment_reason_factory_spec.rb +12 -0
  165. data/spec/lib/spree/core/testing_support/factories/calculator_factory_spec.rb +42 -0
  166. data/spec/lib/spree/core/testing_support/factories/carton_factory_spec.rb +12 -0
  167. data/spec/lib/spree/core/testing_support/factories/country_factory_spec.rb +12 -0
  168. data/spec/lib/spree/core/testing_support/factories/credit_card_factory_spec.rb +12 -0
  169. data/spec/lib/spree/core/testing_support/factories/customer_return_factory_spec.rb +28 -0
  170. data/spec/lib/spree/core/testing_support/factories/image_factory_spec.rb +12 -0
  171. data/spec/lib/spree/core/testing_support/factories/inventory_unit_factory_spec.rb +12 -0
  172. data/spec/lib/spree/core/testing_support/factories/line_item_factory_spec.rb +12 -0
  173. data/spec/lib/spree/core/testing_support/factories/option_type_factory_spec.rb +12 -0
  174. data/spec/lib/spree/core/testing_support/factories/option_value_factory_spec.rb +12 -0
  175. data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +49 -0
  176. data/spec/lib/spree/core/testing_support/factories/order_promotion_factory_spec.rb +12 -0
  177. data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +24 -0
  178. data/spec/lib/spree/core/testing_support/factories/payment_method_factory_spec.rb +30 -0
  179. data/spec/lib/spree/core/testing_support/factories/price_factory_spec.rb +12 -0
  180. data/spec/lib/spree/core/testing_support/factories/product_factory_spec.rb +30 -0
  181. data/spec/lib/spree/core/testing_support/factories/product_option_type_factory_spec.rb +12 -0
  182. data/spec/lib/spree/core/testing_support/factories/product_property_factory_spec.rb +12 -0
  183. data/spec/lib/spree/core/testing_support/factories/promotion_category_factory_spec.rb +12 -0
  184. data/spec/lib/spree/core/testing_support/factories/promotion_code_factory_spec.rb +12 -0
  185. data/spec/lib/spree/core/testing_support/factories/promotion_factory_spec.rb +30 -0
  186. data/spec/lib/spree/core/testing_support/factories/property_factory_spec.rb +12 -0
  187. data/spec/lib/spree/core/testing_support/factories/prototype_factory_spec.rb +12 -0
  188. data/spec/lib/spree/core/testing_support/factories/refund_factory_spec.rb +12 -0
  189. data/spec/lib/spree/core/testing_support/factories/refund_reason_factory_spec.rb +12 -0
  190. data/spec/lib/spree/core/testing_support/factories/reimbursement_factory_spec.rb +12 -0
  191. data/spec/lib/spree/core/testing_support/factories/reimbursement_type_factory_spec.rb +12 -0
  192. data/spec/lib/spree/core/testing_support/factories/return_authorization_factory_spec.rb +12 -0
  193. data/spec/lib/spree/core/testing_support/factories/return_item_factory_spec.rb +18 -0
  194. data/spec/lib/spree/core/testing_support/factories/return_reason_factory_spec.rb +12 -0
  195. data/spec/lib/spree/core/testing_support/factories/role_factory_spec.rb +18 -0
  196. data/spec/lib/spree/core/testing_support/factories/shipment_factory_spec.rb +12 -0
  197. data/spec/lib/spree/core/testing_support/factories/shipping_category_factory_spec.rb +12 -0
  198. data/spec/lib/spree/core/testing_support/factories/shipping_method_factory_spec.rb +28 -0
  199. data/spec/lib/spree/core/testing_support/factories/shipping_rate_factory_spec.rb +12 -0
  200. data/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb +12 -0
  201. data/spec/lib/spree/core/testing_support/factories/stock_item_factory_spec.rb +12 -0
  202. data/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb +24 -0
  203. data/spec/lib/spree/core/testing_support/factories/stock_movement_factory_spec.rb +12 -0
  204. data/spec/lib/spree/core/testing_support/factories/stock_package_factory_spec.rb +26 -0
  205. data/spec/lib/spree/core/testing_support/factories/stock_packer_factory_spec.rb +16 -0
  206. data/spec/lib/spree/core/testing_support/factories/stock_transfer_factory_spec.rb +12 -0
  207. data/spec/lib/spree/core/testing_support/factories/store_credit_category_factory_spec.rb +12 -0
  208. data/spec/lib/spree/core/testing_support/factories/store_credit_event_factory_spec.rb +42 -0
  209. data/spec/lib/spree/core/testing_support/factories/store_credit_factory_spec.rb +12 -0
  210. data/spec/lib/spree/core/testing_support/factories/store_credit_type_factory_spec.rb +18 -0
  211. data/spec/lib/spree/core/testing_support/factories/store_credit_update_reason_factory_spec.rb +12 -0
  212. data/spec/lib/spree/core/testing_support/factories/store_factory_spec.rb +12 -0
  213. data/spec/lib/spree/core/testing_support/factories/tax_category_factory_spec.rb +12 -0
  214. data/spec/lib/spree/core/testing_support/factories/tax_rate_factory_spec.rb +12 -0
  215. data/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb +12 -0
  216. data/spec/lib/spree/core/testing_support/factories/taxonomy_factory_spec.rb +12 -0
  217. data/spec/lib/spree/core/testing_support/factories/tracker_factory_spec.rb +12 -0
  218. data/spec/lib/spree/core/testing_support/factories/user_factory_spec.rb +22 -0
  219. data/spec/lib/spree/core/testing_support/factories/variant_factory_spec.rb +36 -0
  220. data/spec/lib/spree/core/testing_support/factories/variant_property_rule_condition_factory_spec.rb +12 -0
  221. data/spec/lib/spree/core/testing_support/factories/variant_property_rule_factory_spec.rb +12 -0
  222. data/spec/lib/spree/core/testing_support/factories/variant_property_rule_value_factory_spec.rb +12 -0
  223. data/spec/lib/spree/core/testing_support/factories/zone_factory_spec.rb +18 -0
  224. data/spec/lib/spree/core/unreturned_item_charger_spec.rb +1 -1
  225. data/spec/lib/spree/core/version_spec.rb +17 -0
  226. data/spec/lib/spree/money_spec.rb +1 -1
  227. data/spec/mailers/carton_mailer_spec.rb +1 -1
  228. data/spec/mailers/order_mailer_spec.rb +1 -1
  229. data/spec/mailers/reimbursement_mailer_spec.rb +1 -3
  230. data/spec/mailers/test_mailer_spec.rb +1 -3
  231. data/spec/models/spree/address_spec.rb +4 -4
  232. data/spec/models/spree/adjustment_reason_spec.rb +1 -3
  233. data/spec/models/spree/app_configuration_spec.rb +4 -0
  234. data/spec/models/spree/calculator/price_sack_spec.rb +3 -3
  235. data/spec/models/spree/calculator/shipping/price_sack_spec.rb +3 -3
  236. data/spec/models/spree/calculator/tiered_percent_spec.rb +86 -10
  237. data/spec/models/spree/carton_spec.rb +3 -1
  238. data/spec/models/spree/classification_spec.rb +3 -3
  239. data/spec/models/spree/credit_card_spec.rb +16 -16
  240. data/spec/models/spree/customer_return_spec.rb +1 -1
  241. data/spec/models/spree/gateway/bogus_simple.rb +1 -1
  242. data/spec/models/spree/inventory_unit_spec.rb +3 -3
  243. data/spec/models/spree/item_adjustments_spec.rb +1 -1
  244. data/spec/models/spree/line_item_spec.rb +2 -2
  245. data/spec/models/spree/option_type_spec.rb +2 -2
  246. data/spec/models/spree/option_value_spec.rb +2 -2
  247. data/spec/models/spree/order/callbacks_spec.rb +1 -1
  248. data/spec/models/spree/order/checkout_spec.rb +16 -11
  249. data/spec/models/spree/order/payment_spec.rb +24 -22
  250. data/spec/models/spree/order/state_machine_spec.rb +1 -1
  251. data/spec/models/spree/order/validations_spec.rb +1 -1
  252. data/spec/models/spree/order_cancellations_spec.rb +63 -0
  253. data/spec/models/spree/order_contents_spec.rb +1 -1
  254. data/spec/models/spree/order_merger_spec.rb +133 -0
  255. data/spec/models/spree/order_spec.rb +39 -159
  256. data/spec/models/spree/order_update_attributes_spec.rb +82 -0
  257. data/spec/models/spree/order_updater_spec.rb +6 -4
  258. data/spec/models/spree/payment_create_spec.rb +131 -0
  259. data/spec/models/spree/payment_spec.rb +130 -48
  260. data/spec/models/spree/permission_sets/restricted_stock_transfer_management_spec.rb +91 -33
  261. data/spec/models/spree/product_filter_spec.rb +3 -3
  262. data/spec/models/spree/product_spec.rb +80 -26
  263. data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +1 -1
  264. data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +2 -2
  265. data/spec/models/spree/promotion/rules/nth_order_spec.rb +1 -1
  266. data/spec/models/spree/promotion/rules/user_spec.rb +2 -2
  267. data/spec/models/spree/promotion_handler/coupon_spec.rb +2 -2
  268. data/spec/models/spree/promotion_spec.rb +18 -18
  269. data/spec/models/spree/reimbursement_spec.rb +22 -0
  270. data/spec/models/spree/return_item_spec.rb +2 -2
  271. data/spec/models/spree/shipment_spec.rb +28 -12
  272. data/spec/models/spree/shipping_method_spec.rb +2 -2
  273. data/spec/models/spree/shipping_rate_spec.rb +3 -3
  274. data/spec/models/spree/stock/coordinator_spec.rb +5 -0
  275. data/spec/models/spree/stock/estimator_spec.rb +35 -1
  276. data/spec/models/spree/stock/package_spec.rb +1 -1
  277. data/spec/models/spree/stock/packer_spec.rb +2 -3
  278. data/spec/models/spree/stock/shipping_rate_selector_spec.rb +16 -0
  279. data/spec/models/spree/stock/shipping_rate_sorter_spec.rb +16 -0
  280. data/spec/models/spree/stock_item_spec.rb +5 -7
  281. data/spec/models/spree/stock_location_spec.rb +5 -9
  282. data/spec/models/spree/stock_transfer_spec.rb +33 -13
  283. data/spec/models/spree/store_credit_event_spec.rb +1 -1
  284. data/spec/models/spree/store_credit_spec.rb +1 -1
  285. data/spec/models/spree/tax_rate_spec.rb +381 -120
  286. data/spec/models/spree/taxon_spec.rb +3 -3
  287. data/spec/models/spree/transfer_item_spec.rb +4 -4
  288. data/spec/models/spree/unit_cancel_spec.rb +1 -1
  289. data/spec/models/spree/variant_spec.rb +3 -3
  290. data/spec/models/spree/zone_spec.rb +35 -1
  291. data/spec/support/concerns/working_factories.rb +9 -0
  292. data/vendor/assets/javascripts/jquery-migrate-1.0.0.js +498 -0
  293. data/vendor/assets/javascripts/jquery.payment.js +231 -80
  294. metadata +103 -27
  295. data/app/models/spree/order/currency_updater.rb +0 -40
  296. data/spec/models/spree/order/currency_updater_spec.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9161c98f377c58e982a151cdeb6c8ac7a2b5f656
4
- data.tar.gz: 480fc65e5d85570f6eef9ae0f29cb45ca5f47e28
3
+ metadata.gz: 72bff98276c20b404df01879d91ae3c97a36aab8
4
+ data.tar.gz: f4b3d7cada13eb253db7f60ec9d735bbd2194a12
5
5
  SHA512:
6
- metadata.gz: 752f95c291e1810aa18c3973920e6e7cbdd279447de14da7a781d22962e946b41747867ee9c7c2c0c739ced9aa6f05fd357f2756d234b46228593f821f4295ee
7
- data.tar.gz: 3c049638968609ca75f2d49b878c334e7cfa2532a9684b565d1d2c2e0382320ed72841529a6d8610b80c22ecbc2311da70c38c9085e63d07e1c1b6ae39e0f9c5
6
+ metadata.gz: ad9a001cd90d86458f532cf0df351c2d1199f2cbc7abdb61b92ccd5e5eb0fe88603e87a61f8d04d192005fb8b226e77c2e0249a1bdb0b147bcd4065b1da09436
7
+ data.tar.gz: acce15cf134e34e2c8184d53cde1ecd391d6d13f606f62ad5a46b39ce4a1cae936902331f29c855362ea81984ba7380eb295a96d638f4261a1858bb46bc93e82
@@ -107,14 +107,13 @@ module Spree
107
107
  def taxons_tree(root_taxon, current_taxon, max_level = 1)
108
108
  return '' if max_level < 1 || root_taxon.children.empty?
109
109
  content_tag :ul, class: 'taxons-list' do
110
- taxons = root_taxon.children.map do |taxon|
110
+ root_taxon.children.map do |taxon|
111
111
  css_class = (current_taxon && current_taxon.self_and_ancestors.include?(taxon)) ? 'current' : nil
112
112
  content_tag :li, class: css_class do
113
113
  link_to(taxon.name, seo_url(taxon)) +
114
114
  taxons_tree(taxon, current_taxon, max_level - 1)
115
115
  end
116
- end
117
- safe_join(taxons, "\n")
116
+ end.join("\n").html_safe
118
117
  end
119
118
  end
120
119
 
@@ -14,7 +14,7 @@ module Spree
14
14
  # This would mean that the order's total is not altered at all.
15
15
  attrs = {
16
16
  source_id: nil,
17
- updated_at: Time.now
17
+ updated_at: Time.current
18
18
  }
19
19
  adjustment_scope.where.not(spree_orders: { completed_at: nil }).update_all(attrs)
20
20
  end
@@ -6,7 +6,9 @@ module Spree
6
6
  has_one :default_price,
7
7
  -> { where currency: Spree::Config[:currency], is_default: true },
8
8
  class_name: 'Spree::Price',
9
- dependent: :destroy
9
+ inverse_of: :variant,
10
+ dependent: :destroy,
11
+ autosave: true
10
12
 
11
13
  def find_or_build_default_price
12
14
  default_price || build_default_price
@@ -6,7 +6,7 @@ module Spree
6
6
  scope :active, -> { where(active: true) }
7
7
  default_scope -> { order(arel_table[:name].lower) }
8
8
 
9
- validates :name, presence: true, uniqueness: { case_sensitive: false }
9
+ validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }
10
10
  end
11
11
  end
12
12
  end
@@ -23,6 +23,8 @@ module Spree
23
23
  has_many :store_credit_events, through: :store_credits
24
24
  money_methods :total_available_store_credit
25
25
 
26
+ after_create :auto_generate_spree_api_key
27
+
26
28
  include Spree::RansackableAttributes unless included_modules.include?(Spree::RansackableAttributes)
27
29
 
28
30
  self.whitelisted_ransackable_associations = %w[addresses]
@@ -34,6 +36,14 @@ module Spree
34
36
  spree_roles.any? { |role| role.name == role_in_question.to_s }
35
37
  end
36
38
 
39
+ def auto_generate_spree_api_key
40
+ return if !respond_to?(:spree_api_key) || spree_api_key.present?
41
+
42
+ if Spree::Config.generate_api_key_for_all_roles || (spree_roles.map(&:name) & Spree::Config.roles_for_auto_api_key).any?
43
+ generate_spree_api_key!
44
+ end
45
+ end
46
+
37
47
  # @return [Spree::Order] the most-recently-created incomplete order
38
48
  # since the customer's last complete order.
39
49
  def last_incomplete_spree_order(store: nil, only_frontend_viewable: true)
@@ -170,7 +170,7 @@ module Spree
170
170
  # Persist only if changed
171
171
  # This is only not a save! to avoid the extra queries to load the order
172
172
  # (for validations) and to touch the adjustment.
173
- update_columns(eligible: eligible, amount: amount, updated_at: Time.now) if changed?
173
+ update_columns(eligible: eligible, amount: amount, updated_at: Time.current) if changed?
174
174
  end
175
175
  amount
176
176
  end
@@ -2,10 +2,8 @@ module Spree
2
2
  class AdjustmentReason < Spree::Base
3
3
  has_many :adjustments, inverse_of: :adjustment_reason
4
4
 
5
- validates :name, presence: true
6
- validates :name, uniqueness: {case_sensitive: false}
7
- validates :code, presence: true
8
- validates :code, uniqueness: {case_sensitive: false}
5
+ validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }
6
+ validates :code, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }
9
7
 
10
8
  scope :active, -> { where(active: true) }
11
9
  end
@@ -17,6 +17,7 @@
17
17
  #
18
18
  require "spree/core/search/base"
19
19
  require "spree/core/search/variant"
20
+ require 'spree/core/stock_configuration'
20
21
 
21
22
  module Spree
22
23
  class AppConfiguration < Preferences::Configuration
@@ -136,6 +137,11 @@ module Spree
136
137
  # charged (default: +14+)
137
138
  preference :expedited_exchanges_days_window, :integer, default: 14
138
139
 
140
+ # @!attribute [rw] generate_api_key_for_all_roles
141
+ # @return [Boolean] Allow generating api key automatically for user
142
+ # at role_user creation for all roles. (default: +false+)
143
+ preference :generate_api_key_for_all_roles, :boolean, default: false
144
+
139
145
  # @!attribute [rw] layout
140
146
  # @return [String] template to use for layout on the frontend (default: +"spree/layouts/spree_application"+)
141
147
  preference :layout, :string, default: 'spree/layouts/spree_application'
@@ -193,6 +199,12 @@ module Spree
193
199
  # @return [Integer] default: 365
194
200
  preference :return_eligibility_number_of_days, :integer, default: 365
195
201
 
202
+ # @!attribute [rw] roles_for_auto_api_key
203
+ # @return [Array] An array of roles where generating an api key for a user
204
+ # at role_user creation is desired when user has one of these roles.
205
+ # (default: +['admin']+)
206
+ preference :roles_for_auto_api_key, :array, default: ['admin']
207
+
196
208
  # @!attribute [rw] shipping_instructions
197
209
  # @return [Boolean] Request instructions/info for shipping (default: +false+)
198
210
  preference :shipping_instructions, :boolean, default: false
@@ -265,6 +277,16 @@ module Spree
265
277
  @promotion_chooser_class ||= Spree::PromotionChooser
266
278
  end
267
279
 
280
+ attr_writer :shipping_rate_sorter_class
281
+ def shipping_rate_sorter_class
282
+ @shipping_rate_sorter_class ||= Spree::Stock::ShippingRateSorter
283
+ end
284
+
285
+ attr_writer :shipping_rate_selector_class
286
+ def shipping_rate_selector_class
287
+ @shipping_rate_selector_class ||= Spree::Stock::ShippingRateSelector
288
+ end
289
+
268
290
  # Allows providing your own Mailer for shipped cartons.
269
291
  #
270
292
  # @!attribute [rw] carton_shipped_email_class
@@ -276,10 +298,24 @@ module Spree
276
298
  @carton_shipped_email_class ||= Spree::CartonMailer
277
299
  end
278
300
 
301
+ # Allows providing your own class for merging two orders.
302
+ #
303
+ # @!attribute [rw] order_merger_class
304
+ # @return [Class] a class with the same public interfaces
305
+ # as Spree::OrderMerger.
306
+ attr_writer :order_merger_class
307
+ def order_merger_class
308
+ @order_merger_class ||= Spree::OrderMerger
309
+ end
310
+
279
311
  def static_model_preferences
280
312
  @static_model_preferences ||= Spree::Preferences::StaticModelPreferences.new
281
313
  end
282
314
 
315
+ def stock
316
+ Spree::StockConfiguration
317
+ end
318
+
283
319
  # all the following can be deprecated when store prefs are no longer supported
284
320
  # @private
285
321
  DEPRECATED_STORE_PREFERENCES = {
@@ -4,12 +4,21 @@ class Spree::Base < ActiveRecord::Base
4
4
 
5
5
  include Spree::RansackableAttributes
6
6
 
7
- after_initialize do
7
+ def initialize_preference_defaults
8
8
  if has_attribute?(:preferences)
9
9
  self.preferences = default_preferences.merge(preferences)
10
10
  end
11
11
  end
12
12
 
13
+ # Only run preference initialization on models which requires it. Improves
14
+ # performance of record initialization slightly.
15
+ def self.preference(*args)
16
+ # after_initialize can be called multiple times with the same symbol, it
17
+ # will only be called once on initialization.
18
+ after_initialize :initialize_preference_defaults
19
+ super
20
+ end
21
+
13
22
  if Kaminari.config.page_method_name != :page
14
23
  def self.page num
15
24
  send Kaminari.config.page_method_name, num
@@ -23,7 +23,8 @@ module Spree
23
23
  end
24
24
 
25
25
  def compute(object)
26
- base, percent = preferred_tiers.sort.reverse.detect{ |b,_| object.amount >= b }
26
+ order = object.is_a?(Order) ? object : object.order
27
+ base, percent = preferred_tiers.sort.reverse.detect{ |b,_| order.item_total >= b }
27
28
  (object.amount * (percent || preferred_base_percent) / 100).round(2)
28
29
  end
29
30
 
@@ -5,7 +5,7 @@ module Spree
5
5
  belongs_to :product, class_name: "Spree::Product", inverse_of: :classifications
6
6
  belongs_to :taxon, class_name: "Spree::Taxon", inverse_of: :classifications, touch: true
7
7
 
8
- # For #3494
8
+ # For https://github.com/spree/spree/issues/3494
9
9
  validates_uniqueness_of :taxon_id, scope: :product_id, message: :already_linked
10
10
  end
11
11
  end
@@ -13,9 +13,9 @@ module Spree
13
13
  end
14
14
 
15
15
  def self.default
16
- find(Spree::Config[:default_country_id])
17
- rescue ActiveRecord::RecordNotFound
18
- first
16
+ if default_country_id = Spree::Config[:default_country_id]
17
+ find_by_id(default_country_id)
18
+ end || first
19
19
  end
20
20
 
21
21
  def <=>(other)
@@ -11,8 +11,8 @@ module Spree
11
11
 
12
12
  accepts_nested_attributes_for :address
13
13
 
14
+ attr_reader :number
14
15
  attr_accessor :encrypted_data,
15
- :number,
16
16
  :imported,
17
17
  :verification_value
18
18
 
@@ -181,7 +181,7 @@ module Spree
181
181
  def ensure_one_default
182
182
  if self.user_id && self.default
183
183
  CreditCard.where(default: true).where.not(id: self.id).where(user_id: self.user_id).each do |ucc|
184
- ucc.update_columns(default: false, updated_at: Time.now)
184
+ ucc.update_columns(default: false, updated_at: Time.current)
185
185
  end
186
186
  end
187
187
  end
@@ -19,6 +19,9 @@ module Spree
19
19
  money_methods pre_tax_total: { currency: Spree::Config[:currency] },
20
20
  total: { currency: Spree::Config[:currency] }
21
21
 
22
+
23
+ delegate :id, to: :order, prefix: true, allow_nil: true
24
+
22
25
  def total
23
26
  return_items.map(&:total).sum
24
27
  end
@@ -33,10 +36,6 @@ module Spree
33
36
  return_items.first.inventory_unit.order
34
37
  end
35
38
 
36
- def order_id
37
- order.try(:id)
38
- end
39
-
40
39
  def fully_reimbursed?
41
40
  completely_decided? && return_items.accepted.includes(:reimbursement).all? { |return_item| return_item.reimbursement.try(:reimbursed?) }
42
41
  end
@@ -2,9 +2,9 @@ module Spree
2
2
  class InventoryUnit < Spree::Base
3
3
  PRE_SHIPMENT_STATES = %w(backordered on_hand)
4
4
  POST_SHIPMENT_STATES = %w(returned)
5
- CANCELABLE_STATES = ['on_hand', 'backordered']
5
+ CANCELABLE_STATES = ['on_hand', 'backordered', 'shipped']
6
6
 
7
- belongs_to :variant, class_name: "Spree::Variant", inverse_of: :inventory_units
7
+ belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :inventory_units
8
8
  belongs_to :order, class_name: "Spree::Order", inverse_of: :inventory_units
9
9
  belongs_to :shipment, class_name: "Spree::Shipment", touch: true, inverse_of: :inventory_units
10
10
  belongs_to :return_authorization, class_name: "Spree::ReturnAuthorization", inverse_of: :inventory_units
@@ -35,6 +35,16 @@ module Spree
35
35
  .where('spree_orders.completed_at is not null')
36
36
  .backordered.order(Spree::Order.arel_table[:completed_at].asc)
37
37
  end
38
+
39
+ # @param stock_item [Spree::StockItem] the stock item of the desired
40
+ # inventory units
41
+ # @return [ActiveRecord::Relation<Spree::InventoryUnit>] backordered
42
+ # inventory units for the given stock item
43
+ scope :backordered_for_stock_item, ->(stock_item) do
44
+ backordered_per_variant(stock_item)
45
+ .where(spree_shipments: { stock_location_id: stock_item.stock_location_id })
46
+ end
47
+
38
48
  scope :shippable, -> { on_hand }
39
49
 
40
50
  # state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
@@ -57,20 +67,6 @@ module Spree
57
67
  end
58
68
  end
59
69
 
60
- # @param stock_item [Spree::StockItem] the stock item of the desired
61
- # inventory units
62
- # @return [Array<Spree::InventoryUnit>] an array of backordered inventory
63
- # units for the given stock item
64
- def self.backordered_for_stock_item(stock_item)
65
- # This was refactored from a simpler query because the previous
66
- # implementation led to issues once users tried to modify the objects
67
- # returned. That's due to ActiveRecord `joins(shipment: :stock_location)`
68
- # only returning readonly objects
69
- backordered_per_variant(stock_item).select do |unit|
70
- unit.shipment.stock_location == stock_item.stock_location
71
- end
72
- end
73
-
74
70
  # Updates the given inventory units to not be pending.
75
71
  #
76
72
  # @param inventory_units [<Spree::InventoryUnit>] the inventory to be
@@ -79,7 +75,7 @@ module Spree
79
75
  inventory_units.map do |iu|
80
76
  iu.update_columns(
81
77
  pending: false,
82
- updated_at: Time.now,
78
+ updated_at: Time.current,
83
79
  )
84
80
  end
85
81
  end
@@ -91,13 +87,6 @@ module Spree
91
87
  variant_id: variant_id).first
92
88
  end
93
89
 
94
- # @note This returns the variant regardless of whether it was soft
95
- # deleted.
96
- # @return [Spree::Variant] this inventory unit's variant.
97
- def variant
98
- Spree::Variant.unscoped { super }
99
- end
100
-
101
90
  # @return [Spree::ReturnItem] a valid return item for this inventory unit
102
91
  # if one exists, or a new one if one does not
103
92
  def current_or_new_return_item
@@ -63,11 +63,11 @@ module Spree
63
63
  @item.adjustment_total = @item.promo_total + @item.additional_tax_total + item_cancellation_total
64
64
 
65
65
  @item.update_columns(
66
- :promo_total => @item.promo_total,
67
- :included_tax_total => @item.included_tax_total,
68
- :additional_tax_total => @item.additional_tax_total,
69
- :adjustment_total => @item.adjustment_total,
70
- :updated_at => Time.now,
66
+ promo_total: @item.promo_total,
67
+ included_tax_total: @item.included_tax_total,
68
+ additional_tax_total: @item.additional_tax_total,
69
+ adjustment_total: @item.adjustment_total,
70
+ updated_at: Time.current,
71
71
  ) if @item.changed?
72
72
 
73
73
  @item
@@ -2,7 +2,7 @@ module Spree
2
2
  class LineItem < Spree::Base
3
3
  before_validation :invalid_quantity_check
4
4
  belongs_to :order, class_name: "Spree::Order", inverse_of: :line_items, touch: true
5
- belongs_to :variant, class_name: "Spree::Variant", inverse_of: :line_items
5
+ belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :line_items
6
6
  belongs_to :tax_category, class_name: "Spree::TaxCategory"
7
7
 
8
8
  has_one :product, through: :variant
@@ -34,6 +34,11 @@ module Spree
34
34
  after_create :update_tax_charge
35
35
 
36
36
  delegate :name, :description, :sku, :should_track_inventory?, to: :variant
37
+ # @note This will return the product even if it has been deleted.
38
+ # @return [Spree::Product, nil] the product associated with this line
39
+ # item, if there is one
40
+ delegate :product, to: :variant
41
+
37
42
 
38
43
  attr_accessor :target_shipment
39
44
 
@@ -114,20 +119,6 @@ module Spree
114
119
  !sufficient_stock?
115
120
  end
116
121
 
117
- # @note This will return the product even if it has been deleted.
118
- # @return [Spree::Product, nil] the product associated with this line
119
- # item, if there is one
120
- def product
121
- variant.product
122
- end
123
-
124
- # @note This will return the variant even if it has been deleted.
125
- # @return [Spree::Variant, nil] the variant associated with this line
126
- # item, if there is one
127
- def variant
128
- Spree::Variant.unscoped { super }
129
- end
130
-
131
122
  # Sets the options on the line item according to the order's currency or
132
123
  # one passed in.
133
124
  #
@@ -2,7 +2,7 @@ module Spree
2
2
  class LogEntry < Spree::Base
3
3
  belongs_to :source, polymorphic: true
4
4
 
5
- # Fix for #1767
5
+ # Fix for https://github.com/spree/spree/issues/1767
6
6
  # If a payment fails, we want to make sure we keep the record of it failing
7
7
  after_rollback :save_anyway
8
8
 
@@ -12,9 +12,11 @@ module Spree
12
12
  has_many :option_values, -> { order(:position) }, dependent: :destroy, inverse_of: :option_type
13
13
  has_many :product_option_types, dependent: :destroy, inverse_of: :option_type
14
14
  has_many :products, through: :product_option_types
15
- has_and_belongs_to_many :prototypes, join_table: 'spree_option_types_prototypes'
16
15
 
17
- validates :name, presence: true, uniqueness: true
16
+ has_many :option_type_prototypes
17
+ has_many :prototypes, through: :option_type_prototypes
18
+
19
+ validates :name, presence: true, uniqueness: { allow_blank: true }
18
20
  validates :presentation, presence: true
19
21
 
20
22
  default_scope -> { order(:position) }