Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 18 commits
  • 28 files changed
  • 0 commit comments
  • 11 contributors
Commits on May 28, 2012
Bartłomiej Kozal bkzl Display annotations from .coffee files in `rake notes` 4ababde
Commits on May 29, 2012
James Mead floehopper Exceptions like Interrupt should not be rescued in tests.
This is a back-port of rails/rails#6525. See the commit notes there for
details.
0813b45
Rafael Mendonça França rafaelfranca Merge pull request #6531 from freerange/3-2-stable-minitest-passthrou…
…gh-exceptions

Exceptions like Interrupt should not be rescued in tests.
12e5c72
Commits on May 30, 2012
Oscar Del Ben oscardelben Remove irrelevant assertion 2f71d40
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #6519 from oscardelben/3-2-stable
Display annotations in coffee files
f09ae85
Erich Menge True, False, and Nil should be represented in as_json as themselves.
Conflicts:

	activesupport/lib/active_support/json/encoding.rb
	activesupport/test/json/encoding_test.rb
624f801
Aaron Patterson tenderlove Merge pull request #5810 from kennyj/fix_5797
Fix #5797. Error calling dup method on AR model with serialized field
Conflicts:
	activerecord/lib/active_record/core.rb
c470001
Erich Menge Deprecate ActiveSupport::JSON::Variable bcfa013
Piotr Sarnacki drogus Merge pull request #6553 from erichmenge/3-2-stable-json-patch
3 2 stable json patch
9f1b689
Rafael Mendonça França rafaelfranca Merge pull request #6477 from steveklabnik/close_discovered_pg_connec…
…tion

Properly discover a connection is closed in postgresql_adapter
b6727a1
Commits on May 31, 2012
Philip Arndt parndt Revert "Removes unneeded caching from ActiveRecord::Base.relation"
This reverts commit ebfa58a.

This change caused a regression in my application's tests:

* Failing build http://travis-ci.org/#!/resolve/refinerycms/builds/1461242

Broken tests pass after this change is reverted.
4ce7f98
Aaron Patterson tenderlove Merge pull request #6558 from parndt/fix_regression
Fix regression
4c8805d
Martin O'Connor Changed symbol platform to platforms for the commented out call to ge…
…m 'therubyracer'.

Dependency.rb expects the symbol to be named :platforms as opposed to platform. RubyMine's inspections indicate that the symbol should be named :platforms.
Updating tests.
9bbdceb
Rafael Mendonça França rafaelfranca Merge pull request #6562 from martinoconnor/generator-fix-stable
3-2-stable Changed symbol platform to platforms for the commented out call to gem 'therubyracer'.
f8f6ad6
Aaron Patterson tenderlove Merge branch '3-2-stable-sec' into 3-2-stable
* 3-2-stable-sec:
  Strip [nil] from parameters hash. Thanks to Ben Murphy for reporting this!
  predicate builder should not recurse for determining where columns. Thanks to Ben Murphy for reporting this
  bumping to 3.2.4.rc1
d66fd08
Aaron Patterson tenderlove Merge branch '3-2-rel' into 3-2-stable
* 3-2-rel:
  bumping to 3.2.4
  adding security notifications to CHANGELOGs
  updating changelogs
  Merge pull request #6558 from parndt/fix_regression
4df9680
Commits on Jun 01, 2012
Andrew White pixeltrix Restore behavior of Active Record 3.2.3 scopes
A series of commits relating to preloading and scopes caused a regression.
Cloning the relation calls initialize_copy which resets a number of instance
variables to nil. Without this the scope thinks that it is already loaded
when it is called again.

Reverts the following commits:
13f1401
8491740
dffbb52

