aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/app_base.rb7
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt3
-rw-r--r--railties/lib/rails/generators/rails/app/templates/public/500.html1
-rw-r--r--railties/test/application/assets_test.rb56
-rw-r--r--railties/test/railties/mounted_engine_test.rb48
5 files changed, 98 insertions, 17 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 21a2ae4e28..93f5023a7a 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -9,7 +9,7 @@ require 'uri'
module Rails
module Generators
class AppBase < Base
- DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
+ DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver )
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
DATABASES.concat(JDBC_DATABASES)
@@ -154,12 +154,13 @@ module Rails
end
def gem_for_database
- # %w( mysql oracle postgresql sqlite3 frontbase ibm_db jdbcmysql jdbcsqlite3 jdbcpostgresql )
+ # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
case options[:database]
when "oracle" then "ruby-oci8"
when "postgresql" then "pg"
when "frontbase" then "ruby-frontbase"
when "mysql" then "mysql2"
+ when "sqlserver" then "activerecord-sqlserver-adapter"
when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
@@ -205,7 +206,7 @@ module Rails
group :assets do
gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git'
gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails.git'
- gem 'uglifier'
+ gem 'uglifier', '>= 1.0.3'
end
GEMFILE
end
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
index 8e33a65b2d..80198cc21e 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
@@ -41,7 +41,4 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
-
- # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
- config.assets.allow_debugging = true
end
diff --git a/railties/lib/rails/generators/rails/app/templates/public/500.html b/railties/lib/rails/generators/rails/app/templates/public/500.html
index b80307fc16..f3648a0dbc 100644
--- a/railties/lib/rails/generators/rails/app/templates/public/500.html
+++ b/railties/lib/rails/generators/rails/app/templates/public/500.html
@@ -20,7 +20,6 @@
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
</div>
</body>
</html>
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index 1e0a26918b..b9d8c002d7 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -37,7 +37,7 @@ module ApplicationTests
test "assets do not require compressors until it is used" do
app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();"
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true"
+ add_to_config "config.assets.compile = true"
ENV["RAILS_ENV"] = "production"
require "#{app_path}/config/environment"
@@ -64,11 +64,21 @@ module ApplicationTests
end
end
+ test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
+ add_to_config "config.assets.digest = true"
+ add_to_config "config.action_controller.perform_caching = false"
+
+ ENV["RAILS_ENV"] = "production"
+ require "#{app_path}/config/environment"
+
+ assert_equal Sprockets::Index, Rails.application.assets.class
+ end
+
test "precompile creates a manifest file with all the assets listed" do
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
app_file "app/assets/javascripts/application.js", "alert();"
# digest is default in false, we must enable it for test environment
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = true"
+ add_to_config "config.assets.digest = true"
capture(:stdout) do
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
@@ -84,10 +94,10 @@ module ApplicationTests
test "precompile creates a manifest file in a custom path with all the assets listed" do
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
app_file "app/assets/javascripts/application.js", "alert();"
- FileUtils.mkdir "#{app_path}/shared"
- app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = '#{app_path}/shared'"
# digest is default in false, we must enable it for test environment
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = true"
+ add_to_config "config.assets.digest = true"
+ add_to_config "config.assets.manifest = '#{app_path}/shared'"
+ FileUtils.mkdir "#{app_path}/shared"
capture(:stdout) do
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
@@ -103,9 +113,9 @@ module ApplicationTests
test "the manifest file should be saved by default in the same assets folder" do
app_file "app/assets/javascripts/application.js", "alert();"
- app_file "config/initializers/manifest.rb", "Rails.application.config.assets.prefix = '/x'"
# digest is default in false, we must enable it for test environment
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = true"
+ add_to_config "config.assets.digest = true"
+ add_to_config "config.assets.prefix = '/x'"
capture(:stdout) do
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
@@ -119,7 +129,7 @@ module ApplicationTests
test "precompile does not append asset digests when config.assets.digest is false" do
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
app_file "app/assets/javascripts/application.js", "alert();"
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = false"
+ add_to_config "config.assets.digest = false"
capture(:stdout) do
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
@@ -180,10 +190,36 @@ module ApplicationTests
assert_match(/app.js isn't precompiled/, last_response.body)
end
+ test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled if digest is disabled" do
+ app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>"
+ add_to_config "config.assets.compile = false"
+
+ app_file "config/routes.rb", <<-RUBY
+ AppTemplate::Application.routes.draw do
+ match '/posts', :to => "posts#index"
+ end
+ RUBY
+
+ ENV["RAILS_ENV"] = "development"
+ capture(:stdout) do
+ Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
+ end
+
+ # Create file after of precompile
+ app_file "app/assets/javascripts/app.js", "alert();"
+
+ require "#{app_path}/config/environment"
+ class ::PostsController < ActionController::Base ; end
+
+ get '/posts'
+ assert_match(/AssetNotPrecompiledError/, last_response.body)
+ assert_match(/app.js isn't precompiled/, last_response.body)
+ end
+
test "precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV" do
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
# digest is default in false, we must enable it for test environment
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = true"
+ add_to_config "config.assets.digest = true"
# capture(:stdout) do
Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_ENV=test` }
@@ -194,7 +230,7 @@ module ApplicationTests
test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true"
+ add_to_config "config.assets.compile = true"
ENV["RAILS_ENV"] = nil
capture(:stdout) do
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index 94dec405a7..253e61259b 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -11,13 +11,17 @@ module ApplicationTests
add_to_config("config.action_dispatch.show_exceptions = false")
+ @simple_plugin = engine "weblog"
@plugin = engine "blog"
app_file 'config/routes.rb', <<-RUBY
AppTemplate::Application.routes.draw do
+ mount Weblog::Engine, :at => '/', :as => 'weblog'
resources :posts
match "/engine_route" => "application_generating#engine_route"
match "/engine_route_in_view" => "application_generating#engine_route_in_view"
+ match "/weblog_engine_route" => "application_generating#weblog_engine_route"
+ match "/weblog_engine_route_in_view" => "application_generating#weblog_engine_route_in_view"
match "/url_for_engine_route" => "application_generating#url_for_engine_route"
match "/polymorphic_route" => "application_generating#polymorphic_route"
match "/application_polymorphic_path" => "application_generating#application_polymorphic_path"
@@ -28,6 +32,29 @@ module ApplicationTests
end
RUBY
+
+ @simple_plugin.write "lib/weblog.rb", <<-RUBY
+ module Weblog
+ class Engine < ::Rails::Engine
+ end
+ end
+ RUBY
+
+ @simple_plugin.write "config/routes.rb", <<-RUBY
+ Weblog::Engine.routes.draw do
+ match '/weblog' => "weblogs#index", :as => 'weblogs'
+ end
+ RUBY
+
+ @simple_plugin.write "app/controllers/weblogs_controller.rb", <<-RUBY
+ class WeblogsController < ActionController::Base
+ def index
+ render :text => request.url
+ end
+ end
+ RUBY
+
+
@plugin.write "app/models/blog/post.rb", <<-RUBY
module Blog
class Post
@@ -100,6 +127,14 @@ module ApplicationTests
render :inline => "<%= blog.posts_path %>"
end
+ def weblog_engine_route
+ render :text => weblog.weblogs_path
+ end
+
+ def weblog_engine_route_in_view
+ render :inline => "<%= weblog.weblogs_path %>"
+ end
+
def url_for_engine_route
render :text => blog.url_for(:controller => "blog/posts", :action => "index", :user => "john", :only_path => true)
end
@@ -192,5 +227,18 @@ module ApplicationTests
get "/application_polymorphic_path"
assert_equal "/posts/44", last_response.body
end
+
+ test "route path for controller action when engine is mounted at root" do
+ get "/weblog_engine_route"
+ assert_equal "/weblog", last_response.body
+
+ get "/weblog_engine_route_in_view"
+ assert_equal "/weblog", last_response.body
+ end
+
+ test "request url for controller action when engine is mounted at root" do
+ get "/weblog"
+ assert_equal "http://example.org/weblog", last_response.body
+ end
end
end