aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Agrawal <arunagw@gmail.com>2014-07-04 16:18:34 +0200
committerArun Agrawal <arunagw@gmail.com>2014-07-04 16:20:53 +0200
commite197fd7f378815f3f56cac824b2926061fc17203 (patch)
tree334213d390825207678d4a12be333554320d7abf
parentcce376c999af0f35a940235dc56602120aa8462a (diff)
downloadrails-e197fd7f378815f3f56cac824b2926061fc17203.tar.gz
rails-e197fd7f378815f3f56cac824b2926061fc17203.tar.bz2
rails-e197fd7f378815f3f56cac824b2926061fc17203.zip
Display notice in index.html pages in scaffolded generated views
As we are setting notice in destroy action we should display that For more information see https://github.com/rails/rails/pull/14044 And https://github.com/rails/jbuilder/pull/191 closes #14044
-rw-r--r--railties/lib/rails/generators/erb/scaffold/templates/index.html.erb2
-rw-r--r--railties/test/generators/controller_generator_test.rb2
-rw-r--r--railties/test/generators/scaffold_controller_generator_test.rb8
3 files changed, 11 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
index 025b1d8699..5e194783ff 100644
--- a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
+++ b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
@@ -1,3 +1,5 @@
+<p id="notice"><%%= notice %></p>
+
<h1>Listing <%= plural_table_name.titleize %></h1>
<table>
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb
index c906d56b8f..28b527cb0e 100644
--- a/railties/test/generators/controller_generator_test.rb
+++ b/railties/test/generators/controller_generator_test.rb
@@ -73,7 +73,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
def test_skip_routes
run_generator ["account", "foo", "--skip-routes"]
assert_file "config/routes.rb" do |routes|
- assert_no_match /get 'account\/foo'/, routes
+ assert_no_match(/get 'account\/foo'/, routes)
end
end
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb
index 3c1123b53d..46eacd2845 100644
--- a/railties/test/generators/scaffold_controller_generator_test.rb
+++ b/railties/test/generators/scaffold_controller_generator_test.rb
@@ -93,6 +93,14 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/views/layouts/users.html.erb"
end
+ def test_index_page_have_notice
+ run_generator
+
+ %w(index show).each do |view|
+ assert_file "app/views/users/#{view}.html.erb", /notice/
+ end
+ end
+
def test_functional_tests
run_generator ["User", "name:string", "age:integer", "organization:references{polymorphic}"]