solidus_core 1.0.7 → 1.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/base_controller.rb +1 -2
  3. data/app/helpers/spree/base_helper.rb +4 -5
  4. data/app/helpers/spree/products_helper.rb +0 -8
  5. data/app/mailers/spree/carton_mailer.rb +17 -5
  6. data/app/mailers/spree/order_mailer.rb +12 -4
  7. data/app/models/concerns/spree/adjustment_source.rb +7 -8
  8. data/app/models/concerns/spree/default_price.rb +8 -2
  9. data/app/models/concerns/spree/named_type.rb +1 -1
  10. data/app/models/concerns/spree/ordered_property_value_list.rb +28 -0
  11. data/app/models/concerns/spree/user_address_book.rb +125 -0
  12. data/app/models/concerns/spree/user_api_authentication.rb +6 -2
  13. data/app/models/concerns/spree/user_methods.rb +5 -6
  14. data/app/models/spree/ability.rb +1 -38
  15. data/app/models/spree/address.rb +79 -36
  16. data/app/models/spree/adjustment.rb +74 -25
  17. data/app/models/spree/adjustment_reason.rb +1 -1
  18. data/app/models/spree/app_configuration.rb +35 -0
  19. data/app/models/spree/carton.rb +3 -3
  20. data/app/models/spree/country.rb +7 -1
  21. data/app/models/spree/credit_card.rb +5 -1
  22. data/app/models/spree/gateway.rb +0 -8
  23. data/app/models/spree/inventory_unit.rb +1 -1
  24. data/app/models/spree/item_adjustments.rb +1 -1
  25. data/app/models/spree/line_item_action.rb +1 -1
  26. data/app/models/spree/option_type.rb +3 -2
  27. data/app/models/spree/option_value.rb +1 -1
  28. data/app/models/spree/option_values_variant.rb +1 -1
  29. data/app/models/spree/order.rb +28 -56
  30. data/app/models/spree/order/checkout.rb +18 -20
  31. data/app/models/spree/order_mutex.rb +1 -1
  32. data/app/models/spree/order_promotion.rb +1 -1
  33. data/app/models/spree/order_shipping.rb +6 -12
  34. data/app/models/spree/order_stock_location.rb +1 -1
  35. data/app/models/spree/payment.rb +3 -14
  36. data/app/models/spree/payment/processing.rb +7 -14
  37. data/app/models/spree/payment_method.rb +5 -5
  38. data/app/models/spree/permission_sets/default_customer.rb +31 -0
  39. data/app/models/spree/permission_sets/order_display.rb +4 -0
  40. data/app/models/spree/permission_sets/order_management.rb +3 -0
  41. data/app/models/spree/permission_sets/promotion_display.rb +2 -1
  42. data/app/models/spree/permission_sets/restricted_stock_display.rb +16 -0
  43. data/app/models/spree/permission_sets/restricted_stock_management.rb +16 -0
  44. data/app/models/spree/permission_sets/restricted_stock_transfer_display.rb +17 -0
  45. data/app/models/spree/permission_sets/restricted_stock_transfer_management.rb +51 -0
  46. data/app/models/spree/permission_sets/stock_display.rb +1 -1
  47. data/app/models/spree/permission_sets/stock_management.rb +1 -2
  48. data/app/models/spree/permission_sets/stock_transfer_display.rb +10 -0
  49. data/app/models/spree/permission_sets/stock_transfer_management.rb +11 -0
  50. data/app/models/spree/permission_sets/super_user.rb +9 -0
  51. data/app/models/spree/product.rb +66 -28
  52. data/app/models/spree/product/scopes.rb +7 -22
  53. data/app/models/spree/product_option_type.rb +1 -1
  54. data/app/models/spree/product_promotion_rule.rb +6 -0
  55. data/app/models/spree/product_property.rb +2 -20
  56. data/app/models/spree/promotion/rules/product.rb +2 -1
  57. data/app/models/spree/refund.rb +0 -10
  58. data/app/models/spree/reimbursement.rb +1 -1
  59. data/app/models/spree/return_item.rb +5 -3
  60. data/app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb +13 -4
  61. data/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb +2 -2
  62. data/app/models/spree/return_reason.rb +1 -1
  63. data/app/models/spree/role.rb +1 -1
  64. data/app/models/spree/role_user.rb +1 -1
  65. data/app/models/spree/shipment.rb +13 -4
  66. data/app/models/spree/shipping_manifest.rb +9 -3
  67. data/app/models/spree/shipping_method.rb +2 -3
  68. data/app/models/spree/shipping_method_zone.rb +6 -0
  69. data/app/models/spree/state.rb +1 -1
  70. data/app/models/spree/stock_item.rb +15 -3
  71. data/app/models/spree/stock_movement.rb +1 -1
  72. data/app/models/spree/store.rb +3 -0
  73. data/app/models/spree/store_credit.rb +1 -1
  74. data/app/models/spree/store_credit_category.rb +1 -1
  75. data/app/models/spree/store_credit_event.rb +1 -1
  76. data/app/models/spree/store_credit_type.rb +1 -1
  77. data/app/models/spree/store_credit_update_reason.rb +1 -1
  78. data/app/models/spree/store_payment_method.rb +6 -0
  79. data/app/models/spree/tax_rate.rb +3 -10
  80. data/app/models/spree/taxonomy.rb +1 -1
  81. data/app/models/spree/transfer_item.rb +1 -1
  82. data/app/models/spree/unit_cancel.rb +2 -2
  83. data/app/models/spree/user_address.rb +21 -0
  84. data/app/models/spree/user_stock_location.rb +1 -1
  85. data/app/models/spree/variant.rb +28 -13
  86. data/app/models/spree/variant_property_rule.rb +42 -0
  87. data/app/models/spree/variant_property_rule_condition.rb +8 -0
  88. data/app/models/spree/variant_property_rule_value.rb +8 -0
  89. data/app/models/spree/zone.rb +4 -2
  90. data/app/views/spree/carton_mailer/shipped_email.text.erb +1 -1
  91. data/config/locales/en.yml +13 -0
  92. data/db/default/spree/store_credit.rb +0 -1
  93. data/db/default/spree/zones.rb +1 -1
  94. data/db/migrate/20130228210442_create_shipping_method_zone.rb +1 -1
  95. data/db/migrate/20150121022521_remove_environment_from_payment_method.rb +6 -0
  96. data/db/migrate/20150506181611_create_spree_store_credit_payment_method.rb +9 -5
  97. data/db/migrate/20150731201146_add_spree_user_addresses.rb +16 -0
  98. data/db/migrate/20150811210350_remove_mandatory_from_adjustments.rb +5 -0
  99. data/db/migrate/20150811211025_add_finalized_to_spree_adjustments.rb +11 -0
  100. data/db/migrate/20150820160821_add_store_payment_methods.rb +10 -0
  101. data/db/migrate/20150824213633_convert_habtm_to_hmt_for_shipping_methods_zones.rb +17 -0
  102. data/db/migrate/20150824214129_convert_habtm_to_hmt_for_products_promotion_rules.rb +17 -0
  103. data/db/migrate/20150825204216_drop_spree_gateways.rb +20 -0
  104. data/db/migrate/20150909123605_create_variant_properties_and_rules.rb +28 -0
  105. data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
  106. data/lib/generators/spree/install/templates/config/initializers/spree.rb +4 -3
  107. data/lib/spree/core.rb +4 -0
  108. data/lib/spree/core/controller_helpers/payment_parameters.rb +67 -0
  109. data/lib/spree/core/delegate_belongs_to.rb +1 -0
  110. data/lib/spree/core/engine.rb +9 -1
  111. data/lib/spree/core/importer/order.rb +1 -1
  112. data/lib/spree/core/role_configuration.rb +1 -1
  113. data/lib/spree/core/search/variant.rb +20 -2
  114. data/lib/spree/core/unreturned_item_charger.rb +21 -16
  115. data/lib/spree/i18n.rb +6 -24
  116. data/lib/spree/mailer_previews/carton_preview.rb +10 -0
  117. data/lib/spree/mailer_previews/order_preview.rb +18 -0
  118. data/lib/spree/permitted_attributes.rb +4 -1
  119. data/lib/spree/testing_support/capybara_ext.rb +2 -1
  120. data/lib/spree/testing_support/factories/address_factory.rb +9 -1
  121. data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -0
  122. data/lib/spree/testing_support/factories/image_factory.rb +5 -0
  123. data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -8
  124. data/lib/spree/testing_support/factories/user_factory.rb +8 -2
  125. data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +6 -0
  126. data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +16 -0
  127. data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +6 -0
  128. data/lib/tasks/migrations/migrate_user_addresses.rake +29 -0
  129. data/vendor/assets/javascripts/jquery-migrate-1.0.0.js +498 -0
  130. metadata +40 -238
  131. data/CHANGELOG.md +0 -1
  132. data/Gemfile +0 -3
  133. data/Rakefile +0 -16
  134. data/app/models/concerns/spree/user_address.rb +0 -30
  135. data/app/models/spree/permission_sets/restricted_transfer_management.rb +0 -35
  136. data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +0 -19
  137. data/lib/spree/i18n/base.rb +0 -17
  138. data/lib/spree/i18n/initializer.rb +0 -1
  139. data/lib/spree/testing_support/mail.rb +0 -20
  140. data/script/rails +0 -9
  141. data/solidus_core.gemspec +0 -48
  142. data/spec/fixtures/thinking-cat.jpg +0 -0
  143. data/spec/helpers/base_helper_spec.rb +0 -173
  144. data/spec/helpers/order_helper_spec.rb +0 -12
  145. data/spec/helpers/products_helper_spec.rb +0 -220
  146. data/spec/helpers/taxons_helper_spec.rb +0 -17
  147. data/spec/lib/calculated_adjustments_spec.rb +0 -7
  148. data/spec/lib/i18n_spec.rb +0 -123
  149. data/spec/lib/search/base_spec.rb +0 -86
  150. data/spec/lib/search/variant_spec.rb +0 -92
  151. data/spec/lib/spree/core/controller_helpers/auth_spec.rb +0 -66
  152. data/spec/lib/spree/core/controller_helpers/order_spec.rb +0 -92
  153. data/spec/lib/spree/core/controller_helpers/search_spec.rb +0 -17
  154. data/spec/lib/spree/core/controller_helpers/store_spec.rb +0 -16
  155. data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +0 -39
  156. data/spec/lib/spree/core/current_store_spec.rb +0 -36
  157. data/spec/lib/spree/core/delegate_belongs_to_spec.rb +0 -22
  158. data/spec/lib/spree/core/importer/order_spec.rb +0 -431
  159. data/spec/lib/spree/core/role_configuration_spec.rb +0 -138
  160. data/spec/lib/spree/core/validators/email_spec.rb +0 -48
  161. data/spec/lib/spree/localized_number_spec.rb +0 -38
  162. data/spec/lib/spree/migrations_spec.rb +0 -36
  163. data/spec/lib/spree/money_spec.rb +0 -127
  164. data/spec/lib/tasks/exchanges_spec.rb +0 -231
  165. data/spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb +0 -115
  166. data/spec/lib/tasks/order_capturing_spec.rb +0 -56
  167. data/spec/mailers/carton_mailer_spec.rb +0 -43
  168. data/spec/mailers/order_mailer_spec.rb +0 -122
  169. data/spec/mailers/reimbursement_mailer_spec.rb +0 -40
  170. data/spec/mailers/test_mailer_spec.rb +0 -15
  171. data/spec/models/spree/ability_spec.rb +0 -276
  172. data/spec/models/spree/address_spec.rb +0 -250
  173. data/spec/models/spree/adjustment_reason_spec.rb +0 -13
  174. data/spec/models/spree/adjustment_spec.rb +0 -177
  175. data/spec/models/spree/app_configuration_spec.rb +0 -20
  176. data/spec/models/spree/asset_spec.rb +0 -24
  177. data/spec/models/spree/calculator/default_tax_spec.rb +0 -127
  178. data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +0 -25
  179. data/spec/models/spree/calculator/flat_rate_spec.rb +0 -47
  180. data/spec/models/spree/calculator/flexi_rate_spec.rb +0 -41
  181. data/spec/models/spree/calculator/percent_on_line_item_spec.rb +0 -15
  182. data/spec/models/spree/calculator/price_sack_spec.rb +0 -30
  183. data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +0 -51
  184. data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +0 -23
  185. data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +0 -13
  186. data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +0 -52
  187. data/spec/models/spree/calculator/shipping/per_item_spec.rb +0 -20
  188. data/spec/models/spree/calculator/shipping/price_sack_spec.rb +0 -30
  189. data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +0 -36
  190. data/spec/models/spree/calculator/tiered_percent_spec.rb +0 -47
  191. data/spec/models/spree/calculator_spec.rb +0 -36
  192. data/spec/models/spree/carton_spec.rb +0 -133
  193. data/spec/models/spree/classification_spec.rb +0 -15
  194. data/spec/models/spree/concerns/display_money_spec.rb +0 -43
  195. data/spec/models/spree/concerns/user_methods_spec.rb +0 -41
  196. data/spec/models/spree/credit_card_spec.rb +0 -334
  197. data/spec/models/spree/customer_return_spec.rb +0 -276
  198. data/spec/models/spree/exchange_spec.rb +0 -79
  199. data/spec/models/spree/gateway/bogus_simple.rb +0 -20
  200. data/spec/models/spree/gateway/bogus_spec.rb +0 -13
  201. data/spec/models/spree/gateway_spec.rb +0 -82
  202. data/spec/models/spree/inventory_unit_spec.rb +0 -307
  203. data/spec/models/spree/item_adjustments_spec.rb +0 -256
  204. data/spec/models/spree/line_item_spec.rb +0 -191
  205. data/spec/models/spree/option_type_spec.rb +0 -14
  206. data/spec/models/spree/option_value_spec.rb +0 -22
  207. data/spec/models/spree/order/address_spec.rb +0 -50
  208. data/spec/models/spree/order/adjustments_spec.rb +0 -39
  209. data/spec/models/spree/order/callbacks_spec.rb +0 -42
  210. data/spec/models/spree/order/checkout_spec.rb +0 -902
  211. data/spec/models/spree/order/currency_updater_spec.rb +0 -32
  212. data/spec/models/spree/order/finalizing_spec.rb +0 -111
  213. data/spec/models/spree/order/payment_spec.rb +0 -210
  214. data/spec/models/spree/order/risk_assessment_spec.rb +0 -68
  215. data/spec/models/spree/order/state_machine_spec.rb +0 -221
  216. data/spec/models/spree/order/tax_spec.rb +0 -84
  217. data/spec/models/spree/order/totals_spec.rb +0 -24
  218. data/spec/models/spree/order/updating_spec.rb +0 -18
  219. data/spec/models/spree/order/validations_spec.rb +0 -15
  220. data/spec/models/spree/order_cancellations_spec.rb +0 -120
  221. data/spec/models/spree/order_capturing_spec.rb +0 -116
  222. data/spec/models/spree/order_contents_spec.rb +0 -265
  223. data/spec/models/spree/order_inventory_spec.rb +0 -228
  224. data/spec/models/spree/order_mutex_spec.rb +0 -85
  225. data/spec/models/spree/order_promotion_spec.rb +0 -31
  226. data/spec/models/spree/order_shipping_spec.rb +0 -247
  227. data/spec/models/spree/order_spec.rb +0 -1464
  228. data/spec/models/spree/order_stock_location_spec.rb +0 -18
  229. data/spec/models/spree/order_updater_spec.rb +0 -299
  230. data/spec/models/spree/payment_method/store_credit_spec.rb +0 -294
  231. data/spec/models/spree/payment_method_spec.rb +0 -96
  232. data/spec/models/spree/payment_spec.rb +0 -1045
  233. data/spec/models/spree/permission_sets/base_spec.rb +0 -12
  234. data/spec/models/spree/permission_sets/configuration_display.rb +0 -82
  235. data/spec/models/spree/permission_sets/configuration_management_spec.rb +0 -50
  236. data/spec/models/spree/permission_sets/dashboard_display_spec.rb +0 -22
  237. data/spec/models/spree/permission_sets/order_display_spec.rb +0 -49
  238. data/spec/models/spree/permission_sets/order_management_spec.rb +0 -36
  239. data/spec/models/spree/permission_sets/product_display_spec.rb +0 -60
  240. data/spec/models/spree/permission_sets/product_management_spec.rb +0 -40
  241. data/spec/models/spree/permission_sets/promotion_display_spec.rb +0 -34
  242. data/spec/models/spree/permission_sets/promotion_management_spec.rb +0 -26
  243. data/spec/models/spree/permission_sets/report_display_spec.rb +0 -24
  244. data/spec/models/spree/permission_sets/restricted_transfer_management_spec.rb +0 -132
  245. data/spec/models/spree/permission_sets/stock_display_spec.rb +0 -26
  246. data/spec/models/spree/permission_sets/stock_management_spec.rb +0 -24
  247. data/spec/models/spree/permission_sets/user_display_spec.rb +0 -36
  248. data/spec/models/spree/permission_sets/user_management_spec.rb +0 -28
  249. data/spec/models/spree/preference_spec.rb +0 -80
  250. data/spec/models/spree/preferences/configuration_spec.rb +0 -30
  251. data/spec/models/spree/preferences/preferable_spec.rb +0 -294
  252. data/spec/models/spree/preferences/scoped_store_spec.rb +0 -58
  253. data/spec/models/spree/preferences/static_model_preferences_spec.rb +0 -78
  254. data/spec/models/spree/preferences/statically_configurable_spec.rb +0 -60
  255. data/spec/models/spree/preferences/store_spec.rb +0 -39
  256. data/spec/models/spree/price_spec.rb +0 -42
  257. data/spec/models/spree/product/scopes_spec.rb +0 -148
  258. data/spec/models/spree/product_duplicator_spec.rb +0 -103
  259. data/spec/models/spree/product_filter_spec.rb +0 -26
  260. data/spec/models/spree/product_property_spec.rb +0 -20
  261. data/spec/models/spree/product_spec.rb +0 -437
  262. data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +0 -96
  263. data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +0 -165
  264. data/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +0 -115
  265. data/spec/models/spree/promotion/actions/free_shipping_spec.rb +0 -40
  266. data/spec/models/spree/promotion/rules/first_order_spec.rb +0 -75
  267. data/spec/models/spree/promotion/rules/item_total_spec.rb +0 -67
  268. data/spec/models/spree/promotion/rules/nth_order_spec.rb +0 -70
  269. data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +0 -42
  270. data/spec/models/spree/promotion/rules/option_value_spec.rb +0 -94
  271. data/spec/models/spree/promotion/rules/product_spec.rb +0 -143
  272. data/spec/models/spree/promotion/rules/taxon_spec.rb +0 -102
  273. data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +0 -27
  274. data/spec/models/spree/promotion/rules/user_spec.rb +0 -37
  275. data/spec/models/spree/promotion_builder_spec.rb +0 -118
  276. data/spec/models/spree/promotion_category_spec.rb +0 -17
  277. data/spec/models/spree/promotion_code/code_builder_spec.rb +0 -79
  278. data/spec/models/spree/promotion_code_spec.rb +0 -187
  279. data/spec/models/spree/promotion_handler/cart_spec.rb +0 -114
  280. data/spec/models/spree/promotion_handler/coupon_spec.rb +0 -335
  281. data/spec/models/spree/promotion_handler/free_shipping_spec.rb +0 -47
  282. data/spec/models/spree/promotion_handler/page_spec.rb +0 -44
  283. data/spec/models/spree/promotion_rule_spec.rb +0 -28
  284. data/spec/models/spree/promotion_spec.rb +0 -767
  285. data/spec/models/spree/refund_spec.rb +0 -204
  286. data/spec/models/spree/reimbursement/credit_spec.rb +0 -36
  287. data/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb +0 -140
  288. data/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +0 -83
  289. data/spec/models/spree/reimbursement_performer_spec.rb +0 -30
  290. data/spec/models/spree/reimbursement_spec.rb +0 -231
  291. data/spec/models/spree/reimbursement_tax_calculator_spec.rb +0 -51
  292. data/spec/models/spree/reimbursement_type/credit_spec.rb +0 -53
  293. data/spec/models/spree/reimbursement_type/exchange_spec.rb +0 -46
  294. data/spec/models/spree/reimbursement_type/original_payment_spec.rb +0 -107
  295. data/spec/models/spree/reimbursement_type/store_credit_spec.rb +0 -97
  296. data/spec/models/spree/return_authorization_spec.rb +0 -290
  297. data/spec/models/spree/return_item/eligibility_validator/default_spec.rb +0 -77
  298. data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +0 -58
  299. data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +0 -85
  300. data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +0 -32
  301. data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +0 -29
  302. data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +0 -35
  303. data/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +0 -65
  304. data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +0 -43
  305. data/spec/models/spree/return_item_spec.rb +0 -775
  306. data/spec/models/spree/returns_calculator_spec.rb +0 -14
  307. data/spec/models/spree/shipment_spec.rb +0 -709
  308. data/spec/models/spree/shipping_calculator_spec.rb +0 -45
  309. data/spec/models/spree/shipping_method_spec.rb +0 -88
  310. data/spec/models/spree/shipping_rate_spec.rb +0 -142
  311. data/spec/models/spree/state_spec.rb +0 -14
  312. data/spec/models/spree/stock/availability_validator_spec.rb +0 -83
  313. data/spec/models/spree/stock/coordinator_spec.rb +0 -116
  314. data/spec/models/spree/stock/differentiator_spec.rb +0 -39
  315. data/spec/models/spree/stock/estimator_spec.rb +0 -146
  316. data/spec/models/spree/stock/inventory_unit_builder_spec.rb +0 -38
  317. data/spec/models/spree/stock/package_spec.rb +0 -163
  318. data/spec/models/spree/stock/packer_spec.rb +0 -91
  319. data/spec/models/spree/stock/prioritizer_spec.rb +0 -125
  320. data/spec/models/spree/stock/quantifier_spec.rb +0 -115
  321. data/spec/models/spree/stock/splitter/backordered_spec.rb +0 -29
  322. data/spec/models/spree/stock/splitter/base_spec.rb +0 -21
  323. data/spec/models/spree/stock/splitter/shipping_category_spec.rb +0 -50
  324. data/spec/models/spree/stock/splitter/weight_spec.rb +0 -29
  325. data/spec/models/spree/stock_item_spec.rb +0 -426
  326. data/spec/models/spree/stock_location_spec.rb +0 -279
  327. data/spec/models/spree/stock_movement_spec.rb +0 -56
  328. data/spec/models/spree/stock_transfer_spec.rb +0 -290
  329. data/spec/models/spree/store_credit_category_spec.rb +0 -17
  330. data/spec/models/spree/store_credit_event_spec.rb +0 -314
  331. data/spec/models/spree/store_credit_spec.rb +0 -876
  332. data/spec/models/spree/store_spec.rb +0 -55
  333. data/spec/models/spree/tax_category_spec.rb +0 -27
  334. data/spec/models/spree/tax_rate_spec.rb +0 -378
  335. data/spec/models/spree/taxon_spec.rb +0 -74
  336. data/spec/models/spree/taxonomy_spec.rb +0 -18
  337. data/spec/models/spree/tracker_spec.rb +0 -21
  338. data/spec/models/spree/transfer_item_spec.rb +0 -264
  339. data/spec/models/spree/unit_cancel_spec.rb +0 -148
  340. data/spec/models/spree/user_spec.rb +0 -223
  341. data/spec/models/spree/validations/db_maximum_length_validator_spec.rb +0 -23
  342. data/spec/models/spree/variant/scopes_spec.rb +0 -55
  343. data/spec/models/spree/variant_spec.rb +0 -546
  344. data/spec/models/spree/zone_spec.rb +0 -305
  345. data/spec/spec_helper.rb +0 -78
  346. data/spec/support/big_decimal.rb +0 -5
  347. data/spec/support/concerns/default_price.rb +0 -34
  348. data/spec/support/dummy_ability.rb +0 -4
  349. data/spec/support/test_gateway.rb +0 -2
