spree_core 2.0.13 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/base_controller.rb +3 -0
  3. data/app/helpers/spree/base_helper.rb +6 -16
  4. data/app/helpers/spree/products_helper.rb +3 -8
  5. data/app/helpers/spree/taxons_helper.rb +1 -1
  6. data/app/mailers/spree/base_mailer.rb +0 -5
  7. data/app/models/spree/ability.rb +10 -7
  8. data/app/models/spree/address.rb +7 -17
  9. data/app/models/spree/adjustment.rb +15 -11
  10. data/app/models/spree/app_configuration.rb +0 -5
  11. data/app/models/spree/billing_integration.rb +0 -1
  12. data/app/models/spree/calculator/flat_percent_item_total.rb +1 -3
  13. data/app/models/spree/calculator/flat_rate.rb +2 -4
  14. data/app/models/spree/calculator/flexi_rate.rb +6 -9
  15. data/app/models/spree/calculator/per_item.rb +2 -4
  16. data/app/models/spree/calculator/percent_per_item.rb +1 -3
  17. data/app/models/spree/calculator/price_sack.rb +4 -9
  18. data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -2
  19. data/app/models/spree/calculator/shipping/flat_rate.rb +2 -4
  20. data/app/models/spree/calculator/shipping/flexi_rate.rb +4 -9
  21. data/app/models/spree/calculator/shipping/per_item.rb +2 -3
  22. data/app/models/spree/calculator/shipping/price_sack.rb +4 -9
  23. data/app/models/spree/classification.rb +0 -3
  24. data/app/models/spree/country.rb +1 -3
  25. data/app/models/spree/credit_card.rb +37 -38
  26. data/app/models/spree/gateway/bogus_simple.rb +0 -8
  27. data/app/models/spree/gateway.rb +1 -3
  28. data/app/models/spree/image.rb +1 -3
  29. data/app/models/spree/inventory_unit.rb +5 -8
  30. data/app/models/spree/legacy_user.rb +0 -4
  31. data/app/models/spree/line_item.rb +2 -15
  32. data/app/models/spree/option_type.rb +2 -5
  33. data/app/models/spree/option_value.rb +1 -3
  34. data/app/models/spree/order/checkout.rb +4 -13
  35. data/app/models/spree/order.rb +47 -99
  36. data/app/models/spree/order_contents.rb +4 -7
  37. data/app/models/spree/order_inventory.rb +4 -8
  38. data/app/models/spree/order_updater.rb +13 -12
  39. data/app/models/spree/payment/processing.rb +12 -19
  40. data/app/models/spree/payment.rb +17 -30
  41. data/app/models/spree/payment_method.rb +2 -3
  42. data/app/models/spree/preference.rb +1 -1
  43. data/app/models/spree/preferences/configuration.rb +1 -1
  44. data/app/models/spree/preferences/preferable.rb +1 -1
  45. data/app/models/spree/preferences/store.rb +1 -1
  46. data/app/models/spree/price.rb +0 -7
  47. data/app/models/spree/product/scopes.rb +16 -17
  48. data/app/models/spree/product.rb +27 -62
  49. data/app/models/spree/product_property.rb +3 -5
  50. data/app/models/spree/promotion/actions/create_adjustment.rb +9 -8
  51. data/app/models/spree/promotion/actions/create_line_items.rb +1 -2
  52. data/app/models/spree/promotion/rules/first_order.rb +1 -1
  53. data/app/models/spree/promotion/rules/item_total.rb +2 -4
  54. data/app/models/spree/promotion/rules/product.rb +2 -2
  55. data/app/models/spree/promotion/rules/user.rb +1 -3
  56. data/app/models/spree/promotion.rb +23 -24
  57. data/app/models/spree/promotion_action.rb +0 -2
  58. data/app/models/spree/promotion_action_line_item.rb +1 -3
  59. data/app/models/spree/promotion_rule.rb +0 -2
  60. data/app/models/spree/property.rb +2 -4
  61. data/app/models/spree/prototype.rb +0 -2
  62. data/app/models/spree/return_authorization.rb +6 -9
  63. data/app/models/spree/role.rb +0 -2
  64. data/app/models/spree/shipment.rb +19 -25
  65. data/app/models/spree/shipping_calculator.rb +0 -2
  66. data/app/models/spree/shipping_category.rb +0 -2
  67. data/app/models/spree/shipping_method.rb +6 -20
  68. data/app/models/spree/shipping_rate.rb +12 -10
  69. data/app/models/spree/state.rb +2 -4
  70. data/app/models/spree/stock/availability_validator.rb +2 -2
  71. data/app/models/spree/stock/estimator.rb +6 -20
  72. data/app/models/spree/stock/packer.rb +1 -1
  73. data/app/models/spree/stock/quantifier.rb +2 -3
  74. data/app/models/spree/stock/splitter/base.rb +1 -1
  75. data/app/models/spree/stock_item.rb +8 -18
  76. data/app/models/spree/stock_location.rb +2 -11
  77. data/app/models/spree/stock_movement.rb +2 -5
  78. data/app/models/spree/stock_transfer.rb +0 -2
  79. data/app/models/spree/tax_category.rb +0 -2
  80. data/app/models/spree/tax_rate.rb +12 -12
  81. data/app/models/spree/taxon.rb +1 -13
  82. data/app/models/spree/taxonomy.rb +3 -6
  83. data/app/models/spree/tracker.rb +0 -2
  84. data/app/models/spree/variant/scopes.rb +2 -2
  85. data/app/models/spree/variant.rb +13 -31
  86. data/app/models/spree/zone.rb +2 -7
  87. data/app/models/spree/zone_member.rb +0 -2
  88. data/app/views/spree/payments/_payment.html.erb +1 -3
  89. data/config/locales/en.yml +11 -26
  90. data/db/default/spree/countries.rb +230 -229
  91. data/db/default/spree/states.rb +57 -56
  92. data/db/default/spree/zones.rb +5 -5
  93. data/db/migrate/20130213191427_create_default_stock.rb +4 -7
  94. data/db/migrate/20130417120035_update_adjustment_states.rb +2 -2
  95. data/db/migrate/20130417123427_add_shipping_rates_to_shipments.rb +1 -1
  96. data/db/migrate/20130509115210_add_number_to_stock_transfer.rb +1 -1
  97. data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +0 -5
  98. data/db/migrate/20130611185927_add_user_id_index_to_spree_orders.rb +5 -0
  99. data/db/migrate/20130618041418_add_updated_at_to_spree_countries.rb +9 -0
  100. data/db/migrate/20130619012236_add_updated_at_to_spree_states.rb +9 -0
  101. data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +4 -5
  102. data/db/migrate/20130806145853_set_default_stock_location_on_shipments.rb +1 -1
  103. data/lib/generators/spree/dummy/dummy_generator.rb +3 -14
  104. data/lib/generators/spree/dummy/templates/rails/database.yml +0 -10
  105. data/lib/generators/spree/dummy/templates/rails/test.rb +2 -7
  106. data/lib/generators/spree/install/install_generator.rb +11 -8
  107. data/lib/spree/core/calculated_adjustments.rb +9 -8
  108. data/lib/spree/core/controller_helpers/auth.rb +2 -3
  109. data/lib/spree/core/controller_helpers/order.rb +8 -13
  110. data/lib/spree/core/controller_helpers/ssl.rb +13 -22
  111. data/lib/spree/core/controller_helpers/strong_parameters.rb +36 -0
  112. data/lib/spree/core/delegate_belongs_to.rb +0 -2
  113. data/lib/spree/core/engine.rb +1 -5
  114. data/lib/spree/core/ext/active_record.rb +2 -9
  115. data/lib/spree/core/permalinks.rb +1 -5
  116. data/lib/spree/core/product_duplicator.rb +2 -16
  117. data/lib/spree/core/product_filters.rb +37 -33
  118. data/lib/spree/core/search/base.rb +1 -1
  119. data/lib/spree/core/version.rb +1 -1
  120. data/lib/spree/core.rb +3 -31
  121. data/lib/spree/i18n.rb +0 -1
  122. data/lib/spree/money.rb +2 -177
  123. data/lib/spree/permitted_attributes.rb +95 -0
  124. data/lib/spree/promo/coupon_applicator.rb +4 -12
  125. data/lib/spree/testing_support/capybara_ext.rb +13 -17
  126. data/lib/spree/testing_support/common_rake.rb +1 -1
  127. data/lib/spree/testing_support/controller_requests.rb +3 -3
  128. data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
  129. data/lib/spree/testing_support/factories/product_factory.rb +0 -4
  130. data/lib/spree/testing_support/factories/shipping_method_factory.rb +1 -3
  131. data/lib/spree/testing_support/factories/user_factory.rb +1 -1
  132. data/lib/spree/testing_support/factories/variant_factory.rb +0 -15
  133. data/lib/spree/testing_support/factories.rb +1 -1
  134. data/lib/spree/testing_support/order_walkthrough.rb +1 -1
  135. data/lib/tasks/core.rake +2 -2
  136. data/vendor/assets/javascripts/jquery.payment.js +497 -0
  137. metadata +166 -172
  138. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -17
  139. data/db/migrate/20130417120034_add_index_to_source_columns_on_adjustments.rb +0 -5
  140. data/db/migrate/20130830001033_add_shipping_category_to_shipping_methods_and_products.rb +0 -15
  141. data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +0 -19
  142. data/db/migrate/20130909115621_change_states_required_for_countries.rb +0 -9
  143. data/db/migrate/20131001013410_remove_unused_credit_card_fields.rb +0 -12
  144. data/db/migrate/20131026154747_add_track_inventory_to_variant.rb +0 -5
  145. data/db/migrate/20131113035136_add_channel_to_spree_orders.rb +0 -5
  146. data/db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb +0 -5
  147. data/db/migrate/20140205181631_default_variant_weight_to_zero.rb +0 -11
  148. data/db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb +0 -5
  149. data/lib/spree/core/preference_rescue.rb +0 -25
