aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
Commit message (Collapse)AuthorAgeFilesLines
...
* | Test only with Ruby 1.9+Rafael Mendonça França2013-01-061-4/+6
| |
* | Remove warningsRafael Mendonça França2013-01-061-2/+1
| |
* | Fix error when assigning NaN to an integer columnTristan Harward2013-01-061-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also covers any non-castable case by returning nil, which is in-line with the intention of the former implementation, but covers the odd cases which respond to to_i but raise an error when it's called, such as NaN, Infinity and -Infinity. Fixes #8757 Backport of #8781 Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/column_test.rb
* | Fix undefined method `to_i' introduced since 3.2.8Jason Stirk2013-01-042-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes a bug introduced in 96a13fc7 which breaks behaviour of integer fields in 3.2.8. In 3.2.8, setting the value of an integer field to a non-integer (eg. Array, Hash, etc.) would default to 1 (true) : # 3.2.8 p = Post.new p.category_id = [ 1, 2 ] p.category_id # => 1 p.category_id = { 3 => 4 } p.category_id # => 1 In 3.2.9 and above, this will raise a NoMethodError : # 3.2.9 p = Post.new p.category_id = [ 1, 2 ] NoMethodError: undefined method `to_i' for [1, 2]:Array Whilst at first blush this appear to be sensible, it combines in bad ways with scoping. For example, it is common to use scopes to control access to data : @collection = Posts.where(:category_id => [ 1, 2 ]) @new_post = @collection.new In 3.2.8, this would work as expected, creating a new Post object (albeit with @new_post.category_id = 1). However, in 3.2.9 this will cause the NoMethodError to be raised as above. It is difficult to avoid triggering this error without descoping before calling .new, breaking any apps running on 3.2.8 that rely on this behaviour. This patch deviates from 3.2.8 in that it does not retain the somewhat spurious behaviour of setting the attribute to 1. Instead, it explicitly sets these invalid values to nil : p = Post.new p.category_id = [ 1, 2 ] p.category_id # => nil This also fixes the situation where a scope using an array will "pollute" any newly instantiated records. @new_post = @collection.new @new_post.category_id # => nil Finally, 3.2.8 exhibited a behaviour where setting an object to an integer field caused it to be coerced to "1". This has not been retained, as it is spurious and surprising in the same way that setting Arrays and Heshes was : c = Category.find(6) p = Post.new # 3.2.8 p.category_id = c p.category_id # => 1 # This patch p.category_id = c p.category_id # => nil This commit includes explicit test cases that expose the original issue with calling new on a scope that uses an Array. As this is a common situation, an explicit test case is the best way to prevent regressions in the future. It also updates and separates existing tests to be explicit about the situation that is being tested (eg. AR objects vs. other objects vs. non-integers)
* | Merge branch '3-2-sec' into 3-2-secmergeAaron Patterson2012-12-231-0/+12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 3-2-sec: CVE-2012-5664 options hashes should only be extracted if there are extra parameters updating changelog updating the changelogs updating the changelog for the CVE Add release date of Rails 3.2.9 to documentation Conflicts: actionmailer/CHANGELOG.md actionpack/CHANGELOG.md activemodel/CHANGELOG.md activerecord/CHANGELOG.md activeresource/CHANGELOG.md activesupport/CHANGELOG.md railties/CHANGELOG.md
| * CVE-2012-5664 options hashes should only be extracted if there are extra ↵Aaron Patterson2012-12-231-0/+12
| | | | | | | | parameters
* | Serialized attribute can be serialized in an integer columnRafael Mendonça França2012-12-211-0/+8
| | | | | | | | | | | | | | | | | | | | Fix #8575 Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/attribute_methods/serialization.rb activerecord/test/cases/serialized_attribute_test.rb activerecord/test/models/person.rb
* | Backport #8522, Keep index names when using with sqlite3Yves Senn2012-12-191-0/+12
| | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb activerecord/test/cases/migration/rename_column_test.rb
* | recognize migrations, in folders containing numbers and 'rb'.Yves Senn2012-12-131-0/+6
| | | | | | | | | | | | | | | | | | Backport of #8500 Closes #8492 Conflicts: activerecord/test/cases/migrator_test.rb
* | Improve test name related to cache timestamp format [ci skip]Carlos Antonio da Silva2012-12-111-1/+1
| |
* | Add :nsec format only for Ruby 1.9Carlos Antonio da Silva2012-12-111-0/+4
| | | | | | | | | | | | Ruby 1.8 does not support this format in Time, so the format will only be added to the available date formats on Ruby 1.9. Changelog entry was changed to explain that as well.
* | Run backported serialized test without Identity MapCarlos Antonio da Silva2012-12-111-2/+4
| | | | | | | | | | | | It fails with Identity Map because the find call returns the same object, so the "content" attribute that we expect to raise "missing attribute" is actually present.
* | Use 1.8 hash style :bomb:Carlos Antonio da Silva2012-12-111-2/+2
| |
* | Merge pull request #8441 from itzki/fix_decorate_columnsCarlos Antonio da Silva2012-12-111-0/+13
| | | | | | | | | | Backport test to ensure there won't be regressions. The issue only happens on master at the moment.
* | Allow users to choose the timestamp format in the cache keyRafael Mendonça França2012-12-101-1/+10
| | | | | | | | | | | | This can be done using the class attribute cache_timestamp_format Closes #8195
* | Make sure the tests pass in the case closer to described in #8195Rafael Mendonça França2012-12-102-18/+12
| |
* | Merge pull request #6376 from jgaskins/timestamp-microsecondsJeremy Kemper2012-12-101-1/+1
| | | | | | | | | | | | Increase numeric-timestamp precision to nanoseconds Conflicts: activesupport/lib/active_support/core_ext/time/conversions.rb
* | Added regression test for #8195.jacobstr2012-12-101-0/+18
| |
* | Remove warning of unused variableRafael Mendonça França2012-12-101-1/+1
| |
* | Unscope update_column(s) query to ignore default scopeCarlos Antonio da Silva2012-12-061-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When applying default_scope to a class with a where clause, using update_column(s) could generate a query that would not properly update the record due to the where clause from the default_scope being applied to the update query. class User < ActiveRecord::Base default_scope where(active: true) end user = User.first user.active = false user.save! user.update_column(:active, true) # => false In this situation we want to skip the default_scope clause and just update the record based on the primary key. With this change: user.update_column(:active, true) # => true Backport of #8436 fix. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/persistence.rb activerecord/test/cases/persistence_test.rb
* | backport #8403, no intermediate AR objects when eager loading.Yves Senn2012-12-041-0/+6
| | | | | | | | | | | | | | | | | | Closes #3313 Conflicts: activerecord/CHANGELOG.md activerecord/test/models/developer.rb
* | Merge pull request #4942 from bogdan/pluck_joinsJosé Valim2012-12-031-0/+10
| | | | | | | | | | | | | | | | AR::Relation#pluck: improve to work with joins Conflicts: activerecord/lib/active_record/relation/calculations.rb activerecord/test/cases/calculations_test.rb
* | Merge pull request #7689 from cbarton/assume_migration_version_with_prefix_fixAaron Patterson2012-11-281-8/+28
|\ \ | | | | | | Fixing a schema:load when using a prefix and suffix on the tables [Reopen/backport]
| * | Making test accurately reflect what is going on in the schema migrations testChris Barton2012-09-181-8/+28
| | |
* | | Merge pull request #8311 from alisdair/dirty-nullable-datetimeCarlos Antonio da Silva2012-11-251-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't call will_change! for datetime nil->"". Setting a nil datetime attribute to a blank string should not cause the attribute to be dirty. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
* | | backport #8291, prevent mass assignment of polymorphic type with `build`Yves Senn2012-11-221-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Closes #8265 Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/associations/association.rb
* | | Merge pull request #8276 from pwnall/pgsql_text_limitsRafael Mendonça França2012-11-201-0/+18
| | | | | | | | | | | | | | | | | | | | | Postgresql doesn't accepts limits on text columns Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
* | | Merge pull request #8258 from kommen/eager_loading_with_select_test2Carlos Antonio da Silva2012-11-191-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add test to ensure preloading works as expected with "group", "select" and "includes". Conflicts: activerecord/test/cases/relations_test.rb Chery-pick a739340d3c9e66814429af6f3f410c01ff86810a: Ensure ordering to make the test pass with postgresql Conflicts: activerecord/test/cases/relations_test.rb
* | | Merge pull request #7983 from georgebrock/bug7950-squashedCarlos Antonio da Silva2012-11-161-0/+7
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport 4bc2ae0 to fix #7950 Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/calculations.rb
| * | | Test/changelog for has_many bug on unsaved recordsGeorge Brocklehurst2012-11-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | See issue #7950. The previous commit fixes this bug, and is a backport of 4bc2ae0da1dd812aee759f6d13ad428354cd0e13.
* | | | fix testJon Leighton2012-11-131-3/+3
| | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/test/cases/locking_test.rb
* | | | Merge pull request #8209 from senny/backport_8176Rafael Mendonça França2012-11-131-0/+6
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | backport #8176, `#pluck` can be used on a relation with `select` clause. Conflicts: activerecord/CHANGELOG.md
| * | | | backport #8176, `#pluck` can be used on a relation with `select` clause.Yves Senn2012-11-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/calculations.rb activerecord/test/cases/calculations_test.rb
* | | | | Merge pull request #8204 from nikitug/fix_dynamic_finder_result_checkRafael Mendonça França2012-11-131-0/+5
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use nil? instead of blank? to check dynamic finder result Conflicts: activerecord/CHANGELOG.md
| * | | | | Use nil? instead of blank? to check dynamic finder resultNikita Afanasenko2012-11-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's safe to use `nil?` instead of `blank?` because it's impossible to get an array on finder with bang; `all_by` finder matches against regex without bang: `when /^find_(all_|last_)?by_([_a-zA-Z]\w*)$/`. Fixes #7238
* | | | | | Fix deleting from a HABTM join table upon destroying an object of a model ↵Nick Rogers2012-11-131-1/+11
|/ / / / / | | | | | | | | | | | | | | | with optimistic locking enabled. Fixes #5332.
* / / / / Backport #8074 to 3-2-stable. Use query cache/uncache, when using not only ↵kennyj2012-11-141-0/+11
|/ / / / | | | | | | | | | | | | database.yml but also DATABASE_URL.
* | | | Fix warning with assigned but not used variableCarlos Antonio da Silva2012-11-131-3/+3
| | | |
* | | | Update mocha version to 0.13.0 and change requiresCarlos Antonio da Silva2012-11-131-1/+1
| | | |
* | | | Merge pull request #8154 from bogdan/has_one_association_performanceCarlos Antonio da Silva2012-11-121-0/+6
|/ / / | | | | | | | | | | | | | | | | | | Remove unwanted transaction when has one association is built Conflicts: activerecord/CHANGELOG.md
* | | Backport #8078: Fix `attributes_before_type_cast` for serialised attributes.Nikita Afanasenko2012-11-091-0/+10
| | | | | | | | | | | | Public method attributes_before_type_cast used to return internal AR structure (ActiveRecord::AttributeMethods::Serialization::Attribute), patch fixes this. Now behaves like read_attribute_before_type_cast and returns unserialised values.
* | | Merge pull request #7987 from ↵Santiago Pastorino2012-11-081-1/+22
|\ \ \ | | | | | | | | | | | | | | | | alexisbernard/3-2_find_in_batches_compatible_with_strings Fix find_in_batches with customized primary_key on 3-2-stable
| * | | Fix find_in_batches against string IDs when start option is not specified.Alexis Bernard2012-11-081-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/batches.rb
| * | | Fix test_find_in_batches_should_use_any_column_as_primary_keySantiago Pastorino2012-11-081-11/+8
| | | |
| * | | start could be a stringSantiago Pastorino2012-11-081-0/+15
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | Related to 761bc751d31c22e2c2fdae2b4cdd435b68b6d783 and eb876c4d07130f15be2cac7be968cc393f959c62 Conflicts: activerecord/lib/active_record/relation/batches.rb activerecord/test/cases/batches_test.rb
* | | Use a more descriptive test nameRafael Mendonça França2012-11-081-1/+1
| | |
* | | Fix accepts_nested_attributes for child classesGabriel Sobrinho & Ricardo Henrique2012-11-071-0/+11
|/ / | | | | | | Closes GH-8131
* | Ensure calling first/last with options correctly set inverse associationCarlos Antonio da Silva2012-11-011-0/+8
| | | | | | | | Also related to #8087. Thanks @al2o3cr.
* | Fix issue with collection associations and first(n)/last(n)Carlos Antonio da Silva2012-11-011-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When calling first(n) or last(n) in a collection, Active Record was improperly trying to set the inverse of instance in case that option existed. This change was introduced by fdf4eae506fa9895e831f569bed3c4aa6a999a22. In such cases we don't need to do that "manually", since the way collection will be loaded will already handle that, so we just skip setting the inverse association when any argument is given to first(n)/last(n). The test included ensures that these scenarios will have the inverse of instance set properly. Fixes #8087, Closes #8094.
* | relaxes assertionXavier Noria2012-10-311-1/+1
| | | | | | | | | | | | | | | | | | This method returns the status of the operation, but as we generally do in the code base it does not commit to any particular exact value. Hence, we do not have to check for a singleton, because if the implementation changes and returns some other true value the test should pass.