diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-10-16 10:27:35 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-10-16 10:30:55 +0900 |
commit | b0b0cd1fd77af3eec8b2b8760bace2572e04a3a3 (patch) | |
tree | 2e750d1022426c9adac58b7ee0468d95b4f45e9b /railties/test | |
parent | b7c29fc962588b28d2955dfcb14e5f655e181164 (diff) | |
parent | ecb2850a04adc6c6665f9a30a1d60ca73965ccfa (diff) | |
download | rails-b0b0cd1fd77af3eec8b2b8760bace2572e04a3a3.tar.gz rails-b0b0cd1fd77af3eec8b2b8760bace2572e04a3a3.tar.bz2 rails-b0b0cd1fd77af3eec8b2b8760bace2572e04a3a3.zip |
Merge pull request #29204 from RasPat1/issue-29200-scaffold-reference-display-memory-address
Issue #29200 scaffold an object with a reference displays an object memory address to user
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 21b5013484..3cffdddd38 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -435,8 +435,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end end - def test_scaffold_generator_belongs_to - run_generator ["account", "name", "currency:belongs_to"] + def test_scaffold_generator_belongs_to_and_references + run_generator ["account", "name", "currency:belongs_to", "user:references"] assert_file "app/models/account.rb", /belongs_to :currency/ @@ -449,7 +449,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase assert_file "app/controllers/accounts_controller.rb" do |content| assert_instance_method :account_params, content do |m| - assert_match(/permit\(:name, :currency_id\)/, m) + assert_match(/permit\(:name, :currency_id, :user_id\)/, m) end end @@ -457,6 +457,16 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase assert_match(/^\W{4}<%= form\.text_field :name %>/, content) assert_match(/^\W{4}<%= form\.text_field :currency_id %>/, content) end + + assert_file "app/views/accounts/index.html.erb" do |content| + assert_match(/^\W{8}<td><%= account\.name %><\/td>/, content) + assert_match(/^\W{8}<td><%= account\.user_id %><\/td>/, content) + end + + assert_file "app/views/accounts/show.html.erb" do |content| + assert_match(/^\W{2}<%= @account\.name %>/, content) + assert_match(/^\W{2}<%= @account\.user_id %>/, content) + end end def test_scaffold_generator_database |