@@ -1,57 +1,58 @@
1
- # encoding: utf-8
2
- country = Spree::Country.find_by_name('United States')
1
+ country = Spree::Country.find_by(name: 'United States')
3
2
 
4
- Spree::State.create!({"name"=>"Michigan", "abbr"=>"MI", :country=>country}, :without_protection => true)
5
- Spree::State.create!({"name"=>"South Dakota", "abbr"=>"SD", :country=>country}, :without_protection => true)
6
- Spree::State.create!({"name"=>"Washington", "abbr"=>"WA", :country=>country}, :without_protection => true)
7
- Spree::State.create!({"name"=>"Wisconsin", "abbr"=>"WI", :country=>country}, :without_protection => true)
8
- Spree::State.create!({"name"=>"Arizona", "abbr"=>"AZ", :country=>country}, :without_protection => true)
9
- Spree::State.create!({"name"=>"Illinois", "abbr"=>"IL", :country=>country}, :without_protection => true)
10
- Spree::State.create!({"name"=>"New Hampshire", "abbr"=>"NH", :country=>country}, :without_protection => true)
11
- Spree::State.create!({"name"=>"North Carolina", "abbr"=>"NC", :country=>country}, :without_protection => true)
12
- Spree::State.create!({"name"=>"Kansas", "abbr"=>"KS", :country=>country}, :without_protection => true)
13
- Spree::State.create!({"name"=>"Missouri", "abbr"=>"MO", :country=>country}, :without_protection => true)
14
- Spree::State.create!({"name"=>"Arkansas", "abbr"=>"AR", :country=>country}, :without_protection => true)
15
- Spree::State.create!({"name"=>"Nevada", "abbr"=>"NV", :country=>country}, :without_protection => true)
16
- Spree::State.create!({"name"=>"District of Columbia", "abbr"=>"DC", :country=>country}, :without_protection => true)
17
- Spree::State.create!({"name"=>"Idaho", "abbr"=>"ID", :country=>country}, :without_protection => true)
18
- Spree::State.create!({"name"=>"Nebraska", "abbr"=>"NE", :country=>country}, :without_protection => true)
19
- Spree::State.create!({"name"=>"Pennsylvania", "abbr"=>"PA", :country=>country}, :without_protection => true)
20
- Spree::State.create!({"name"=>"Hawaii", "abbr"=>"HI", :country=>country}, :without_protection => true)
21
- Spree::State.create!({"name"=>"Utah", "abbr"=>"UT", :country=>country}, :without_protection => true)
22
- Spree::State.create!({"name"=>"Vermont", "abbr"=>"VT", :country=>country}, :without_protection => true)
23
- Spree::State.create!({"name"=>"Delaware", "abbr"=>"DE", :country=>country}, :without_protection => true)
24
- Spree::State.create!({"name"=>"Rhode Island", "abbr"=>"RI", :country=>country}, :without_protection => true)
25
- Spree::State.create!({"name"=>"Oklahoma", "abbr"=>"OK", :country=>country}, :without_protection => true)
26
- Spree::State.create!({"name"=>"Louisiana", "abbr"=>"LA", :country=>country}, :without_protection => true)
27
- Spree::State.create!({"name"=>"Montana", "abbr"=>"MT", :country=>country}, :without_protection => true)
28
- Spree::State.create!({"name"=>"Tennessee", "abbr"=>"TN", :country=>country}, :without_protection => true)
29
- Spree::State.create!({"name"=>"Maryland", "abbr"=>"MD", :country=>country}, :without_protection => true)
30
- Spree::State.create!({"name"=>"Florida", "abbr"=>"FL", :country=>country}, :without_protection => true)
31
- Spree::State.create!({"name"=>"Virginia", "abbr"=>"VA", :country=>country}, :without_protection => true)
32
- Spree::State.create!({"name"=>"Minnesota", "abbr"=>"MN", :country=>country}, :without_protection => true)
33
- Spree::State.create!({"name"=>"New Jersey", "abbr"=>"NJ", :country=>country}, :without_protection => true)
34
- Spree::State.create!({"name"=>"Ohio", "abbr"=>"OH", :country=>country}, :without_protection => true)
35
- Spree::State.create!({"name"=>"California", "abbr"=>"CA", :country=>country}, :without_protection => true)
36
- Spree::State.create!({"name"=>"North Dakota", "abbr"=>"ND", :country=>country}, :without_protection => true)
37
- Spree::State.create!({"name"=>"Maine", "abbr"=>"ME", :country=>country}, :without_protection => true)
38
- Spree::State.create!({"name"=>"Indiana", "abbr"=>"IN", :country=>country}, :without_protection => true)
39
- Spree::State.create!({"name"=>"Texas", "abbr"=>"TX", :country=>country}, :without_protection => true)
40
- Spree::State.create!({"name"=>"Oregon", "abbr"=>"OR", :country=>country}, :without_protection => true)
41
- Spree::State.create!({"name"=>"Wyoming", "abbr"=>"WY", :country=>country}, :without_protection => true)
42
- Spree::State.create!({"name"=>"Alabama", "abbr"=>"AL", :country=>country}, :without_protection => true)
43
- Spree::State.create!({"name"=>"Iowa", "abbr"=>"IA", :country=>country}, :without_protection => true)
44
- Spree::State.create!({"name"=>"Mississippi", "abbr"=>"MS", :country=>country}, :without_protection => true)
45
- Spree::State.create!({"name"=>"Kentucky", "abbr"=>"KY", :country=>country}, :without_protection => true)
46
- Spree::State.create!({"name"=>"New Mexico", "abbr"=>"NM", :country=>country}, :without_protection => true)
47
- Spree::State.create!({"name"=>"Georgia", "abbr"=>"GA", :country=>country}, :without_protection => true)
48
- Spree::State.create!({"name"=>"Colorado", "abbr"=>"CO", :country=>country}, :without_protection => true)
49
- Spree::State.create!({"name"=>"Massachusetts", "abbr"=>"MA", :country=>country}, :without_protection => true)
50
- Spree::State.create!({"name"=>"Connecticut", "abbr"=>"CT", :country=>country}, :without_protection => true)
51
- Spree::State.create!({"name"=>"New York", "abbr"=>"NY", :country=>country}, :without_protection => true)
52
- Spree::State.create!({"name"=>"South Carolina", "abbr"=>"SC", :country=>country}, :without_protection => true)
53
- Spree::State.create!({"name"=>"Alaska", "abbr"=>"AK", :country=>country}, :without_protection => true)
54
- Spree::State.create!({"name"=>"West Virginia", "abbr"=>"WV", :country=>country}, :without_protection => true)
55
- Spree::State.create!({"name"=>"U.S. Armed Forces – Americas", "abbr"=>"AA", :country=>country}, :without_protection => true)
56
- Spree::State.create!({"name"=>"U.S. Armed Forces Europe", "abbr"=>"AE", :country=>country}, :without_protection => true)
57
- Spree::State.create!({"name"=>"U.S. Armed Forces Pacific", "abbr"=>"AP", :country=>country}, :without_protection => true)
3
+ Spree::State.create!([
4
+ { name: 'Michigan', abbr: 'MI', country: country },
5
+ { name: 'South Dakota', abbr: 'SD', country: country },
6
+ { name: 'Washington', abbr: 'WA', country: country },
7
+ { name: 'Wisconsin', abbr: 'WI', country: country },
8
+ { name: 'Arizona', abbr: 'AZ', country: country },
9
+ { name: 'Illinois', abbr: 'IL', country: country },
10
+ { name: 'New Hampshire', abbr: 'NH', country: country },
11
+ { name: 'North Carolina', abbr: 'NC', country: country },
12
+ { name: 'Kansas', abbr: 'KS', country: country },
13
+ { name: 'Missouri', abbr: 'MO', country: country },
14
+ { name: 'Arkansas', abbr: 'AR', country: country },
15
+ { name: 'Nevada', abbr: 'NV', country: country },
16
+ { name: 'District of Columbia', abbr: 'DC', country: country },
17
+ { name: 'Idaho', abbr: 'ID', country: country },
18
+ { name: 'Nebraska', abbr: 'NE', country: country },
19
+ { name: 'Pennsylvania', abbr: 'PA', country: country },
20
+ { name: 'Hawaii', abbr: 'HI', country: country },
21
+ { name: 'Utah', abbr: 'UT', country: country },
22
+ { name: 'Vermont', abbr: 'VT', country: country },
23
+ { name: 'Delaware', abbr: 'DE', country: country },
24
+ { name: 'Rhode Island', abbr: 'RI', country: country },
25
+ { name: 'Oklahoma', abbr: 'OK', country: country },
26
+ { name: 'Louisiana', abbr: 'LA', country: country },
27
+ { name: 'Montana', abbr: 'MT', country: country },
28
+ { name: 'Tennessee', abbr: 'TN', country: country },
29
+ { name: 'Maryland', abbr: 'MD', country: country },
30
+ { name: 'Florida', abbr: 'FL', country: country },
31
+ { name: 'Virginia', abbr: 'VA', country: country },
32
+ { name: 'Minnesota', abbr: 'MN', country: country },
33
+ { name: 'New Jersey', abbr: 'NJ', country: country },
34
+ { name: 'Ohio', abbr: 'OH', country: country },
35
+ { name: 'California', abbr: 'CA', country: country },
36
+ { name: 'North Dakota', abbr: 'ND', country: country },
37
+ { name: 'Maine', abbr: 'ME', country: country },
38
+ { name: 'Indiana', abbr: 'IN', country: country },
39
+ { name: 'Texas', abbr: 'TX', country: country },
40
+ { name: 'Oregon', abbr: 'OR', country: country },
41
+ { name: 'Wyoming', abbr: 'WY', country: country },
42
+ { name: 'Alabama', abbr: 'AL', country: country },
43
+ { name: 'Iowa', abbr: 'IA', country: country },
44
+ { name: 'Mississippi', abbr: 'MS', country: country },
45
+ { name: 'Kentucky', abbr: 'KY', country: country },
46
+ { name: 'New Mexico', abbr: 'NM', country: country },
47
+ { name: 'Georgia', abbr: 'GA', country: country },
48
+ { name: 'Colorado', abbr: 'CO', country: country },
49
+ { name: 'Massachusetts', abbr: 'MA', country: country },
50
+ { name: 'Connecticut', abbr: 'CT', country: country },
51
+ { name: 'New York', abbr: 'NY', country: country },
52
+ { name: 'South Carolina', abbr: 'SC', country: country },
53
+ { name: 'Alaska', abbr: 'AK', country: country },
54
+ { name: 'West Virginia', abbr: 'WV', country: country },
55
+ { name: 'U.S. Armed Forces - Americas', abbr: 'AA', country: country },
56
+ { name: 'U.S. Armed Forces - Europe', abbr: 'AE', country: country },
57
+ { name: 'U.S. Armed Forces - Pacific', abbr: 'AP', country: country }
58
+ ])
@@ -1,17 +1,17 @@
1
- eu_vat = Spree::Zone.create!(:name => "EU_VAT", :description => "Countries that make up the EU VAT zone.")
2
- north_america = Spree::Zone.create!(:name => "North America", :description => "USA + Canada")
1
+ eu_vat = Spree::Zone.create!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.")
2
+ north_america = Spree::Zone.create!(name: "North America", description: "USA + Canada")
3
3
 
