solidus_core 1.3.2 → 1.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/app/helpers/spree/base_helper.rb +6 -2
- data/app/mailers/spree/base_mailer.rb +1 -1
- data/app/mailers/spree/carton_mailer.rb +1 -1
- data/app/mailers/spree/order_mailer.rb +2 -2
- data/app/mailers/spree/reimbursement_mailer.rb +7 -7
- data/app/mailers/spree/test_mailer.rb +3 -2
- data/app/models/concerns/spree/user_payment_source.rb +1 -1
- data/app/models/spree/address.rb +14 -4
- data/app/models/spree/adjustment.rb +11 -19
- data/app/models/spree/app_configuration.rb +23 -1
- data/app/models/spree/base.rb +9 -0
- data/app/models/spree/country.rb +2 -2
- data/app/models/spree/exchange.rb +1 -1
- data/app/models/spree/gateway.rb +1 -1
- data/app/models/spree/item_adjustments.rb +7 -0
- data/app/models/spree/line_item.rb +1 -13
- data/app/models/spree/order/checkout.rb +19 -16
- data/app/models/spree/order/payments.rb +0 -2
- data/app/models/spree/order.rb +7 -21
- data/app/models/spree/order_contents.rb +60 -4
- data/app/models/spree/order_merger.rb +2 -4
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/order_update_attributes.rb +0 -2
- data/app/models/spree/order_updater.rb +14 -11
- data/app/models/spree/payment.rb +2 -3
- data/app/models/spree/payment_create.rb +5 -2
- data/app/models/spree/payment_method/store_credit.rb +6 -5
- data/app/models/spree/product/scopes.rb +2 -1
- data/app/models/spree/product.rb +2 -5
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/option_value.rb +2 -3
- data/app/models/spree/promotion/rules/product.rb +9 -3
- data/app/models/spree/promotion/rules/taxon.rb +33 -7
- data/app/models/spree/promotion/rules/user.rb +2 -3
- data/app/models/spree/promotion.rb +16 -6
- data/app/models/spree/promotion_handler/coupon.rb +1 -1
- data/app/models/spree/shipment.rb +12 -16
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/package.rb +0 -1
- data/app/models/spree/stock_item.rb +2 -6
- data/app/models/spree/store.rb +2 -1
- data/app/models/spree/tax_rate.rb +1 -1
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +29 -0
- data/app/models/spree/wallet/default_payment_builder.rb +26 -0
- data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +46 -0
- data/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb +1 -1
- data/app/views/spree/shared/_base_mailer_footer.html.erb +1 -20
- data/app/views/spree/shared/_base_mailer_header.html.erb +1 -31
- data/config/initializers/spree_user.rb +1 -1
- data/config/locales/en.yml +58 -34
- data/db/migrate/20130414000512_update_name_fields_on_spree_credit_cards.rb +1 -1
- data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +15 -3
- data/db/migrate/20160527070401_rename_shipment_address_field.rb +7 -0
- data/db/migrate/20160616232103_remove_user_id_from_promotion_rules.rb +11 -0
- data/db/migrate/20160718205341_add_payment_id_index_to_spree_refunds.rb +5 -0
- data/db/migrate/20160718205859_add_reimbursement_id_index_to_spree_refunds.rb +5 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +3 -1
- data/lib/generators/spree/dummy/templates/rails/test.rb +4 -2
- data/lib/generators/spree/install/install_generator.rb +6 -16
- data/lib/spree/core/controller_helpers/auth.rb +1 -1
- data/lib/spree/core/controller_helpers/common.rb +1 -1
- data/lib/spree/core/controller_helpers/order.rb +2 -2
- data/lib/spree/core/current_store.rb +5 -1
- data/lib/spree/core/delegate_belongs_to.rb +1 -1
- data/lib/spree/core/routes.rb +6 -32
- data/lib/spree/core/search/base.rb +2 -2
- data/lib/spree/core/stock_configuration.rb +6 -0
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +2 -1
- data/lib/spree/i18n.rb +7 -0
- data/lib/spree/mailer_previews/carton_preview.rb +2 -1
- data/lib/spree/mailer_previews/order_preview.rb +8 -3
- data/lib/spree/mailer_previews/reimbursement_preview.rb +11 -0
- data/lib/spree/migrations.rb +13 -7
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +6 -1
- data/lib/spree/testing_support/common_rake.rb +3 -7
- data/lib/spree/testing_support/controller_requests.rb +8 -0
- data/lib/spree/testing_support/factories/order_factory.rb +30 -8
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +6 -0
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -0
- data/lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake +3 -1
- data/solidus_core.gemspec +3 -3
- data/spec/helpers/base_helper_spec.rb +18 -2
- data/spec/lib/i18n_spec.rb +4 -0
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +16 -4
- data/spec/lib/spree/core/controller_helpers/payment_parameters_spec.rb +75 -59
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +1 -1
- data/spec/lib/spree/core/importer/order_spec.rb +4 -2
- data/spec/lib/spree/core/stock_configuration_spec.rb +17 -0
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +195 -0
- data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +6 -0
- data/spec/lib/spree/core/testing_support/factories/reimbursement_factory_spec.rb +6 -0
- data/spec/lib/spree/migrations_spec.rb +3 -9
- data/spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb +1 -1
- data/spec/mailers/carton_mailer_spec.rb +1 -1
- data/spec/mailers/order_mailer_spec.rb +2 -2
- data/spec/mailers/reimbursement_mailer_spec.rb +1 -1
- data/spec/models/spree/address_spec.rb +22 -0
- data/spec/models/spree/adjustment_spec.rb +0 -10
- data/spec/models/spree/carton_spec.rb +1 -1
- data/spec/models/spree/country_spec.rb +9 -1
- data/spec/models/spree/gateway/bogus_spec.rb +1 -1
- data/spec/models/spree/item_adjustments_spec.rb +33 -0
- data/spec/models/spree/line_item_spec.rb +2 -21
- data/spec/models/spree/order/checkout_spec.rb +32 -45
- data/spec/models/spree/order/payment_spec.rb +1 -16
- data/spec/models/spree/order_cancellations_spec.rb +8 -3
- data/spec/models/spree/order_contents_spec.rb +48 -0
- data/spec/models/spree/order_merger_spec.rb +8 -5
- data/spec/models/spree/order_shipping_spec.rb +3 -4
- data/spec/models/spree/order_spec.rb +23 -59
- data/spec/models/spree/order_update_attributes_spec.rb +1 -5
- data/spec/models/spree/order_updater_spec.rb +39 -11
- data/spec/models/spree/payment_create_spec.rb +61 -0
- data/spec/models/spree/payment_method/store_credit_spec.rb +23 -10
- data/spec/models/spree/payment_spec.rb +17 -4
- data/spec/models/spree/product_spec.rb +1 -1
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +8 -13
- data/spec/models/spree/promotion/rules/product_spec.rb +33 -0
- data/spec/models/spree/promotion/rules/taxon_spec.rb +52 -8
- data/spec/models/spree/promotion_spec.rb +18 -12
- data/spec/models/spree/return_authorization_spec.rb +0 -16
- data/spec/models/spree/shipment_spec.rb +57 -36
- data/spec/models/spree/stock/coordinator_spec.rb +0 -5
- data/spec/models/spree/stock/package_spec.rb +0 -1
- data/spec/models/spree/stock_item_spec.rb +35 -145
- data/spec/models/spree/store_spec.rb +24 -10
- data/spec/models/spree/tax_rate_spec.rb +2 -2
- data/spec/models/spree/user_spec.rb +1 -1
- data/spec/models/spree/validations/db_maximum_length_validator_spec.rb +20 -12
- data/spec/support/concerns/working_factories.rb +4 -0
- metadata +30 -10
- data/config/routes.rb +0 -1
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
include ControllerHelpers::Pricing
|
9
9
|
|
10
10
|
included do
|
11
|
-
|
11
|
+
before_action :set_current_order
|
12
12
|
|
13
13
|
helper_method :current_order
|
14
14
|
helper_method :simple_current_order
|
@@ -59,7 +59,7 @@ module Spree
|
|
59
59
|
|
60
60
|
def set_current_order
|
61
61
|
if try_spree_current_user && current_order
|
62
|
-
try_spree_current_user.orders.incomplete.where('id != ?', current_order.id).each do |order|
|
62
|
+
try_spree_current_user.orders.by_store(current_store).incomplete.where('id != ?', current_order.id).each do |order|
|
63
63
|
current_order.merge!(order, try_spree_current_user)
|
64
64
|
end
|
65
65
|
end
|
@@ -31,7 +31,7 @@ module DelegateBelongsTo
|
|
31
31
|
# delegate_belongs_to :contact, [:defaults, :address, :fullname], :class_name => 'VCard'
|
32
32
|
##
|
33
33
|
def delegate_belongs_to(association, *attrs)
|
34
|
-
|
34
|
+
Spree::Deprecation.warn "delegate_belongs_to is deprecated. Instead use rails built in delegates.", caller
|
35
35
|
opts = attrs.extract_options!
|
36
36
|
initialize_association :belongs_to, association, opts
|
37
37
|
attrs = get_association_column_names(association) if attrs.empty?
|
data/lib/spree/core/routes.rb
CHANGED
@@ -2,44 +2,18 @@ module Spree
|
|
2
2
|
module Core
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
def self.add_routes(&block)
|
5
|
-
|
6
|
-
|
7
|
-
# Anything that causes the application's routes to be reloaded,
|
8
|
-
# will cause this method to be called more than once
|
9
|
-
# i.e. https://github.com/plataformatec/devise/blob/31971e69e6a1bcf6c7f01eaaa44f227c4af5d4d2/lib/devise/rails.rb#L14
|
10
|
-
# In the case of Devise, this *only* happens in the production env
|
11
|
-
# This coupled with Rails 4's insistence that routes are not drawn twice,
|
12
|
-
# poses quite a serious problem.
|
13
|
-
#
|
14
|
-
# This is mainly why this whole file exists in the first place.
|
15
|
-
#
|
16
|
-
# Thus we need to make sure that the routes aren't drawn twice.
|
17
|
-
unless @spree_routes.include?(block)
|
18
|
-
@spree_routes << block
|
19
|
-
end
|
5
|
+
Spree::Deprecation.warn "Spree::Core::Engine.add_routes is deprecated, use Spree::Core::Engine.routes.draw instead"
|
6
|
+
routes.draw(&block)
|
20
7
|
end
|
21
8
|
|
22
9
|
def self.append_routes(&block)
|
23
|
-
|
24
|
-
|
25
|
-
unless @append_routes.include?(block)
|
26
|
-
@append_routes << block
|
27
|
-
end
|
10
|
+
Spree::Deprecation.warn "Spree::Core::Engine.append_routes is deprecated, use Spree::Core::Engine.routes.append instead"
|
11
|
+
routes.append(&block)
|
28
12
|
end
|
29
13
|
|
30
14
|
def self.draw_routes(&block)
|
31
|
-
|
32
|
-
|
33
|
-
eval_block(block) if block_given?
|
34
|
-
@spree_routes.each { |r| eval_block(&r) }
|
35
|
-
@append_routes.each { |r| eval_block(&r) }
|
36
|
-
# # Clear out routes so that they aren't drawn twice.
|
37
|
-
@spree_routes = []
|
38
|
-
@append_routes = []
|
39
|
-
end
|
40
|
-
|
41
|
-
def eval_block(&block)
|
42
|
-
Spree::Core::Engine.routes.send :eval_block, block
|
15
|
+
Spree::Deprecation.warn "Spree::Core::Engine.draw_routes is deprecated, use Spree::Core::Engine.routes.draw instead"
|
16
|
+
routes.draw(&block)
|
43
17
|
end
|
44
18
|
end
|
45
19
|
end
|
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
curr_page = page || 1
|
31
31
|
|
32
32
|
unless Spree::Config.show_products_without_price
|
33
|
-
@products = @products.joins(:prices).merge(Spree::Price.where(pricing_options.search_arguments)).
|
33
|
+
@products = @products.joins(:prices).merge(Spree::Price.where(pricing_options.search_arguments)).distinct
|
34
34
|
end
|
35
35
|
@products = @products.page(curr_page).per(per_page)
|
36
36
|
end
|
@@ -46,7 +46,7 @@ module Spree
|
|
46
46
|
protected
|
47
47
|
|
48
48
|
def get_base_scope
|
49
|
-
base_scope = Spree::Product.available
|
49
|
+
base_scope = Spree::Product.display_includes.available
|
50
50
|
base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
|
51
51
|
base_scope = get_products_conditions_for(base_scope, keywords)
|
52
52
|
base_scope = add_search_scopes(base_scope)
|
@@ -1,8 +1,14 @@
|
|
1
1
|
module Spree
|
2
2
|
module Core
|
3
3
|
class StockConfiguration
|
4
|
+
attr_writer :coordinator_class
|
4
5
|
attr_writer :estimator_class
|
5
6
|
|
7
|
+
def coordinator_class
|
8
|
+
@coordinator_class ||= '::Spree::Stock::Coordinator'
|
9
|
+
@coordinator_class.constantize
|
10
|
+
end
|
11
|
+
|
6
12
|
def estimator_class
|
7
13
|
@estimator_class ||= '::Spree::Stock::Estimator'
|
8
14
|
@estimator_class.constantize
|
data/lib/spree/core/version.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Spree
|
2
2
|
def self.version
|
3
|
-
|
3
|
+
Spree::Deprecation.warn("Spree.version does not work and will be removed from solidus. Use Spree.solidus_version instead to determine the solidus version")
|
4
4
|
"2.4.6.beta"
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.solidus_version
|
8
|
-
"1.
|
8
|
+
"1.4.0.beta1"
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.solidus_gem_version
|
data/lib/spree/core.rb
CHANGED
@@ -49,7 +49,7 @@ module Spree
|
|
49
49
|
def self.const_missing(name)
|
50
50
|
case name
|
51
51
|
when :AdjustmentSource, :CalculatedAdjustments, :UserAddress, :UserPaymentSource
|
52
|
-
|
52
|
+
Spree::Deprecation.warn("Spree::Core::#{name} is deprecated! Use Spree::#{name} instead.", caller)
|
53
53
|
Spree.const_get(name)
|
54
54
|
else
|
55
55
|
super
|
@@ -99,5 +99,6 @@ require 'spree/deprecation'
|
|
99
99
|
|
100
100
|
require 'spree/mailer_previews/order_preview'
|
101
101
|
require 'spree/mailer_previews/carton_preview'
|
102
|
+
require 'spree/mailer_previews/reimbursement_preview'
|
102
103
|
|
103
104
|
require 'spree/core/price_migrator'
|
data/lib/spree/i18n.rb
CHANGED
@@ -6,9 +6,16 @@ module Spree
|
|
6
6
|
include ActionView::Helpers::TranslationHelper
|
7
7
|
end
|
8
8
|
|
9
|
+
# This value is used as a count for the pluralization helpers related to I18n
|
10
|
+
# ex: Spree::Order.model_name.human(count: Spree::I18N_GENERIC_PLURAL)
|
11
|
+
# Related to Solidus issue #1164, this is needed to avoid problems with
|
12
|
+
# some pluralization calculators
|
13
|
+
I18N_GENERIC_PLURAL = 2.1
|
14
|
+
|
9
15
|
class << self
|
10
16
|
# Add spree namespace and delegate to Rails TranslationHelper for some nice
|
11
17
|
# extra functionality. e.g return reasonable strings for missing translations
|
18
|
+
|
12
19
|
def translate(key, options = {})
|
13
20
|
options[:scope] = [:spree, *options[:scope]]
|
14
21
|
TranslationHelperWrapper.new.translate(key, options)
|
@@ -2,7 +2,8 @@ module Spree
|
|
2
2
|
class MailerPreviews
|
3
3
|
class CartonPreview < ActionMailer::Preview
|
4
4
|
def shipped
|
5
|
-
carton = Carton.
|
5
|
+
carton = Carton.joins(:orders).last
|
6
|
+
raise "Your database needs at one shipped order with a carton to render this preview" unless carton
|
6
7
|
Spree::Config.carton_shipped_email_class.shipped_email(order: carton.orders.first, carton: carton)
|
7
8
|
end
|
8
9
|
end
|
@@ -2,15 +2,20 @@ module Spree
|
|
2
2
|
class MailerPreviews
|
3
3
|
class OrderPreview < ActionMailer::Preview
|
4
4
|
def confirm
|
5
|
-
|
5
|
+
order = Order.complete.last
|
6
|
+
raise "Your database needs at least one completed order to render this preview" unless order
|
7
|
+
OrderMailer.confirm_email(order)
|
6
8
|
end
|
7
9
|
|
8
10
|
def cancel
|
9
|
-
|
11
|
+
order = Order.with_state(:canceled).last
|
12
|
+
raise "Your database needs at least one cancelled order to render this preview" unless order
|
13
|
+
OrderMailer.cancel_email(order)
|
10
14
|
end
|
11
15
|
|
12
16
|
def inventory_cancellation
|
13
|
-
order = Order.
|
17
|
+
order = Spree::Order.joins(:inventory_units).merge(Spree::InventoryUnit.canceled).last
|
18
|
+
raise "Your database needs at least one order with a canceled inventory unit to render this preview" unless order
|
14
19
|
OrderMailer.inventory_cancellation_email(order, [order.inventory_units.first])
|
15
20
|
end
|
16
21
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Spree
|
2
|
+
class MailerPreviews
|
3
|
+
class ReimbursementPreview < ActionMailer::Preview
|
4
|
+
def reimbursement
|
5
|
+
reimbursement = Reimbursement.last
|
6
|
+
raise "Your database needs at least one Reimbursement to render this preview" unless reimbursement
|
7
|
+
ReimbursementMailer.reimbursement_email(reimbursement)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/spree/migrations.rb
CHANGED
@@ -22,13 +22,6 @@ module Spree
|
|
22
22
|
# engine name on the file name
|
23
23
|
def check
|
24
24
|
if File.directory?(app_dir)
|
25
|
-
engine_in_app = app_migrations.map do |file_name|
|
26
|
-
name, engine = file_name.split(".", 2)
|
27
|
-
next unless match_engine?(engine)
|
28
|
-
name
|
29
|
-
end.compact
|
30
|
-
|
31
|
-
missing_migrations = engine_migrations.sort - engine_in_app.sort
|
32
25
|
unless missing_migrations.empty?
|
33
26
|
puts "[#{engine_name.capitalize} WARNING] Missing migrations."
|
34
27
|
missing_migrations.each do |migration|
|
@@ -40,6 +33,19 @@ module Spree
|
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
36
|
+
def missing_migrations
|
37
|
+
@missing_migrations ||=
|
38
|
+
begin
|
39
|
+
engine_in_app = app_migrations.map do |file_name|
|
40
|
+
name, engine = file_name.split(".", 2)
|
41
|
+
next unless match_engine?(engine)
|
42
|
+
name
|
43
|
+
end.compact
|
44
|
+
|
45
|
+
engine_migrations.sort - engine_in_app.sort
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
43
49
|
private
|
44
50
|
|
45
51
|
def engine_migrations
|
@@ -45,7 +45,7 @@ module Spree
|
|
45
45
|
@@address_book_attributes = address_attributes + [:default]
|
46
46
|
|
47
47
|
@@checkout_attributes = [
|
48
|
-
:coupon_code, :email, :
|
48
|
+
:coupon_code, :email, :special_instructions, :use_billing
|
49
49
|
]
|
50
50
|
|
51
51
|
@@credit_card_update_attributes = [
|
@@ -26,11 +26,16 @@ module CapybaraExt
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def select2_search(value, options)
|
29
|
+
options = {
|
30
|
+
search: value, # by default search for the value
|
31
|
+
select: true
|
32
|
+
}.merge(options)
|
29
33
|
label = find_label_by_text(options[:from])
|
30
34
|
within label.first(:xpath, ".//..") do
|
31
35
|
options[:from] = "##{find('.select2-container')['id']}"
|
32
36
|
end
|
33
|
-
|
37
|
+
select2_search_without_selection(options[:search], from: options[:from])
|
38
|
+
select_select2_result(value) if options[:select]
|
34
39
|
end
|
35
40
|
|
36
41
|
def select2_search_without_selection(value, options)
|
@@ -17,24 +17,20 @@ namespace :common do
|
|
17
17
|
|
18
18
|
puts "Setting up dummy database..."
|
19
19
|
|
20
|
-
|
21
|
-
sh "bundle exec rake db:drop db:create db:migrate"
|
22
|
-
end
|
20
|
+
sh "bundle exec rake db:migrate VERBOSE=false"
|
23
21
|
|
24
22
|
begin
|
25
23
|
require "generators/#{ENV['LIB_NAME']}/install/install_generator"
|
26
24
|
puts 'Running extension installation generator...'
|
27
25
|
"#{ENV['LIB_NAME'].camelize}::Generators::InstallGenerator".constantize.start(["--auto-run-migrations"])
|
28
26
|
rescue LoadError
|
29
|
-
|
27
|
+
# No extension generator to run
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
task :seed do |_t, _args|
|
34
32
|
puts "Seeding ..."
|
35
33
|
|
36
|
-
|
37
|
-
sh "bundle exec rake db:seed RAILS_ENV=test"
|
38
|
-
end
|
34
|
+
sh "bundle exec rake db:seed RAILS_ENV=test"
|
39
35
|
end
|
40
36
|
end
|
@@ -49,37 +49,45 @@ module Spree
|
|
49
49
|
def spree_get(action, parameters = nil, session = nil, flash = nil)
|
50
50
|
process_spree_action(action, parameters, session, flash, "GET")
|
51
51
|
end
|
52
|
+
deprecate spree_get: :get, deprecator: Spree::Deprecation
|
52
53
|
|
53
54
|
# Executes a request simulating POST HTTP method and set/volley the response
|
54
55
|
def spree_post(action, parameters = nil, session = nil, flash = nil)
|
55
56
|
process_spree_action(action, parameters, session, flash, "POST")
|
56
57
|
end
|
58
|
+
deprecate spree_post: :post, deprecator: Spree::Deprecation
|
57
59
|
|
58
60
|
# Executes a request simulating PUT HTTP method and set/volley the response
|
59
61
|
def spree_put(action, parameters = nil, session = nil, flash = nil)
|
60
62
|
process_spree_action(action, parameters, session, flash, "PUT")
|
61
63
|
end
|
64
|
+
deprecate spree_put: :put, deprecator: Spree::Deprecation
|
62
65
|
|
63
66
|
# Executes a request simulating DELETE HTTP method and set/volley the response
|
64
67
|
def spree_delete(action, parameters = nil, session = nil, flash = nil)
|
65
68
|
process_spree_action(action, parameters, session, flash, "DELETE")
|
66
69
|
end
|
70
|
+
deprecate spree_delete: :delete, deprecator: Spree::Deprecation
|
67
71
|
|
68
72
|
def spree_xhr_get(action, parameters = nil, session = nil, flash = nil)
|
69
73
|
process_spree_xhr_action(action, parameters, session, flash, :get)
|
70
74
|
end
|
75
|
+
deprecate spree_xhr_get: :get, deprecator: Spree::Deprecation
|
71
76
|
|
72
77
|
def spree_xhr_post(action, parameters = nil, session = nil, flash = nil)
|
73
78
|
process_spree_xhr_action(action, parameters, session, flash, :post)
|
74
79
|
end
|
80
|
+
deprecate spree_xhr_post: :post, deprecator: Spree::Deprecation
|
75
81
|
|
76
82
|
def spree_xhr_put(action, parameters = nil, session = nil, flash = nil)
|
77
83
|
process_spree_xhr_action(action, parameters, session, flash, :put)
|
78
84
|
end
|
85
|
+
deprecate spree_xhr_put: :put, deprecator: Spree::Deprecation
|
79
86
|
|
80
87
|
def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
|
81
88
|
process_spree_xhr_action(action, parameters, session, flash, :delete)
|
82
89
|
end
|
90
|
+
deprecate spree_xhr_delete: :delete, deprecator: Spree::Deprecation
|
83
91
|
|
84
92
|
private
|
85
93
|
|
@@ -46,12 +46,31 @@ FactoryGirl.define do
|
|
46
46
|
end
|
47
47
|
order.line_items.reload
|
48
48
|
|
49
|
-
create(:shipment, order: order, cost: evaluator.shipment_cost, shipping_method: evaluator.shipping_method,
|
49
|
+
create(:shipment, order: order, cost: evaluator.shipment_cost, shipping_method: evaluator.shipping_method, stock_location: evaluator.stock_location)
|
50
50
|
order.shipments.reload
|
51
51
|
|
52
52
|
order.update!
|
53
53
|
end
|
54
54
|
|
55
|
+
factory :order_ready_to_complete do
|
56
|
+
state 'confirm'
|
57
|
+
payment_state 'checkout'
|
58
|
+
|
59
|
+
transient do
|
60
|
+
payment_type :credit_card_payment
|
61
|
+
end
|
62
|
+
|
63
|
+
after(:create) do |order, evaluator|
|
64
|
+
create(evaluator.payment_type, {
|
65
|
+
amount: order.total,
|
66
|
+
order: order,
|
67
|
+
state: order.payment_state
|
68
|
+
})
|
69
|
+
|
70
|
+
order.payments.reload
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
55
74
|
factory :completed_order_with_totals do
|
56
75
|
state 'complete'
|
57
76
|
|
@@ -94,7 +113,7 @@ FactoryGirl.define do
|
|
94
113
|
next unless evaluator.with_cartons
|
95
114
|
Spree::Carton.create!(
|
96
115
|
stock_location: shipment.stock_location,
|
97
|
-
address:
|
116
|
+
address: order.ship_address,
|
98
117
|
shipping_method: shipment.shipping_method,
|
99
118
|
inventory_units: shipment.inventory_units,
|
100
119
|
shipped_at: Time.current
|
@@ -108,19 +127,22 @@ FactoryGirl.define do
|
|
108
127
|
end
|
109
128
|
end
|
110
129
|
|
111
|
-
factory :completed_order_with_promotion, parent: :
|
130
|
+
factory :completed_order_with_promotion, parent: :order_with_line_items, class: "Spree::Order" do
|
112
131
|
transient do
|
113
132
|
promotion nil
|
114
|
-
promotion_code nil
|
115
133
|
end
|
116
134
|
|
117
135
|
after(:create) do |order, evaluator|
|
118
136
|
promotion = evaluator.promotion || create(:promotion, code: "test")
|
119
|
-
promotion_code =
|
137
|
+
promotion_code = promotion.codes.first || create(:promotion_code, promotion: promotion)
|
120
138
|
|
121
|
-
promotion.
|
122
|
-
|
123
|
-
|
139
|
+
promotion.activate(order: order, promotion_code: promotion_code)
|
140
|
+
order.order_promotions.create!(promotion: promotion, promotion_code: promotion_code)
|
141
|
+
|
142
|
+
# Complete the order after the promotion has been activated
|
143
|
+
order.refresh_shipment_rates
|
144
|
+
order.update_column(:completed_at, Time.current)
|
145
|
+
order.update_column(:state, "complete")
|
124
146
|
end
|
125
147
|
end
|
126
148
|
end
|
@@ -6,7 +6,7 @@ require 'spree/testing_support/factories/store_credit_factory'
|
|
6
6
|
FactoryGirl.define do
|
7
7
|
factory :payment, aliases: [:credit_card_payment], class: Spree::Payment do
|
8
8
|
association(:payment_method, factory: :credit_card_payment_method)
|
9
|
-
|
9
|
+
source { create(:credit_card, user: order.user) }
|
10
10
|
order
|
11
11
|
state 'checkout'
|
12
12
|
response_code '12345'
|
@@ -32,6 +32,12 @@ FactoryGirl.define do
|
|
32
32
|
after :create do |product|
|
33
33
|
product.master.stock_items.first.adjust_count_on_hand(10)
|
34
34
|
end
|
35
|
+
|
36
|
+
factory :product_not_backorderable do
|
37
|
+
after :create do |product|
|
38
|
+
product.master.stock_items.first.update_column(:backorderable, false)
|
39
|
+
end
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
factory :product_with_option_types do
|
@@ -49,13 +49,15 @@ namespace 'spree:migrations:copy_shipped_shipments_to_cartons' do
|
|
49
49
|
#{db_concat("'C'", 'spree_shipments.number')}, -- number
|
50
50
|
spree_shipments.id, -- imported_from_shipment_id
|
51
51
|
spree_shipments.stock_location_id,
|
52
|
-
|
52
|
+
spree_orders.ship_address_id,
|
53
53
|
spree_shipping_rates.shipping_method_id,
|
54
54
|
spree_shipments.tracking,
|
55
55
|
spree_shipments.shipped_at,
|
56
56
|
'#{Time.current.to_s(:db)}', -- created_at
|
57
57
|
'#{Time.current.to_s(:db)}' -- updated_at
|
58
58
|
from spree_shipments
|
59
|
+
left join spree_orders
|
60
|
+
on spree_orders.id = spree_shipments.order_id
|
59
61
|
left join spree_shipping_rates
|
60
62
|
on spree_shipping_rates.shipment_id = spree_shipments.id
|
61
63
|
and spree_shipping_rates.selected = #{Spree::Carton.connection.quoted_true}
|
data/solidus_core.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency 'activemerchant', '~> 1.48'
|
23
23
|
s.add_dependency 'acts_as_list', '~> 0.3'
|
24
|
-
s.add_dependency 'awesome_nested_set', '~> 3.0.1'
|
24
|
+
s.add_dependency 'awesome_nested_set', '~> 3.0', '>= 3.0.1'
|
25
25
|
s.add_dependency 'carmen', '~> 1.0.0'
|
26
26
|
s.add_dependency 'cancancan', '~> 1.10'
|
27
27
|
s.add_dependency 'ffaker', '~> 2.0'
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency 'highline', '~> 1.6.18' # Necessary for the install generator
|
30
30
|
s.add_dependency 'kaminari', '~> 0.15', '>= 0.15.1'
|
31
31
|
s.add_dependency 'monetize', '~> 1.1'
|
32
|
-
s.add_dependency 'paperclip', '~> 4.2
|
32
|
+
s.add_dependency 'paperclip', '~> 4.2'
|
33
33
|
s.add_dependency 'paranoia', '~> 2.1', '>= 2.1.4'
|
34
34
|
s.add_dependency 'premailer-rails'
|
35
35
|
s.add_dependency 'rails', '~> 4.2.5'
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.add_dependency 'responders'
|
38
38
|
s.add_dependency 'state_machines-activerecord', '~> 0.2'
|
39
39
|
s.add_dependency 'stringex', '~> 1.5.1'
|
40
|
-
s.add_dependency 'truncate_html', '0.9.2'
|
40
|
+
s.add_dependency 'truncate_html', '~> 0.9', '>= 0.9.2'
|
41
41
|
s.add_dependency 'twitter_cldr', '~> 3.0'
|
42
42
|
|
43
43
|
s.add_development_dependency 'email_spec', '~> 1.6'
|
@@ -60,7 +60,7 @@ describe Spree::BaseHelper, type: :helper do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should not raise errors when style exists" do
|
63
|
-
|
63
|
+
Spree::Deprecation.silence do
|
64
64
|
very_strange_image(product)
|
65
65
|
end
|
66
66
|
end
|
@@ -152,7 +152,7 @@ describe Spree::BaseHelper, type: :helper do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should not raise errors when helper method called" do
|
155
|
-
|
155
|
+
Spree::Deprecation.silence do
|
156
156
|
foobar_image(product)
|
157
157
|
end
|
158
158
|
end
|
@@ -167,4 +167,20 @@ describe Spree::BaseHelper, type: :helper do
|
|
167
167
|
expect(pretty_time(DateTime.new(2012, 5, 6, 13, 33))).to eq "May 06, 2012 1:33 PM"
|
168
168
|
end
|
169
169
|
end
|
170
|
+
|
171
|
+
context "plural_resource_name" do
|
172
|
+
let(:plural_config) { Spree::I18N_GENERIC_PLURAL }
|
173
|
+
let(:base_class) { Spree::Product }
|
174
|
+
|
175
|
+
subject { plural_resource_name(base_class) }
|
176
|
+
|
177
|
+
it "should use ActiveModel::Naming module to pluralize model names" do
|
178
|
+
expect(subject).to eq base_class.model_name.human(count: plural_config)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should use the Spree::I18N_GENERIC_PLURAL constant" do
|
182
|
+
expect(base_class.model_name).to receive(:human).with(hash_including(count: plural_config))
|
183
|
+
subject
|
184
|
+
end
|
185
|
+
end
|
170
186
|
end
|
data/spec/lib/i18n_spec.rb
CHANGED
@@ -40,6 +40,10 @@ describe "i18n" do
|
|
40
40
|
expect(Spree.t(:missing_entry)).to include("<span")
|
41
41
|
end
|
42
42
|
|
43
|
+
it "should have a Spree::I18N_GENERIC_PLURAL constant" do
|
44
|
+
expect(Spree::I18N_GENERIC_PLURAL).to eq 2.1
|
45
|
+
end
|
46
|
+
|
43
47
|
context "missed + unused translations" do
|
44
48
|
def key_with_locale(key)
|
45
49
|
"#{key} (#{I18n.locale})"
|
@@ -66,14 +66,26 @@ describe Spree::Core::ControllerHelpers::Order, type: :controller do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
describe '#set_current_order' do
|
69
|
-
let(:incomplete_order) { create(:order, user: user) }
|
69
|
+
let(:incomplete_order) { create(:order, store: incomplete_order_store, user: user) }
|
70
70
|
|
71
71
|
context 'when current order not equal to users incomplete orders' do
|
72
72
|
before { allow(controller).to receive_messages(current_order: order, last_incomplete_order: incomplete_order, cookies: double(signed: { guest_token: 'guest_token' })) }
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
context "an order from another store" do
|
75
|
+
let(:incomplete_order_store) { create(:store) }
|
76
|
+
|
77
|
+
it 'doesnt call Spree::Order#merge! method' do
|
78
|
+
expect(order).to_not receive(:merge!)
|
79
|
+
controller.set_current_order
|
80
|
+
end
|
81
|
+
end
|
82
|
+
context "an order from the same store" do
|
83
|
+
let(:incomplete_order_store) { store }
|
84
|
+
|
85
|
+
it 'calls Spree::Order#merge! method' do
|
86
|
+
expect(order).to receive(:merge!).with(incomplete_order, user)
|
87
|
+
controller.set_current_order
|
88
|
+
end
|
77
89
|
end
|
78
90
|
end
|
79
91
|
end
|