aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/scoping/named_scoping_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #14544 from jefflai2/named_scope_sti"Rafael Mendonça França2014-05-211-6/+1
| | | | | | | | | | | | This reverts commit 9a1abedcdeecd9464668695d4f9c1d55a2fd9332, reversing changes made to c72d6c91a7c0c2dc81cc857a1d6db496e84e0065. Conflicts: activerecord/CHANGELOG.md activerecord/test/models/comment.rb This change break integration with activerecord-deprecated_finders so I'm reverting until we find a way to make it work with this gem.
* Merge pull request #14544 from jefflai2/named_scope_stiRafael Mendonça França2014-05-201-1/+6
|\ | | | | | | | | | | | | Fixes Issue #13466. Conflicts: activerecord/CHANGELOG.md
| * Fixes Issue #13466.Jefferson Lai2014-04-231-1/+6
| | | | | | | | | | | | Changed the call to a scope block to be evaluated with instance_eval. The result is that ScopeRegistry can use the actual class instead of base_class when caching scopes so queries made by classes with a common ancestor won't leak scopes.
* | Block a few default Class methods as scope name.Arthur Neves2014-04-031-0/+3
|/ | | | | | Add tests to make sure scopes cannot be create with names such as: private, protected, public. Make sure enum values don't collide with those methods too.
* Remove warnings for already defined methodsRafael Mendonça França2014-02-011-1/+3
|
* `scope` now raises on "dangerous" name conflictsGodfrey Chan2014-01-291-0/+57
| | | | | | | | | | Similar to dangerous attribute methods, a scope name conflict is dangerous if it conflicts with an existing class method defined within `ActiveRecord::Base` but not its ancestors. See also #13389. *Godfrey Chan*, *Philippe Creux*
* Ensure #second acts like #first AR finderJason Meller2014-01-201-4/+4
| | | | | | | | | | | | This commit bring the famous ordinal Array instance methods defined in ActiveSupport into ActiveRecord as fully-fledged finders. These finders ensure a default ascending order of the table's primary key, and utilize the OFFSET SQL verb to locate the user's desired record. If an offset is defined in the query, calling #second adds to the offset to get the actual desired record. Fixes #13743.
* Remove deprecated `scope` use without passing a callable object.Arun Agrawal2013-07-031-10/+0
| | | | Removed tests from deprecated code.
* calling default_scope without a proc will raise ArgumentErrorNeeraj Singh2013-07-021-3/+2
| | | | Calling default_scope without a proc will now raise `ArgumentError`.
* remove deprecated implicit join references.Yves Senn2013-06-291-5/+0
|
* Fix scope chaining + STIJon Leighton2013-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See #9869 and #9929. The problem arises from the following example: class Project < ActiveRecord::Base scope :completed, -> { where completed: true } end class MajorProject < Project end When calling: MajorProject.where(tasks_count: 10).completed This expands to: MajorProject.where(tasks_count: 10).scoping { MajorProject.completed } However the lambda for the `completed` scope is defined on Project. This means that when it is called, `self` is Project rather than MajorProject. So it expands to: MajorProject.where(tasks_count: 10).scoping { Project.where(completed: true) } Since the scoping was applied on MajorProject, and not Project, this fails to apply the tasks_count condition. The solution is to make scoping apply across STI classes. I am slightly concerned about the possible side-effects of this, but no tests fail and it seems ok. I guess we'll see.
* failing test for #9869Neeraj Singh2013-04-051-0/+5
|
* rename named_scope_test.rb to a proper file nameTakehiro Adachi2013-03-301-0/+462
The file name should be name_scoping_test.rb and the class should be `NamedScopingTest` according to ActiveRecord::Scoping::Name