diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-12 17:35:57 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-12 17:35:57 +0000 |
commit | e1b828de95ececbe630e74caf3b18e47c669c58d (patch) | |
tree | c4d7752813e127a9d23e1df4487630cb0590aea7 /test | |
parent | 571494a028fc9355f918987cba9b1c89e8b2dc5f (diff) | |
download | redmine-e1b828de95ececbe630e74caf3b18e47c669c58d.tar.gz redmine-e1b828de95ececbe630e74caf3b18e47c669c58d.zip |
Adds ability to filter watched issues (#846).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2456 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/watchers.yml | 4 | ||||
-rw-r--r-- | test/unit/query_test.rb | 22 |
2 files changed, 25 insertions, 1 deletions
diff --git a/test/fixtures/watchers.yml b/test/fixtures/watchers.yml index 6c8cdfb5e..803b03e5e 100644 --- a/test/fixtures/watchers.yml +++ b/test/fixtures/watchers.yml @@ -7,4 +7,8 @@ watchers_002: watchable_type: Message watchable_id: 1 user_id: 1 +watchers_003: + watchable_type: Issue + watchable_id: 2 + user_id: 1
\ No newline at end of file diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 3bdc4a7a2..d568604c3 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -18,7 +18,7 @@ require File.dirname(__FILE__) + '/../test_helper' class QueryTest < Test::Unit::TestCase - fixtures :projects, :enabled_modules, :users, :members, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :versions, :queries + fixtures :projects, :enabled_modules, :users, :members, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :watchers, :custom_fields, :custom_values, :versions, :queries def test_custom_fields_for_all_projects_should_be_available_in_global_queries query = Query.new(:project => nil, :name => '_') @@ -162,6 +162,26 @@ class QueryTest < Test::Unit::TestCase find_issues_with_query(query) end + def test_filter_watched_issues + User.current = User.find(1) + query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}}) + result = find_issues_with_query(query) + assert_not_nil result + assert !result.empty? + assert_equal Issue.visible.watched_by(User.current).sort_by(&:id), result.sort_by(&:id) + User.current = nil + end + + def test_filter_unwatched_issues + User.current = User.find(1) + query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '!', :values => ['me']}}) + result = find_issues_with_query(query) + assert_not_nil result + assert !result.empty? + assert_equal((Issue.visible - Issue.watched_by(User.current)).sort_by(&:id).size, result.sort_by(&:id).size) + User.current = nil + end + def test_default_columns q = Query.new assert !q.columns.empty? |