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
@@ -13,19 +13,11 @@ module CapybaraExt
13
13
  end
14
14
 
15
15
  def within_row(num, &block)
16
- if example.metadata[:js]
17
- within("table.index tbody tr:nth-child(#{num})", &block)
18
- else
19
- within(:xpath, all("table.index tbody tr")[num-1].path, &block)
20
- end
16
+ within("table.index tbody tr:nth-child(#{num})", &block)
21
17
  end
22
18
 
23
19
  def column_text(num)
24
- if example.metadata[:js]
25
- find("td:nth-child(#{num})").text
26
- else
27
- all("td")[num-1].text
28
- end
20
+ find("td:nth-child(#{num})").text
29
21
  end
30
22
 
31
23
  def set_select2_field(field, value)
@@ -36,8 +28,8 @@ module CapybaraExt
36
28
  label = find_label_by_text(options[:from])
37
29
  within label.first(:xpath,".//..") do
38
30
  options[:from] = "##{find(".select2-container")["id"]}"
31
+ targetted_select2_search(value, options)
39
32
  end
40
- targetted_select2_search(value, options)
41
33
  end
42
34
 
43
35
  def targetted_select2_search(value, options)
@@ -51,8 +43,8 @@ module CapybaraExt
51
43
 
52
44
  within label.first(:xpath,".//..") do
53
45
  options[:from] = "##{find(".select2-container")["id"]}"
46
+ targetted_select2(value, options)
54
47
  end
55
- targetted_select2(value, options)
56
48
  end
57
49
 
58
50
  def select2_no_label value, options={}
@@ -73,10 +65,9 @@ module CapybaraExt
73
65
  end
74
66
 
75
67
  def select_select2_result(value)
