diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/scaffold_controller_generator_test.rb | 9 | ||||
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 30 |
2 files changed, 39 insertions, 0 deletions
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index 1348744b0b..8278b72a5a 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -89,6 +89,15 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase end end + def test_controller_permit_attachments_attributes_only + run_generator ["Message", "photos:attachments"] + + assert_file "app/controllers/messages_controller.rb" do |content| + assert_match(/def message_params/, content) + assert_match(/params\.require\(:message\)\.permit\(photos: \[\]\)/, content) + end + end + def test_helper_are_invoked_with_a_pluralized_name run_generator assert_file "app/helpers/users_helper.rb", /module UsersHelper/ diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index bfa52a1beb..fa9a42215b 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -487,6 +487,36 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase assert_match(/^\W{4}<%= form\.file_field :video %>/, content) assert_match(/^\W{4}<%= form\.file_field :photos, multiple: true %>/, content) end + + assert_file "app/views/messages/show.html.erb" do |content| + assert_match(/^\W{2}<%= link_to @message\.video\.filename, @message\.video if @message\.video\.attached\? %>/, content) + assert_match(/^\W{4}<div><%= link_to photo\.filename, photo %>/, content) + end + + assert_file "test/system/messages_test.rb" do |content| + assert_no_match(/fill_in "Video"/, content) + assert_no_match(/fill_in "Photos"/, content) + end + end + + def test_scaffold_generator_rich_text + run_generator ["message", "content:rich_text"] + + assert_file "app/models/message.rb", /rich_text :content/ + + assert_file "app/controllers/messages_controller.rb" do |content| + assert_instance_method :message_params, content do |m| + assert_match(/permit\(:content\)/, m) + end + end + + assert_file "app/views/messages/_form.html.erb" do |content| + assert_match(/^\W{4}<%= form\.rich_text_area :content %>/, content) + end + + assert_file "test/system/messages_test.rb" do |content| + assert_no_match(/fill_in "Content"/, content) + end end def test_scaffold_generator_database |