@@ -9,24 +9,6 @@ module Spree
9
9
  search_scopes << name.to_sym
10
10
  end
11
11
 
12
- def self.simple_scopes
13
- [
14
- :ascend_by_updated_at,
15
- :descend_by_updated_at,
16
- :ascend_by_name,
17
- :descend_by_name
18
- ]
19
- end
20
-
21
- def self.add_simple_scopes(scopes)
22
- scopes.each do |name|
23
- # We should not define price scopes here, as they require something slightly different
24
- next if name.to_s.include?("master_price")
25
- parts = name.to_s.match(/(.*)_by_(.*)/)
26
- self.scope(name.to_s, -> { order("#{Product.quoted_table_name}.#{parts[2]} #{parts[1] == 'ascend' ? "ASC" : "DESC"}") })
27
- end
28
- end
29
-
30
12
  def self.property_conditions(property)
31
13
  properties = Property.table_name
32
14
  conditions = case property
@@ -36,14 +18,17 @@ module Spree
36
18
  end
37
19
  end
38
20
 
39
- add_simple_scopes simple_scopes
21
+ scope :ascend_by_updated_at, -> { order(updated_at: :asc) }
22
+ scope :descend_by_updated_at, -> { order(updated_at: :desc) }
23
+ scope :ascend_by_name, -> { order(name: :asc) }
24
+ scope :descend_by_name, -> { order(name: :desc) }
40
25
 
