aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG.md5
-rw-r--r--actionpack/actionpack.gemspec2
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb7
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb15
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb9
-rw-r--r--activerecord/CHANGELOG.md24
-rw-r--r--activerecord/lib/active_record/associations.rb1
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb22
-rw-r--r--activerecord/lib/active_record/railties/databases.rake4
-rw-r--r--activerecord/lib/active_record/store.rb2
-rw-r--r--activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb5
-rw-r--r--activerecord/test/cases/store_test.rb11
-rw-r--r--activerecord/test/models/admin/user.rb1
-rw-r--r--activerecord/test/schema/schema.rb5
-rw-r--r--railties/test/application/assets_test.rb31
15 files changed, 105 insertions, 39 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index cc1c6ba46b..9d413c8fb3 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,8 @@
+## Rails 3.2.9 (unreleased) ##
+
+* `javascript_include_tag :all` will now not include `application.js` if the file does not exists. *Prem Sichanugrist*
+
+
## Rails 3.2.8 (Aug 9, 2012) ##
* There is an XSS vulnerability in the strip_tags helper in Ruby on Rails, the
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index ac2040935f..3d67541557 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
s.add_dependency('rack', '~> 1.4.0')
s.add_dependency('rack-test', '~> 0.6.1')
s.add_dependency('journey', '~> 1.0.4')
- s.add_dependency('sprockets', '~> 2.1.3')
+ s.add_dependency('sprockets', '~> 2.1')
s.add_dependency('erubis', '~> 2.7.0')
s.add_development_dependency('tzinfo', '~> 0.3.29')
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index ac784b3b60..a4c6c84939 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -18,8 +18,8 @@ module ActionDispatch
# a Hash, or a String that is appropriately encoded
# (<tt>application/x-www-form-urlencoded</tt> or
# <tt>multipart/form-data</tt>).
- # - +headers+: Additional HTTP headers to pass, as a Hash. The keys will
- # automatically be upcased, with the prefix 'HTTP_' added if needed.
+ # - +headers+: Additional headers to pass, as a Hash. The headers will be
+ # merged into the Rack env hash.
#
# This method returns an Response object, which one can use to
# inspect the details of the response. Furthermore, if this method was
@@ -62,8 +62,7 @@ module ActionDispatch
#
# The request_method is +:get+, +:post+, +:put+, +:delete+ or +:head+; the
# parameters are +nil+, a hash, or a url-encoded or multipart string;
- # the headers are a hash. Keys are automatically upcased and prefixed
- # with 'HTTP_' if not already.
+ # the headers are a hash.
def xml_http_request(request_method, path, parameters = nil, headers = nil)
headers ||= {}
headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
index d9f1f88ade..b79b625c12 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
@@ -27,7 +27,8 @@ module ActionView
def expand_sources(sources, recursive = false)
if sources.include?(:all)
- all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application']) << 'application'
+ all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application'])
+ add_application_js(all_asset_files, sources)
((determine_source(:defaults, expansions).dup & all_asset_files) + all_asset_files).uniq
else
expanded_sources = sources.inject([]) do |list, source|
@@ -40,7 +41,7 @@ module ActionView
end
def add_application_js(expanded_sources, sources)
- if sources.include?(:defaults) && File.exist?(File.join(custom_dir, "application.#{extension}"))
+ if (sources.include?(:defaults) || sources.include?(:all)) && File.exist?(File.join(custom_dir, "application.#{extension}"))
expanded_sources.delete('application')
expanded_sources << "application"
end
@@ -101,8 +102,8 @@ module ActionView
#
# config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js)
#
- # When using <tt>:defaults</tt>, if an <tt>application.js</tt> file exists in
- # <tt>public/javascripts</tt> it will be included as well at the end.
+ # When using <tt>:defaults</tt> or <tt>:all</tt>, if an <tt>application.js</tt> file exists
+ # in <tt>public/javascripts</tt> it will be included as well at the end.
#
# You can modify the HTML attributes of the script tag by passing a hash as the
# last argument.
@@ -129,16 +130,16 @@ module ActionView
# # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
#
- # * = The application.js file is only referenced if it exists
+ # Note: The application.js file is only referenced if it exists
#
# You can also include all JavaScripts in the +javascripts+ directory using <tt>:all</tt> as the source:
#
# javascript_include_tag :all
# # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/shop.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/checkout.js?1284139606"></script>
+ # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
#
# Note that your defaults of choice will be included first, so they will be available to all subsequently
# included files.
@@ -161,9 +162,9 @@ module ActionView
# javascript_include_tag :all, :cache => true
# # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/shop.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/checkout.js?1284139606"></script>
+ # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
#
# # assuming config.perform_caching is true
# javascript_include_tag :all, :cache => true
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 6a0fdf0590..b1a01b53b1 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -338,6 +338,15 @@ class AssetTagHelperTest < ActionView::TestCase
assert_raise(ArgumentError) { javascript_include_tag(:defaults) }
end
+ def test_all_javascript_expansion_not_include_application_js_if_not_exists
+ FileUtils.mv(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.js'),
+ File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.bak'))
+ assert_no_match(/application\.js/, javascript_include_tag(:all))
+ ensure
+ FileUtils.mv(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.bak'),
+ File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'application.js'))
+ end
+
def test_stylesheet_path
ENV["RAILS_ASSET_ID"] = ""
StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 44a58e0bee..69387cd77c 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,21 @@
+## Rails 3.2.9 (unreleased)
+
+* Allow store to work with an empty column.
+ Fix #4840.
+
+ *Jeremy Walker*
+
+* Remove prepared statement from system query in postgresql adapter.
+ Fix #5872.
+
+ *Ivan Evtuhovich*
+
+* Make sure `:environment` task is executed before `db:schema:load` or `db:structure:load`
+ Fixes #4772.
+
+ *Seamus Abshere*
+
+
## Rails 3.2.8 (Aug 9, 2012) ##
* Do not consider the numeric attribute as changed if the old value is zero and the new value
@@ -6,6 +24,12 @@
*Rafael Mendonça França*
+* Do not consider the numeric attribute as changed if the old value is zero and the new value
+ is not a string.
+ Fixes #7237.
+
+ *Rafael Mendonça França*
+
* Removes the deprecation of `update_attribute`. *fxn*
* Reverted the deprecation of `composed_of`. *Rafael Mendonça França*
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 8ebb27b682..5aa9e26fa6 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -105,6 +105,7 @@ module ActiveRecord
# See ActiveRecord::Associations::ClassMethods for documentation.
module Associations # :nodoc:
+ extend ActiveSupport::Autoload
extend ActiveSupport::Concern
# These classes will be loaded when associations are created.
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index cd565787b3..3dfd150d5a 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -795,22 +795,22 @@ module ActiveRecord
binds = [[nil, table]]
binds << [nil, schema] if schema
- exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
+ exec_query(<<-SQL, 'SCHEMA').rows.first[0].to_i > 0
SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
- AND c.relname = $1
- AND n.nspname = #{schema ? '$2' : 'ANY (current_schemas(false))'}
+ AND c.relname = '#{table.gsub(/(^"|"$)/,'')}'
+ AND n.nspname = #{schema ? "'#{schema}'" : 'ANY (current_schemas(false))'}
SQL
end
# Returns true if schema exists.
def schema_exists?(name)
- exec_query(<<-SQL, 'SCHEMA', [[nil, name]]).rows.first[0].to_i > 0
+ exec_query(<<-SQL, 'SCHEMA').rows.first[0].to_i > 0
SELECT COUNT(*)
FROM pg_namespace
- WHERE nspname = $1
+ WHERE nspname = '#{name}'
SQL
end
@@ -914,8 +914,8 @@ module ActiveRecord
end
def serial_sequence(table, column)
- result = exec_query(<<-eosql, 'SCHEMA', [[nil, table], [nil, column]])
- SELECT pg_get_serial_sequence($1, $2)
+ result = exec_query(<<-eosql, 'SCHEMA')
+ SELECT pg_get_serial_sequence('#{table}', '#{column}')
eosql
result.rows.first.first
end
@@ -992,13 +992,13 @@ module ActiveRecord
# Returns just a table's primary key
def primary_key(table)
- row = exec_query(<<-end_sql, 'SCHEMA', [[nil, table]]).rows.first
+ row = exec_query(<<-end_sql, 'SCHEMA').rows.first
SELECT DISTINCT(attr.attname)
FROM pg_attribute attr
INNER JOIN pg_depend dep ON attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
- AND dep.refobjid = $1::regclass
+ AND dep.refobjid = '#{table}'::regclass
end_sql
row && row.first
@@ -1108,7 +1108,7 @@ module ActiveRecord
# Construct a clean list of column names from the ORDER BY clause, removing
# any ASC/DESC modifiers
- order_columns = orders.collect { |s| s.gsub(/\s+(ASC|DESC)\s*/i, '') }
+ order_columns = orders.collect { |s| s.gsub(/\s+(ASC|DESC)\s*(NULLS\s+(FIRST|LAST)\s*)?/i, '') }
order_columns.delete_if { |c| c.blank? }
order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| "#{s} AS alias_#{i}" }
@@ -1243,7 +1243,7 @@ module ActiveRecord
# Returns the current ID of a table's sequence.
def last_insert_id(sequence_name) #:nodoc:
- r = exec_query("SELECT currval($1)", 'SQL', [[nil, sequence_name]])
+ r = exec_query("SELECT currval('#{sequence_name}')", 'SQL')
Integer(r.rows.first.first)
end
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 79032fe4df..83d9126ccb 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -369,7 +369,7 @@ db_namespace = namespace :db do
end
end
- task :load_if_ruby => 'db:create' do
+ task :load_if_ruby => [:environment, 'db:create'] do
db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby
end
end
@@ -445,7 +445,7 @@ db_namespace = namespace :db do
end
end
- task :load_if_sql => 'db:create' do
+ task :load_if_sql => [:environment, 'db:create'] do
db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql
end
end
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb
index 8cc84f81d0..49d01de365 100644
--- a/activerecord/lib/active_record/store.rb
+++ b/activerecord/lib/active_record/store.rb
@@ -36,11 +36,13 @@ module ActiveRecord
def store_accessor(store_attribute, *keys)
Array(keys).flatten.each do |key|
define_method("#{key}=") do |value|
+ send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash)
send(store_attribute)[key] = value
send("#{store_attribute}_will_change!")
end
define_method(key) do
+ send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash)
send(store_attribute)[key]
end
end
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
index d57794daf8..3eb73d3093 100644
--- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
@@ -179,6 +179,11 @@ module ActiveRecord
assert_equal Arel.sql('$2'), bind
end
+ def test_distinct_with_nulls
+ assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls first"])
+ assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls last"])
+ end
+
private
def insert(ctx, data)
binds = data.map { |name, value|
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb
index 5a3f9a9711..277fc9d676 100644
--- a/activerecord/test/cases/store_test.rb
+++ b/activerecord/test/cases/store_test.rb
@@ -4,7 +4,7 @@ require 'models/admin/user'
class StoreTest < ActiveRecord::TestCase
setup do
- @john = Admin::User.create(:name => 'John Doe', :color => 'black')
+ @john = Admin::User.create(:name => 'John Doe', :color => 'black', :remember_login => true)
end
test "reading store attributes through accessors" do
@@ -31,4 +31,13 @@ class StoreTest < ActiveRecord::TestCase
@john.color = 'red'
assert @john.settings_changed?
end
+
+ test "object initialization with not nullable column" do
+ assert_equal true, @john.remember_login
+ end
+
+ test "writing with not nullable column" do
+ @john.remember_login = false
+ assert_equal false, @john.remember_login
+ end
end
diff --git a/activerecord/test/models/admin/user.rb b/activerecord/test/models/admin/user.rb
index c12c88e195..d0e628bd50 100644
--- a/activerecord/test/models/admin/user.rb
+++ b/activerecord/test/models/admin/user.rb
@@ -1,4 +1,5 @@
class Admin::User < ActiveRecord::Base
belongs_to :account
store :settings, :accessors => [ :color, :homepage ]
+ store :preferences, :accessors => [ :remember_login ]
end
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index d6eed1552f..2b7ea0ce34 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -37,7 +37,10 @@ ActiveRecord::Schema.define do
create_table :admin_users, :force => true do |t|
t.string :name
- t.text :settings
+ t.string :settings, :null => true, :limit => 1024
+ # MySQL does not allow default values for blobs. Fake it out with a
+ # big varchar below.
+ t.string :preferences, :null => true, :default => '', :limit => 1024
t.references :account
end
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index ba32e4904f..6e638ed85f 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -83,9 +83,8 @@ module ApplicationTests
images_should_compile = ["a.png", "happyface.png", "happy_face.png", "happy.face.png",
"happy-face.png", "happy.happy_face.png", "happy_happy.face.png",
- "happy.happy.face.png", "happy", "happy.face", "-happyface",
- "-happy.png", "-happy.face.png", "_happyface", "_happy.face.png",
- "_happy.png"]
+ "happy.happy.face.png", "-happy.png", "-happy.face.png",
+ "_happy.face.png", "_happy.png"]
images_should_compile.each do |filename|
app_file "app/assets/images/#{filename}", "happy"
@@ -94,20 +93,28 @@ module ApplicationTests
precompile!
images_should_compile.each do |filename|
- assert File.exists?("#{app_path}/public/assets/#{filename}")
+ assert_file_exists "#{app_path}/public/assets/#{filename}"
end
- assert File.exists?("#{app_path}/public/assets/application.js")
- assert File.exists?("#{app_path}/public/assets/application.css")
+ assert_file_exists("#{app_path}/public/assets/application.js")
+ assert_file_exists("#{app_path}/public/assets/application.css")
+
+ assert_no_file_exists("#{app_path}/public/assets/someapplication.js")
+ assert_no_file_exists("#{app_path}/public/assets/someapplication.css")
- assert !File.exists?("#{app_path}/public/assets/someapplication.js")
- assert !File.exists?("#{app_path}/public/assets/someapplication.css")
+ assert_no_file_exists("#{app_path}/public/assets/something.min.js")
+ assert_no_file_exists("#{app_path}/public/assets/something.min.css")
- assert !File.exists?("#{app_path}/public/assets/something.min.js")
- assert !File.exists?("#{app_path}/public/assets/something.min.css")
+ assert_no_file_exists("#{app_path}/public/assets/something.else.js")
+ assert_no_file_exists("#{app_path}/public/assets/something.else.css")
+ end
+
+ def assert_file_exists(filename)
+ assert File.exists?(filename), "missing #{filename}"
+ end
- assert !File.exists?("#{app_path}/public/assets/something.else.js")
- assert !File.exists?("#{app_path}/public/assets/something.else.css")
+ def assert_no_file_exists(filename)
+ assert !File.exists?(filename), "#{filename} does exist"
end
test "precompile something.js for directory containing index file" do