diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-10 05:10:43 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-10 05:10:43 +0000 |
commit | 22c1e2b8cf8527c1e97de976f3dd46e7bee7cba3 (patch) | |
tree | c868aacb521e2918f8ef1d67adf0b4c47b5b4ac2 /test | |
parent | cfa1f0c231309c596900a0e82e89f15a4ab071a1 (diff) | |
download | redmine-22c1e2b8cf8527c1e97de976f3dd46e7bee7cba3.tar.gz redmine-22c1e2b8cf8527c1e97de976f3dd46e7bee7cba3.zip |
Adds named scopes to replace custom finders.
* Adds watched_by class method in ActsAsWatchable
* Adds Issue#recently_updated, Issue#with_limit and Issue#on_active_project
#2482
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3557 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/issue_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 24442b5d4..f0db47a31 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -656,4 +656,24 @@ class IssueTest < ActiveSupport::TestCase assert_equal 2, groups.size assert_equal 5, groups.inject(0) {|sum, group| sum + group['total'].to_i} end + + def test_recently_updated_with_limit_scopes + #should return the last updated issue + assert_equal 1, Issue.recently_updated.with_limit(1).length + assert_equal Issue.find(:first, :order => "updated_on DESC"), Issue.recently_updated.with_limit(1).first + end + + def test_on_active_projects_scope + assert Project.find(2).archive + + before = Issue.on_active_project.length + # test inclusion to results + issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first) + assert_equal before + 1, Issue.on_active_project.length + + # Move to an archived project + issue.project = Project.find(2) + assert issue.save + assert_equal before, Issue.on_active_project.length + end end |