4
4
  ["Poland", "Finland", "Portugal", "Romania", "Germany", "France",
5
5
  "Slovakia", "Hungary", "Slovenia", "Ireland", "Austria", "Spain",
6
6
  "Italy", "Belgium", "Sweden", "Latvia", "Bulgaria", "United Kingdom",
7
7
  "Lithuania", "Cyprus", "Luxembourg", "Malta", "Denmark", "Netherlands",
8
8
  "Estonia"].
9
- each do |name|
10
- eu_vat.zone_members.create!(:zoneable => Spree::Country.find_by_name!(name))
9
+ each do |name|
10
+ eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(name: name))
11
11
  end
12
12
 
13
13
  ["United States", "Canada"].each do |name|
14
- north_america.zone_members.create!(:zoneable => Spree::Country.find_by_name!(name))
14
+ north_america.zone_members.create!(zoneable: Spree::Country.find_by!(name: name))
15
15
  end
16
16
 
17
17
 
@@ -4,13 +4,10 @@ class CreateDefaultStock < ActiveRecord::Migration
4
4
  Spree::StockItem.skip_callback(:save, :after, :process_backorders)
5
5
  location = Spree::StockLocation.new(name: 'default')
6
6
  location.save(validate: false)
7
-
8
- Spree::Variant.find_each do |variant|
9
- stock_item = Spree::StockItem.unscoped.build(stock_location: location, variant: variant)
7
+ Spree::Variant.all.each do |variant|
8
+ stock_item = location.stock_items.build(variant: variant)
10
9
  stock_item.send(:count_on_hand=, variant.count_on_hand)