Fixes #6575, #6576 & #6577
7056079
Aaron Patterson tenderlove bumping to 3.2.5 b57fa0b
Showing with 122 additions and 67 deletions.
  1. +1 1  RAILS_VERSION
  2. +1 1  actionmailer/lib/action_mailer/version.rb
  3. +1 1  actionpack/lib/action_pack/version.rb
  4. +1 1  activemodel/lib/active_model/version.rb
  5. +2 3 activerecord/lib/active_record/associations/preloader/association.rb
  6. +4 3 activerecord/lib/active_record/attribute_methods/serialization.rb
  7. +1 1  activerecord/lib/active_record/base.rb
  8. +2 1  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  9. +1 1  activerecord/lib/active_record/locking/optimistic.rb
  10. +2 2 activerecord/lib/active_record/scoping/named.rb
  11. +1 1  activerecord/lib/active_record/version.rb
  12. +0 24 activerecord/test/cases/associations/eager_test.rb
  13. +9 0 activerecord/test/cases/base_test.rb
  14. +0 2  activerecord/test/models/comment.rb
  15. +1 1  activeresource/lib/active_resource/version.rb
  16. +3 0  activesupport/CHANGELOG.md
  17. +6 6 activesupport/lib/active_support/json/encoding.rb
  18. +9 1 activesupport/lib/active_support/json/variable.rb
  19. +5 0 activesupport/lib/active_support/testing/setup_and_teardown.rb
  20. +1 1  activesupport/lib/active_support/version.rb
  21. +14 3 activesupport/test/json/encoding_test.rb
  22. +42 2 activesupport/test/test_case_test.rb
  23. +1 1  railties/lib/rails/generators/app_base.rb
  24. +2 2 railties/lib/rails/source_annotation_extractor.rb
  25. +1 1  railties/lib/rails/version.rb
  26. +9 5 railties/test/application/rake/notes_test.rb
  27. +1 1  railties/test/generators/app_generator_test.rb
  28. +1 1  version.rb
