Skip to content

Commit 26bbab7

Browse files
koheisgsebjacobs
authored andcommitted
removed rails 5.0 check for mailer preview generator (rspec#2037)
* removed rails 5.0 check for mailer preview generator * Add test fot mailer generator
1 parent 21e578d commit 26bbab7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/generators/rspec/mailer/templates/preview.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class <%= class_name %>Preview < ActionMailer::Preview
55

66
# Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
77
def <%= action %>
8-
<%= class_name %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>.<%= action %>
8+
<%= Rails.version.to_f >= 5.0 ? class_name.sub(/(Mailer)?$/, 'Mailer') : class_name %>.<%= action %>
99
end
1010
<% end -%>
1111

spec/generators/rspec/mailer/mailer_generator_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
it { is_expected.to exist }
5757
it { is_expected.to contain(/class PostsPreview < ActionMailer::Preview/) }
5858
it { is_expected.to contain(/def index/) }
59+
if Rails.version.to_f >= 5.0
60+
it { is_expected.to contain(/PostsMailer.index/) }
61+
else
62+
it { is_expected.to contain(/Posts.index/) }
63+
end
5964
it { is_expected.to contain(/def show/) }
65+
if Rails.version.to_f >= 5.0
66+
it { is_expected.to contain(/PostsMailer.show/) }
67+
else
68+
it { is_expected.to contain(/Posts.show/) }
69+
end
6070
end
6171
end

0 commit comments

Comments
 (0)