41
26
  add_search_scope :ascend_by_master_price do
42
- joins(:master => :default_price).order("#{price_table_name}.amount ASC")
27
+ joins(:master => :default_price).order(Spree::Price.arel_table[:amount].asc)
43
28
  end
44
29
 
45
30
  add_search_scope :descend_by_master_price do
46
- joins(:master => :default_price).order("#{price_table_name}.amount DESC")
31
+ joins(:master => :default_price).order(Spree::Price.arel_table[:amount].desc)
47
32
  end
48
33
 
49
34
  add_search_scope :price_between do |low, high|
@@ -78,7 +63,7 @@ module Spree
78
63
  add_search_scope :in_taxon do |taxon|
79
64
  includes(:classifications).
80
65
  where("spree_products_taxons.taxon_id" => taxon.self_and_descendants.pluck(:id)).
81
- order("spree_products_taxons.position ASC")
66
+ order(Spree::Classification.arel_table[:position].asc)
82
67
  end
83
68
 
84
69
  # This scope selects products in all taxons AND all its descendants
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class ProductOptionType < Spree::Base
3
- belongs_to :product, class_name: 'Spree::Product', inverse_of: :product_option_types
3
+ belongs_to :product, class_name: 'Spree::Product', inverse_of: :product_option_types, touch: true
4
4
  belongs_to :option_type, class_name: 'Spree::OptionType', inverse_of: :product_option_types
