-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overriding
rodauth.rails_url_options
This allows setting different URL options depending on the mailer's default URL options, for example: class RodauthMailer < ApplicationMailer # ... private def rodauth(account_id, &block) instance = RodauthApp.rodauth.allocate instance.rails_url_options.merge!(default_url_options) # ... end def default_url_options { host: "subdomain.example.com" } end end Resolves #306.
- Loading branch information
Showing
5 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
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 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 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 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 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 |
---|---|---|
@@ -1,20 +1,28 @@ | ||
require "test_helper" | ||
|
||
class InternalRequestTest < UnitTest | ||
test "inheriting URL options from config.action_mailer" do | ||
test "inheriting URL options from Action Mailer" do | ||
RodauthApp.rodauth.create_account(login: "[email protected]", password: "secret") | ||
email = ActionMailer::Base.deliveries.last | ||
assert_match %r{https://example\.com}, email.body.to_s | ||
end | ||
|
||
test "allowing overriding URL options" do | ||
test "overriding URL options directly" do | ||
rodauth = RodauthApp.rodauth.allocate | ||
rodauth.rails_url_options[:host] = "sub.example.com" | ||
|
||
assert_equal "https://sub.example.com", rodauth.base_url | ||
assert_equal "example.com", ActionMailer::Base.default_url_options[:host] | ||
end | ||
|
||
test "overriding URL options via rack env" do | ||
env = { "HTTP_HOST" => "foobar.com", "rack.url_scheme" => "http" } | ||
RodauthApp.rodauth.create_account(login: "[email protected]", password: "secret", env: env) | ||
email = ActionMailer::Base.deliveries.last | ||
assert_match %r{http://foobar\.com}, email.body.to_s | ||
end | ||
|
||
test "missing config.action_mailer.default_url_options" do | ||
test "missing Action Mailer default URL options" do | ||
Rails.configuration.action_mailer.stub(:default_url_options, nil) do | ||
assert_equal "/create-account", RodauthApp.rodauth.create_account_path | ||
assert_raises Rodauth::Rails::Error do | ||
|