Skip to content

Commit 56d333b

Browse files
committed
Add test for controller scaffold with namespace
Only for Rails::VERSION::MAJOR >= 6 because the method `show_helper` doesn't handle well the namespaces on previous versions.
1 parent 1d387e0 commit 56d333b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/scaffold_controller_generator_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
5959
end
6060
end
6161

62+
if Rails::VERSION::MAJOR >= 6
63+
test 'controller with namespace' do
64+
run_generator %w(Admin::Post --model-name=Post)
65+
assert_file 'app/controllers/admin/posts_controller.rb' do |content|
66+
assert_instance_method :create, content do |m|
67+
assert_match %r{format\.html \{ redirect_to admin_post_url\(@post\), notice: "Post was successfully created\." \}}, m
68+
end
69+
70+
assert_instance_method :update, content do |m|
71+
assert_match %r{format\.html \{ redirect_to admin_post_url\(@post\), notice: "Post was successfully updated\." \}}, m
72+
end
73+
74+
assert_instance_method :destroy, content do |m|
75+
assert_match %r{format\.html \{ redirect_to admin_posts_url, notice: "Post was successfully destroyed\." \}}, m
76+
end
77+
end
78+
end
79+
end
80+
6281
test 'dont use require and permit if there are no attributes' do
6382
run_generator %w(Post)
6483

0 commit comments

Comments
 (0)