Skip to content

Commit

Permalink
Merge branch '3-1-stable' of github.com:rails/rails into 3-1-stable
Browse files Browse the repository at this point in the history
* '3-1-stable' of github.com:rails/rails: (91 commits)
  Merge pull request rails#3049 from brainopia/fix_to_query_edge_case
  Bump AR-JDBC version. THis version is compatible with 3.1 and above
  Revert "Fixed Apache configuration for gzipped assets: FilesMatch and LocationMatch cannot be nested."
  Fixed Apache configuration for gzipped assets: FilesMatch and LocationMatch cannot be nested. (cherry picked from commit 5e2bf4d)
  Proper lines numbers for stack trace info
  Merge pull request rails#3040 from guilleiguaran/asset-host-should-not-be-nil-precompile
  cherry-pick rails#1318 into 3-1-stable
  Bumping up to 3.1.1.rc1
  Add some CHANGELOG missing stuff
  Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation.
  Add equivalent nginx configuration
  Fix typos and broken link on asset pipeline guide
  Merge pull request rails#3015 from guilleiguaran/clear-tmp-cache-on-precompile
  Merge pull request rails#3012 from guilleiguaran/3-1-1-changelogs
  Revert "Provide a way to access to assets without using the digest, useful for static files and emails"
  Merge pull request rails#3011 from guilleiguaran/disable-sprockets-server
  Provide a way to access to assets without using the digest, useful for static files and emails
  Merge pull request rails#2922 from wayneeseguin/master
  getting_started.textile: Fix typo and split up a sentence in section "Building a Multi-Model Form"
  getting_started.textile: Fix typos in section "Rendering a Partial Form"
  ...
  • Loading branch information
shwoodard committed Sep 19, 2011
2 parents f08d391 + 081d41a commit 4b2c9a9
Show file tree
Hide file tree
Showing 96 changed files with 890 additions and 281 deletions.
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem "bcrypt-ruby", "~> 3.0.0"
gem "jquery-rails"
# This needs to be with require false to avoid
# it being automatically loaded by sprockets
gem "uglifier", ">= 1.0.0", :require => false
gem "uglifier", ">= 1.0.3", :require => false

# Temp fix until rake 0.9.3 is out
if RUBY_VERSION >= "1.9.3"
Expand Down Expand Up @@ -68,16 +68,16 @@ end
platforms :jruby do
gem "ruby-debug", ">= 0.10.3"
gem "json"
gem "activerecord-jdbcsqlite3-adapter"
gem "activerecord-jdbcsqlite3-adapter", ">= 1.2.0"

# This is needed by now to let tests work on JRuby
# TODO: When the JRuby guys merge jruby-openssl in
# jruby this will be removed
gem "jruby-openssl"

group :db do
gem "activerecord-jdbcmysql-adapter"
gem "activerecord-jdbcpostgresql-adapter"
gem "activerecord-jdbcmysql-adapter", ">= 1.2.0"
gem "activerecord-jdbcpostgresql-adapter", ">= 1.2.0"
end
end

Expand Down
2 changes: 1 addition & 1 deletion RAILS_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1.rc1
5 changes: 5 additions & 0 deletions actionmailer/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*Rails 3.1.1 (unreleased)*

* No changes


*Rails 3.1.0 (August 30, 2011)*

* No changes
Expand Down
4 changes: 2 additions & 2 deletions actionmailer/lib/action_mailer/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 3
MINOR = 1
TINY = 0
PRE = nil
TINY = 1
PRE = "rc1"

STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
Expand Down
6 changes: 4 additions & 2 deletions actionmailer/test/old_base/mail_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ def test_from_without_name_for_smtp
assert_not_nil mail
mail, from, to = mail

assert_equal 'system@loudthinking.com', from.to_s
assert_equal ['root@loudthinking.com'], to
assert_equal 'system@loudthinking.com', from
end