5
5
  acts_as_list scope: :product
6
6
  end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ class ProductPromotionRule < Spree::Base
3
+ belongs_to :product
4
+ belongs_to :promotion_rule
5
+ end
6
+ end
@@ -1,28 +1,10 @@
1
1
  module Spree
2
2
  class ProductProperty < Spree::Base
3
- acts_as_list
3
+ include Spree::OrderedPropertyValueList
4
+
4
5
  belongs_to :product, touch: true, class_name: 'Spree::Product', inverse_of: :product_properties
5
6
  belongs_to :property, class_name: 'Spree::Property', inverse_of: :product_properties
6
7
 
7
- validates :property, presence: true
8
- validates :value, length: { maximum: 255 }
9
-
10
- default_scope -> { order("#{self.table_name}.position") }
11
-
12
8
  self.whitelisted_ransackable_attributes = ['value']
13
-
14
- # virtual attributes for use with AJAX completion stuff
15
- def property_name
16
- property.name if property
17
- end
18
-
19
- def property_name=(name)
20
- unless name.blank?
21
- unless property = Property.find_by(name: name)
22
- property = Property.create(name: name, presentation: name)
23
- end
24
- self.property = property
25
- end
26
- end
27
9
  end
28
10
  end
@@ -6,7 +6,8 @@ module Spree
6
6
  # either come from assigned product group or are assingned directly to
