Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '3-1-stable' into 3-1-0

* 3-1-stable: (21 commits)
  Added a test to check for correct behaviour with no options in add_index command recorder
  Using .try to test for the existence of a method option in a nil-resistent manner. Inlined the determination of the options hash for reversing using a ternary operator. Shortens the method in a way that keeps the code neat
  Neatened up the invert_add_index method as per suggeston
  Simple fix for correctly inverting an add_index migration when a name has been provided
  Merge pull request #2524 from JonathonMA/fix_ecd37084b28a05f05251
  Fix Sprockets rewrite_asset_path
  Merge pull request #2620 from cesario/3-1-0
  Fix sprockets warnings
  Use typewriter styling on url_for in documentation
  Merge pull request #2609 from guilleiguaran/bump-sprockets-beta14
  remove extra space since comment_if already returns the space. (cherry picked from commit 5e73a2f)
  Merge pull request #2596 from dharmatech/patch-1
  Merge pull request #2595 from smartinez87/assets-guide
  Merge pull request #2597 from dharmatech/patch-2
  Merge pull request #2604 from vijaydev/params_wrapper_docs
  Merge pull request #2602 from ernie/fix_predicate_builder_primary_key_assumption
  Merge pull request #2603 from vijaydev/guides
  Merge pull request #2581 from guilleiguaran/debug-assets-in-dev
  Revert "Deprecate the use of non-public methods by Module#delegate"
  mailer guide: fixes indentation, and use fixed width fonts wherever necessary
  ...
  • Loading branch information...
commit 1f1d4aa939772b0f3f8869adfc4812912b690f90 2 parents c2ab1b1 + 2f20c6c
@tenderlove tenderlove authored
View
9 actionpack/lib/sprockets/assets.rake
@@ -13,17 +13,20 @@ namespace :assets do
# Ensure that action view is loaded and the appropriate sprockets hooks get executed
ActionView::Base
- assets = Rails.application.config.assets.precompile
# Always perform caching so that asset_path appends the timestamps to file references.
Rails.application.config.action_controller.perform_caching = true
+
+ config = Rails.application.config
+ assets = config.assets.precompile.dup
+ assets << {:to => File.join(Rails.public_path, config.assets.prefix)}
Rails.application.assets.precompile(*assets)
end
end
desc "Remove compiled assets"
task :clean => [:environment, 'tmp:cache:clear'] do
- assets = Rails.application.config.assets
- public_asset_path = Rails.public_path + assets.prefix
+ config = Rails.application.config
+ public_asset_path = File.join(Rails.public_path, config.assets.prefix)
rm_rf public_asset_path, :secure => true
end
end
View
13 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -112,11 +112,22 @@ def asset_for(source, ext)
asset_environment[source]
end
+ def digest_for(logical_path)
+ if asset = asset_environment[logical_path]
+ return asset.digest_path
+ end
+
+ logical_path
+ end
+
def rewrite_asset_path(source, dir)
if source[0] == ?/
source
else
- asset_environment.path(source, performing_caching?, dir)
+ source = digest_for(source) if performing_caching?
+ source = File.join(dir, source)
+ source = "/#{source}" unless source =~ /^\//
+ source
end
end
View
5 actionpack/lib/sprockets/railtie.rb
@@ -18,9 +18,8 @@ class Railtie < ::Rails::Railtie
require 'sprockets'
app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
- env.static_root = File.join(app.root.join('public'), config.assets.prefix)
- env.logger = ::Rails.logger
- env.version = ::Rails.env + "#{'-' + config.assets.version if config.assets.version.present?}"
+ env.logger = ::Rails.logger
+ env.version = ::Rails.env + "-#{config.assets.version}"
if config.assets.cache_store != false
env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache
View
6 activerecord/lib/active_record/migration/command_recorder.rb
@@ -79,8 +79,10 @@ def invert_rename_column(args)
end
def invert_add_index(args)
- table, columns, _ = *args
- [:remove_index, [table, {:column => columns}]]
+ table, columns, options = *args
+ index_name = options.try(:[], :name)
+ options_hash = index_name ? {:name => index_name} : {:column => columns}
+ [:remove_index, [table, options_hash]]
end
def invert_remove_timestamps(args)
View
2  activerecord/lib/active_record/relation/predicate_builder.rb
@@ -19,7 +19,7 @@ def self.build_from_hash(engine, attributes, default_table)
case value
when ActiveRecord::Relation
- value.select_values = [value.klass.arel_table['id']] if value.select_values.empty?
+ value = value.select(value.klass.arel_table[value.klass.primary_key]) if value.select_values.empty?
attribute.in(value.arel.ast)
when Array, ActiveRecord::Associations::CollectionProxy
values = value.to_a.map { |x|
View
12 activerecord/test/cases/migration/command_recorder_test.rb
@@ -91,6 +91,18 @@ def test_invert_add_index
assert_equal [:remove_index, [:table, {:column => [:one, :two]}]], remove
end
+ def test_invert_add_index_with_name
+ @recorder.record :add_index, [:table, [:one, :two], {:name => "new_index"}]
+ remove = @recorder.inverse.first
+ assert_equal [:remove_index, [:table, {:name => "new_index"}]], remove
+ end
+
+ def test_invert_add_index_with_no_options
+ @recorder.record :add_index, [:table, [:one, :two]]
+ remove = @recorder.inverse.first
+ assert_equal [:remove_index, [:table, {:column => [:one, :two]}]], remove
+ end
+
def test_invert_rename_index
@recorder.record :rename_index, [:old, :new]
rename = @recorder.inverse.first
View
23 activerecord/test/cases/relations_test.rb
@@ -531,6 +531,29 @@ def test_find_all_using_where_with_relation
}
end
+ def test_find_all_using_where_with_relation_and_alternate_primary_key
+ cool_first = minivans(:cool_first)
+ # switching the lines below would succeed in current rails
+ # assert_queries(2) {
+ assert_queries(1) {
+ relation = Minivan.where(:minivan_id => Minivan.where(:name => cool_first.name))
+ assert_equal [cool_first], relation.all
+ }
+ end
+
+ def test_find_all_using_where_with_relation_does_not_alter_select_values
+ david = authors(:david)
+
+ subquery = Author.where(:id => david.id)
+
+ assert_queries(1) {
+ relation = Author.where(:id => subquery)
+ assert_equal [david], relation.all
+ }
+
+ assert_equal 0, subquery.select_values.size
+ end
+
def test_find_all_using_where_with_relation_with_joins
david = authors(:david)
assert_queries(1) {
View
2  railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -4,7 +4,7 @@
require 'rails/all'
<% else -%>
# Pick the frameworks you want:
-<%= comment_if :skip_active_record %> require "active_record/railtie"
+<%= comment_if :skip_active_record %>require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
Please sign in to comment.
Something went wrong with that request. Please try again.