76
- # results are in a div appended to the end of the document
77
- within(:xpath, '//body') do
78
- page.find("div.select2-result-label", text: %r{#{Regexp.escape(value)}}i).click
79
- end
68
+ #p %Q{$("div.select2-result-label:contains('#{value}')").mouseup()}
69
+ sleep(1)
70
+ page.execute_script(%Q{$("div.select2-result-label:contains('#{value}')").mouseup()})
80
71
  end
81
72
 
82
73
  def find_label_by_text(text)
@@ -103,7 +94,7 @@ module CapybaraExt
103
94
 
104
95
  def wait_for_ajax
105
96
  counter = 0
106
- while page.evaluate_script("$.active").to_i > 0
97
+ while page.execute_script("return $.active").to_i > 0
107
98
  counter += 1
108
99
  sleep(0.1)
109
100
  raise "AJAX request took longer than 5 seconds." if counter >= 50
@@ -111,6 +102,11 @@ module CapybaraExt
111
102
  end
112
103
  end
113
104
 
105
+ Capybara.configure do |config|
106
+ config.match = :prefer_exact
107
+ config.ignore_hidden_elements = true
108
+ end
109
+
114
110
  RSpec::Matchers.define :have_meta do |name, expected|
115
111
  match do |actual|
116
112
  has_css?("meta[name='#{name}'][content='#{expected}']", visible: false)
@@ -10,7 +10,7 @@ namespace :common do
10
10
  args.with_defaults(:user_class => "Spree::LegacyUser")
11
11
  require "#{ENV['LIB_NAME']}"
12
12
 
13
- Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", "--database=#{ENV['DB_NAME']}", "--quiet"]
13
+ Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", "--quiet"]
14
14
  Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", "--auto-accept", "--migrate=false", "--seed=false", "--sample=false", "--quiet", "--user_class=#{args[:user_class]}"]
15
15
 
16
16
  puts "Setting up dummy database..."
@@ -4,9 +4,9 @@
4
4
  # Inside your spec_helper.rb, include this module inside the RSpec.configure
5
5
  # block by doing this:
6
6
  #
7
- # require 'spree/testing_support/controller_requests'
7
+ # require 'spree/core/testing_support/controller_requests'
8
8
  # RSpec.configure do |c|
9
- # c.include Spree::TestingSupport::ControllerRequests, :type => :controller
9
+ # c.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
10
10
  # end
11
11
  #
12
12
  # Then, in your controller tests, you can access spree routes like this:
@@ -56,7 +56,7 @@ module Spree
56
56
 
57
57
  def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
58
58
  parameters ||= {}
59
- process(action, parameters.merge!(:use_route => :spree), session, flash, method)
59
+ process(action, method, parameters.merge!(:use_route => :spree), session, flash)
60
60
  end
61
61
  end
62
62
  end
@@ -7,7 +7,7 @@ FactoryGirl.define do
7
7
  factory :credit_card, class: TestCard do
8
8
  verification_value 123
9
9
  month 12
10
- year { Time.now.year }
10
+ year 2013
11
11
  number '4111111111111111'
12
12
  end
13
13
  end
@@ -12,10 +12,6 @@ FactoryGirl.define do
12
12
  # ensure stock item will be created for this products master
13
13
  before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 }
14
14
 
15
- after(:create) do |p|
16
- p.variants_including_master.each { |v| v.save! }
17
- end
18
-
19
15
  factory :custom_product do
20
16
  name 'Custom Product'
21
17
  price 17.99
@@ -4,9 +4,7 @@ FactoryGirl.define do
4
4
  name 'UPS Ground'
5
5
 
6
6
  before(:create) do |shipping_method, evaluator|
7
- if shipping_method.shipping_categories.empty?
8
- shipping_method.shipping_categories << (Spree::ShippingCategory.first || create(:shipping_category))
9
- end
7
+ shipping_method.shipping_categories << (Spree::ShippingCategory.first || create(:shipping_category))
10
8
  end
11
9
 
12
10
  factory :shipping_method, class: Spree::ShippingMethod do
@@ -11,7 +11,7 @@ FactoryGirl.define do
11
11
  authentication_token { generate(:user_authentication_token) } if Spree.user_class.attribute_method? :authentication_token
12
12
 
13
13
  factory :admin_user do
14
- spree_roles { [Spree::Role.find_by_name('admin') || create(:role, name: 'admin')] }
14
+ spree_roles { [Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')] }
15
15
  end
16
16
  end
17
17
  end
@@ -9,8 +9,6 @@ FactoryGirl.define do
9
9
  height { generate(:random_float) }
10
10
  width { generate(:random_float) }
11
11
  depth { generate(:random_float) }
12
- is_master 0
13
- track_inventory true
14
12
 
15
13
  product { |p| p.association(:base_product) }
16
14
  option_values { [create(:option_value)] }
@@ -22,18 +20,5 @@ FactoryGirl.define do
22
20
  # on_hand 5
23
21
  product { |p| p.association(:product) }
24
22
  end
25
-
26
- factory :master_variant do
27
- is_master 1
28
- end
29
-
30
- factory :on_demand_variant do
31
- track_inventory false
32
-
33
- factory :on_demand_master_variant do
34
- is_master 1
35
- end
36
- end
37
-
38
23
  end
39
24
  end
@@ -2,7 +2,7 @@ require 'factory_girl'
2
2
 
3
3
  Spree::Zone.class_eval do
4
4
  def self.global
5
- find_by_name('GlobalZone') || FactoryGirl.create(:global_zone)
5
+ find_by(name: 'GlobalZone') || FactoryGirl.create(:global_zone)
6
6
  end
7
7
  end
8
8
 
@@ -50,7 +50,7 @@ class OrderWalkthrough
50
50
  end
51
51
 
52
52
  def self.payment(order)
53
- order.payments.create!({:payment_method => Spree::PaymentMethod.first, :amount => order.total}, :without_protection => true)
53
+ order.payments.create!(:payment_method => Spree::PaymentMethod.first, :amount => order.total)
54
54
  # TODO: maybe look at some way of making this payment_state change automatic
55
55
  order.payment_state = 'paid'
56
56
  order.next!
data/lib/tasks/core.rake CHANGED
@@ -86,8 +86,8 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
86
86
  end
87
87
 
88
88
  if load_sample
89
- # Reload models' attributes in case they were loaded in old migrations with wrong attributes
90
- ActiveRecord::Base.descendants.each(&:reset_column_information)
89
+ #prevent errors for missing attributes (since rails 3.1 upgrade)
90
+
91
91
  Rake::Task["spree_sample:load"].invoke
92
92
  end
93
93