Skip to content

Commit f7ec132

Browse files
byrootrafaelfranca
authored andcommitted
Merge pull request #55495 from joaquintomas2003/authentication_test_files_generator
Move authentication test files generation to `test_unit` specific generator
1 parent 830363a commit f7ec132

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

railties/lib/rails/generators/rails/authentication/authentication_generator.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ def create_authentication_files
2929

3030
template "app/views/passwords_mailer/reset.html.erb"
3131
template "app/views/passwords_mailer/reset.text.erb"
32-
33-
template "test/mailers/previews/passwords_mailer_preview.rb"
3432
end
3533

3634
def configure_application_controller

railties/lib/rails/generators/test_unit/authentication/authentication_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def create_user_test_files
99
template "test/fixtures/users.yml"
1010
template "test/models/user_test.rb"
1111
end
12+
13+
def create_mailer_preview_files
14+
template "test/mailers/previews/passwords_mailer_preview.rb" if defined?(ActionMailer::Railtie)
15+
end
1216
end
1317
end
1418
end
File renamed without changes.

railties/test/generators/authentication_generator_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ def test_model_test_is_skipped_if_test_framework_is_given
110110
assert_no_file "test/models/user_test.rb"
111111
end
112112

113+
def mailer_preview_is_skipped_if_test_framework_is_given
114+
generator([destination_root], ["-t", "rspec"])
115+
116+
run_generator_instance
117+
118+
assert_no_file "test/mailers/previews/passwords_mailer_preview.rb"
119+
end
120+
113121
def test_connection_class_skipped_without_action_cable
114122
old_value = ActionCable.const_get(:Engine)
115123
ActionCable.send(:remove_const, :Engine)

0 commit comments

Comments
 (0)