11
- # Avoid running default_scope defined by acts_as_paranoid, related to #3805,
12
- # validations would run a query with a delete_at column that might not be present yet
13
- stock_item.save! validate: false
10
+ stock_item.save!
14
11
  end
15
12
 
16
13
  remove_column :spree_variants, :count_on_hand
@@ -19,7 +16,7 @@ class CreateDefaultStock < ActiveRecord::Migration
19
16
  def down
20
17
  add_column :spree_variants, :count_on_hand, :integer
21
18
 
22
- Spree::StockItem.find_each do |stock_item|
19
+ Spree::StockItem.all.each do |stock_item|
23
20
  stock_item.variant.update_column :count_on_hand, stock_item.count_on_hand
24
21
  end
25
22
 
@@ -1,10 +1,10 @@
1
1
  class UpdateAdjustmentStates < ActiveRecord::Migration
2
2
  def up
3
- Spree::Order.complete.find_each do |order|
3
+ Spree::Order.complete.each do |order|
4
4
  order.adjustments.update_all(:state => 'closed')
5
5
  end
6
6
 
7
- Spree::Shipment.shipped.includes(:adjustment).find_each do |shipment|
7
+ Spree::Shipment.shipped.each do |shipment|
8
8
  shipment.adjustment.update_column(:state, 'finalized') if shipment.adjustment
