Skip to content

Commit 2f69c18

Browse files
author
Neeraj Singh
committed
Do not use this gem in production
Add env specific stuff not during initialization
1 parent 96daaa7 commit 2f69c18

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

lib/mail_interceptor.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def initialize options = {}
1212
@forward_emails_to = options.fetch :forward_emails_to
1313
@env = options.fetch :env, InterceptorEnv.new
1414

15-
add_env_info_to_subject_prefix
1615
sanitize_forward_emails_to
1716
end
1817

@@ -40,7 +39,8 @@ def normalize_recipients recipients
4039
def add_subject_prefix message
4140
return if subject_prefix.blank?
4241

43-
message.subject = "#{subject_prefix} #{message.subject}"
42+
modified_subject_prefix = add_env_info_to_subject_prefix
43+
message.subject = "#{modified_subject_prefix} #{message.subject}"
4444
end
4545

4646
def sanitize_forward_emails_to
@@ -52,10 +52,7 @@ def sanitize_forward_emails_to
5252
end
5353

5454
def add_env_info_to_subject_prefix
55-
return if subject_prefix.blank?
56-
57-
_prefix = env.intercept? ? "#{subject_prefix} #{env.name}" : subject_prefix
58-
self.subject_prefix = "[#{_prefix}]"
55+
"[#{subject_prefix} #{env.name}]"
5956
end
6057

6158
def forward_emails_to_empty?

test/mail_interceptor_test.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,6 @@ def test_subject_prefix_in_test
6060
assert_equal "[wheel TEST] Another Forgot password", @message.subject
6161
end
6262

63-
def test_subject_prefix_in_production
64-
interceptor = ::MailInterceptor::Interceptor.new env: env('production'),
65-
forward_emails_to: 'test@example.com',
66-
subject_prefix: 'wheel'
67-
@message.subject = 'Forgot password'
68-
69-
interceptor.delivering_email @message
70-
assert_equal "[wheel] Forgot password", @message.subject
71-
end
72-
7363
def test_error_if_forward_emails_to_is_empty
7464
message = "forward_emails_to should not be empty"
7565

0 commit comments

Comments
 (0)