-
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2590 from luisramos0/spree2_mail_method_create
Spree 2 - MailMethod - CreateMailMethod is now MailConfiguration
- Loading branch information
Showing
5 changed files
with
67 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Configures Rails to use the specified mail configuration | ||
# by setting entries on the Spree Config | ||
# and initializing Spree:MailSettings that uses the Spree::Config. | ||
class MailConfiguration | ||
# @param entries [Hash] Spree Config entries | ||
def self.entries=(entries) | ||
entries.each do | name, value | | ||
Spree::Config[name] = value | ||
end | ||
apply_mail_settings | ||
end | ||
|
||
private | ||
|
||
def self.apply_mail_settings | ||
Spree::Core::MailSettings.init | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe MailConfiguration do | ||
describe 'entries=' do | ||
let(:mail_settings) { instance_double(Spree::Core::MailSettings) } | ||
let(:entries) do | ||
{ smtp_username: "smtp_username", mail_auth_type: "login" } | ||
end | ||
|
||
before do | ||
allow(Spree::Core::MailSettings).to receive(:init) { mail_settings } | ||
end | ||
|
||
# keeps spree_config unchanged | ||
around do |example| | ||
original_smtp_username = Spree::Config[:smtp_username] | ||
original_mail_auth_type = Spree::Config[:mail_auth_type] | ||
example.run | ||
Spree::Config[:smtp_username] = original_smtp_username | ||
Spree::Config[:mail_auth_type] = original_mail_auth_type | ||
end | ||
|
||
it 'sets config entries in the Spree Config' do | ||
described_class.entries= entries | ||
expect(Spree::Config[:smtp_username]).to eq("smtp_username") | ||
expect(Spree::Config[:mail_auth_type]).to eq("login") | ||
end | ||
|
||
it 'initializes the mail settings' do | ||
described_class.entries= entries | ||
expect(Spree::Core::MailSettings).to have_received(:init) | ||
end | ||
end | ||
end |