Skip to content

Commit 09c0ce1

Browse files
committed
Improve comment
Provide a more accurate description of the behavior we are avoiding and why the current behavior is used. [ci skip]
1 parent adaf823 commit 09c0ce1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/rspec-rails.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ def config_default_preview_path(options)
5252
end
5353

5454
def supports_action_mailer_previews?(config)
55-
# If the action mailer railtie isn't loaded the config will not
56-
# respond.
55+
# These checks avoid loading `ActionMailer`. Using `defined?` has the
56+
# side-effect of the class getting loaded if it is available. This is
57+
# problematic because loading `ActionMailer::Base` will cause it to
58+
# read the config settings; this is the only time the config is read.
59+
# If the config is loaded now, any settings declared in a config block
60+
# in an initializer will be ignored.
5761
#
58-
# This string version check avoids loading the ActionMailer class, as
59-
# would happen using `defined?`. This is necessary because the
60-
# ActionMailer class only loads it's settings once, at load time. If we
61-
# load the class now any settings declared in a config block in an
62-
# initializer will be ignored.
63-
#
64-
# We cannot use `config.action_mailer.respond_to?(:preview_path)` here
65-
# as it will always return `true`.
62+
# If the action mailer railtie has not been loaded then `config` will
63+
# not respond to the method. However, we cannot use
64+
# `config.action_mailer.respond_to?(:preview_path)` here as it will
65+
# always return `true`.
6666
config.respond_to?(:action_mailer) && ::Rails::VERSION::STRING > '4.1'
6767
end
6868
end

0 commit comments

Comments
 (0)