def test_from_with_name_for_smtp
Expand All @@ -525,6 +526,7 @@ def test_from_with_name_for_smtp
assert_not_nil mail
mail, from, to = mail

assert_equal ['root@loudthinking.com'], to
assert_equal 'system@loudthinking.com', from
end

Expand Down Expand Up @@ -979,7 +981,7 @@ def test_file_delivery_should_create_a_file
TestMailer.delivery_method = :file
tmp_location = TestMailer.file_settings[:location]

result = TestMailer.cc_bcc(@recipient).deliver
TestMailer.cc_bcc(@recipient).deliver
assert File.exists?(tmp_location)
assert File.directory?(tmp_location)
assert File.exists?(File.join(tmp_location, @recipient))
Expand Down
14 changes: 14 additions & 0 deletions actionpack/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
*Rails 3.1.1 (unreleased)*

* Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation.
Useful for linking assets from static html files or from emails when the user
could probably look at an older html email with an older asset. [Santiago Pastorino]

* Don't mount Sprockets server at config.assets.prefix if config.assets.compile is false. [Mark J. Titorenko]

* Set relative url root in assets when controller isn't available for Sprockets (eg. Sass files using asset_path). Fixes #2435 [Guillermo Iguaran]

* Fix basic auth credential generation to not make newlines. GH #2882

* Fixed the behavior of asset pipeline when config.assets.digest and config.assets.compile are false and requested asset isn't precompiled.
Before the requested asset were compiled anyway ignoring that the config.assets.compile flag is false. [Guillermo Iguaran]

Expand All @@ -11,6 +21,10 @@

* Fixed stylesheet_link_tag and javascript_include_tag to respect additional options passed by the users when debug is on. [Guillermo Iguaran]

* Fix ActiveRecord#exists? when passsed a nil value

* Fix assert_select_email to work on multipart and non-multipart emails as the method stopped working correctly in Rails 3.x due to changes in the new mail gem.


*Rails 3.1.0 (August 30, 2011)*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def decode_credentials(request)
end

def encode_credentials(user_name, password)
"Basic #{ActiveSupport::Base64.encode64("#{user_name}:#{password}")}"
"Basic #{ActiveSupport::Base64.encode64s("#{user_name}:#{password}")}"
end

def authentication_request(controller, realm)
Expand Down
4 changes: 3 additions & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ def define_generate_prefix(app, name)
prefix_options = options.slice(*_route.segment_keys)
# we must actually delete prefix segment keys to avoid passing them to next url_for
_route.segment_keys.each { |k| options.delete(k) }
_routes.url_helpers.send("#{name}_path", prefix_options)
prefix = _routes.url_helpers.send("#{name}_path", prefix_options)
prefix = '' if prefix == '/'
prefix
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/testing/assertions/selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ def assert_select_email(&block)
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
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_pack/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module ActionPack
module VERSION #:nodoc:
MAJOR = 3
MINOR = 1
TINY = 0
PRE = nil
TINY = 1
PRE = "rc1"

STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
Expand Down
20 changes: 11 additions & 9 deletions actionpack/lib/action_view/asset_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ def initialize(config, controller = nil)
# When :relative (default), the protocol will be determined by the client using current protocol
# When :request, the protocol will be the request protocol
# Otherwise, the protocol is used (E.g. :http, :https, etc)
def compute_public_path(source, dir, ext = nil, include_host = true, protocol = nil)
def compute_public_path(source, dir, options = {})
source = source.to_s
return source if is_uri?(source)

source = rewrite_extension(source, dir, ext) if ext
source = rewrite_asset_path(source, dir)
source = rewrite_relative_url_root(source, relative_url_root) if has_request?
source = rewrite_host_and_protocol(source, protocol) if include_host
options[:include_host] ||= true
source = rewrite_extension(source, dir, options[:ext]) if options[:ext]
source = rewrite_asset_path(source, dir, options)
source = rewrite_relative_url_root(source, relative_url_root)
source = rewrite_host_and_protocol(source, options[:protocol]) if options[:include_host]
source
end