9
9
  end
10
10
 
@@ -1,6 +1,6 @@
1
1
  class AddShippingRatesToShipments < ActiveRecord::Migration
2
2
  def up
3
- Spree::Shipment.find_each do |shipment|
3
+ Spree::Shipment.all.each do |shipment|
4
4
  shipment.shipping_rates.create(:shipping_method_id => shipment.shipping_method_id,
5
5
  :cost => shipment.cost,
6
6
  :selected => true)
@@ -6,7 +6,7 @@ class AddNumberToStockTransfer < ActiveRecord::Migration
6
6
  rename_column :spree_stock_transfers, :reference_number, :reference
7
7
  add_column :spree_stock_transfers, :number, :string
8
8
 
9
- Spree::StockTransfer.find_each do |transfer|
9
+ Spree::StockTransfer.all.each do |transfer|
10
10
  transfer.send(:generate_stock_transfer_number)
11
11
  transfer.save!
12
12
  end
@@ -1,10 +1,5 @@
1
1
  class RenameShippingMethodsZonesToSpreeShippingMethodsZones < ActiveRecord::Migration
2
2
  def change
3
3
  rename_table :shipping_methods_zones, :spree_shipping_methods_zones
4
- # If Spree::ShippingMethod zones association was patched in
5
- # CreateShippingMethodZone migrations, it needs to be patched back
6
- Spree::ShippingMethod.has_and_belongs_to_many :zones, :join_table => 'spree_shipping_methods_zones',
7
- :class_name => 'Spree::Zone',
8
- :foreign_key => 'shipping_method_id'
9
4
  end
10
5
  end
