Skip to content

Commit

Permalink
finishing mailtrap setup on production
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasConnolly committed Aug 6, 2023
1 parent e5e66e9 commit 5617e8a
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 69 deletions.
8 changes: 8 additions & 0 deletions app/mailers/test_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class TestMailer < ApplicationMailer
def testing
mail(
to: "tom.connolly@comcast.net",
subject: "just a test",
)
end
end
2 changes: 0 additions & 2 deletions app/mailers/vnote_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class VnoteMailer < ApplicationMailer


def vnote_created(vnote)
@vnote = vnote
@url = vnote_url(@vnote)
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class User < ApplicationRecord

def maybe_add_stripe_id
return unless stripe_id.blank?

customer = Stripe::Customer.create(email:)
update(stripe_id: customer.id)
end
Expand Down
File renamed without changes.
11 changes: 5 additions & 6 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:user_name => ENV['MAILTRAP_USERNAME'],
:password => ENV['MAILTRAP_PASSWORD'],
:address => 'smtp.mailtrap.io',
:domain => 'smtp.mailtrap.io',
:port => '2525',
:authentication => :cram_md5
host: sandbox.smtp.mailtgrap.io
port: 25 or 465 or 587 or 2525
username: ENV['MAILTRAP_USERNAME'],
password: ENV['MAILTRAP_PASSWORD'],
auth: Optional (STARTTLS on all ports)
}


Expand Down
11 changes: 7 additions & 4 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
Rails.application.config.assets.version = "1.0"

# Add additional assets to the asset load path.
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font",
"lib", "assets", "stylesheets")
Rails.application.config.assets.paths << Rails.root.join(
"node_modules/bootstrap-icons/font",
"lib",
"assets",
"stylesheets",
)

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w( actiontext.css )

Rails.application.config.assets.precompile += %w(actiontext.css)
4 changes: 2 additions & 2 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if ENV["REDISCLOUD_URL"]
$redis = Redis.new(:url => ENV["REDISCLOUD_URL"])
$redis = Redis.new(url: ENV["REDISCLOUD_URL"])
else
redis_url = ENV["REDIS_URL"] || 'redis://localhost:6379/0'
redis_url = ENV["REDIS_URL"] || "redis://localhost:6379/0"
REDIS = Redis.new(url: redis_url)
end
59 changes: 59 additions & 0 deletions log/development.log
Original file line number Diff line number Diff line change
Expand Up @@ -4161,3 +4161,62 @@ Completed 200 OK in 12ms (Views: 7.6ms | ActiveRecord: 1.3ms | Allocations: 9911
Profile Load (0.4ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = $1 LIMIT $2 [["user_id", 798], ["LIMIT", 1]]
TRANSACTION (3.7ms) COMMIT
User Pluck (0.9ms) SELECT "users"."email" FROM "users" WHERE ( 'vestry' = ANY (roles))
TestMailer#test_mailer: processed outbound mail in 30.2ms
Rendering layout layouts/mailer.html.erb
Rendering test_mailer/testing.html.erb within layouts/mailer
Rendered test_mailer/testing.html.erb within layouts/mailer (Duration: 0.8ms | Allocations: 431)
Rendered layout layouts/mailer.html.erb (Duration: 1.2ms | Allocations: 712)
TestMailer#testing: processed outbound mail in 102.0ms
Delivered mail 64cfbd47b2418_2252f16942596e@G15.mail (42.7ms)
Date: Sun, 06 Aug 2023 11:33:27 -0400
From: tedwardconnolly@gmail.com
To: tom.connolly@comcast.net
Message-ID: <64cfbd47b2418_2252f16942596e@G15.mail>
Subject: just a test
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_64cfbd47b1a99_2252f169425865"
Content-Transfer-Encoding: 7bit


----==_mimepart_64cfbd47b1a99_2252f169425865
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit

test

A test from saint pauls developer.
----==_mimepart_64cfbd47b1a99_2252f169425865
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>




<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>test</title>





<p>A test from saint pauls developer.</p>




</body>
</html>

----==_mimepart_64cfbd47b1a99_2252f169425865--

3 changes: 3 additions & 0 deletions spec/mailers/previews/test_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Preview all emails at http://localhost:3000/rails/mailers/test_mailer
class TestMailerPreview < ActionMailer::Preview
end
5 changes: 5 additions & 0 deletions spec/mailers/test_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "rails_helper"

RSpec.describe(TestMailer, type: :mailer) do
pending "add some examples to (or delete) #{__FILE__}"
end
12 changes: 6 additions & 6 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
require "rspec/rails"
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
Expand All @@ -27,11 +27,11 @@
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip
abort(e.to_s.strip)
end
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.fixture_path = "#{Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
Expand Down
96 changes: 47 additions & 49 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
config.expect_with(:rspec) do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
Expand All @@ -30,7 +30,7 @@

# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
config.mock_with(:rspec) do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
Expand All @@ -44,51 +44,49 @@
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
# is tagged with `:focus`, all examples get run. RSpec also provides
# aliases for `it`, `describe`, and `context` that include `:focus`
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
config.filter_run_when_matching :focus
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
config.disable_monkey_patching!
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = "doc"
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# # This allows you to limit a spec run to individual examples or groups
# # you care about by tagging them with `:focus` metadata. When nothing
# # is tagged with `:focus`, all examples get run. RSpec also provides
# # aliases for `it`, `describe`, and `context` that include `:focus`
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
# config.filter_run_when_matching :focus
#
# # Allows RSpec to persist some state between runs in order to support
# # the `--only-failures` and `--next-failure` CLI options. We recommend
# # you configure your source control system to ignore this file.
# config.example_status_persistence_file_path = "spec/examples.txt"
#
# # Limits the available syntax to the non-monkey patched syntax that is
# # recommended. For more details, see:
# # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
# config.disable_monkey_patching!
#
# # Many RSpec users commonly either run the entire suite or an individual
# # file, and it's useful to allow more verbose output when running an
# # individual spec file.
# if config.files_to_run.one?
# # Use the documentation formatter for detailed output,
# # unless a formatter has already been configured
# # (e.g. via a command-line flag).
# config.default_formatter = "doc"
# end
#
# # Print the 10 slowest examples and example groups at the
# # end of the spec run, to help surface which specs are running
# # particularly slow.
# config.profile_examples = 10
#
# # Run specs in random order to surface order dependencies. If you find an
# # order dependency and want to debug it, you can fix the order by providing
# # the seed, which is printed after each run.
# # --seed 1234
# config.order = :random
#
# # Seed global randomization in this process using the `--seed` CLI option.
# # Setting this allows you to use `--seed` to deterministically reproduce
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed
end

0 comments on commit 5617e8a

Please sign in to comment.