We’re showing branches in this repository, but you can also compare across forks.
|
|
bkzl |
Display annotations from .coffee files in `rake notes`
|
4ababde
|
|
|
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
|
|
|
|
rafaelfranca |
Merge pull request #6531 from freerange/3-2-stable-minitest-passthrou…
…
…gh-exceptions Exceptions like Interrupt should not be rescued in tests. |
12e5c72
|
|
|
oscardelben |
Remove irrelevant assertion
|
2f71d40
|
|
|
|
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
|
|
|
|
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
|
|
|
|
drogus |
Merge pull request #6553 from erichmenge/3-2-stable-json-patch
…
3 2 stable json patch |
9f1b689
|
|
|
|
rafaelfranca |
Merge pull request #6477 from steveklabnik/close_discovered_pg_connec…
…
…tion Properly discover a connection is closed in postgresql_adapter |
b6727a1
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
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
|
|
|
|
tenderlove |
bumping to 3.2.5
|
b57fa0b
|
| @@ -1 +1 @@ | ||
| -3.2.4 | ||
| +3.2.5 |
| @@ -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,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,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('.') | ||
| @@ -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])) | ||
| @@ -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 | ||
| @@ -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) | ||
| @@ -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 | ||
| @@ -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 | ||
| @@ -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,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('.') | ||
| @@ -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 | ||
| @@ -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) | ||
| @@ -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,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,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) ## | ||
| @@ -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 | ||
| @@ -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 | ||
| @@ -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,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('.') | ||
| @@ -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) | ||
| @@ -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 | ||
| @@ -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 | ||
| @@ -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,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('.') | ||
| @@ -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 | ||
| @@ -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,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('.') | ||