@@ -0,0 +1,5 @@
1
+ class AddUserIdIndexToSpreeOrders < ActiveRecord::Migration
2
+ def change
3
+ add_index :spree_orders, :user_id
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class AddUpdatedAtToSpreeCountries < ActiveRecord::Migration
2
+ def up
3
+ add_column :spree_countries, :updated_at, :datetime
4
+ end
5
+
6
+ def down
7
+ remove_column :spree_countries, :updated_at
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddUpdatedAtToSpreeStates < ActiveRecord::Migration
2
+ def up
3
+ add_column :spree_states, :updated_at, :datetime
4
+ end
5
+
6
+ def down
7
+ remove_column :spree_states, :updated_at
8
+ end
9
+ end
@@ -1,10 +1,9 @@
1
1
  class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
2
2
  def change
3
- Spree::LineItem.find_each do |line_item|
4
- next if line_item.variant.nil?
5
- next if line_item.variant.product.nil?
6
- next if line_item.product.nil?
7
- line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
3
+ Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
4
+ line_items.each do |line_item|
5
+ line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
6
+ end
8
7
  end
9
8
  end
10
9
  end
@@ -1,7 +1,7 @@
1
1
  class SetDefaultStockLocationOnShipments < ActiveRecord::Migration
2
2
  def change
3
3
  if Spree::Shipment.where('stock_location_id IS NULL').count > 0
4
- location = Spree::StockLocation.find_by_name('default') || Spree::StockLocation.first
4
+ location = Spree::StockLocation.find_by(name: 'default') || Spree::StockLocation.first
5
5
  Spree::Shipment.where('stock_location_id IS NULL').update_all(stock_location_id: location.id)
6
6
  end
7
7
  end
@@ -53,9 +53,9 @@ module Spree
53
53
  def test_dummy_inject_extension_requirements
54
54
  if DummyGeneratorHelper.inject_extension_requirements
55
55
  inside dummy_path do
56
- inject_require_for('spree_frontend')
57
- inject_require_for('spree_backend')
58
- inject_require_for('spree_api')
56
+ %w(spree_frontend spree_backend spree_api).each do |requirement|
57
+ inject_into_file 'config/application.rb', "require '#{requirement}'\n", :before => /require '#{@lib_name}'/, :verbose => true
58
+ end
59
59
  end
60
60
  end
61
61
  end
@@ -82,17 +82,6 @@ module Spree
82
82
  attr :database
83
83
 
84
84
  protected
85
-
86
- def inject_require_for(requirement)
87
- inject_into_file 'config/application.rb', %Q[
88
- begin
89
- require '#{requirement}'
90
- rescue LoadError
91
- # #{requirement} is not available.
92
- end
93
- ], :before => /require '#{@lib_name}'/, :verbose => true
94
- end
95
-
96
85
  def dummy_path
97
86
  ENV['DUMMY_PATH'] || 'spec/dummy'
98
87
  end
@@ -27,31 +27,21 @@ production:
27
27
  database: <%= database_prefix %>spree_production
28
28
  encoding: utf8
29
29
  <% when 'postgres' %>
30
- <% db_host = ENV['DB_HOST'] -%>
31
30
  development:
32
31
  adapter: postgresql
33
32
  database: <%= database_prefix %>spree_development
34
33
  username: postgres
35
34
  min_messages: warning
36
- <% unless db_host.blank? %>
37
- host: <%= db_host %>
38
- <% end %>
39
35
  test:
40
36
  adapter: postgresql
41
37
  database: <%= database_prefix %>spree_test
42
38
  username: postgres
43
39
  min_messages: warning
44
- <% unless db_host.blank? %>
45
- host: <%= db_host %>
46
- <% end %>
47
40
  production:
48
41
  adapter: postgresql
49
42
  database: <%= database_prefix %>spree_production
50
43
  username: postgres
51
44
  min_messages: warning
52
- <% unless db_host.blank? %>
53
- host: <%= db_host %>
54
- <% end %>
55
45
  <% else %>
56
46
  development:
57
47
  adapter: sqlite3
@@ -11,13 +11,12 @@ Dummy::Application.configure do
11
11
  config.serve_static_assets = true
12
12
  config.static_cache_control = "public, max-age=3600"
13
13
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
14
  # Show full error reports and disable caching
18
15
  config.consider_all_requests_local = true
19
16
  config.action_controller.perform_caching = false
20
17
 
18
+ config.eager_load = false
19
+
21
20
  # Raise exceptions instead of rendering exception templates
22
21
  config.action_dispatch.show_exceptions = false
23
22
 
@@ -30,10 +29,6 @@ Dummy::Application.configure do
30
29
  config.action_mailer.delivery_method = :test
31
30
  ActionMailer::Base.default :from => "spree@example.com"
32
31
 
33
- # Raise exception on mass assignment protection for Active Record models
34
- config.active_record.mass_assignment_sanitizer = :strict
35
-
36
32
  # Print deprecation notices to the stderr
37
33
  config.active_support.deprecation = :stderr
38
34
  end
39
-
@@ -70,14 +70,19 @@ Disallow: /account
70
70
  def setup_assets
71
71
  @lib_name = 'spree'
72
72
  %w{javascripts stylesheets images}.each do |path|