7
7
  # the rule.
8
8
  class Product < PromotionRule
9
- has_and_belongs_to_many :products, class_name: '::Spree::Product', join_table: 'spree_products_promotion_rules', foreign_key: 'promotion_rule_id'
9
+ has_many :product_promotion_rules, class_name: 'Spree::ProductPromotionRule', foreign_key: :promotion_rule_id
10
+ has_many :products, class_name: 'Spree::Product', through: :product_promotion_rules
10
11
 
11
12
  MATCH_POLICIES = %w(any all none)
12
13
  preference :match_policy, :string, default: MATCH_POLICIES.first
@@ -11,7 +11,6 @@ module Spree
11
11
  validates :transaction_id, presence: true, on: :update # can't require this on create because the before_create needs to run first
12
12
  validates :amount, presence: true, numericality: {greater_than: 0}
13
13
 
14
- validate :check_payment_environment, on: :create, if: :payment
15
14
  validate :amount_is_less_than_or_equal_to_allowed_amount, on: :create
16
15
 
17
16
  after_create :perform!
@@ -70,15 +69,6 @@ module Spree
70
69
  raise Core::GatewayError.new(Spree.t(:unable_to_connect_to_gateway))
71
70
  end
72
71
 
73
- # Saftey check to make sure we're not accidentally performing operations on a live gateway.
74
- # Ex. When testing in staging environment with a copy of production data.
75
- def check_payment_environment
76
- if payment.payment_method.environment != Rails.env
77
- message = Spree.t(:gateway_config_unavailable) + " - #{Rails.env}"
78
- errors.add(:base, message)
79
- end
80
- end
81
-
82
72
  def create_log_entry
