diff options
author | tanraya <demerest@gmail.com> | 2013-12-21 12:09:52 +0600 |
---|---|---|
committer | tanraya <demerest@gmail.com> | 2014-07-26 09:40:24 +0600 |
commit | 6bd812605de2e2360606be3821a046778b874254 (patch) | |
tree | 4da2d0cf4a616ba2c841892591bdc266202a1836 /railties/test/generators | |
parent | 3f4e97f807eb475ac8c311e5baf138249a8a1ab2 (diff) | |
download | rails-6bd812605de2e2360606be3821a046778b874254.tar.gz rails-6bd812605de2e2360606be3821a046778b874254.tar.bz2 rails-6bd812605de2e2360606be3821a046778b874254.zip |
Use local variables in _form.html.erb generated by scaffold generator.
It seems a good idea to use local variables in generated partials instead of using instance variables.
Before
<%= render 'form' %>
After
<%= render 'form', product: @product %>
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 524bbde2b7..c44ce32122 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -68,6 +68,17 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end assert_no_file "app/views/layouts/product_lines.html.erb" + # Views local variables + assert_file "app/views/product_lines/_form.html.erb" do |test| + assert_no_match(/@product_line/, test) + end + + %w(edit new).each do |view| + assert_file "app/views/product_lines/#{view}.html.erb" do |test| + assert_match(/product_line: @product_line/, test) + end + end + # Helpers assert_file "app/helpers/product_lines_helper.rb" assert_file "test/helpers/product_lines_helper_test.rb" |