73
- empty_directory "app/assets/#{path}/store"
74
- empty_directory "app/assets/#{path}/admin"
73
+ empty_directory "app/assets/#{path}/store" if defined? Spree::Frontend || Rails.env.test?
74
+ empty_directory "app/assets/#{path}/admin" if defined? Spree::Backend || Rails.env.test?
75
75
  end
76
76
 
77
- template "app/assets/javascripts/store/all.js"
78
- template "app/assets/javascripts/admin/all.js"
79
- template "app/assets/stylesheets/store/all.css"
80
- template "app/assets/stylesheets/admin/all.css"
77
+ if defined? Spree::Frontend || Rails.env.test?
78
+ template "app/assets/javascripts/store/all.js"
79
+ template "app/assets/stylesheets/store/all.css"
80
+ end
81
+
82
+ if defined? Spree::Backend || Rails.env.test?
83
+ template "app/assets/javascripts/admin/all.js"
84
+ template "app/assets/stylesheets/admin/all.css"
85
+ end
81
86
  end
82
87
 
83
88
  def create_overrides_directory
@@ -99,8 +104,6 @@ Disallow: /account
99
104
  end
100
105
  end
101
106
  APP
102
-
103
- append_file "config/environment.rb", "\nActiveRecord::Base.include_root_in_json = false\n"
104
107
  end
105
108
 
106
109
  def include_seed_data
@@ -5,7 +5,6 @@ module Spree
5
5
  klass.class_eval do
6
6
  has_one :calculator, :class_name => "Spree::Calculator", :as => :calculable, :dependent => :destroy
7
7
  accepts_nested_attributes_for :calculator
8
- attr_accessible :calculator_type, :calculator_attributes
9
8
  validates :calculator, :presence => true
10
9
 
11
10
  def self.calculators
@@ -33,12 +32,14 @@ module Spree
33
32
  calculable = calculable.to_package if calculable.is_a?(Spree::Shipment)
34
33
  amount = compute_amount(calculable)
35
34
  return if amount == 0 && !mandatory
36
- target.adjustments.create({ :amount => amount,
37
- :source => old_calculable,
38
- :originator => self,
39
- :label => label,
40
- :mandatory => mandatory,
41
- :state => state }, :without_protection => true)
35
+ target.adjustments.create(
36
+ :amount => amount,
37
+ :source => old_calculable,
38
+ :originator => self,
39
+ :label => label,
40
+ :mandatory => mandatory,
41
+ :state => state
42
+ )
42
43
  end
43
44
 
44
45
  # Updates the amount of the adjustment using our Calculator and calling the +compute+ method with the +calculable+
@@ -49,7 +50,7 @@ module Spree
49
50
  # It's only the package that contains the correct information.
50
51
  # See https://github.com/spree/spree_active_shipping/pull/96 et. al
51
52
  calculable = calculable.to_package if calculable.is_a?(Spree::Shipment)
52
- adjustment.update_attribute_without_callbacks(:amount, compute_amount(calculable))
53
+ adjustment.update_column(:amount, compute_amount(calculable))
53
54
  end
54
55
 
55
56
  # Calculate the amount to be used when creating an adjustment
@@ -9,7 +9,7 @@ module Spree
9
9
  helper_method :try_spree_current_user
10
10
 
11
11
  rescue_from CanCan::AccessDenied do |exception|
12
- return unauthorized
12
+ unauthorized
13
13
  end
14
14
  end
15
15
 
@@ -27,8 +27,7 @@ module Spree
27
27
  redirect_to '/unauthorized'
28
28
  else
29
29
  store_location
30
- url = spree.respond_to?(:login_path) ? spree.login_path : spree.root_path
31
- redirect_to url
30
+ redirect_to respond_to?(:spree_login_path) ? spree_login_path : spree.root_path
32
31
  end
33
32
  end
34
33
 
@@ -11,16 +11,13 @@ module Spree
11
11
  end
12
12
 
13
13
  # The current incomplete order from the session for use in cart and during checkout
14
- def current_order(options = {})
15
- options[:create_order_if_necessary] ||= false
16
- options[:lock] ||= false
14
+ def current_order(create_order_if_necessary = false)
17
15
  return @current_order if @current_order
18
16
  if session[:order_id]
19
- current_order = Spree::Order.includes(:adjustments).lock(options[:lock]).where(id: session[:order_id], currency: current_currency).first
17
+ current_order = Spree::Order.includes(:adjustments).find_by(id: session[:order_id], currency: current_currency)
20
18
  @current_order = current_order unless current_order.try(:completed?)
21
19
  end
22
-
23
- if options[:create_order_if_necessary] and (@current_order.nil? or @current_order.completed?)
20
+ if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)
24
21
  @current_order = Spree::Order.new(currency: current_currency)
25
22
  @current_order.user ||= try_spree_current_user
26
23
  # See issue #3346 for reasons why this line is here
@@ -42,16 +39,14 @@ module Spree
42
39
  def associate_user
43
40
  @order ||= current_order
44
41
  if try_spree_current_user && @order
45
- if @order.user.blank? || @order.email.blank?
46
- @order.associate_user!(try_spree_current_user)
47
- end
42
+ @order.associate_user!(try_spree_current_user) if @order.user.blank? || @order.email.blank?
48
43
  end
49
44
 
50
45
  # This will trigger any "first order" promotions to be triggered
51
46
  # Assuming of course that this session variable was set correctly in