Expand Down Expand Up @@ -119,10 +120,11 @@ def compute_asset_host(source)
end

def relative_url_root
config = controller.config if controller.respond_to?(:config)
config ||= config.action_controller if config.action_controller.present?
config ||= config
config.relative_url_root
if config.action_controller.present?
config.action_controller.relative_url_root
else
config.relative_url_root
end
end

def asset_host_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def include_tag(*sources)

private

def path_to_asset(source, include_host = true, protocol = nil)
asset_paths.compute_public_path(source, asset_name.to_s.pluralize, extension, include_host, protocol)
def path_to_asset(source, options = {})
asset_paths.compute_public_path(source, asset_name.to_s.pluralize, options.merge(:ext => extension))
end

def path_to_asset_source(source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def rewrite_extension(source, dir, ext)

# Break out the asset path rewrite in case plugins wish to put the asset id
# someplace other than the query string.
def rewrite_asset_path(source, dir)
def rewrite_asset_path(source, dir, options = nil)
source = "/#{dir}/#{source}" unless source[0] == ?/
path = config.asset_path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def register_javascript_expansion(expansions)
# javascript_path "http://www.example.com/js/xmlhr" # => http://www.example.com/js/xmlhr
# javascript_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
def javascript_path(source)
asset_paths.compute_public_path(source, 'javascripts', 'js')
asset_paths.compute_public_path(source, 'javascripts', :ext => 'js')
end
alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extension

def asset_tag(source, options)
# We force the :request protocol here to avoid a double-download bug in IE7 and IE8
tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => ERB::Util.html_escape(path_to_asset(source, true, :request)) }.merge(options), false, false)
tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => ERB::Util.html_escape(path_to_asset(source, :protocol => :request)) }.merge(options), false, false)
end

def custom_dir
Expand Down Expand Up @@ -61,7 +61,7 @@ def register_stylesheet_expansion(expansions)
# stylesheet_path "http://www.example.com/css/style" # => http://www.example.com/css/style
# stylesheet_path "http://www.example.com/css/style.css" # => http://www.example.com/css/style.css
def stylesheet_path(source)
asset_paths.compute_public_path(source, 'stylesheets', 'css', true, :request)
asset_paths.compute_public_path(source, 'stylesheets', :ext => 'css', :protocol => :request)
end
alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route

Expand Down
5 changes: 4 additions & 1 deletion actionpack/lib/sprockets/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace :assets do
Kernel.exec $0, *ARGV
else
Rake::Task["environment"].invoke
Rake::Task["tmp:cache:clear"].invoke

# Ensure that action view is loaded and the appropriate sprockets hooks get executed
ActionView::Base
Expand All @@ -26,6 +27,8 @@ namespace :assets do
env.each_logical_path do |logical_path|
if path.is_a?(Regexp)
next unless path.match(logical_path)
elsif path.is_a?(Proc)
next unless path.call(logical_path)
else
next unless File.fnmatch(path.to_s, logical_path)
end
Expand All @@ -42,7 +45,7 @@ namespace :assets do
end
end

File.open("#{manifest_path}/manifest.yml", 'w') do |f|
File.open("#{manifest_path}/manifest.yml", 'wb') do |f|
YAML.dump(manifest, f)
end
end
Expand Down
28 changes: 15 additions & 13 deletions actionpack/lib/sprockets/helpers/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,40 @@ def javascript_include_tag(*sources)
options = sources.extract_options!
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
body = options.key?(:body) ? options.delete(:body) : false
digest = options.key?(:digest) ? options.delete(:digest) : digest_assets?

