Skip to content

Commit 37b8bc3

Browse files
committed
add maily, letter_opener and bullet
1 parent 7e0386e commit 37b8bc3

File tree

8 files changed

+92
-0
lines changed

8 files changed

+92
-0
lines changed

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ end
5656

5757
group :development do
5858
gem "hotwire-spark"
59+
gem "bullet"
60+
gem "letter_opener"
61+
gem "maily"
5962
# Use console on exceptions pages [https://github.com/rails/web-console]
6063
gem "web-console"
6164
end

Gemfile.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ GEM
8888
brakeman (7.0.0)
8989
racc
9090
builder (3.3.0)
91+
bullet (8.0.0)
92+
activesupport (>= 3.0.0)
93+
uniform_notifier (~> 1.11)
9194
capybara (3.40.0)
9295
addressable
9396
matrix
@@ -97,6 +100,8 @@ GEM
97100
rack-test (>= 0.6.3)
98101
regexp_parser (>= 1.5, < 3.0)
99102
xpath (~> 3.2)
103+
childprocess (5.1.0)
104+
logger (~> 1.5)
100105
concurrent-ruby (1.3.5)
101106
connection_pool (2.5.0)
102107
crass (1.0.6)
@@ -163,6 +168,12 @@ GEM
163168
listen (3.9.0)
164169
rb-fsevent (~> 0.10, >= 0.10.3)
165170
rb-inotify (~> 0.9, >= 0.9.10)
171+
launchy (3.1.0)
172+
addressable (~> 2.8)
173+
childprocess (~> 5.0)
174+
logger (~> 1.6)
175+
letter_opener (1.10.0)
176+
launchy (>= 2.2, < 4)
166177
logger (1.6.5)
167178
loofah (2.24.0)
168179
crass (~> 1.0.2)
@@ -172,6 +183,8 @@ GEM
172183
net-imap
173184
net-pop
174185
net-smtp
186+
maily (2.1.0)
187+
rails (>= 4.2)
175188
marcel (1.0.4)
176189
matrix (0.4.2)
177190
mini_mime (1.1.5)
@@ -373,6 +386,7 @@ GEM
373386
unicode-display_width (3.1.4)
374387
unicode-emoji (~> 4.0, >= 4.0.4)
375388
unicode-emoji (4.0.4)
389+
uniform_notifier (1.16.0)
376390
uri (1.0.2)
377391
useragent (0.16.11)
378392
web-console (4.2.1)
@@ -406,13 +420,16 @@ DEPENDENCIES
406420
bcrypt (~> 3.1.7)
407421
bootsnap
408422
brakeman
423+
bullet
409424
capybara
410425
debug
411426
factory_bot_rails
412427
hotwire-spark
413428
importmap-rails
414429
jbuilder
415430
kamal
431+
letter_opener
432+
maily
416433
pg (~> 1.1)
417434
propshaft
418435
puma (>= 5.0)

config/environments/development.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
require "active_support/core_ext/integer/time"
22

33
Rails.application.configure do
4+
if defined?(Bullet)
5+
config.after_initialize do
6+
Bullet.enable = true
7+
Bullet.alert = true
8+
Bullet.bullet_logger = true
9+
Bullet.console = true
10+
Bullet.rails_logger = true
11+
Bullet.add_footer = true
12+
end
13+
end
14+
415
# Settings specified here will take precedence over those in config/application.rb.
516

617
# Make code changes take effect immediately without server restart.
@@ -31,6 +42,9 @@
3142
# Store uploaded files on the local file system (see config/storage.yml for options).
3243
config.active_storage.service = :local
3344

45+
config.action_mailer.delivery_method = :letter_opener
46+
config.action_mailer.perform_deliveries = true
47+
3448
# Don't care if the mailer can't send.
3549
config.action_mailer.raise_delivery_errors = false
3650

config/environments/test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
# and recreated between test runs. Don't rely on the data there!
55

66
Rails.application.configure do
7+
if defined?(Bullet)
8+
config.after_initialize do
9+
Bullet.enable = true
10+
Bullet.bullet_logger = true
11+
Bullet.raise = true # raise an error if n+1 query occurs
12+
end
13+
end
14+
715
# Settings specified here will take precedence over those in config/application.rb.
816

917
# While tests run files are not watched, reloading is not necessary.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if defined?(LetterOpener)
2+
LetterOpener.configure do |config|
3+
# To overrider the location for message storage.
4+
# Default value is `tmp/letter_opener`
5+
config.location = Rails.root.join("tmp", "my_mails")
6+
7+
# To render only the message body, without any metadata or extra containers or styling.
8+
# Default value is `:default` that renders styled message with showing useful metadata.
9+
config.message_template = :light
10+
11+
# To change default file URI scheme you can provide `file_uri_scheme` config.
12+
# It might be useful when you use WSL (Windows Subsystem for Linux) and default
13+
# scheme doesn't work for you.
14+
# Default value is blank
15+
config.file_uri_scheme = "file://///wsl$/Ubuntu-18.04"
16+
end
17+
end

config/initializers/maily.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
if defined?(Maily)
2+
Maily.setup do |config|
3+
# On/off engine
4+
config.enabled = Rails.env.development?
5+
6+
# Allow templates edition
7+
# config.allow_edition = !Rails.env.production?
8+
9+
# Allow deliveries
10+
config.allow_delivery = nil
11+
12+
# Your application available_locales (or I18n.available_locales) by default
13+
config.available_locales = [ :en, :es ]
14+
15+
# Run maily under different controller ('ActionController::Base' by default)
16+
# config.base_controller = '::AdminController'
17+
18+
# Configure hooks path
19+
# config.hooks_path = 'lib/maily_hooks.rb'
20+
21+
# Http basic authentication (nil by default)
22+
# config.http_authorization = { username: 'admin', password: 'secret' }
23+
24+
# Customize welcome message
25+
# config.welcome_message = "Welcome to our email testing platform. If you have any problem, please contact support team at [email protected]."
26+
end
27+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Rails.application.routes.draw do
22
resources :regions
3+
mount Maily::Engine, at: "/maily"
34
root "home#index"
45
get "home/index", as: :home
56
resource :session

lib/maily_hooks.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
user = ""
2+
3+
Maily.hooks_for("PasswordsMailer") do |mailer|
4+
mailer.register_hook(:reset, user)
5+
end

0 commit comments

Comments
 (0)