83
73
  log_entries.create!(details: @response.to_yaml)
84
74
  end
@@ -152,7 +152,7 @@ module Spree
152
152
  end
153
153
 
154
154
  def send_reimbursement_email
155
- Spree::ReimbursementMailer.reimbursement_email(self.id).deliver_now
155
+ Spree::ReimbursementMailer.reimbursement_email(self.id).deliver_later
156
156
  end
157
157
 
158
158
  # If there are multiple different reimbursement types for a single
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- class ReturnItem < ActiveRecord::Base
2
+ class ReturnItem < Spree::Base
3
3
 
4
4
  INTERMEDIATE_RECEPTION_STATUSES = %i(given_to_customer lost_in_transit shipped_wrong_item short_shipped in_transit)
5
5
  COMPLETED_RECEPTION_STATUSES = INTERMEDIATE_RECEPTION_STATUSES + [:received]
@@ -89,6 +89,7 @@ module Spree
89
89
  event(:lost) { transition to: :lost_in_transit, from: :awaiting }
90
90
  event(:wrong_item_shipped) { transition to: :shipped_wrong_item, from: :awaiting }
91
91
  event(:short_shipped) { transition to: :short_shipped, from: :awaiting }
92
+ event(:in_transit) { transition to: :in_transit, from: :awaiting }
92
93
  event(:expired) { transition to: :expired, from: :awaiting }
93
94
  end
94
95
 
@@ -161,10 +162,11 @@ module Spree
161
162
  end
162
163
 
163
164
  # @note This uses the exchange_variant_engine configured on the class.
165
+ # @param stock_locations [Array<Spree::StockLocation>] the stock locations to check
164
166
  # @return [ActiveRecord::Relation<Spree::Variant>] the variants eligible
165
167
  # for exchange for this return item
166
- def eligible_exchange_variants
167
- exchange_variant_engine.eligible_variants(variant)
168
+ def eligible_exchange_variants(stock_locations = nil)
169
+ exchange_variant_engine.eligible_variants(variant, stock_locations: stock_locations)
168
170
  end
169
171
 
170
172
  # Builds the exchange inventory unit for this return item, only if an
@@ -19,12 +19,21 @@ module Spree
19
19
  # green pants with 32 waist and 30 inseam
20
20
  # blue pants with 34 waist and 32 inseam
21
21
 
22
- def self.eligible_variants(variant)
23
- product_variants = SameProduct.eligible_variants(variant).includes(option_values: :option_type)
24
-
22
+ def self.eligible_variants(variant, options = {})
23
+ product_variants = SameProduct.eligible_variants(variant, options).includes(option_values: :option_type)
25
24
  relevant_option_values = variant.option_values.select { |ov| option_type_restrictions.include? ov.option_type.name }