sources.collect do |source|
if debug && asset = asset_paths.asset_for(source, 'js')
asset.to_a.map { |dep|
super(dep.to_s, { :src => asset_path(dep, 'js', true) }.merge!(options))
super(dep.to_s, { :src => asset_path(dep, :ext => 'js', :body => true, :digest => digest) }.merge!(options))
}
else
super(source.to_s, { :src => asset_path(source, 'js', body) }.merge!(options))
super(source.to_s, { :src => asset_path(source, :ext => 'js', :body => body, :digest => digest) }.merge!(options))
end
end.join("\n").html_safe
end

def stylesheet_link_tag(*sources)
options = sources.extract_options!
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
body = options.key?(:body) ? options.delete(:body) : false
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
body = options.key?(:body) ? options.delete(:body) : false
digest = options.key?(:digest) ? options.delete(:digest) : digest_assets?

sources.collect do |source|
if debug && asset = asset_paths.asset_for(source, 'css')
asset.to_a.map { |dep|
super(dep.to_s, { :href => asset_path(dep, 'css', true, :request) }.merge!(options))
super(dep.to_s, { :href => asset_path(dep, :ext => 'css', :body => true, :protocol => :request, :digest => digest) }.merge!(options))
}
else
super(source.to_s, { :href => asset_path(source, 'css', body, :request) }.merge!(options))
super(source.to_s, { :href => asset_path(source, :ext => 'css', :body => body, :protocol => :request, :digest => digest) }.merge!(options))
end
end.join("\n").html_safe
end

def asset_path(source, default_ext = nil, body = false, protocol = nil)
def asset_path(source, options = {})
source = source.logical_path if source.respond_to?(:logical_path)
path = asset_paths.compute_public_path(source, 'assets', default_ext, true, protocol)
body ? "#{path}?body=1" : path
path = asset_paths.compute_public_path(source, 'assets', options.merge(:body => true))
options[:body] ? "#{path}?body=1" : path
end

private
Expand Down Expand Up @@ -105,8 +107,8 @@ class AssetPaths < ::ActionView::AssetPaths #:nodoc:

class AssetNotPrecompiledError < StandardError; end

def compute_public_path(source, dir, ext=nil, include_host=true, protocol=nil)
super(source, asset_prefix, ext, include_host, protocol)
def compute_public_path(source, dir, options = {})
super(source, asset_prefix, options)
end

# Return the filesystem path for the source
Expand Down Expand Up @@ -136,11 +138,11 @@ def digest_for(logical_path)
end
end

def rewrite_asset_path(source, dir)
def rewrite_asset_path(source, dir, options = {})
if source[0] == ?/
source
else
source = digest_for(source)
source = digest_for(source) unless options[:digest] == false
source = File.join(dir, source)
source = "/#{source}" unless source =~ /^\//
source
Expand Down
8 changes: 5 additions & 3 deletions actionpack/lib/sprockets/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ class Railtie < ::Rails::Railtie
end
end

app.routes.prepend do
mount app.assets => config.assets.prefix
if config.assets.compile
app.routes.prepend do
mount app.assets => config.assets.prefix
end
end

if config.action_controller.perform_caching
if config.assets.digest
app.assets = app.assets.index
end
end
Expand Down
19 changes: 19 additions & 0 deletions actionpack/test/controller/assert_select_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def test(html)
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
Expand Down Expand Up @@ -313,6 +322,16 @@ def test_assert_select_email
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
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/http_basic_authentication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def authenticate_long_credentials
end
end

def test_encode_credentials_has_no_newline
username = 'laskjdfhalksdjfhalkjdsfhalksdjfhklsdjhalksdjfhalksdjfhlakdsjfh'
password = 'kjfhueyt9485osdfasdkljfh4lkjhakldjfhalkdsjf'
result = ActionController::HttpAuthentication::Basic.encode_credentials(
username, password)
assert_no_match(/\n/, result)
end

test "authentication request without credential" do
get :display

Expand Down
Loading

0 comments on commit 4b2c9a9

Please sign in to comment.