spree_core 2.4.10 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/app/assets/images/logo/spree_50.png +0 -0
- data/app/controllers/spree/base_controller.rb +1 -2
- data/app/helpers/spree/base_helper.rb +41 -131
- data/app/helpers/spree/products_helper.rb +1 -1
- data/app/models/concerns/spree/adjustment_source.rb +51 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +1 -0
- data/app/models/concerns/spree/display_money.rb +32 -0
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/number_generator.rb +39 -0
- data/app/models/concerns/spree/user_reporting.rb +3 -8
- data/app/models/spree/address.rb +0 -2
- data/app/models/spree/adjustable/adjustments_updater.rb +70 -0
- data/app/models/spree/adjustable/promotion_accumulator.rb +75 -0
- data/app/models/spree/adjustment.rb +17 -26
- data/app/models/spree/app_configuration.rb +4 -33
- data/app/models/spree/base.rb +0 -3
- data/app/models/spree/calculator.rb +0 -5
- data/app/models/spree/classification.rb +1 -1
- data/app/models/spree/country.rb +10 -4
- data/app/models/spree/credit_card.rb +14 -15
- data/app/models/spree/customer_return.rb +18 -25
- data/app/models/spree/gateway/bogus.rb +0 -4
- data/app/models/spree/line_item.rb +2 -5
- data/app/models/spree/option_type.rb +2 -4
- data/app/models/spree/option_value.rb +0 -2
- data/app/models/spree/order.rb +74 -134
- data/app/models/spree/order/checkout.rb +1 -1
- data/app/models/spree/order_contents.rb +9 -8
- data/app/models/spree/order_updater.rb +8 -1
- data/app/models/spree/payment.rb +13 -23
- data/app/models/spree/payment/gateway_options.rb +86 -0
- data/app/models/spree/payment/processing.rb +8 -39
- data/app/models/spree/payment_method.rb +3 -6
- data/app/models/spree/price.rb +2 -6
- data/app/models/spree/product.rb +27 -16
- data/app/models/spree/product_property.rb +1 -5
- data/app/models/spree/promotion.rb +7 -15
- data/app/models/spree/promotion/actions/create_adjustment.rb +4 -45
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +8 -63
- data/app/models/spree/promotion/actions/create_line_items.rb +3 -12
- data/app/models/spree/promotion/actions/free_shipping.rb +4 -24
- data/app/models/spree/promotion/rules/option_value.rb +49 -0
- data/app/models/spree/promotion_action.rb +6 -0
- data/app/models/spree/promotion_handler/cart.rb +14 -18
- data/app/models/spree/promotion_handler/coupon.rb +1 -1
- data/app/models/spree/promotion_rule.rb +0 -1
- data/app/models/spree/property.rb +0 -2
- data/app/models/spree/refund.rb +0 -15
- data/app/models/spree/reimbursement.rb +4 -4
- data/app/models/spree/reimbursement_type/credit.rb +1 -1
- data/app/models/spree/reimbursement_type/original_payment.rb +1 -1
- data/app/models/spree/return_authorization.rb +4 -11
- data/app/models/spree/return_item.rb +16 -11
- data/app/models/spree/return_item/eligibility_validator/default.rb +2 -0
- data/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb +16 -0
- data/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb +16 -0
- data/app/models/spree/shipment.rb +20 -31
- data/app/models/spree/shipment_handler.rb +1 -1
- data/app/models/spree/shipping_method.rb +12 -13
- data/app/models/spree/state.rb +7 -0
- data/app/models/spree/state_change.rb +1 -6
- data/app/models/spree/stock/availability_validator.rb +9 -10
- data/app/models/spree/stock/coordinator.rb +1 -1
- data/app/models/spree/stock/estimator.rb +6 -6
- data/app/models/spree/stock/quantifier.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -7
- data/app/models/spree/stock_location.rb +3 -1
- data/app/models/spree/stock_movement.rb +1 -8
- data/app/models/spree/stock_transfer.rb +11 -5
- data/app/models/spree/store.rb +2 -2
- data/app/models/spree/tax_rate.rb +30 -55
- data/app/models/spree/taxon.rb +8 -8
- data/app/models/spree/taxonomy.rb +8 -13
- data/app/models/spree/tracker.rb +1 -1
- data/app/models/spree/variant.rb +6 -15
- data/app/models/spree/zone.rb +43 -9
- data/config/initializers/user_class_extensions.rb +0 -12
- data/config/locales/en.yml +76 -85
- data/config/routes.rb +1 -1
- data/db/default/spree/countries.rb +23 -13
- data/db/default/spree/states.rb +24 -12
- data/db/default/spree/stores.rb +1 -1
- data/db/migrate/20120831092320_spree_one_two.rb +36 -36
- data/db/migrate/20120831092359_spree_promo_one_two.rb +1 -1
- data/db/migrate/20130211190146_create_spree_stock_items.rb +1 -1
- data/db/migrate/20130211191120_create_spree_stock_locations.rb +1 -1
- data/db/migrate/20130301162924_create_shipping_method_categories.rb +1 -1
- data/db/migrate/20130304162240_create_spree_shipping_rates.rb +1 -1
- data/db/migrate/20130305143310_create_stock_movements.rb +1 -1
- data/db/migrate/20130418125341_create_spree_stock_transfers.rb +1 -1
- data/db/migrate/20140205120320_create_spree_payment_capture_events.rb +1 -1
- data/db/migrate/20140309024355_create_spree_stores.rb +1 -1
- data/db/migrate/20140309033438_create_store_from_preferences.rb +0 -7
- data/db/migrate/20140625214618_create_spree_refunds.rb +1 -1
- data/db/migrate/20140702140656_create_spree_return_authorization_inventory_unit.rb +1 -1
- data/db/migrate/20140713140455_create_spree_return_authorization_reasons.rb +1 -1
- data/db/migrate/20140713140527_create_spree_refund_reasons.rb +1 -1
- data/db/migrate/20140715182625_create_spree_promotion_categories.rb +1 -1
- data/db/migrate/20140718133010_create_spree_customer_returns.rb +1 -1
- data/db/migrate/20140725131539_create_spree_reimbursements.rb +1 -1
- data/db/migrate/20140731150017_create_spree_reimbursement_types.rb +1 -1
- data/db/migrate/20140911173301_add_kind_to_zone.rb +11 -0
- data/db/migrate/20141215232040_remove_token_permissions_table.rb +6 -0
- data/db/migrate/20141215235502_remove_extra_products_slug_index.rb +5 -0
- data/db/migrate/20141217215630_update_product_slug_index.rb +6 -0
- data/db/migrate/20141218025915_rename_identifier_to_number_for_payment.rb +5 -0
- data/db/migrate/20150121022521_remove_environment_from_payment_method.rb +6 -0
- data/db/migrate/20150122145607_add_resellable_to_return_items.rb +5 -0
- data/db/migrate/20150122202432_add_code_to_spree_promotion_categories.rb +5 -0
- data/db/migrate/20150128032538_remove_environment_from_tracker.rb +6 -0
- data/db/migrate/20150128060325_remove_spree_configurations.rb +16 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +4 -0
- data/lib/spree/core.rb +2 -12
- data/lib/spree/core/controller_helpers/respond_with.rb +8 -18
- data/lib/spree/core/engine.rb +1 -7
- data/lib/spree/core/routes.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +10 -10
- data/lib/spree/permitted_attributes.rb +4 -8
- data/lib/spree/testing_support/authorization_helpers.rb +3 -5
- data/lib/spree/testing_support/capybara_ext.rb +3 -3
- data/lib/spree/testing_support/common_rake.rb +2 -2
- data/lib/spree/testing_support/factories/order_factory.rb +3 -13
- data/lib/spree/testing_support/factories/payment_method_factory.rb +0 -3
- data/lib/spree/testing_support/factories/prototype_factory.rb +5 -0
- data/lib/spree/testing_support/factories/return_item_factory.rb +5 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +3 -3
- data/lib/spree/testing_support/factories/tracker_factory.rb +0 -1
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_factory.rb +8 -0
- data/lib/tasks/core.rake +1 -1
- data/lib/tasks/email.rake +6 -3
- metadata +48 -35
- data/app/helpers/spree/checkout_helper.rb +0 -31
- data/app/helpers/spree/orders_helper.rb +0 -17
- data/app/helpers/spree/store_helper.rb +0 -16
- data/app/helpers/spree/taxons_helper.rb +0 -19
- data/app/models/concerns/spree/ransackable_attributes.rb +0 -19
- data/app/models/friendly_id/slug_decorator.rb +0 -3
- data/app/models/spree/billing_integration.rb +0 -21
- data/app/models/spree/configuration.rb +0 -5
- data/app/models/spree/item_adjustments.rb +0 -82
- data/app/models/spree/order_merger.rb +0 -65
- data/app/models/spree/order_populator.rb +0 -43
- data/app/models/spree/product_scope/scopes.rb +0 -47
- data/app/models/spree/variant/scopes.rb +0 -42
- data/db/migrate/20150515211137_fix_adjustment_order_id.rb +0 -70
- data/db/migrate/20150522181728_add_deleted_at_to_friendly_id_slugs.rb +0 -6
- data/db/migrate/20150707204155_enable_acts_as_paranoid_on_calculators.rb +0 -6
- data/lib/spree/core/controller_helpers/ssl.rb +0 -60
- data/lib/spree/core/permalinks.rb +0 -71
- data/lib/spree/testing_support/factories/configuration_factory.rb +0 -6
@@ -1,12 +1,5 @@
|
|
1
1
|
class CreateStoreFromPreferences < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
# workaround for spree_i18n and Store translations
|
4
|
-
Spree::Store.class_eval do
|
5
|
-
def self.translated?(name)
|
6
|
-
false
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
3
|
preference_store = Spree::Preferences::Store.instance
|
11
4
|
if store = Spree::Store.where(default: true).first
|
12
5
|
store.meta_description = preference_store.get('spree/app_configuration/default_meta_description') {}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddKindToZone < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :spree_zones, :kind, :string
|
4
|
+
add_index :spree_zones, :kind
|
5
|
+
|
6
|
+
Spree::Zone.find_each do |zone|
|
7
|
+
last_type = zone.members.where.not(zoneable_type: nil).pluck(:zoneable_type).last
|
8
|
+
zone.update_column :kind, last_type.demodulize.underscore if last_type
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class RemoveSpreeConfigurations < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
drop_table "spree_configurations"
|
4
|
+
end
|
5
|
+
|
6
|
+
def down
|
7
|
+
create_table "spree_configurations", force: true do |t|
|
8
|
+
t.string "name"
|
9
|
+
t.string "type", limit: 50
|
10
|
+
t.datetime "created_at"
|
11
|
+
t.datetime "updated_at"
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index "spree_configurations", ["name", "type"], name: "index_spree_configurations_on_name_and_type"
|
15
|
+
end
|
16
|
+
end
|
@@ -8,7 +8,7 @@ Dummy::Application.configure do
|
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
config.
|
11
|
+
config.serve_static_files = true
|
12
12
|
config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
14
|
# Show full error reports and disable caching
|
@@ -3,6 +3,10 @@
|
|
3
3
|
# Note: Initializing preferences available within the Admin will overwrite any changes that were made through the user interface when you restart.
|
4
4
|
# If you would like users to be able to update a setting with the Admin it should NOT be set here.
|
5
5
|
#
|
6
|
+
# Note: If a preference is set here it will be stored within the cache & database upon initialization.
|
7
|
+
# Just removing an entry from this initializer will not make the preference value go away.
|
8
|
+
# Instead you must either set a new value or remove entry, clear cache, and remove database entry.
|
9
|
+
#
|
6
10
|
# In order to initialize a setting do:
|
7
11
|
# config.setting_name = 'new value'
|
8
12
|
Spree.config do |config|
|
data/lib/spree/core.rb
CHANGED
@@ -12,7 +12,8 @@ require 'paperclip'
|
|
12
12
|
require 'paranoia'
|
13
13
|
require 'premailer/rails'
|
14
14
|
require 'ransack'
|
15
|
-
require '
|
15
|
+
require 'responders'
|
16
|
+
require 'state_machines-activerecord'
|
16
17
|
|
17
18
|
module Spree
|
18
19
|
|
@@ -64,22 +65,11 @@ require 'spree/permitted_attributes'
|
|
64
65
|
|
65
66
|
require 'spree/core/delegate_belongs_to'
|
66
67
|
require 'spree/core/importer'
|
67
|
-
require 'spree/core/permalinks'
|
68
68
|
require 'spree/core/product_duplicator'
|
69
69
|
require 'spree/core/controller_helpers/auth'
|
70
70
|
require 'spree/core/controller_helpers/common'
|
71
71
|
require 'spree/core/controller_helpers/order'
|
72
72
|
require 'spree/core/controller_helpers/respond_with'
|
73
73
|
require 'spree/core/controller_helpers/search'
|
74
|
-
require 'spree/core/controller_helpers/ssl'
|
75
74
|
require 'spree/core/controller_helpers/store'
|
76
75
|
require 'spree/core/controller_helpers/strong_parameters'
|
77
|
-
|
78
|
-
# Hack waiting on https://github.com/pluginaweek/state_machine/pull/275
|
79
|
-
module StateMachine
|
80
|
-
module Integrations
|
81
|
-
module ActiveModel
|
82
|
-
public :around_validation
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -3,26 +3,17 @@ require 'spree/responder'
|
|
3
3
|
module ActionController
|
4
4
|
class Base
|
5
5
|
def respond_with(*resources, &block)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if defined_response = collector.response and !Spree::BaseController.spree_responders.keys.include?(self.class.to_s.to_sym)
|
13
|
-
if action = options.delete(:action)
|
14
|
-
render :action => action
|
15
|
-
else
|
16
|
-
defined_response.call
|
17
|
-
end
|
6
|
+
if Spree::BaseController.spree_responders.keys.include?(self.class.to_s.to_sym)
|
7
|
+
# Checkout AS Array#extract_options! and original respond_with
|
8
|
+
# implementation for a better picture of this hack
|
9
|
+
if resources.last.is_a? Hash
|
10
|
+
resources.last.merge! action_name: action_name.to_sym
|
18
11
|
else
|
19
|
-
|
20
|
-
options.merge!(:action_name => action_name.to_sym)
|
21
|
-
# If responder is not specified then pass in Spree::Responder
|
22
|
-
responder = options.delete(:responder) || self.responder
|
23
|
-
responder.call(self, resources, options)
|
12
|
+
resources.push action_name: action_name.to_sym
|
24
13
|
end
|
25
14
|
end
|
15
|
+
|
16
|
+
super
|
26
17
|
end
|
27
18
|
end
|
28
19
|
end
|
@@ -36,7 +27,6 @@ module Spree
|
|
36
27
|
included do
|
37
28
|
cattr_accessor :spree_responders
|
38
29
|
self.spree_responders = {}
|
39
|
-
|
40
30
|
self.responder = Spree::Responder
|
41
31
|
end
|
42
32
|
|
data/lib/spree/core/engine.rb
CHANGED
@@ -78,6 +78,7 @@ module Spree
|
|
78
78
|
Spree::Promotion::Rules::UserLoggedIn,
|
79
79
|
Spree::Promotion::Rules::OneUsePerUser,
|
80
80
|
Spree::Promotion::Rules::Taxon,
|
81
|
+
Spree::Promotion::Rules::OptionValue
|
81
82
|
]
|
82
83
|
end
|
83
84
|
|
@@ -101,13 +102,6 @@ module Spree
|
|
101
102
|
initializer "spree.core.checking_migrations" do |app|
|
102
103
|
Migrations.new(config, engine_name).check
|
103
104
|
end
|
104
|
-
|
105
|
-
config.to_prepare do
|
106
|
-
# Load application's model / class decorators
|
107
|
-
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
|
108
|
-
Rails.configuration.cache_classes ? require(c) : load(c)
|
109
|
-
end
|
110
|
-
end
|
111
105
|
end
|
112
106
|
end
|
113
107
|
end
|
data/lib/spree/core/routes.rb
CHANGED
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/money.rb
CHANGED
@@ -4,22 +4,22 @@ require 'money'
|
|
4
4
|
|
5
5
|
module Spree
|
6
6
|
class Money
|
7
|
+
class <<self
|
8
|
+
attr_accessor :default_formatting_rules
|
9
|
+
end
|
10
|
+
self.default_formatting_rules = {
|
11
|
+
# Ruby money currently has this as false, which is wrong for the vast
|
12
|
+
# majority of locales.
|
13
|
+
sign_before_symbol: true
|
14
|
+
}
|
15
|
+
|
7
16
|
attr_reader :money
|
8
17
|
|
9
18
|
delegate :cents, to: :money
|
10
19
|
|
11
20
|
def initialize(amount, options={})
|
12
21
|
@money = Monetize.parse([amount, (options[:currency] || Spree::Config[:currency])].join)
|
13
|
-
@options =
|
14
|
-
@options[:with_currency] = Spree::Config[:display_currency]
|
15
|
-
@options[:symbol_position] = Spree::Config[:currency_symbol_position].to_sym
|
16
|
-
@options[:no_cents] = Spree::Config[:hide_cents]
|
17
|
-
@options[:decimal_mark] = Spree::Config[:currency_decimal_mark]
|
18
|
-
@options[:thousands_separator] = Spree::Config[:currency_thousands_separator]
|
19
|
-
@options[:sign_before_symbol] = Spree::Config[:currency_sign_before_symbol]
|
20
|
-
@options.merge!(options)
|
21
|
-
# Must be a symbol because the Money gem doesn't do the conversion
|
22
|
-
@options[:symbol_position] = @options[:symbol_position].to_sym
|
22
|
+
@options = Spree::Money.default_formatting_rules.merge(options)
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_s
|
@@ -40,7 +40,7 @@ module Spree
|
|
40
40
|
:coupon_code, :email, :shipping_method_id, :special_instructions, :use_billing
|
41
41
|
]
|
42
42
|
|
43
|
-
@@customer_return_attributes = [:stock_location_id, return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :acceptance_status, :exchange_variant_id]]
|
43
|
+
@@customer_return_attributes = [:stock_location_id, return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :acceptance_status, :exchange_variant_id, :resellable]]
|
44
44
|
|
45
45
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
46
46
|
|
@@ -61,9 +61,7 @@ module Spree
|
|
61
61
|
:meta_keywords, :price, :sku, :deleted_at, :prototype_id,
|
62
62
|
:option_values_hash, :weight, :height, :width, :depth,
|
63
63
|
:shipping_category_id, :tax_category_id,
|
64
|
-
:taxon_ids, :cost_currency, :cost_price
|
65
|
-
option_type_ids: []
|
66
|
-
]
|
64
|
+
:taxon_ids, :option_type_ids, :cost_currency, :cost_price]
|
67
65
|
|
68
66
|
@@property_attributes = [:name, :presentation]
|
69
67
|
|
@@ -103,10 +101,8 @@ module Spree
|
|
103
101
|
|
104
102
|
@@variant_attributes = [
|
105
103
|
:name, :presentation, :cost_price, :lock_version,
|
106
|
-
:position, :track_inventory,
|
104
|
+
:position, :option_value_ids, :track_inventory,
|
107
105
|
:product_id, :product, :option_values_attributes, :price,
|
108
|
-
:weight, :height, :width, :depth, :sku, :cost_currency,
|
109
|
-
options: [:name, :value], option_value_ids: []
|
110
|
-
]
|
106
|
+
:weight, :height, :width, :depth, :sku, :cost_currency, options: [ :name, :value ]]
|
111
107
|
end
|
112
108
|
end
|
@@ -37,9 +37,7 @@ module Spree
|
|
37
37
|
end
|
38
38
|
|
39
39
|
before do
|
40
|
-
|
41
|
-
with(hash_including(:spree_api_key)).
|
42
|
-
and_return(Spree.user_class.new)
|
40
|
+
allow_any_instance_of(Api::BaseController).to receive(:try_spree_current_user).and_return(Spree.user_class.new)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -58,6 +56,6 @@ module Spree
|
|
58
56
|
end
|
59
57
|
|
60
58
|
RSpec.configure do |config|
|
61
|
-
config.extend Spree::TestingSupport::AuthorizationHelpers::Controller, type
|
62
|
-
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type
|
59
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Controller, :type => :controller
|
60
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, :type => :feature
|
63
61
|
end
|
@@ -4,7 +4,7 @@ module CapybaraExt
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def click_icon(type)
|
7
|
-
find(".
|
7
|
+
find(".icon-#{type}").click
|
8
8
|
end
|
9
9
|
|
10
10
|
def eventually_fill_in(field, options={})
|
@@ -14,9 +14,9 @@ module CapybaraExt
|
|
14
14
|
|
15
15
|
def within_row(num, &block)
|
16
16
|
if RSpec.current_example.metadata[:js]
|
17
|
-
within("table.
|
17
|
+
within("table.table tbody tr:nth-child(#{num})", &block)
|
18
18
|
else
|
19
|
-
within(:xpath, all("table.
|
19
|
+
within(:xpath, all("table.table tbody tr")[num-1].path, &block)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|