Skip to content

Commit

Permalink
Add test environment default mailer port configuration and update lin…
Browse files Browse the repository at this point in the history
…k helpers tests to consider an optional port in the URL
  • Loading branch information
juankuquintana committed May 21, 2023
1 parent daead31 commit 3fa574c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Metrics/BlockLength:
- lib/github_oauthable.rb
- app/models/concerns/**/*.rb
- config/routes.rb
- config/environments/development.rb

Metrics/ClassLength:
Max: 356 # TODO: Lower to 100
Expand Down
1 change: 1 addition & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = { host: Gemcutter::HOST,
port: "31337",
protocol: Gemcutter::PROTOCOL }

# Print deprecation notices to the stderr.
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/email_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def mails_count
def confirmation_link
refute_empty ActionMailer::Base.deliveries
body = last_email.parts[1].body.decoded.to_s
link = %r{http://localhost/email_confirmations([^";]*)}.match(body)
link = %r{http://localhost(?::\d+)?/email_confirmations([^";]*)}.match(body)
link[0]
end
end
2 changes: 1 addition & 1 deletion test/integration/password_reset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PasswordResetTest < SystemTest

def password_reset_link
body = ActionMailer::Base.deliveries.last.parts[1].body.decoded.to_s
link = %r{http://localhost/users([^";]*)}.match(body)
link = %r{http://localhost(?::\d+)?/users([^";]*)}.match(body)
link[0]
end

Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
Capybara.default_max_wait_time = 2
Capybara.app_host = "#{Gemcutter::PROTOCOL}://#{Gemcutter::HOST}"
Capybara.always_include_port = true
Capybara.server_port = 31_337
Capybara.server = :puma

GoodJob::Execution.delete_all
Expand Down

0 comments on commit 3fa574c

Please sign in to comment.