aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/command_line.textile2
-rw-r--r--railties/lib/rails/application/configuration.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt5
-rw-r--r--railties/lib/rails/source_annotation_extractor.rb8
-rw-r--r--railties/lib/rails/tasks/engine.rake2
-rw-r--r--railties/test/application/assets_test.rb22
-rw-r--r--railties/test/application/rake_test.rb21
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb8
-rw-r--r--railties/test/railties/generators_test.rb2
11 files changed, 57 insertions, 19 deletions
diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile
index b0edc1017d..9e3b25d794 100644
--- a/railties/guides/source/command_line.textile
+++ b/railties/guides/source/command_line.textile
@@ -507,7 +507,7 @@ We had to create the *gitapp* directory and initialize an empty git repository b
<shell>
$ cat config/database.yml
-# PostgreSQL. Versions 7.4 and 8.x are supported.
+# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the ruby-postgres driver:
# gem install ruby-postgres
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 3b74de690a..1a29483a73 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -34,7 +34,7 @@ module Rails
@assets = ActiveSupport::OrderedOptions.new
@assets.enabled = false
@assets.paths = []
- @assets.precompile = [ /\w+\.(?!js|css).+/, "application.js", "application.css" ]
+ @assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
@assets.prefix = "/assets"
@assets.js_compressor = nil
diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml
index 996ff4baa3..fe9466b366 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml
+++ b/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml
@@ -1,4 +1,4 @@
-# PostgreSQL. Versions 7.4 and 8.x are supported.
+# PostgreSQL. Versions 8.2 and up are supported.
#
# Configure Using Gemfile
# gem 'activerecord-jdbcpostgresql-adapter'
diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
index 467dfc3956..f08f86aac3 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
+++ b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
@@ -1,4 +1,4 @@
-# PostgreSQL. Versions 7.4 and 8.x are supported.
+# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
index ffd9058238..3e0c29a587 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
@@ -22,6 +22,11 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
+ <%- unless options.skip_active_record? -%>
+ # Raise exception on mass assignment protection for ActiveRecord models
+ config.active_record.mass_assignment_sanitizer = :strict
+ <%- end -%>
+
# Do not compress assets
config.assets.compress = false
end
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb
index 6d6e7f8b59..1eed763aa3 100644
--- a/railties/lib/rails/source_annotation_extractor.rb
+++ b/railties/lib/rails/source_annotation_extractor.rb
@@ -28,9 +28,9 @@ class SourceAnnotationExtractor
end
end
- # Prints all annotations with tag +tag+ under the root directories +app+, +lib+,
- # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+,
- # +.rxml+, +.rhtml+, or +.erb+ are taken into account. The +options+
+ # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+,
+ # +script+, and +test+ (recursively). Only filenames with extension
+ # +.builder+, +.rb+, +.rxml+, +.rhtml+, or +.erb+ are taken into account. The +options+
# hash is passed to each annotation's +to_s+.
#
# This class method is the single entry point for the rake tasks.
@@ -49,7 +49,7 @@ class SourceAnnotationExtractor
# with their annotations. Only files with annotations are included, and only
# those with extension +.builder+, +.rb+, +.rxml+, +.rhtml+, and +.erb+
# are taken into account.
- def find(dirs=%w(app lib test))
+ def find(dirs=%w(app config lib script test))
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
end
diff --git a/railties/lib/rails/tasks/engine.rake b/railties/lib/rails/tasks/engine.rake
index 2f0e7be896..2152e811f5 100644
--- a/railties/lib/rails/tasks/engine.rake
+++ b/railties/lib/rails/tasks/engine.rake
@@ -67,3 +67,5 @@ def find_engine_path(path)
find_engine_path(File.expand_path('..', path))
end
end
+
+Rake.application.invoke_task(:load_app)
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index b76dae8e18..e1eee71a9e 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -35,16 +35,30 @@ module ApplicationTests
assert_match "alert()", last_response.body
end
+ test "assets do not require compressors until it is used" do
+ app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();"
+ ENV["RAILS_ENV"] = "production"
+ require "#{app_path}/config/environment"
+
+ assert !defined?(Uglifier)
+ get "/assets/demo.js"
+ assert_match "alert()", last_response.body
+ assert defined?(Uglifier)
+ end
+
test "assets are compiled properly" do
app_file "app/assets/javascripts/application.js", "alert();"
+ app_file "app/assets/javascripts/foo/application.js", "alert();"
capture(:stdout) do
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
end
-
- file = Dir["#{app_path}/public/assets/application-*.js"][0]
- assert_not_nil file, "Expected application.js asset to be generated, but none found"
- assert_equal "alert();\n", File.read(file)
+ files = Dir["#{app_path}/public/assets/application-*.js"]
+ files << Dir["#{app_path}/public/assets/foo/application-*.js"].first
+ files.each do |file|
+ assert_not_nil file, "Expected application.js asset to be generated, but none found"
+ assert_equal "alert();\n", File.read(file)
+ end
end
test "assets are cleaned up properly" do
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index b61e2851bf..7671c129e9 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -61,22 +61,22 @@ module ApplicationTests
def test_rake_test_error_output
Dir.chdir(app_path){ `rake db:migrate` }
-
+
app_file "config/database.yml", <<-RUBY
development:
RUBY
-
+
app_file "test/unit/one_unit_test.rb", <<-RUBY
RUBY
-
+
app_file "test/functional/one_functional_test.rb", <<-RUBY
raise RuntimeError
RUBY
-
+
app_file "test/integration/one_integration_test.rb", <<-RUBY
raise RuntimeError
RUBY
-
+
silence_stderr do
output = Dir.chdir(app_path){ `rake test` }
assert_match /Errors running test:units! #<ActiveRecord::AdapterNotSpecified/, output
@@ -151,5 +151,14 @@ module ApplicationTests
assert_equal 2, ::AppTemplate::Application::Product.count
assert_equal 0, ::AppTemplate::Application::User.count
end
+
+ def test_scaffold_tests_pass_by_default
+ content = Dir.chdir(app_path) do
+ `rails generate scaffold user username:string password:string`
+ `bundle exec rake db:migrate db:test:clone test`
+ end
+
+ assert_match(/7 tests, 10 assertions, 0 failures, 0 errors/, content)
+ end
end
-end
+end \ No newline at end of file
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index be72391e58..4bd77ff7e3 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -159,6 +159,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
assert_match(/1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`)
end
+ def test_ensure_that_migration_tasks_work_with_mountable_option
+ run_generator [destination_root, "--mountable"]
+ FileUtils.cd destination_root
+ quietly { system 'bundle install' }
+ `bundle exec rake db:migrate`
+ assert_equal 0, $?.exitstatus
+ end
+
def test_creating_engine_in_full_mode
run_generator [destination_root, "--full"]
assert_file "app/assets/javascripts/bukkits"
diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb
index 08dd1ebbc2..1d4ba0e5b6 100644
--- a/railties/test/railties/generators_test.rb
+++ b/railties/test/railties/generators_test.rb
@@ -32,8 +32,8 @@ module RailtiesTests
end
def build_engine(is_mountable=false)
+ FileUtils.rm_rf(engine_path)
FileUtils.mkdir_p(engine_path)
- FileUtils.rm_r(engine_path)
mountable = is_mountable ? "--mountable" : ""