Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate unused Spree::Config#mails_from #4712

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions api/spec/requests/spree/api/orders_spec.rb
Expand Up @@ -919,8 +919,6 @@ module Spree::Api

context "can cancel an order" do
before do
stub_spree_preferences(mails_from: "solidus@example.com")

order.completed_at = Time.current
order.state = 'complete'
order.shipment_state = 'ready'
Expand Down
Expand Up @@ -9,9 +9,6 @@ Spree.config do |config|
# Default currency for new sites
config.currency = "USD"

# from address for transactional emails
config.mails_from = "store@example.com"

# Uncomment to stop tracking inventory levels in the application
# config.track_inventory_levels = false

Expand Down
10 changes: 10 additions & 0 deletions core/lib/spree/app_configuration.rb
Expand Up @@ -193,7 +193,17 @@ class AppConfiguration < Preferences::Configuration

# @!attribute [rw] mails_from
# @return [String] Email address used as +From:+ field in transactional emails.
# @deprecated Spree::Store#mail_from_address is used instead
preference :mails_from, :string, default: 'solidus@example.com'
def mails_from=(value)
Spree::Deprecation.warn(<<~MSG) && preferences[:mail_from] = value
Solidus doesn't use `Spree::Config.mails_from` preference and it'll
removed on the next major release. Please, remove its definition in
`config/initializers/spree.rb`. Use the `Spree::Store#mail_from_address`
attribute for the default email address used as the 'From:' field in
transactional emails.
MSG
end

# @!attribute [rw] max_level_in_taxons_menu
# @return [Integer] maximum nesting level in taxons menu (default: +1+)
Expand Down
1 change: 0 additions & 1 deletion core/lib/spree/testing_support/dummy_app.rb
Expand Up @@ -138,7 +138,6 @@ class Application < ::Rails::Application
Spree.user_class = 'Spree::LegacyUser'
Spree.load_defaults(Spree.solidus_version)
Spree.config do |config|
config.mails_from = "store@example.com"
config.use_legacy_events = ENV['USE_LEGACY_EVENTS'].present?

if ENV['DISABLE_ACTIVE_STORAGE']
Expand Down
16 changes: 16 additions & 0 deletions core/spec/lib/spree/app_configuration_spec.rb
Expand Up @@ -161,4 +161,20 @@ class DummyClass; end;
it 'has default Event adapter' do
expect(prefs.events.adapter).to eq Spree::Event::Adapters::ActiveSupportNotifications
end

context 'mails_from' do
it 'is deprecated' do
expect(Spree::Deprecation).to receive(:warn).with(/Solidus doesn't use `Spree::Config.mails_from`/)

prefs.mails_from=('solidus@example.com')
end

it "still sets the value so that consumers aren't broken" do
Spree::Deprecation.silence do
prefs.mails_from=('solidus@example.com')
end

expect(prefs.mails_from).to eq('solidus@example.com')
end
end
end
10 changes: 5 additions & 5 deletions core/spec/lib/spree/core/testing_support/preferences_spec.rb
Expand Up @@ -14,15 +14,15 @@
describe '#with_unfrozen_spree_preference_store' do
it 'changes the original settings, but returns them to original values at exit' do
with_unfrozen_spree_preference_store do
Spree::Config.mails_from = 'override@example.com'
expect(Spree::Config.mails_from).to eq 'override@example.com'
expect(Spree::Config.preference_store[:mails_from]).to eq 'override@example.com'
Spree::Config.currency = 'EUR'
expect(Spree::Config.currency).to eq 'EUR'
expect(Spree::Config.preference_store[:currency]).to eq 'EUR'
end

# both the original frozen store and the unfrozen store are unaffected by changes above:
expect(Spree::Config.mails_from).to eq 'store@example.com'
expect(Spree::Config.currency).to eq 'USD'
with_unfrozen_spree_preference_store do
expect(Spree::Config.mails_from).to eq 'store@example.com'
expect(Spree::Config.currency).to eq 'USD'
end
end
end
Expand Down