25
+
26
26
  if relevant_option_values.present?
27
- product_variants.select { |v| (relevant_option_values & v.option_values) == relevant_option_values }
27
+ # Finds all the OptionValueVariants that have any of the
28
+ # relevant option values, groups by variant and ensures the variant
29
+ # has ALL of the relevant option values.
30
+ variant_ids = Spree::OptionValuesVariant.
31
+ where(variant_id: product_variants.distinct.pluck(:id)).
32
+ where(option_value: relevant_option_values).
33
+ group(:variant_id).
34
+ having('COUNT(*) = ?', relevant_option_values.size).
35
+ pluck(:variant_id)
36
+ product_variants.where(id: variant_ids)
28
37
  else
29
38
  product_variants
30
39
  end
@@ -1,8 +1,8 @@
1
1
  module Spree
2
2
  module ReturnItem::ExchangeVariantEligibility
3
3
  class SameProduct
4
- def self.eligible_variants(variant)
5
- Spree::Variant.where(product_id: variant.product_id, is_master: variant.is_master?).in_stock
4
+ def self.eligible_variants(variant, stock_locations: nil)
5
+ Spree::Variant.where(product_id: variant.product_id, is_master: variant.is_master?).in_stock(stock_locations)
6
6
  end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- class ReturnReason < ActiveRecord::Base
2
+ class ReturnReason < Spree::Base
3
3
  include Spree::NamedType
4
4
 
5
5
  has_many :return_authorizations
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class Role < Spree::Base
3
- has_many :role_users, class_name: "Spree::RoleUser"
3
+ has_many :role_users, class_name: "Spree::RoleUser", dependent: :destroy
4
4
  has_many :users, through: :role_users
5
5
 
6
6
  def admin?
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- class RoleUser < ActiveRecord::Base
2
+ class RoleUser < Spree::Base
3
3
  self.table_name = "spree_roles_users"
4
4
  belongs_to :role, class_name: "Spree::Role"
5
5
  belongs_to :user, class_name: Spree::UserClassHandle.new
@@ -3,12 +3,12 @@ require 'ostruct'
3
3
  module Spree
4
4
  class Shipment < Spree::Base
5
5
  belongs_to :order, class_name: 'Spree::Order', touch: true, inverse_of: :shipments
6
- belongs_to :address, class_name: 'Spree::Address', inverse_of: :shipments
6
+ belongs_to :address, class_name: 'Spree::Address'
7
7
  belongs_to :stock_location, class_name: 'Spree::StockLocation'
8
8
 
9
9
  has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :delete_all
10
10
  has_many :inventory_units, dependent: :destroy, inverse_of: :shipment
11
- has_many :shipping_rates, -> { order('cost ASC') }, dependent: :delete_all
11
+ has_many :shipping_rates, -> { order(:cost) }, dependent: :delete_all
12
12
  has_many :shipping_methods, through: :shipping_rates
13
13
  has_many :state_changes, as: :stateful
14
14
  has_many :cartons, -> { uniq }, through: :inventory_units
@@ -72,6 +72,7 @@ module Spree
72
72
  end
73
73
  end
74
74
 
75
+ self.whitelisted_ransackable_associations = ['order']
75
76
  self.whitelisted_ransackable_attributes = ['number']
76
77
 
77
78
  def can_transition_from_pending_to_shipped?
@@ -129,9 +130,17 @@ module Spree
129
130
  item_cost + final_price
130
131
  end
131
132
 
133
+ # Decrement the stock counts for all pending inventory units in this
134
+ # shipment and mark.
135
+ # Any previous non-pending inventory units are skipped as their stock had
136
+ # already been allocated.
132
137
  def finalize!
133
- InventoryUnit.finalize_units!(inventory_units)
134
- manifest.each { |item| manifest_unstock(item) }
138
+ transaction do
139
+ pending_units = inventory_units.select(&:pending?)
140
+ pending_manifest = ShippingManifest.new(inventory_units: pending_units)
141
+ pending_manifest.items.each { |item| manifest_unstock(item) }
142
+ InventoryUnit.finalize_units!(pending_units)
143
+ end
135
144
  end
136
145
 
137
146
  def include?(variant)
@@ -2,14 +2,20 @@ class Spree::ShippingManifest
2
2
  ManifestItem = Struct.new(:line_item, :variant, :quantity, :states)
3
3
 
4
4
  def initialize(inventory_units:)
5
- @inventory_units = inventory_units
5
+ @inventory_units = inventory_units.to_a
6
+ end
7
+
8
+ def for_order(order)
9
+ Spree::ShippingManifest.new(
10
+ inventory_units: @inventory_units.select {|iu| iu.order_id == order.id }
11
+ )
6
12
  end
7
13
 
8
14
  def items
9
15
  # Grouping by the ID means that we don't have to call out to the association accessor
10
16
  # This makes the grouping by faster because it results in less SQL cache hits.
11
- @inventory_units.group_by(&:variant_id).map do |variant_id, units|
12
- units.group_by(&:line_item_id).map do |line_item_id, units|
17
+ @inventory_units.group_by(&:variant_id).map do |variant_id, variant_units|
18
+ variant_units.group_by(&:line_item_id).map do |line_item_id, units|
13
19
 
14
20
  states = {}
15
21
  units.group_by(&:state).each { |state, iu| states[state] = iu.count }
@@ -12,9 +12,8 @@ module Spree
12
12
  has_many :shipments, :through => :shipping_rates