2  RAILS_VERSION
View
@@ -1 +1 @@
-3.2.4
+3.2.5
2  actionmailer/lib/action_mailer/version.rb
View
@@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
2  actionpack/lib/action_pack/version.rb
View
@@ -2,7 +2,7 @@ module ActionPack
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
2  activemodel/lib/active_model/version.rb
View
@@ -2,7 +2,7 @@ module ActiveModel
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
5 activerecord/lib/active_record/associations/preloader/association.rb
View
@@ -77,7 +77,7 @@ def associated_records_by_owner
# Some databases impose a limit on the number of ids in a list (in Oracle it's 1000)
# Make several smaller queries if necessary or make one query if the adapter supports it
sliced = owner_keys.each_slice(model.connection.in_clause_length || owner_keys.size)
- records = sliced.map { |slice| records_for(slice).to_a }.flatten
+ records = sliced.map { |slice| records_for(slice) }.flatten
end
# Each record may have multiple owners, and vice-versa
@@ -93,8 +93,7 @@ def associated_records_by_owner
end
def build_scope
- scope = klass.unscoped
- scope.default_scoped = true
+ scope = klass.scoped
scope = scope.where(process_conditions(options[:conditions]))
scope = scope.where(process_conditions(preload_options[:conditions]))
7 activerecord/lib/active_record/attribute_methods/serialization.rb
View
@@ -58,12 +58,13 @@ def serialize(attr_name, class_name = Object)
self.serialized_attributes = serialized_attributes.merge(attr_name.to_s => coder)
end
- def initialize_attributes(attributes) #:nodoc:
- super
+ def initialize_attributes(attributes, options = {}) #:nodoc:
+ serialized = (options.delete(:serialized) { true }) ? :serialized : :unserialized
+ super(attributes, options)
serialized_attributes.each do |key, coder|
if attributes.key?(key)
- attributes[key] = Attribute.new(coder, attributes[key], :serialized)
+ attributes[key] = Attribute.new(coder, attributes[key], serialized)
end
end
2  activerecord/lib/active_record/base.rb
View
@@ -534,7 +534,7 @@ def init_with(coder)
# The dup method does not preserve the timestamps (created|updated)_(at|on).
def initialize_dup(other)
cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)
- self.class.initialize_attributes(cloned_attributes)
+ self.class.initialize_attributes(cloned_attributes, :serialized => false)
cloned_attributes.delete(self.class.primary_key)
3  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
@@ -344,7 +344,8 @@ def clear_cache!
# Is this connection alive and ready for queries?
def active?
- @connection.status == PGconn::CONNECTION_OK
+ @connection.query 'SELECT 1'
+ true
rescue PGError
false
end
2  activerecord/lib/active_record/locking/optimistic.rb
View
@@ -170,7 +170,7 @@ def update_counters(id, counters)
# start the lock version at zero. Note we can't use
# <tt>locking_enabled?</tt> at this point as
# <tt>@attributes</tt> may not have been initialized yet.
- def initialize_attributes(attributes) #:nodoc:
+ def initialize_attributes(attributes, options = {}) #:nodoc:
if attributes.key?(locking_column) && lock_optimistically
attributes[locking_column] ||= 0
end
4 activerecord/lib/active_record/scoping/named.rb
View
@@ -34,7 +34,7 @@ def scoped(options = nil)
if current_scope
current_scope.clone
else
- scope = relation
+ scope = relation.clone
scope.default_scoped = true
scope
end
@@ -48,7 +48,7 @@ def scope_attributes # :nodoc:
if current_scope
current_scope.scope_for_create
else
- scope = relation
+ scope = relation.clone
scope.default_scoped = true
scope.scope_for_create
end
2  activerecord/lib/active_record/version.rb
View
@@ -2,7 +2,7 @@ module ActiveRecord
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
24 activerecord/test/cases/associations/eager_test.rb
View
@@ -1095,28 +1095,4 @@ def test_join_eager_with_nil_order_should_generate_valid_sql
Post.includes(:comments).order(nil).where(:comments => {:body => "Thank you for the welcome"}).first
end
end
-
- def test_deep_including_through_habtm
- posts = Post.find(:all, :include => {:categories => :categorizations}, :order => "posts.id, categories.id")
- assert_no_queries { assert_equal 2, posts[0].categories[0].categorizations.length }
- assert_no_queries { assert_equal 1, posts[0].categories[1].categorizations.length }
- assert_no_queries { assert_equal 2, posts[1].categories[0].categorizations.length }
- end
-
- test "scoping with a circular preload" do
- assert_equal Comment.find(1), Comment.preload(:post => :comments).scoping { Comment.find(1) }
- end
-
- test "circular preload does not modify unscoped" do
- expected = FirstPost.unscoped.find(2)
- FirstPost.preload(:comments => :first_post).find(1)
- assert_equal expected, FirstPost.unscoped.find(2)
- end
-
- test "preload ignores the scoping" do
- assert_equal(
- Comment.find(1).post,
- Post.where('1 = 0').scoping { Comment.preload(:post).find(1).post }
- )
- end
end
9 activerecord/test/cases/base_test.rb
View
@@ -1280,6 +1280,15 @@ def test_serialized_attribute_before_type_cast_returns_unserialized_value
assert_equal({ :foo => :bar }, t.content_before_type_cast)
end
+ def test_serialized_attribute_calling_dup_method
+ klass = Class.new(ActiveRecord::Base)
+ klass.table_name = "topics"
+ klass.serialize :content, JSON
+
+ t = klass.new(:content => { :foo => :bar }).dup
+ assert_equal({ :foo => :bar }, t.content_before_type_cast)
+ end
+
def test_serialized_attribute_declared_in_subclass
hash = { 'important1' => 'value1', 'important2' => 'value2' }
important_topic = ImportantTopic.create("important" => hash)
2  activerecord/test/models/comment.rb
View
@@ -11,8 +11,6 @@ class Comment < ActiveRecord::Base
belongs_to :post, :counter_cache => true
has_many :ratings
- belongs_to :first_post, :foreign_key => :post_id
-
has_many :children, :class_name => 'Comment', :foreign_key => :parent_id
belongs_to :parent, :class_name => 'Comment', :counter_cache => :children_count
2  activeresource/lib/active_resource/version.rb
View
@@ -2,7 +2,7 @@ module ActiveResource
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
3  activesupport/CHANGELOG.md
View
@@ -3,6 +3,9 @@
* Added #beginning_of_hour and #end_of_hour to Time and DateTime core
extensions. *Mark J. Titorenko*
+* ActiveSupport::JSON::Variable is deprecated. Define your own #as_json and #encode_json methods
+ for custom JSON string literals. *Erich Menge*
+
## Rails 3.2.3 (March 30, 2012) ##
12 activesupport/lib/active_support/json/encoding.rb
View
@@ -158,18 +158,18 @@ def as_json(options = nil)
end
class TrueClass
- AS_JSON = ActiveSupport::JSON::Variable.new('true').freeze
- def as_json(options = nil) AS_JSON end #:nodoc:
+ def as_json(options = nil) self end #:nodoc:
+ def encode_json(encoder) to_s end #:nodoc:
end
class FalseClass
- AS_JSON = ActiveSupport::JSON::Variable.new('false').freeze
- def as_json(options = nil) AS_JSON end #:nodoc:
+ def as_json(options = nil) self end #:nodoc:
+ def encode_json(encoder) to_s end #:nodoc:
end
class NilClass
- AS_JSON = ActiveSupport::JSON::Variable.new('null').freeze
- def as_json(options = nil) AS_JSON end #:nodoc:
+ def as_json(options = nil) self end #:nodoc:
+ def encode_json(encoder) 'null' end #:nodoc:
end
class String
10 activesupport/lib/active_support/json/variable.rb
View
@@ -1,7 +1,15 @@
+require 'active_support/deprecation'
+
module ActiveSupport
module JSON
- # A string that returns itself as its JSON-encoded form.
+ # Deprecated: A string that returns itself as its JSON-encoded form.
class Variable < String
+ def initialize(*args)
+ ActiveSupport::Deprecation.warn 'ActiveSupport::JSON::Variable is deprecated and will be removed in Rails 4.0. ' \
+ 'For your own custom JSON literals, define #as_json and #encode_json yourself.'
+ super
+ end
+
def as_json(options = nil) self end #:nodoc:
def encode_json(encoder) self end #:nodoc:
end
5 activesupport/lib/active_support/testing/setup_and_teardown.rb
View
@@ -28,17 +28,22 @@ def teardown(*args, &block)
end
module ForMiniTest
+ PASSTHROUGH_EXCEPTIONS = MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS rescue [NoMemoryError, SignalException, Interrupt, SystemExit]
def run(runner)
result = '.'
begin
run_callbacks :setup do
result = super
end
+ rescue *PASSTHROUGH_EXCEPTIONS => e
+ raise e
rescue Exception => e
result = runner.puke(self.class, method_name, e)
ensure
begin
run_callbacks :teardown
+ rescue *PASSTHROUGH_EXCEPTIONS => e
+ raise e
rescue Exception => e
result = runner.puke(self.class, method_name, e)
end
2  activesupport/lib/active_support/version.rb
View
@@ -2,7 +2,7 @@ module ActiveSupport
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
17 activesupport/test/json/encoding_test.rb
View
@@ -3,7 +3,7 @@
require 'active_support/core_ext/string/inflections'
require 'active_support/json'
-class TestJSONEncoding < Test::Unit::TestCase
+class TestJSONEncoding < ActiveSupport::TestCase
class Foo
def initialize(a, b)
@a, @b = a, b
@@ -46,8 +46,6 @@ def as_json(options)
HashlikeTests = [[ Hashlike.new, %({\"a\":1}) ]]
CustomTests = [[ Custom.new, '"custom"' ]]
- VariableTests = [[ ActiveSupport::JSON::Variable.new('foo'), 'foo'],
- [ ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")']]
RegexpTests = [[ /^a/, '"(?-mix:^a)"' ], [/^\w{1,2}[a-z]+/ix, '"(?ix-m:^\\\\w{1,2}[a-z]+)"']]
DateTests = [[ Date.new(2005,2,1), %("2005/02/01") ]]
@@ -79,6 +77,13 @@ def sorted_json(json)
end
end
+ def test_json_variable
+ assert_deprecated do
+ assert_equal ActiveSupport::JSON::Variable.new('foo'), 'foo'
+ assert_equal ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")'
+ end
+ end
+
def test_hash_encoding
assert_equal %({\"a\":\"b\"}), ActiveSupport::JSON.encode(:a => :b)
assert_equal %({\"a\":1}), ActiveSupport::JSON.encode('a' => 1)
@@ -270,6 +275,12 @@ def test_struct_encoding
JSON.parse(json_string_and_date))
end
+ def test_nil_true_and_false_represented_as_themselves
+ assert_equal nil, nil.as_json
+ assert_equal true, true.as_json
+ assert_equal false, false.as_json
+ end
+
protected
def object_keys(json_object)
44 activesupport/test/test_case_test.rb
View
@@ -19,7 +19,7 @@ def options
end
if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions
- def test_callback_with_exception
+ def test_standard_error_raised_within_setup_callback_is_puked
tc = Class.new(TestCase) do
setup :bad_callback
def bad_callback; raise 'oh noes' end
@@ -38,7 +38,7 @@ def test_true; assert true end
assert_equal 'oh noes', exception.message
end
- def test_teardown_callback_with_exception
+ def test_standard_error_raised_within_teardown_callback_is_puked
tc = Class.new(TestCase) do
teardown :bad_callback
def bad_callback; raise 'oh noes' end
@@ -56,6 +56,46 @@ def test_true; assert true end
assert_equal test_name, name
assert_equal 'oh noes', exception.message
end
+
+ def test_passthrough_exception_raised_within_test_method_is_not_rescued
+ tc = Class.new(TestCase) do
+ def test_which_raises_interrupt; raise Interrupt; end
+ end
+
+ test_name = 'test_which_raises_interrupt'
+ fr = FakeRunner.new
+
+ test = tc.new test_name
+ assert_raises(Interrupt) { test.run fr }
+ end
+
+ def test_passthrough_exception_raised_within_setup_callback_is_not_rescued
+ tc = Class.new(TestCase) do
+ setup :callback_which_raises_interrupt
+ def callback_which_raises_interrupt; raise Interrupt; end
+ def test_true; assert true end
+ end
+
+ test_name = 'test_true'
+ fr = FakeRunner.new
+
+ test = tc.new test_name
+ assert_raises(Interrupt) { test.run fr }
+ end
+
+ def test_passthrough_exception_raised_within_teardown_callback_is_not_rescued
+ tc = Class.new(TestCase) do
+ teardown :callback_which_raises_interrupt
+ def callback_which_raises_interrupt; raise Interrupt; end
+ def test_true; assert true end
+ end
+
+ test_name = 'test_true'
+ fr = FakeRunner.new
+
+ test = tc.new test_name
+ assert_raises(Interrupt) { test.run fr }
+ end
end
end
end
2  railties/lib/rails/generators/app_base.rb
View
@@ -234,7 +234,7 @@ def javascript_runtime_gemfile_entry
if defined?(JRUBY_VERSION)
"gem 'therubyrhino'\n"
else
- "# gem 'therubyracer', :platform => :ruby\n"
+ "# gem 'therubyracer', :platforms => :ruby\n"
end
end
4 railties/lib/rails/source_annotation_extractor.rb
View
@@ -53,7 +53,7 @@ def find(dirs=%w(app config lib script test))
# Returns a hash that maps filenames under +dir+ (recursively) to arrays
# with their annotations. Only files with annotations are included, and only
- # those with extension +.builder+, +.rb+, +.erb+, +.haml+ and +.slim+
+ # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+ and +.coffee+
# are taken into account.
def find_in(dir)
results = {}
@@ -63,7 +63,7 @@ def find_in(dir)
if File.directory?(item)
results.update(find_in(item))
- elsif item =~ /\.(builder|rb)$/
+ elsif item =~ /\.(builder|rb|coffee)$/
results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
elsif item =~ /\.erb$/
results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
2  railties/lib/rails/version.rb
View
@@ -2,7 +2,7 @@ module Rails
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
14 railties/test/application/rake/notes_test.rb
View
@@ -7,7 +7,7 @@ def setup
build_app
require "rails/all"
end
-
+
def teardown
teardown_app
end
@@ -17,6 +17,8 @@ def teardown
app_file "app/views/home/index.html.erb", "<% # TODO: note in erb %>"
app_file "app/views/home/index.html.haml", "-# TODO: note in haml"
app_file "app/views/home/index.html.slim", "/ TODO: note in slim"
+ app_file "app/assets/javascripts/application.js.coffee", "# TODO: note in coffee"
+ app_file "app/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby"
boot_rails
require 'rake'
@@ -24,17 +26,19 @@ def teardown
require 'rake/testtask'
Rails.application.load_tasks
-
+
Dir.chdir(app_path) do
output = `bundle exec rake notes`
-
+
assert_match /note in erb/, output
assert_match /note in haml/, output
assert_match /note in slim/, output
+ assert_match /note in ruby/, output
+ assert_match /note in coffee/, output
end
-
+
end
-
+
private
def boot_rails
super
2  railties/test/generators/app_generator_test.rb
View
@@ -253,7 +253,7 @@ def test_inclusion_of_javascript_runtime
if defined?(JRUBY_VERSION)
assert_file "Gemfile", /gem\s+["']therubyrhino["']$/
else
- assert_file "Gemfile", /# gem\s+["']therubyracer["']+, :platform => :ruby$/
+ assert_file "Gemfile", /# gem\s+["']therubyracer["']+, :platforms => :ruby$/
end
end
2  version.rb
View
@@ -2,7 +2,7 @@ module Rails
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 4
+ TINY = 5
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')

No commit comments for this range

Something went wrong with that request. Please try again.