solidus_core 2.11.10 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -2
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/helpers/spree/products_helper.rb +2 -2
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +30 -11
- data/app/models/concerns/spree/active_storage_adapter.rb +1 -1
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/default_price.rb +39 -10
- data/app/models/concerns/spree/ransackable_attributes.rb +24 -4
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +10 -37
- data/app/models/concerns/spree/user_methods.rb +38 -13
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -186
- data/app/models/spree/adjustment.rb +7 -33
- data/app/models/spree/base.rb +0 -53
- data/app/models/spree/calculator/flat_fee.rb +21 -0
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -7
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/country.rb +2 -7
- data/app/models/spree/credit_card.rb +1 -28
- data/app/models/spree/customer_return.rb +5 -7
- data/app/models/spree/image/active_storage_attachment.rb +2 -7
- data/app/models/spree/image/paperclip_attachment.rb +2 -2
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +6 -49
- data/app/models/spree/log_entry.rb +74 -1
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_value.rb +10 -1
- data/app/models/spree/order/number_generator.rb +7 -1
- data/app/models/spree/order.rb +82 -170
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_contents.rb +2 -1
- data/app/models/spree/order_inventory.rb +1 -1
- data/app/models/spree/order_merger.rb +2 -2
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_shipping.rb +6 -9
- data/app/models/spree/order_taxation.rb +6 -4
- data/app/models/spree/order_updater.rb +17 -16
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment/processing.rb +58 -55
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +6 -7
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +8 -0
- data/app/models/spree/payment_method.rb +26 -110
- data/app/models/spree/price.rb +3 -3
- data/app/models/spree/product/scopes.rb +24 -33
- data/app/models/spree/product.rb +15 -42
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/actions/create_adjustment.rb +4 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -9
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +92 -0
- data/app/models/spree/promotion/rules/item_total.rb +50 -6
- data/app/models/spree/promotion/rules/product.rb +20 -8
- data/app/models/spree/promotion/rules/store.rb +4 -0
- data/app/models/spree/promotion/rules/taxon.rb +6 -15
- data/app/models/spree/promotion/rules/user.rb +4 -0
- data/app/models/spree/promotion.rb +39 -32
- data/app/models/spree/promotion_action.rb +6 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +11 -7
- data/app/models/spree/promotion_handler/cart.rb +26 -6
- data/app/models/spree/promotion_rule.rb +5 -0
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/refund.rb +8 -52
- data/app/models/spree/reimbursement.rb +5 -43
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +2 -5
- data/app/models/spree/return_item.rb +4 -24
- data/app/models/spree/shipment.rb +3 -56
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/shipping_rate_tax.rb +1 -1
- data/app/models/spree/state.rb +1 -5
- data/app/models/spree/stock/allocator/on_hand_first.rb +2 -2
- data/app/models/spree/stock/availability.rb +11 -3
- data/app/models/spree/stock/quantifier.rb +12 -8
- data/app/models/spree/stock/simple_coordinator.rb +8 -26
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +2 -8
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +14 -1
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/store_credit_prioritizer.rb +17 -0
- data/app/models/spree/tax/item_tax.rb +3 -2
- data/app/models/spree/tax/order_tax.rb +3 -1
- data/app/models/spree/tax/tax_helpers.rb +2 -2
- data/app/models/spree/tax/tax_location.rb +4 -7
- data/app/models/spree/tax_calculator/default.rb +31 -0
- data/app/models/spree/tax_calculator/shipping_rate.rb +2 -13
- data/app/models/spree/tax_rate.rb +9 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +2 -7
- data/app/models/spree/taxon/paperclip_attachment.rb +3 -8
- data/app/models/spree/taxon.rb +1 -12
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +34 -4
- data/app/models/spree/variant.rb +52 -66
- data/app/models/spree/zone.rb +1 -1
- data/app/subscribers/spree/mailer_subscriber.rb +4 -0
- data/app/subscribers/spree/order_mailer_subscriber.rb +35 -0
- data/config/i18n-tasks.yml +134 -0
- data/config/locales/en.yml +406 -263
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/db/migrate/20201127212108_add_type_before_removal_to_spree_payment_methods.rb +7 -0
- data/db/migrate/20210312061050_change_column_null_on_prices.rb +7 -0
- data/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb +20 -0
- data/db/migrate/20220805202442_add_level_to_spree_tax_rates.rb +5 -0
- data/db/migrate/20221123152807_add_shipping_category_to_spree_variants.rb +5 -0
- data/db/seeds.rb +4 -1
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +21 -0
- data/lib/generators/solidus/install/app_templates/authentication/devise.rb +16 -0
- data/lib/generators/solidus/install/app_templates/authentication/existing.rb +10 -0
- data/lib/generators/solidus/install/app_templates/authentication/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +54 -0
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +16 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +2 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +3 -0
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +13 -0
- data/lib/generators/solidus/install/app_templates/payment_method/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +10 -0
- data/lib/generators/solidus/install/install_generator.rb +247 -149
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +15 -60
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/backend/all.js +2 -2
- data/lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt +30 -0
- data/lib/generators/solidus/update/update_generator.rb +112 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +6 -4
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +2 -6
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +12 -9
- data/lib/generators/spree/dummy/templates/rails/application.rb.tt +0 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +81 -39
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +134 -64
- data/lib/spree/bus.rb +20 -0
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +10 -15
- data/lib/spree/core/controller_helpers/current_host.rb +5 -3
- data/lib/spree/core/controller_helpers/order.rb +12 -32
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/search.rb +1 -1
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +54 -50
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +1 -41
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +18 -35
- data/lib/spree/core/state_machines/order.rb +2 -2
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/stock_configuration.rb +18 -0
- data/lib/spree/core/validators/email.rb +5 -3
- data/lib/spree/core/version.rb +5 -1
- data/lib/spree/core/versioned_value.rb +75 -0
- data/lib/spree/core.rb +40 -11
- data/lib/spree/deprecation.rb +1 -1
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +7 -7
- data/lib/spree/event.rb +1 -32
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/migrations.rb +13 -11
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permission_sets/default_customer.rb +8 -1
- data/lib/spree/permitted_attributes.rb +17 -59
- data/lib/spree/preferences/configuration.rb +84 -0
- data/lib/spree/preferences/preferable.rb +13 -0
- data/lib/spree/preferences/preferable_class_methods.rb +37 -4
- data/lib/spree/preferences/preference_differentiator.rb +29 -0
- data/lib/spree/preferences/static_model_preferences.rb +25 -10
- data/lib/spree/rails_compatibility.rb +106 -0
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/bus_helpers.rb +101 -0
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/common_rake.rb +71 -23
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/database.yml +42 -22
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +47 -34
- data/lib/spree/testing_support/factories/address_factory.rb +9 -6
- data/lib/spree/testing_support/factories/calculator_factory.rb +3 -0
- data/lib/spree/testing_support/factories/country_factory.rb +1 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +8 -5
- data/lib/spree/testing_support/factories/product_factory.rb +4 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +28 -14
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/factories/state_factory.rb +8 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +4 -4
- data/lib/spree/testing_support/factories/user_factory.rb +6 -0
- data/lib/spree/testing_support/factory_bot.rb +2 -2
- data/lib/spree/testing_support/order_walkthrough.rb +6 -8
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support/silence_deprecations.rb +9 -0
- data/lib/tasks/colorado_delivery_fee.rake +28 -0
- data/lib/tasks/payment_method.rake +29 -0
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +18 -0
- data/lib/tasks/solidus/delete_prices_with_nil_amount.rake +8 -0
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +33 -0
- data/solidus_core.gemspec +14 -7
- metadata +127 -78
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/app/models/spree/tax/shipping_rate_taxer.rb +0 -24
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/frontend/all.js +0 -10
- data/lib/generators/solidus/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_address_names.rake +0 -158
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -26
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/upgrade.rake +0 -13
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spree/preferences/preference_differentiator'
|
4
|
+
require 'rails/generators'
|
5
|
+
|
6
|
+
module Solidus
|
7
|
+
# @private
|
8
|
+
class UpdateGenerator < ::Rails::Generators::Base
|
9
|
+
FROM = Spree.previous_solidus_minor_version
|
10
|
+
|
11
|
+
desc 'Generates a new initializer to preview the new defaults for current Solidus version'
|
12
|
+
|
13
|
+
source_root File.expand_path('templates', __dir__)
|
14
|
+
|
15
|
+
class_option :initializer_basename,
|
16
|
+
type: :string,
|
17
|
+
default: 'new_solidus_defaults',
|
18
|
+
banner: 'The name for the new initializer'
|
19
|
+
|
20
|
+
class_option :previous_version_prompt,
|
21
|
+
type: :boolean,
|
22
|
+
default: true,
|
23
|
+
banner: 'Prompt to warn about only previous version support'
|
24
|
+
|
25
|
+
class_option :from,
|
26
|
+
type: :string,
|
27
|
+
default: FROM,
|
28
|
+
banner: 'Solidus version from which you are upgrading'
|
29
|
+
|
30
|
+
class_option :to,
|
31
|
+
type: :string,
|
32
|
+
default: Spree.solidus_version,
|
33
|
+
hide: true
|
34
|
+
|
35
|
+
class_option :initializer_directory,
|
36
|
+
type: :string,
|
37
|
+
default: 'config/initializers/',
|
38
|
+
hide: true
|
39
|
+
|
40
|
+
def create_new_defaults_initializer
|
41
|
+
previous_version_prompt = options[:previous_version_prompt]
|
42
|
+
return if previous_version_prompt && !yes?(<<~MSG, :red)
|
43
|
+
The update process is only supported if you are coming from version #{FROM}. If this is not the case, please, skip it and update your application to use Solidus #{FROM} before retrying.
|
44
|
+
If you are confident you want to upgrade from a previous version, you must rerun the generator with the "--from={OLD_VERSION}" argument.
|
45
|
+
Are you sure you want to continue? (y/N)
|
46
|
+
MSG
|
47
|
+
|
48
|
+
from = options[:from]
|
49
|
+
to = options[:to]
|
50
|
+
@from = from
|
51
|
+
@core_changes = core_changes_template(from, to)
|
52
|
+
@frontend_changes = frontend_changes_template(from, to)
|
53
|
+
@backend_changes = backend_changes_template(from, to)
|
54
|
+
@api_changes = api_changes_template(from, to)
|
55
|
+
|
56
|
+
template 'config/initializers/new_solidus_defaults.rb.tt',
|
57
|
+
File.join(options[:initializer_directory], "#{options[:initializer_basename]}.rb")
|
58
|
+
end
|
59
|
+
|
60
|
+
def print_message
|
61
|
+
say <<~MSG
|
62
|
+
|
63
|
+
***********************************************************************
|
64
|
+
|
65
|
+
Other tasks may be needed to update to the new Solidus version. Please,
|
66
|
+
check https://github.com/solidusio/solidus/blob/v#{options[:to]}/CHANGELOG.md
|
67
|
+
for details.
|
68
|
+
|
69
|
+
Thanks for using Solidus!
|
70
|
+
|
71
|
+
***********************************************************************
|
72
|
+
|
73
|
+
MSG
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def core_changes_template(from, to)
|
79
|
+
changes_template_for(Spree::AppConfiguration, from, to)
|
80
|
+
end
|
81
|
+
|
82
|
+
def frontend_changes_template(from, to)
|
83
|
+
return '' unless defined?(Spree::Frontend::Engine)
|
84
|
+
|
85
|
+
changes_template_for(Spree::FrontendConfiguration, from, to)
|
86
|
+
end
|
87
|
+
|
88
|
+
def backend_changes_template(from, to)
|
89
|
+
return '' unless defined?(Spree::Backend::Engine)
|
90
|
+
|
91
|
+
changes_template_for(Spree::BackendConfiguration, from, to)
|
92
|
+
end
|
93
|
+
|
94
|
+
def api_changes_template(from, to)
|
95
|
+
return '' unless defined?(Spree::Api::Engine)
|
96
|
+
|
97
|
+
changes_template_for(Spree::ApiConfiguration, from, to)
|
98
|
+
end
|
99
|
+
|
100
|
+
def changes_template_for(klass, from, to)
|
101
|
+
changes = Spree::Preferences::PreferenceDifferentiator.new(klass).call(from: from, to: to)
|
102
|
+
return '# No changes' if changes.empty?
|
103
|
+
|
104
|
+
[
|
105
|
+
["config.load_defaults('#{from}')"] +
|
106
|
+
changes.map do |pref_key, change|
|
107
|
+
" # config.#{pref_key} = #{change[:to]}"
|
108
|
+
end.flatten
|
109
|
+
].join("\n")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -22,10 +22,12 @@ module Spree
|
|
22
22
|
migration_template 'migration.rb.tt', "db/migrate/add_spree_fields_to_custom_user_table.rb"
|
23
23
|
template 'authentication_helpers.rb.tt', "lib/spree/authentication_helpers.rb"
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
initializer 'solidus_authentication', <<~RUBY
|
26
|
+
Rails.application.config.to_prepare do
|
27
|
+
ApplicationController.include Spree::AuthenticationHelpers, Spree::CurrentUserHelpers
|
28
|
+
Spree::Api::BaseController.include Spree::CurrentUserHelpers if defined? Spree::Api
|
29
|
+
end
|
30
|
+
RUBY
|
29
31
|
|
30
32
|
gsub_file 'config/initializers/spree.rb', /Spree\.user_class.?=.?.+$/, %{Spree.user_class = "#{class_name}"}
|
31
33
|
end
|
@@ -9,7 +9,8 @@ module Spree
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def spree_current_user
|
12
|
-
|
12
|
+
# TODO: Replace this with your implementation for retrieving the current user
|
13
|
+
Spree.user_class.new
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -33,8 +34,3 @@ module Spree
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
36
|
-
|
37
|
-
ApplicationController.send :include, Spree::AuthenticationHelpers
|
38
|
-
ApplicationController.send :include, Spree::CurrentUserHelpers
|
39
|
-
|
40
|
-
Spree::Api::BaseController.send :include, Spree::CurrentUserHelpers
|
@@ -1,7 +1,11 @@
|
|
1
1
|
class AddSpreeFieldsToCustomUserTable < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
if table_exists?(<%= table_name.inspect %>)
|
4
|
+
add_column <%= table_name.inspect %>, :spree_api_key, :string, :limit => 48 unless column_exists?(<%= table_name.inspect %>, :spree_api_key)
|
5
|
+
add_column <%= table_name.inspect %>, :ship_address_id, :integer unless column_exists?(<%= table_name.inspect %>, :ship_address_id)
|
6
|
+
add_column <%= table_name.inspect %>, :bill_address_id, :integer unless column_exists?(<%= table_name.inspect %>, :bill_address_id)
|
7
|
+
add_column <%= table_name.inspect %>, :deleted_at, :datetime unless column_exists?(<%= table_name.inspect %>, :deleted_at)
|
8
|
+
add_index <%= table_name.inspect %>, :deleted_at unless column_exists?(<%= table_name.inspect %>, :deleted_at)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
@@ -43,7 +43,7 @@ module Spree
|
|
43
43
|
opts[:skip_test] = true
|
44
44
|
opts[:skip_yarn] = true
|
45
45
|
opts[:skip_bootsnap] = true
|
46
|
-
opts[:
|
46
|
+
opts[:skip_javascript] = true
|
47
47
|
|
48
48
|
puts "Generating dummy Rails application..."
|
49
49
|
invoke Rails::Generators::AppGenerator,
|
@@ -55,6 +55,7 @@ module Spree
|
|
55
55
|
@database = options[:database]
|
56
56
|
|
57
57
|
template "rails/database.yml", "#{dummy_path}/config/database.yml", force: true
|
58
|
+
template "rails/storage.yml", "#{dummy_path}/config/storage/test.yml", force: true
|
58
59
|
template "rails/boot.rb", "#{dummy_path}/config/boot.rb", force: true
|
59
60
|
template "rails/application.rb.tt", "#{dummy_path}/config/application.rb", force: true
|
60
61
|
template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true
|
@@ -95,13 +96,15 @@ module Spree
|
|
95
96
|
protected
|
96
97
|
|
97
98
|
def inject_require_for(requirement)
|
98
|
-
inject_into_file 'config/application.rb',
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
99
|
+
inject_into_file 'config/application.rb', (
|
100
|
+
<<~RUBY
|
101
|
+
begin
|
102
|
+
require '#{requirement}'
|
103
|
+
rescue LoadError
|
104
|
+
# #{requirement} is not available.
|
105
|
+
end
|
106
|
+
RUBY
|
107
|
+
), before: /require '#{@lib_name}'/, verbose: true
|
105
108
|
end
|
106
109
|
|
107
110
|
def dummy_path
|
@@ -117,7 +120,7 @@ end
|
|
117
120
|
dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
|
118
121
|
unless options[:pretend] || !File.exist?(dummy_application_path)
|
119
122
|
contents = File.read(dummy_application_path)
|
120
|
-
contents[(contents.index("module #{module_name}"))
|
123
|
+
contents[(contents.index("module #{module_name}"))..]
|
121
124
|
end
|
122
125
|
end
|
123
126
|
end
|
@@ -1,61 +1,105 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
1
|
+
<% db = case ENV['DB']
|
2
|
+
when 'mysql'
|
3
|
+
'mysql'
|
4
|
+
when 'postgres', 'postgresql'
|
5
|
+
'postgres'
|
6
|
+
when 'sqlite', '', nil
|
7
|
+
'sqlite'
|
8
|
+
else
|
9
|
+
raise "Invalid DB specified: #{ENV['DB']}"
|
10
|
+
end %>
|
11
|
+
<% db_host = case db
|
12
|
+
when 'mysql'
|
13
|
+
ENV['DB_MYSQL_HOST'] || ENV['DB_HOST']
|
14
|
+
when 'postgres'
|
15
|
+
ENV['DB_POSTGRES_HOST'] || ENV['DB_HOST']
|
16
|
+
else
|
17
|
+
ENV['DB_HOST']
|
18
|
+
end %>
|
19
|
+
<% db_username = ENV['DB_USERNAME'] %>
|
20
|
+
<% db_password = ENV['DB_PASSWORD'] %>
|
21
|
+
|
4
22
|
<% case ENV['DB']
|
5
|
-
when '
|
6
|
-
development:
|
7
|
-
adapter: sqlite3
|
8
|
-
database: db/solidus_development.sqlite3
|
9
|
-
test:
|
10
|
-
adapter: sqlite3
|
11
|
-
database: db/solidus_test.sqlite3
|
12
|
-
timeout: 10000
|
13
|
-
production:
|
14
|
-
adapter: sqlite3
|
15
|
-
database: db/solidus_production.sqlite3
|
16
|
-
<% when 'mysql' %>
|
23
|
+
when 'mysql' %>
|
17
24
|
development:
|
18
25
|
adapter: mysql2
|
19
|
-
database: <%=
|
26
|
+
database: <%= options[:lib_name] %>_solidus_development
|
27
|
+
<% unless db_username.blank? %>
|
28
|
+
username: <%= db_username %>
|
29
|
+
<% end %>
|
30
|
+
<% unless db_password.blank? %>
|
31
|
+
password: <%= db_password %>
|
32
|
+
<% end %>
|
33
|
+
<% unless db_host.blank? %>
|
34
|
+
host: <%= db_host %>
|
35
|
+
<% end %>
|
20
36
|
encoding: utf8
|
21
37
|
test:
|
22
38
|
adapter: mysql2
|
23
|
-
|
24
|
-
|
25
|
-
|
39
|
+
database: <%= options[:lib_name] %>_solidus_test
|
40
|
+
<% unless db_username.blank? %>
|
41
|
+
username: <%= db_username %>
|
42
|
+
<% end %>
|
43
|
+
<% unless db_password.blank? %>
|
44
|
+
password: <%= db_password %>
|
45
|
+
<% end %>
|
46
|
+
<% unless db_host.blank? %>
|
47
|
+
host: <%= db_host %>
|
26
48
|
<% end %>
|
27
|
-
database: <%= database_prefix %><%= options[:lib_name] %>_solidus_test
|
28
49
|
encoding: utf8
|
29
50
|
production:
|
30
51
|
adapter: mysql2
|
31
|
-
database: <%=
|
52
|
+
database: <%= options[:lib_name] %>_solidus_production
|
53
|
+
<% unless db_username.blank? %>
|
54
|
+
username: <%= db_username %>
|
55
|
+
<% end %>
|
56
|
+
<% unless db_password.blank? %>
|
57
|
+
password: <%= db_password %>
|
58
|
+
<% end %>
|
59
|
+
<% unless db_host.blank? %>
|
60
|
+
host: <%= db_host %>
|
61
|
+
<% end %>
|
32
62
|
encoding: utf8
|
33
63
|
<% when 'postgres', 'postgresql' %>
|
34
|
-
<% db_host = ENV['DB_HOST'] -%>
|
35
64
|
development:
|
36
65
|
adapter: postgresql
|
37
|
-
database: <%=
|
38
|
-
|
39
|
-
|
40
|
-
<%
|
66
|
+
database: <%= options[:lib_name] %>_solidus_development
|
67
|
+
<% unless db_username.blank? %>
|
68
|
+
username: <%= db_username %>
|
69
|
+
<% end %>
|
70
|
+
<% unless db_password.blank? %>
|
71
|
+
password: <%= db_password %>
|
72
|
+
<% end %>
|
73
|
+
<% unless db_host.blank? %>
|
41
74
|
host: <%= db_host %>
|
42
|
-
<% end %>
|
75
|
+
<% end %>
|
76
|
+
min_messages: warning
|
43
77
|
test:
|
44
78
|
adapter: postgresql
|
45
|
-
database: <%=
|
46
|
-
|
47
|
-
|
48
|
-
<%
|
79
|
+
database: <%= options[:lib_name] %>_solidus_test
|
80
|
+
<% unless db_username.blank? %>
|
81
|
+
username: <%= db_username %>
|
82
|
+
<% end %>
|
83
|
+
<% unless db_password.blank? %>
|
84
|
+
password: <%= db_password %>
|
85
|
+
<% end %>
|
86
|
+
<% unless db_host.blank? %>
|
49
87
|
host: <%= db_host %>
|
50
|
-
<% end %>
|
88
|
+
<% end %>
|
89
|
+
min_messages: warning
|
51
90
|
production:
|
52
91
|
adapter: postgresql
|
53
|
-
database: <%=
|
54
|
-
|
55
|
-
|
56
|
-
<%
|
92
|
+
database: <%= options[:lib_name] %>_solidus_production
|
93
|
+
<% unless db_username.blank? %>
|
94
|
+
username: <%= db_username %>
|
95
|
+
<% end %>
|
96
|
+
<% unless db_password.blank? %>
|
97
|
+
password: <%= db_password %>
|
98
|
+
<% end %>
|
99
|
+
<% unless db_host.blank? %>
|
57
100
|
host: <%= db_host %>
|
58
|
-
<% end %>
|
101
|
+
<% end %>
|
102
|
+
min_messages: warning
|
59
103
|
<% when 'sqlite', '', nil %>
|
60
104
|
development:
|
61
105
|
adapter: sqlite3
|
@@ -66,6 +110,4 @@ test:
|
|
66
110
|
production:
|
67
111
|
adapter: sqlite3
|
68
112
|
database: db/solidus_production.sqlite3
|
69
|
-
<% else %>
|
70
|
-
<% raise "Invalid DB specified: #{ENV['DB']}" %>
|
71
113
|
<% end %>
|
@@ -29,6 +29,8 @@ Dummy::Application.configure do
|
|
29
29
|
config.action_mailer.delivery_method = :test
|
30
30
|
ActionMailer::Base.default from: "solidus@example.com"
|
31
31
|
|
32
|
+
config.active_storage.service = :test
|
33
|
+
|
32
34
|
# Raise on deprecation warnings
|
33
35
|
if ENV['SOLIDUS_RAISE_DEPRECATIONS'].present?
|
34
36
|
Spree::Deprecation.behavior = :raise
|