13
13
  has_many :cartons, inverse_of: :shipping_method
14
14
 
15
- has_and_belongs_to_many :zones, :join_table => 'spree_shipping_methods_zones',
16
- :class_name => 'Spree::Zone',
17
- :foreign_key => 'shipping_method_id'
15
+ has_many :shipping_method_zones
16
+ has_many :zones, through: :shipping_method_zones
18
17
 
19
18
  belongs_to :tax_category, :class_name => 'Spree::TaxCategory'
20
19
 
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ class ShippingMethodZone < Spree::Base
3
+ belongs_to :zone
4
+ belongs_to :shipping_method
5
+ end
6
+ end
@@ -13,7 +13,7 @@ module Spree
13
13
  # blank is added elsewhere, if needed
14
14
  def self.states_group_by_country_id
15
15
  state_info = Hash.new { |h, k| h[k] = [] }
16
- self.order('name ASC').each { |state|
16
+ self.order(:name).each { |state|
17
17
  state_info[state.country_id.to_s].push [state.id, state.name]
18
18
  }
19
19
  state_info
@@ -98,11 +98,23 @@ module Spree
98
98
  end
99
99
 
100
100
  def conditional_variant_touch
101
+ variant.touch if inventory_cache_threshold.nil? || should_touch_variant?
102
+ end
103
+
104
+ def should_touch_variant?
101
105
  # the variant_id changes from nil when a new stock location is added
102
- stock_changed = (count_on_hand_changed? && count_on_hand_change.any? { |c| c < 1 }) || variant_id_changed?
106
+ inventory_cache_threshold &&
107
+ (count_on_hand_changed? && count_on_hand_change.any? { |c| c < inventory_cache_threshold }) ||
108
+ variant_id_changed?
109
+ end
103
110
 
104
- if !Spree::Config.binary_inventory_cache || stock_changed
105
- variant.touch
111
+ def inventory_cache_threshold
112
+ # only warn if store is setting binary_inventory_cache (default = false)
113
+ @cache_threshold ||= if Spree::Config.binary_inventory_cache
114
+ ActiveSupport::Deprecation.warn "Spree::Config.binary_inventory_cache=true is DEPRECATED. Instead use Spree::Config.inventory_cache_threshold=1"
115
+ 1
116
+ else
117
+ Spree::Config.inventory_cache_threshold
106
118
  end
107
119
  end
108
120
  end
@@ -8,7 +8,7 @@ module Spree
8
8
  validates :stock_item, presence: true
9
9
  validates :quantity, presence: true
10
10
 
11
- scope :recent, -> { order('created_at DESC') }
11
+ scope :recent, -> { order(created_at: :desc) }
12
12
 
13
13
  self.whitelisted_ransackable_attributes = ['quantity']
14
14
 
@@ -1,5 +1,8 @@
1
1
  module Spree
2
2
  class Store < Spree::Base
3
+ has_many :store_payment_methods, inverse_of: :store
4
+ has_many :payment_methods, through: :store_payment_methods
5
+
3
6
  validates :code, presence: true, uniqueness: { allow_blank: true }
4
7
  validates :name, presence: true
5
8
  validates :url, presence: true
@@ -1,4 +1,4 @@
1
- class Spree::StoreCredit < ActiveRecord::Base
1
+ class Spree::StoreCredit < Spree::Base
2
2
  acts_as_paranoid
3
3
 
4
4
  VOID_ACTION = 'void'
@@ -1,4 +1,4 @@
1
- class Spree::StoreCreditCategory < ActiveRecord::Base
1
+ class Spree::StoreCreditCategory < Spree::Base
2
2
  class_attribute :non_expiring_credit_types
3
3
  self.non_expiring_credit_types = [Spree.t("store_credit.non_expiring")]
4
4
 
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- class StoreCreditEvent < ActiveRecord::Base
2
+ class StoreCreditEvent < Spree::Base
3
3
  acts_as_paranoid
4
4
 
5
5
  belongs_to :store_credit
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- class StoreCreditType < ActiveRecord::Base
2
+ class StoreCreditType < Spree::Base
3
3
  DEFAULT_TYPE_NAME = Spree.t("store_credit.expiring")
4
4
  has_many :store_credits, class_name: 'Spree::StoreCredit', foreign_key: 'type_id'
5
5
  end
@@ -1,2 +1,2 @@
1
- class Spree::StoreCreditUpdateReason < ActiveRecord::Base
1
+ class Spree::StoreCreditUpdateReason < Spree::Base
2
2
  end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ class StorePaymentMethod < Spree::Base
3
+ belongs_to :store, inverse_of: :store_payment_methods
4
+ belongs_to :payment_method, inverse_of: :store_payment_methods
5
+ end
6
+ end
@@ -51,17 +51,10 @@ module Spree
51
51
  # This little bit of code at the end stops the Spanish refund from appearing.
52
52
  #
53
53
  # For further discussion, see #4397 and #4327.
54
-
55
- remaining_rates = rates.dup
56
- rates.each do |rate|
57
- if rate.included_in_price?
58
- if remaining_rates.any?{|r| r != rate && r.tax_category == rate.tax_category }
59
- remaining_rates.delete(rate)
60
- end
61
- end
54
+ rates.delete_if do |rate|
55
+ rate.included_in_price? &&
56
+ (rates - [rate]).map(&:tax_category).include?(rate.tax_category)
62
57
  end
63
-
64
- remaining_rates
65
58
  end
66
59
 
67
60
  # Pre-tax amounts must be stored so that we can calculate