提交 6e6cfb66 编写于 作者: R Rafael Mendonça França

Merge pull request #21176 from y-yagi/fix_scaffold_tests_inside_api_engine

make generated scaffold functional tests work inside API engines
......@@ -3,7 +3,10 @@
<% module_namespacing do -%>
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
setup do
@<%= singular_table_name %> = <%= table_name %>(:one)
@<%= singular_table_name %> = <%= fixture_name %>(:one)
<% if mountable_engine? -%>
@routes = Engine.routes
<% end -%>
end
test "should get index" do
......
......@@ -505,4 +505,32 @@ def test_scaffold_tests_pass_by_default_inside_full_engine
assert_match(/8 runs, 13 assertions, 0 failures, 0 errors/, `bin/rails test 2>&1`)
end
end
def test_scaffold_tests_pass_by_default_inside_api_mountable_engine
Dir.chdir(destination_root) { `bundle exec rails plugin new bukkits --mountable --api` }
engine_path = File.join(destination_root, "bukkits")
Dir.chdir(engine_path) do
quietly do
`bin/rails g scaffold User name:string age:integer;
bundle exec rake db:migrate`
end
assert_match(/6 runs, 8 assertions, 0 failures, 0 errors/, `bin/rails test 2>&1`)
end
end
def test_scaffold_tests_pass_by_default_inside_api_full_engine
Dir.chdir(destination_root) { `bundle exec rails plugin new bukkits --full --api` }
engine_path = File.join(destination_root, "bukkits")
Dir.chdir(engine_path) do
quietly do
`bin/rails g scaffold User name:string age:integer;
bundle exec rake db:migrate`
end
assert_match(/6 runs, 8 assertions, 0 failures, 0 errors/, `bin/rails test 2>&1`)
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册