aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/selector.rb4
-rw-r--r--actionpack/test/controller/assert_select_test.rb19
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb2
-rw-r--r--railties/test/application/assets_test.rb27
4 files changed, 36 insertions, 16 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
index 5fa91d1a76..b4555f4f59 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -415,9 +415,9 @@ module ActionDispatch
assert !deliveries.empty?, "No e-mail in delivery list"
for delivery in deliveries
- for part in delivery.parts
+ for part in (delivery.parts.empty? ? [delivery] : delivery.parts)
if part["Content-Type"].to_s =~ /^text\/html\W/
- root = HTML::Document.new(part.body).root
+ root = HTML::Document.new(part.body.to_s).root
assert_select root, ":root", &block
end
end
diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb
index 878484eb57..5eef8a32d7 100644
--- a/actionpack/test/controller/assert_select_test.rb
+++ b/actionpack/test/controller/assert_select_test.rb
@@ -20,6 +20,15 @@ class AssertSelectTest < ActionController::TestCase
end
end
+ class AssertMultipartSelectMailer < ActionMailer::Base
+ def test(options)
+ mail :subject => "Test e-mail", :from => "test@test.host", :to => "test <test@test.host>" do |format|
+ format.text { render :text => options[:text] }
+ format.html { render :text => options[:html] }
+ end
+ end
+ end
+
class AssertSelectController < ActionController::Base
def response_with=(content)
@content = content
@@ -313,6 +322,16 @@ EOF
end
end
+ def test_assert_select_email_multipart
+ AssertMultipartSelectMailer.test(:html => "<div><p>foo</p><p>bar</p></div>", :text => 'foo bar').deliver
+ assert_select_email do
+ assert_select "div:root" do
+ assert_select "p:first-child", "foo"
+ assert_select "p:last-child", "bar"
+ end
+ end
+ end
+
protected
def render_html(html)
@controller.response_with = html
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 4fb487ade1..35f400f9df 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -371,7 +371,7 @@ module ActiveSupport
protected
def require_tzinfo
- require 'tzinfo'
+ require 'tzinfo' unless defined?(::TZInfo)
rescue LoadError
$stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
raise
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index 8a5cafe71b..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"
@@ -65,8 +65,9 @@ module ApplicationTests
end
test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
- app_file "config/initializers/digest.rb", "Rails.application.config.assets.digest = true"
- app_file "config/initializers/caching.rb", "Rails.application.config.action_controller.perform_caching = false"
+ 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"
@@ -77,7 +78,7 @@ module ApplicationTests
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` }
@@ -93,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` }
@@ -112,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` }
@@ -128,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` }
@@ -191,7 +192,7 @@ module ApplicationTests
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' %>"
- app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = false"
+ add_to_config "config.assets.compile = false"
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do
@@ -218,7 +219,7 @@ module ApplicationTests
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` }
@@ -229,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