aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | Merge branch 'master' into rm-uuid-fixturesRafael Mendonça França2014-04-104-2/+11
| |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md activesupport/CHANGELOG.md
| * \ \ \ \ Merge pull request #12016 from roderickvd/uuid_fixesRafael Mendonça França2014-04-042-0/+6
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Auto-generate stable fixture UUIDs on PostgreSQL Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/fixtures.rb activerecord/test/cases/adapters/postgresql/uuid_test.rb activesupport/CHANGELOG.md
| | * | | | | Auto-generate stable fixture UUIDs on PostgreSQL.Roderick van Domburg2014-01-072-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: #11524
* | | | | | | propogate bind values collected in arel to SQL generationAaron Patterson2014-04-111-0/+2
| |_|/ / / / |/| | | | |
* | | | | | The `source` option for `has_many => through` should accept StringLauro Caetano2014-04-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | values. With the changes introduced by 16b70fddd4dc7e7fb7be108add88bae6e3c2509b it was expecting the value to be a Symbol, while it could be also a String value.
* | | | | | Fix the test defining the models in the right placeRafael Mendonça França2014-04-042-0/+5
| | | | | |
* | | | | | Merge pull request #14562 from jefflai2/collection_proxyRafael Mendonça França2014-04-041-0/+4
|\ \ \ \ \ \ | |/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | CollectionProxy uses the arel of its association's scope. Conflicts: activerecord/CHANGELOG.md
| * | | | | CollectionProxy uses the arel of its association's scope.Jefferson Lai2014-04-021-0/+4
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | CollectionProxy should be able to reuse the behavior (methods) of its parent class, but with its own state. This change allows CollectionProxy to use the arel object corresponding to its association's scope.
* / | | | Fix error when using `with_options` with lambda.Lauro Caetano2014-04-032-0/+6
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was causing error when using `with_options` passing a lambda as its last argument. class User < ActiveRecord::Base with_options dependent: :destroy do |assoc| assoc.has_many :profiles, -> { where(active: true) } end end It was happening because the `option_merger` was taking the last argument and checking if it was a Hash. This breaks the HasMany usage, because its last argument can be a Hash or a Proc. As the behavior described in this test: https://github.com/rails/rails/blob/master/activesupport/test/option_merger_test.rb#L69 the method will only accept the lambda, this way it will keep the expected behavior. See 9eaa0a34
* | | | Merge pull request #14154 from al2o3cr/issue12770Aaron Patterson2014-03-271-0/+1
|\ \ \ \ | | | | | | | | | | Pass a base relation to build_default_scope when joining
| * | | | Pass a base relation to build_default_scope when joiningMatt Jones2014-02-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This allows the default scope to be built using the current table alias. Resolves #12770
* | | | | AR .persisted? throws SystemStackError for an unsaved model with achrisfinne2014-03-271-0/+2
| |_|_|/ |/| | | | | | | | | | | custom primary_key that didn't save due to validation error
* | | | Obey `validate: false` option for habtmCarlos Antonio da Silva2014-03-142-0/+14
| | | | | | | | | | | | | | | | Fixes #14383.
* | | | Add tests for default scope behaviour changeJon Leighton2014-02-231-0/+2
|/ / / | | | | | | | | | See #13875
* | | Revert "context in validation goes through has many relationship"Aaron Patterson2014-02-202-16/+0
| | | | | | | | | | | | This reverts commit 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.
* | | Merge pull request #13978 from Fortisque/kevin/validation_context_for_childrenAaron Patterson2014-02-082-0/+16
|\ \ \ | | | | | | | | context in validation goes through has many relationship
| * | | context in validation goes through has many relationshipKevin Casey2014-02-082-0/+16
| | | |
* | | | Add test case for autosave HasMany with accepts_nested_attributes.Lauro Caetano2014-02-082-0/+4
|/ / / | | | | | | | | | | | | | | | | | | It should not save the parent record when the nested attributes are invalid. Test case to cover #8194.
* | | docs, AR already auto-detects primary keys. Closes #13946. [ci skip]Yves Senn2014-02-051-2/+0
| | | | | | | | | | | | | | | This behavior was introduced since Rails 3.1 (207f266ccaaa9cd04cd2a7513ae5598c4358b510) but the docs were still out of date.
* | | pass `habtm :autosave` to underlying `hm:t` association. Closes #13923.Yves Senn2014-02-031-0/+1
| | |
* | | Add more tests for the dirty feature for enumsRafael Mendonça França2014-01-211-0/+1
| | |
* | | Make AR::Base#touch fire the after_commit and after_rollback callbacksHarry Brundage2014-01-162-1/+17
| | |
* | | Don't try to get the subclass if the inheritance column doesn't existUjjwal Thaakar2014-01-141-0/+5
|/ / | | | | | | | | | | | | The `subclass_from_attrs` method is called even if the column specified by the `inheritance_column` setting doesn't exist. This prevents setting associations via the attributes hash if the association name clashes with the value of the setting, typically `:type`. This worked previously in Rails 3.2.
* | Remove warnings in test suiteMatthias Zirnstein2014-01-061-1/+1
| | | | | | | | | | | | | | lib/active_record/store.rb:79: warning: method redefined; discarding old color= lib/active_record/store.rb:79: warning: previous definition of color= was here lib/active_record/store.rb:83: warning: method redefined; discarding old color lib/active_record/store.rb:83: warning: previous definition of color was here
* | Fix: ActiveRecord::Store TypeError conversion when using YAML coderThales Oliveira2014-01-061-0/+1
| | | | | | | | | | | | | | | | | | | | Renaming the test accordingly to its behaviour Adding 'Fixes' statement to changelog Improving tests legibility & changelog Undoing mistakenly removed empty line & further improving changelog
* | Remove method redefined warnings for test suiteMatthias Zirnstein2014-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | has_many definitions with "name" as singular and as plural e.g. has_many :welcome_posts_with_comment has_many :welcome_posts_with_comments Ruby mentions it with: lib/active_record/associations/builder/collection_association.rb:65: warning: method redefined; discarding old welcome_posts_with_comment_ids lib/active_record/associations/builder/collection_association.rb:65: warning: previous definition of welcome_posts_with_comment_ids was here lib/active_record/associations/builder/collection_association.rb:75: warning: method redefined; discarding old welcome_posts_with_comment_ids= lib/active_record/associations/builder/collection_association.rb:75: warning: previous definition of welcome_posts_with_comment_ids= was here
* | make sure cached table name is a string. fixes #12582Aaron Patterson2013-12-121-0/+4
| |
* | changed update counter to act on unscoped modelheruku2013-11-261-0/+4
| |
* | Raise `RecordNotDestroyed` when children can't be replacedBrian Thomas Storti2013-11-252-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #12812 Raise `ActiveRecord::RecordNotDestroyed` when a child marked with `dependent: destroy` can't be destroyed. The following code: ```ruby class Post < ActiveRecord::Base has_many :comments, dependent: :destroy end class Comment < ActiveRecord::Base before_destroy do return false end end post = Post.create!(comments: [Comment.create!]) post.comments = [Comment.create!] ```` would result in a `post` with two `comments`. With this commit, the same code would raise a `RecordNotDestroyed` exception, keeping the `post` with the same `comment`.
* | Fix ActiveRecord::Relation#unscopeJon Leighton2013-11-201-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm pretty confused about the addition of this method. The documentation says that it was intended to allow the removal of values from the default scope (in contrast to #except). However it behaves exactly the same as except: https://gist.github.com/jonleighton/7537008 (other than having a slightly enhanced syntax). The removal of the default scope is allowed by 94924dc32baf78f13e289172534c2e71c9c8cade, which was not a change we could make until 4.1 due to the need to deprecate things. However after that change #unscope still gives us nothing that #except doesn't already give us. However there *is* a desire to be able to unscope stuff in a way that persists across merges, which would allow associations to be defined which unscope stuff from the default scope of the associated model. E.g. has_many :comments, -> { unscope where: :trashed } So that's what this change implements. I've also corrected the documentation. I removed the guide references to #except as I think unscope really supercedes #except now. While we're here, there's also a potential desire to be able to write this: has_many :comments, -> { unscoped } However, it doesn't make sense and would not be straightforward to implement. While with #unscope we're specifying exactly what we want to be removed from the relation, with "unscoped" we're just saying that we want it to not have some things which were added earlier on by the default scope. However in the case of an association, we surely don't want *all* conditions to be removed, otherwise the above would just become "SELECT * FROM comments" with no foreign key constraint. To make the above work, we'd have to somehow tag the relation values which get added when evaluating the default scope in order to differentiate them from other relation values. Which is way too much complexity and therefore not worth it when most use cases can be satisfied with unscope. Closes #10643, #11061.
* Add AR::Base.to_param for convenient "pretty" URLs derived from a model's ↵Javan Makhmali2013-11-141-0/+2
| | | | attribute or method.
* define enum methods inside a `Module` to make them overwritable.Yves Senn2013-11-051-0/+5
|
* Explicit mapping for enumYury Korolev2013-11-021-0/+1
|
* Fix to work on Ruby 1.9.3, example and changelog improvementsCarlos Antonio da Silva2013-11-021-2/+2
|
* Added ActiveRecord::Base#enum for declaring enum attributes where the values ↵David Heinemeier Hansson2013-11-021-2/+4
| | | | map to integers in the database, but can be queried by name
* Skip `include_values` from through associations chains for building target scopePaul Nikitochkin2013-10-271-0/+3
| | | | Fixes: #12242, #9517, #10240
* scope_chain should not be mutated for other reflectionsNeeraj Singh2013-10-145-0/+19
| | | | | | | | | | | Currently `scope_chain` uses same array for building different `scope_chain` for different associations. During processing these arrays are sometimes mutated and because of in-place mutation the changed `scope_chain` impacts other reflections. Fix is to dup the value before adding to the `scope_chain`. Fixes #3882.
* Port test from cf1904f to avoid future regressionPrem Sichanugrist2013-10-031-0/+5
| | | | Related issue: #11939, #12084
* adding a test to demonstrate how to use STI subclasses on the far rightAaron Patterson2013-09-272-0/+3
| | | | side of a hm:t association along with preloading.
* Merge pull request #12359 from arthurnn/inverse_on_callbacksRafael Mendonça França2013-09-251-1/+5
|\ | | | | Make sure inverse_of is visible on the has_many callbacks
| * Make sure inverse_of is visible on the has_many callbacksArthur Neves2013-09-251-1/+5
| |
* | adding a test for sti on middle tables with sorting on RHSAaron Patterson2013-09-231-0/+5
|/
* Merge pull request #12011 from jetthoughts/11963_fix_join_with_association_scopeRafael Mendonça França2013-09-161-0/+7
|\ | | | | | | | | | | | | Collapse where constraints to the Arel::Nodes::And node Conflicts: activerecord/CHANGELOG.md
| * Collapse where constraints to one where constraintPaul Nikitochkin2013-09-131-0/+7
| | | | | | | | | | | | | | In order to remove duplication with joining arel where constraints with `AND`, all constraints on `build_arel` are collapsed into one head node: `Arel::Nodes::And` Closes: #11963
* | More unused associations in AR test modelsAkira Matsuda2013-09-108-13/+0
| |
* | :scissors: [ci skip]Carlos Antonio da Silva2013-09-101-1/+1
| |
* | change function def self.table_name to self.table_nameRajarshi Das2013-09-102-5/+3
| | | | | | | | | | | | change def self.primary_key to self.primary_key change def self.primary_key to self.primary_key
* | Clean up unused associations in AR test modelAkira Matsuda2013-09-101-3/+0
|/
* pk should not be required for hm:t associationsAaron Patterson2013-08-291-0/+8
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-08-1711-3/+21
|\ | | | | | | | | | | | | | | Conflicts: actionview/README.rdoc activerecord/lib/active_record/migration.rb guides/source/development_dependencies_install.md guides/source/getting_started.md