52
47
  # the authentication provider's registrations controller
53
48
  if session[:spree_user_signup] && @order
54
- fire_event('spree.user.signup', :user => try_spree_current_user, :order => @order)
49
+ fire_event('spree.user.signup', user: try_spree_current_user, order: @order)
55
50
  session[:spree_user_signup] = nil
56
51
  end
57
52
 
@@ -63,8 +58,8 @@ module Spree
63
58
  last_incomplete_order = user.last_incomplete_spree_order
64
59
  if session[:order_id].nil? && last_incomplete_order
65
60
  session[:order_id] = last_incomplete_order.id
66
- elsif current_order(create_order_if_necessary: true) && last_incomplete_order && current_order != last_incomplete_order
67
- current_order.merge!(last_incomplete_order, user)
61
+ elsif current_order(true) && last_incomplete_order && current_order != last_incomplete_order
62
+ current_order.merge!(last_incomplete_order)
68
63
  end
69
64
  end
70
65
  end
@@ -74,7 +69,7 @@ module Spree
74
69
  end
75
70
 
76
71
  def ip_address
77
- request.remote_ip
72
+ request.env['HTTP_X_REAL_IP'] || request.env['REMOTE_ADDR']
78
73
  end
79
74
  end
80
75
  end
@@ -6,20 +6,20 @@ module Spree
6
6
 
7
7
  included do
8
8
  before_filter :force_non_ssl_redirect, :if => Proc.new { Spree::Config[:redirect_https_to_http] }
9
- class_attribute :ssl_allowed_actions
10
9
 
11
10
  def self.ssl_allowed(*actions)
12
- self.ssl_allowed_actions ||= []
13
- self.ssl_allowed_actions.concat actions
11
+ class_attribute :ssl_allowed_actions
12
+ self.ssl_allowed_actions = actions
14
13
  end
15
14
 
16
15
  def self.ssl_required(*actions)
17
- ssl_allowed *actions
16
+ class_attribute :ssl_required_actions
17
+ self.ssl_required_actions = actions
18
18
  if ssl_supported?
19
- if actions.empty? or Rails.application.config.force_ssl
19
+ if ssl_required_actions.empty? or Rails.application.config.force_ssl
20
20
  force_ssl
21
21
  else
22
- force_ssl :only => actions
22
+ force_ssl :only => ssl_required_actions
23
23
  end
24
24
  end
25
25
  end
@@ -31,28 +31,19 @@ module Spree
31
31
  end
32
32
 
33
33
  private
34
- def ssl_allowed?
35
- (!ssl_allowed_actions.nil? && (ssl_allowed_actions.empty? || ssl_allowed_actions.include?(action_name.to_sym)))
36
- end
37
34
 
38
35
  # Redirect the existing request to use the HTTP protocol.
39
36
  #
40
37
  # ==== Parameters
41
38
  # * <tt>host</tt> - Redirect to a different host name
42
39
  def force_non_ssl_redirect(host = nil)
43
- if request.ssl? && !ssl_allowed?
44
- if request.get?
45
- redirect_options = {
46
- :protocol => 'http://',
47
- :host => host || request.host,
48
- :path => request.fullpath,
49
- }
50
- flash.keep if respond_to?(:flash)
51
- insecure_url = ActionDispatch::Http::URL.url_for(redirect_options)
52
- redirect_to insecure_url, :status => :moved_permanently
53
- else
54
- render :text => Spree.t(:change_protocol, :scope => :ssl), :status => :upgrade_required
55
- end
40
+ return true if defined?(ssl_allowed_actions) and ssl_allowed_actions.include?(action_name.to_sym)
41
+ if request.ssl? and (!defined?(ssl_required_actions) or !ssl_required_actions.include?(action_name.to_sym))
42
+ redirect_options = {:protocol => 'http://', :status => :moved_permanently}
43
+ redirect_options.merge!(:host => host) if host
44
+ redirect_options.merge!(:params => request.query_parameters)
45
+ flash.keep if respond_to?(:flash)
46
+ redirect_to redirect_options
56
47
  end
57
48
  end
58
49
  end
@@ -0,0 +1,36 @@
1
+ module Spree
2
+ module Core
3
+ module ControllerHelpers
4
+ module StrongParameters
5
+ def permitted_attributes
6
+ Spree::PermittedAttributes
7
+ end
8
+
9
+ delegate *Spree::PermittedAttributes::ATTRIBUTES,
10
+ :to => :permitted_attributes,
11
+ :prefix => :permitted
12
+
13
+ def permitted_payment_attributes
14
+ permitted_attributes.payment_attributes + [
15
+ :source_attributes => permitted_source_attributes
16
+ ]
17
+ end
18
+
19
+ def permitted_checkout_attributes
20
+ permitted_attributes.checkout_attributes + [
21
+ :bill_address_attributes => permitted_address_attributes,
22
+ :ship_address_attributes => permitted_address_attributes,
23
+ :payments_attributes => permitted_payment_attributes,
24
+ :shipments_attributes => permitted_shipment_attributes
25
+ ]
26
+ end
27
+
28
+ def permitted_order_attributes
29
+ permitted_checkout_attributes + [
30
+ :line_items_attributes => permitted_line_item_attributes
31
+ ]
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end