Skip to content

Fix action mailer preview path setup. #1327

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

Merged
merged 2 commits into from
Mar 18, 2015
Merged

Conversation

cupakromer
Copy link
Member

This removes the unnecessary warning about a preview path set to a
location other than /spec/mailers/preview.

This does not force ActionMailer to load when the Railtie runs by
removing the defined? check. This is necessary because the
ActionMailer class only loads it's settings once, after it is first
loaded. If we load the class in our Railtie any custom settings declared
in a config block in an initializer will be ignored.

An improved spec suite for the different permutations of availability of
action mailer previews is included as well.

Resolve #1313, #1325

@cupakromer cupakromer force-pushed the update-action-mailer-railtie branch from 1e4b4df to 74b95f2 Compare March 2, 2015 04:40
mxie added a commit to thoughtbot/clearance that referenced this pull request Mar 2, 2015
ActionMailer is prematurely loaded in rspec-rails, causing some issues when
reading its config. There's a PR out for it:
rspec/rspec-rails#1327.

It was also recommended in rspec/rspec-rails#1313 that
we not refer to the app's config in initializers, but to refer to ActionMailer
itself to set the config.
This removes the unnecessary warning about a preview path set to a
location other than `/spec/mailers/preview`.

This does not force `ActionMailer` to load when the Railtie runs by
removing the `defined?` check. This is necessary because the
`ActionMailer` class only loads it's settings once, after it is first
loaded. If we load the class in our Railtie any custom settings declared
in a config block in an initializer will be ignored.

An improved spec suite for the different permutations of availability of
action mailer previews is included as well.
@cupakromer cupakromer force-pushed the update-action-mailer-railtie branch from 74b95f2 to f61100e Compare March 18, 2015 01:41
cupakromer added a commit that referenced this pull request Mar 18, 2015
@cupakromer cupakromer merged commit fba0669 into master Mar 18, 2015
@cupakromer cupakromer deleted the update-action-mailer-railtie branch March 18, 2015 01:49
@cupakromer cupakromer mentioned this pull request May 26, 2015
@olance
Copy link

olance commented Jun 3, 2015

Hi,

rspec-rails 3.2.2 is broken with Rails 3.2.21 (and probably Rails 3.x) as the test to configure preview_path default value seems to have been overly simplified.
preview_path is indeed not available in Rails 3.x (not even before Rails 4.1.8), however it will be added to ActionMailer configuration if Rails' version is less than '4.2' and in development mode.

Resulting in the following error at server start:

/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:438:in 'method_missing': undefined method 'preview_path=' for ActionMailer::Base:Class (NoMethodError)

I believe this PR is responsible for this break?

@tagliala
Copy link

tagliala commented Jun 3, 2015

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.1.0 -> 3.2.0 breaks url generation
3 participants