aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | Remove unused variableRafael Mendonça França2014-04-041-1/+1
| | | | |
| * | | | Fix error when using `with_options` with lambda.Lauro Caetano2014-04-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #14546 from ↵Aaron Patterson2014-03-311-1/+16
| |\ \ \ \ | | |_|_|/ | |/| | | | | | | | | | | | | eileencodes/fix_delete_all_to_not_use_IN_statement Fix delete all to not produce sql in statement
| | * | | add test to compare sql statements in delete_all queryeileencodes2014-03-311-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | delete_all sql if an association is not loaded should behave the same as if the association is loaded. This test ensures the SQL statements are exactly the same.
| * | | | Simplify Preloader#grouped_records code.thedarkone2014-03-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new method relies on AR::Associations::Association knowing about both reflection and a model class. AR::Base#association now raises a descriptive error when trying to access non-existent associations. Previously it would blow up with a confusing NoMethodError: undefined method `association_class' for nil:NilClass.
| * | | | Fix polymorphic preloads on NOT NULL _type columns.thedarkone2014-03-301-0/+11
| |/ / / | | | | | | | | | | | | Defer to Association#klass instead of having a custom/duplicate code.
| * | | Merge pull request #14154 from al2o3cr/issue12770Aaron Patterson2014-03-271-0/+9
| |\ \ \ | | | | | | | | | | Pass a base relation to build_default_scope when joining
| | * | | Pass a base relation to build_default_scope when joiningMatt Jones2014-02-211-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | This allows the default scope to be built using the current table alias. Resolves #12770
| * | | | Use rails convetionsRafael Mendonça França2014-03-251-2/+2
| | | | |
| * | | | Merge pull request #14390 from huoxito/true-touchRafael Mendonça França2014-03-251-0/+11
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Still touch associations when theres no timestamp
| | * | | | Still touch associations when theres no timestampWashington Luiz2014-03-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to Rails 4.0.4 when touching a object which doesn't have timestamp attributes (updated_at / updated_on) rails would still touch all associations. After 73ba2c14cd7d7dfb2d132b18c47ade995401736f it updates associations but rollsback because `touch` would return nil since there's no timestamp attribute
* | | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-03-255-3/+48
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (96 commits) clarify CHANGELOG [ci skip]. Fix Generation of proper migration when ActiveRecord::Base.pluralize_table_names = false. update comments to reflect that options support is not available synchronize changelogs and 4.1 release notes. [ci skip] do not rely on method_missing hitting arel use ARel factory methods for building AST nodes Fix date_select option overwriting html classes - Rename `increment_or_decrement` to an apt `set_cache_value` since it actually doesn't increment/decrement in localstore. Check if any sqlite files are not included in the gitignore Remove sqlite3 lines from .gitignore if the application is not using sqlite3. Adding active_model in Rails::Info Clean up tables after each test. Swapped parameters of assert_equal in assert_select Update test helper to use latest Digestor API Digestor should just rely on the finder to know about the format and the variant -- trying to pass it back in makes a mess of things (oh, and doesnt work) Log the full path, including variant, that the digestor is trying to find Fix for digestor to consider variants for partials -- this still needs more testing!! fix log_tags request object grammar Extract with_example_table into helper method. test for structure:dump without schema information table. refs eafec46 ... Conflicts: activerecord/test/cases/relation/where_chain_test.rb
| * | | | | Add counter cache test for class_nameArthur Neves2014-03-171-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | Backport test from #14410
| * | | | | `where.not` adds `references` for `includes`.Yves Senn2014-03-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Closes #14406.
| * | | | | Merge pull request #14380 from ↵Yves Senn2014-03-152-3/+3
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | tgxworld/use_teardown_helper_method_in_activerecord Use teardown helper method.
| | * | | | | Use teardown helper method.Guo Xiang Tan2014-03-142-3/+3
| | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-Up to https://github.com/rails/rails/pull/14348 Ensure that SQLCounter.clear_log is called after each test. This is a step to prevent side effects when running tests. This will allow us to run them in random order.
| * / / / / Obey `validate: false` option for habtmCarlos Antonio da Silva2014-03-141-0/+24
| |/ / / / | | | | | | | | | | | | | | | Fixes #14383.
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-03-131-3/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: passing an instance of an AR object to `find` is deprecated passing an ActiveRecord object to `exists?` is deprecated.
| * | | | passing an instance of an AR object to `find` is deprecatedAaron Patterson2014-03-131-3/+3
| | | | | | | | | | | | | | | | | | | | please pass the id of the AR object by calling `.id` on the model first.
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-03-133-1/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (108 commits) make tests pass on Ruby 2.2 Use Sqlite3 adapter in examples use the body proxy to freeze headers just ask the response for the commit status, we do not need to ask the jar only write the jar if the response isn't committed Fix a grammatical error in the i18n guide [ci skip] use method_defined? to check whether or not a method is defined Enhance docs for update_attribute [ci-skip] Change usec to 0 on tests that compare seconds Unit test for mysql quote time usec Changelog entry for mysql56 microseconds Test microsecond on mysql 5.6 MySQL 5.6 and later supports microsecond precision in datetime. [ci skip] Add documentation for original_fullpath. Remove mocking on save, when not necessary comment why we are modifying global state. [ci skip] `change_table` supports `citext`. Follow up to #12523. Removed unnecessary command "application" register OID for PostgreSQL citex datatype [Troy Kruthoff & Lachlan Sylvester] Fixes STI when 2+ levels deep. ...
| * | | | Replace map.flatten with flat_map in activerecordErik Michaels-Ober2014-03-031-1/+1
| | | | |
| * | | | Remove unnecessary db call when replacing.Arthur Neves2014-02-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When replacing a has_many association with the same one, there is no need to do a round-trip to the db to create/and drop a new transaction. [fixes #14220]
| * | | | `includes` uses SQL parsing when String joins are involved.Yves Senn2014-02-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a partial revert of 22b3481ba2aa55fad1f9a5db94072312b345fb55. The current implementation of `references_eager_loaded_tables?` needs to know every table involved in the query. With the current API this is not possible without SQL parsing. While a2dab46cae35a06fd5c5500037177492a047c252 deprecated SQL parsing for `includes`. It did not issue deprecation warnings when String joins are involved. This resulted in a breaking change after the deprecated behavior was removed (22b3481ba2aa55fad1f9a5db94072312b345fb55). We will need to rethink the usage of `includes`, `preload` and `eager_load` but for now, this brings back the old *working* behavior.
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-02-263-10/+28
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (55 commits) [ci skip] Move association class method notes extract common code in `uuid_test.rb`. move PostgreSQL UUID tests from `datatype_test.rb` to `uuid_test.rb`. [ci skip] remove guide section on models in migrations test case for custom PostgreSQL enum type. Remove inclusion of rubysl gem for rbx on generated Gemfile let `insert_record` actuall save the object. [skip ci] Fix test name typo in app generator tests. travis s/2.1.0/2.1.1 Bump version of bcrypt gem Skip test_migrate_revert_add_index_with_name if databases do not allow to create duplicate indexes on the same columns Optimize getting started guide images, and use png instead of jpg :scissors: [ci skip] Point master changelogs to 4-1-stable branch Add missing parantheses in index_exists? `ActionDispatch::Head` was replaced by `Rack::Head`. Closes #14191. [skip ci] Standardized punctuation. [skip ci] Fix typo in link_to :method option description refactor, with_locale is not needed because I18n is mocked. Fix ActionView label translation for more than 10 nested elements ...
| * | | | let `insert_record` actuall save the object.Aaron Patterson2014-02-251-0/+21
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `before_add` callbacks are fired before the record is saved on `has_and_belongs_to_many` assocations *and* on `has_many :through` associations. Before this change, `before_add` callbacks would be fired before the record was saved on `has_and_belongs_to_many` associations, but *not* on `has_many :through` associations. Fixes #14144
| * | | Revert "context in validation goes through has many relationship"Aaron Patterson2014-02-201-10/+0
| | | | | | | | | | | | | | | | This reverts commit 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.
| * | | Add regression test for collection proxy readerArthur Neves2014-02-201-0/+7
| |/ / | | | | | | | | | [related #14116]
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-02-171-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: Revert "Merge pull request #13344 from ccutrer/fix-from-default-select" No need to use symbols Don't skip tests if they are not broken. Just don't define they Fix typo [ci skip] Resolve encoding issues with arrays of hstore (bug 11135). Fix coffeescript sample [ci skip]
| * | Don't skip tests if they are not broken. Just don't define theyRafael Mendonça França2014-02-161-2/+2
| | |
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-02-175-65/+159
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (311 commits) Add a missing changelog entry for #13981 and #14035 Revert "Fixed plugin_generator test" implements new option :month_format_string for date select helpers [Closes #13618] add factory methods for empty alias trackers guarantee a list in the alias tracker so we can remove a conditional stop exposing table_joins make most parameters to the AliasTracker required make a singleton for AssociationScope pass the association and connection to the scope method pass the tracker down the stack and construct it in the scope method clean up add_constraints signature remove the reflection delegate remove klass delegator remove railties changes. fixes #14054 remove chain delegate remove scope_chain delegate Add verb to sanitization note fix path shown in mailer's templates updated Travis build status image url fix guide active_support_core_extensions. add Note to String#indent [ci skip] ... Conflicts: activerecord/lib/active_record/associations/join_dependency.rb activerecord/test/cases/associations/association_scope_test.rb
| * | 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
| | |
| * | context in validation goes through has many relationshipKevin Casey2014-02-081-0/+10
| | |
| * | fix HABTM w/out primary key errors on destructionKevin Casey2014-02-021-0/+10
| | |
| * | 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`.
| * | Fix indent on test case [ci skip]Carlos Antonio da Silva2014-01-281-2/+2
| | |
| * | Ensure AR #second, #third, etc. finders work through associationsJason Meller2014-01-211-61/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes two regressions introduced in cafe31a078 where newly created finder methods #second, #third, #forth, and #fifth caused a NoMethodError error on reload associations and where we were pulling the wrong element out of cached associations. Examples: some_book.authors.reload.second # Before # => NoMethodError: undefined method 'first' for nil:NilClass # After # => #<Author id: 2, name: "Sally Second", ...> some_book.first.authors.first some_book.first.authors.second # Before # => #<Author id: 1, name: "Freddy First", ...> # => #<Author id: 1, name: "Freddy First", ...> # After # => #<Author id: 1, name: "Freddy First", ...> # => #<Author id: 2, name: "Sally Second", ...> Fixes #13783.
| * | `has_one` and `belongs_to` accessors don't add ORDER BY to the queries anymore.Rafael Mendonça França2014-01-212-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Rails 4.0, we add an ORDER BY in the `first` method to ensure consistent results among different database engines. But for singular associations this behavior is not needed since we will have one record to return. As this ORDER BY option can lead some performance issues we are removing it for singular associations accessors. Fixes #12623.
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-01-171-96/+99
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: Fix eager load of Serializers on Active Model Consistence in the block style Remove warnings on Ruby 2.1 Only some dynamic finders are deprecated. clean up security guide: his => their [ci skip] Remove warning Extract a method to simplify setup code Use minitest's skip rather than conditionals + early returns Move AR test classes inside the test case Do not set up a variable used only in two tests No need for instance vars on single tests Cleanup duplicated setup of callbacks in transactions tests No need to use #send with public methods Update deprecation warning to give more information about caller Update changelog Avoid scanning multiple render calls as a single match. Improve ERB dependency detection.
| * | Extract a method to simplify setup codeCarlos Antonio da Silva2014-01-161-23/+27
| | |
| * | Use minitest's skip rather than conditionals + early returnsCarlos Antonio da Silva2014-01-161-47/+38
| | |
| * | Move AR test classes inside the test caseCarlos Antonio da Silva2014-01-161-38/+46
| | |
* | | check bind parameter uniquenessAaron Patterson2014-01-131-1/+6
|/ /
* | 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
* | Merge pull request #10134 from ↵Rafael Mendonça França2014-01-031-1/+5
|\ \ | | | | | | | | | | | | derikson/collection_proxy_select_with_multiple_args Change CollectionProxy#select to take the same arguments as ActiveRecord::select
| * | Changed ActiveRecord::Associations::CollectionProxy#select to take multiple ↵Dan Erikson2013-04-081-1/+5
| | | | | | | | | | | | | | | | | | arguments. This makes the arguments the same as ActiveRecord::QueryMethods::select.
* | | Improve the tests to not call assert_nothing_raisedRafael Mendonça França2014-01-011-4/+1
| | |
* | | https://github.com/rails/rails/commit/2075f39d726cef361170218fd16421fc52bed5 ↵Vipul A M2013-12-311-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a8 introduced a regression in includes/preloades by calling `read_attribute` on an association when preloading takes places, instead of using loaded records in `association.target`. tl;dr Records are not made properly available via `read_attribute` when preloding in simultaneous, but value of `@loaded` is already set true, and records concatenated in `association.target` on an association object. When `@loaded` is true we return an object of `AlreadyLoaded` in preload_for. In `AlreadyLoaded` to return preloaded records we make wrong use of `read_attribute`, instead of `target` records. The regression is fixed by making use of the loaded records in `association.target` when the preloading takes place. Fixes #13437
* | | On destroying do not touch destroyed belongs to association.Paul Nikitochkin2013-12-231-0/+8
| | | | | | | | | | | | Fixes: #13445
* | | Prefer assert_raise instead of flunk + rescue to test for exceptionsCarlos Antonio da Silva2013-12-191-5/+3
| | | | | | | | | | | | | | | | | | Change most tests to make use of assert_raise returning the raised exception rather than relying on a combination of flunk + rescue to check for exception types/messages.