aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* Fixed STI classes not defining an attribute method if there is aGodfrey Chan2014-02-233-11/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | conflicting private method defined on its ancestors. The problem is that `method_defined_within?(name, klass, superklass)` only works correclty when `klass` and `superklass` are both `Class`es. If both `klass` and `superklass` are both `Class`es, they share the same inheritance chain, so if a method is defined on `klass` but not `superklass`, this method must be introduced at some point between `klass` and `superklass`. This does not work when `superklass` is a `Module`. A `Module`'s inheritance chain contains just itself. So if a method is defined on `klass` but not on `superklass`, the method could still be defined somewhere upstream, e.g. in `Object`. This fix works by avoiding calling `method_defined_within?` with a module while still fufilling the requirement (checking that the method is defined withing `superclass` but not is not a generated attribute method). 4d8ee288 is likely an attempted partial fix for this problem. This unrolls that fix and properly check the `superclass` as intended. Fixes #11569.
* deprecate support for pg ranges with excluding beginnings.Yves Senn2014-02-231-23/+55
| | | | | | | | | | | | | | | The Ruby Range object does not support excluding beginnings. We currently support excluding beginnings for some subtypes using manually by incrementing them (now using the `#succ` method). This is approach is flawed as it's not equal to an excluding beginning. This commit deprecates the current support for excluding beginnings. It also raises an `ArgumentError` for subtypes that do not implement the `succ` method. This is a temporary solution to get rid of the broken state. We might still add complete support for excluding beginnings afterwards. (Probably with a new `PGRange` object, which acts like a `Range` but has excluding beginnings.
* dynamically define PostgreSQL OID range types.Yves Senn2014-02-231-11/+40
| | | | | | | | This gets AR working with custom defined range types. It also removes the need for subtype specific branches in `OID::Range`. This expands the interface of all `OID` types with the `infinity` method. It's responsible to provide a value for positive and negative infinity.
* Add tests for default scope behaviour changeJon Leighton2014-02-232-0/+20
| | | | See #13875
* adding a test for #14106Aaron Patterson2014-02-201-0/+25
|
* Revert "context in validation goes through has many relationship"Aaron Patterson2014-02-203-26/+0
| | | | This reverts commit 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.
* Add regression test for collection proxy readerArthur Neves2014-02-201-0/+7
| | | | [related #14116]
* Merge branch '4-1-0-beta2'Rafael Mendonça França2014-02-181-0/+8
|\ | | | | | | | | | | Conflicts: actionview/CHANGELOG.md activerecord/CHANGELOG.md
| * Correctly escape PostgreSQL arrays.Aaron Patterson2014-02-181-0/+8
| | | | | | | | | | | | Thanks Godfrey Chan for reporting this! Fixes: CVE-2014-0080
* | Revert "Merge pull request #13344 from ccutrer/fix-from-default-select"Rafael Mendonça França2014-02-171-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 3ea840355409dc205a9e0d027fc09f1452636969, reversing changes made to e4cde5d58cbb09d1843796f96ba86225ff94fe05. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/query_methods.rb Reason: using `from` without `select` should not change the select list to SELECT * because it can lead different query results. If it is needed to change the table to a subquery or a view you can pass a table alias in the `from` call or use `select('subquery.*')`. Fixes #14049.
* | Don't skip tests if they are not broken. Just don't define theyRafael Mendonça França2014-02-162-9/+5
| |
* | Resolve encoding issues with arrays of hstore (bug 11135).Josh Goodall2014-02-171-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We didn't have enough encoding for the wire protocol to store an array of hstore types. So, further encode any hstore that is an array member. Whilst we're here, ensure it's an HashWithIndifferentAccess being returned, to be consistent with other serialized forms, and add testing for arrays of hstore. So now the following migration: enable_extension "hstore" create_table :servers do |t| t.string :name t.hstore :interfaces, array: true end produces a model that can used like this, to store an array of hashes: server = Server.create(name: "server01", interfaces: [ { name: "bge0", ipv4: "192.0.2.2", state: "up" }, { name: "de0", state: "disabled", by: "misha" }, { name: "fe0", state: "up" }, ]) More at http://inopinatus.org/2013/07/12/using-arrays-of-hstore-with-rails-4/
* | make a singleton for AssociationScopeAaron Patterson2014-02-141-2/+1
| | | | | | | | | | AssociationScope no longer maintains state, so we're safe to keep a singleton and save on GC time
* | pass the association and connection to the scope methodAaron Patterson2014-02-141-2/+4
| |
* | remove unused fixtures from sqlite3 test casesRajarshi Das2014-02-141-1/+1
| |
* | Merge pull request #14034 from ↵Yves Senn2014-02-132-3/+31
|\ \ | | | | | | | | | | | | hdabrows/drop-correct-index-when-reverting-migration Drop the correct index after reverting a migration
| * | Drop the correct index after reverting a migrationHubert Dąbrowski2014-02-132-3/+31
| | | | | | | | | | | | | | | | | | Previously when reverting a migration which added a named index it would instead drop a corresponding index with matching columns but without a name.
* | | tests are responsible to clean up afterwards.Yves Senn2014-02-131-82/+114
| | | | | | | | | | | | | | | remove created state after test execution, not before the next test. This prevents the leak of the `ex` table outside of a single test.
* | | Terminate the backend ourselves on PG 9.2+Matthew Draper2014-02-121-19/+29
|/ / | | | | | | This should make it harder to accidentally break this test.
* | test case to illustrate current PostgreSQL composite behavior.Yves Senn2014-02-111-0/+42
| |
* | add activerecord test coverage for `sanitize_sql_array`Dmitry Polushkin2014-02-091-0/+5
| | | | | | | | check it is handles empty statement
* | Merge pull request #13981 from Fortisque/kevin/postgresql_reaper_threadsafeAaron Patterson2014-02-082-2/+2
|\ \ | | | | | | Reaper has access to threadsafe active? call
| * | Reaper has access to threadsafe active? callKevin Casey2014-02-082-2/+2
| | |
* | | Merge pull request #13978 from Fortisque/kevin/validation_context_for_childrenAaron Patterson2014-02-083-0/+26
|\ \ \ | | | | | | | | context in validation goes through has many relationship
| * | | context in validation goes through has many relationshipKevin Casey2014-02-083-0/+26
| | | |
* | | | Skips linked folder tests if symlink is invalidMikko Johansson2014-02-091-2/+6
| |/ / |/| |
* | | Add test case for autosave HasMany with accepts_nested_attributes.Lauro Caetano2014-02-083-0/+33
| | | | | | | | | | | | | | | | | | | | | It should not save the parent record when the nested attributes are invalid. Test case to cover #8194.
* | | Adjust test value so that timezone has no effectAndrew White2014-02-071-1/+1
|/ / | | | | | | | | | | If the test is run in a timezone that is behind UTC it fails because the time generated is ahead of 0000-01-01 00:00:00. Just increase the time subtracted so that timezone has no effect.
* | Return sized enumerator from Batches#find_eachMarc-Andre Lafortune2014-02-052-0/+14
| |
* | Return sized enumerator from Batches#find_in_batchesMarc-Andre Lafortune2014-02-051-0/+10
| |
* | Strengthen test with different nb of rows and columnsMarc-Andre Lafortune2014-02-051-2/+4
| |
* | Merge pull request #13949 from vajrasky/fix_typo_column_definition_testYves Senn2014-02-051-2/+2
|\ \ | | | | | | Fixed typos in column_definition_test.rb.
| * | Fixed typo in column_definition_test.rb.Vajrasky Kok2014-02-051-2/+2
| | |
* | | docs, AR already auto-detects primary keys. Closes #13946. [ci skip]Yves Senn2014-02-052-3/+5
|/ / | | | | | | | | This behavior was introduced since Rails 3.1 (207f266ccaaa9cd04cd2a7513ae5598c4358b510) but the docs were still out of date.
* | Merge pull request #13935 from arthurnn/fix_12566Rafael Mendonça França2014-02-041-0/+15
|\ \ | | | | | | Make sure transaction state resets after commit
| * | Make sure transaction state resets after commitArthur Neves2014-02-031-0/+15
| | | | | | | | | | | | [fixes #12566]
* | | Merge pull request #13899 from ↵Rafael Mendonça França2014-02-041-0/+10
|\ \ \ | |/ / |/| | | | | | | | Fortisque/kevin/active_record_HABTM_with_belongs_to destruction errors out on HABTM w/out primary key
| * | fix HABTM w/out primary key errors on destructionKevin Casey2014-02-021-0/+10
| | |
* | | pass `habtm :autosave` to underlying `hm:t` association. Closes #13923.Yves Senn2014-02-032-7/+27
| | |
* | | Remove warnings for already defined methodsRafael Mendonça França2014-02-011-1/+3
| | |
* | | Merge pull request #13688 from jbaudanza/psql-index-existsRafael Mendonça França2014-02-011-0/+12
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL implementation of SchemaStatements#index_name_exists? Conflicts: activerecord/CHANGELOG.md
| * | | psql implementation of #index_name_exists?Jonathan Baudanza2014-01-161-0/+12
| | | |
* | | | Fixes issue with parsing whitespace content back from database - fixes #13907Mauricio Linhares2014-02-011-0/+12
| |/ / |/| |
* | | Merge pull request #13896 from laurocaetano/dangerous_association_namesCarlos Antonio da Silva2014-01-313-0/+30
|\ \ \ | | | | | | | | Associations now raises `ArgumentError` on name conflicts. Closes #13217.
| * | | Associations now raise `ArgumentError` on name conflicts.Lauro Caetano2014-01-313-0/+30
| | | | | | | | | | | | | | | | | | | | Dangerous association names conflicts include instance or class methods already defined by `ActiveRecord::Base`.
* | | | Remove unused variable.Tim Fenney2014-01-311-1/+1
|/ / /
* | | Merge pull request #13859 from huoxito/let-it-goRafael Mendonça França2014-01-301-0/+10
|\ \ \ | | | | | | | | Let `unscope` ignore non Arel scope.where_values
| * | | Let `unscope` ignore non Arel scope.where_valuesWashington Luiz2014-01-301-0/+10
| | | |
* | | | Merge pull request #13886 from arthurnn/fix_relation_arelRafael Mendonça França2014-01-301-0/+23
|\ \ \ \ | |/ / / |/| | | Fix regression on .select method
| * | | Fix regression on `.select_*` methods.Arthur Neves2014-01-301-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]