Feature #38402 » fix-any_searchable-does-not-support-mine-and-bookmarks.patch
| app/models/issue_query.rb | ||
|---|---|---|
|
if project
|
||
|
projects = project_scope.where(project_statement)
|
||
|
elsif has_filter?('project_id')
|
||
|
case values_for('project_id').first
|
||
|
when 'mine'
|
||
|
project_ids = User.current.projects.ids
|
||
|
when 'bookmarks'
|
||
|
project_ids = User.current.bookmarked_project_ids
|
||
|
else
|
||
|
project_ids = values_for('project_id')
|
||
|
end
|
||
|
projects = project_scope.where(
|
||
|
sql_for_field('project_id', operator_for('project_id'), values_for('project_id'), Project.table_name, 'id')
|
||
|
sql_for_field('project_id', operator_for('project_id'), project_ids, Project.table_name, 'id')
|
||
|
)
|
||
|
else
|
||
|
projects = nil
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert_equal [1, 3], result.map(&:id).sort
|
||
|
end
|
||
|
def test_filter_any_searchable_with_my_projects
|
||
|
# This user's project is ecookbook only
|
||
|
User.current = User.find_by(login: 'dlopper')
|
||
|
query = IssueQuery.new(
|
||
|
:name => '_',
|
||
|
:filters => {
|
||
|
'any_searchable' => {:operator => '~', :values => ['issue']},
|
||
|
'project_id' => {:operator => '=', :values => ['mine']}
|
||
|
}
|
||
|
)
|
||
|
result = find_issues_with_query(query)
|
||
|
assert_equal [7, 8, 11, 12], result.map(&:id).sort
|
||
|
result.each {|issue| assert_equal 1, issue.project_id}
|
||
|
end
|
||
|
def test_filter_any_searchable_with_my_bookmarks
|
||
|
# This user bookmarks two projects, ecookbook and private-child
|
||
|
User.current = User.find(1)
|
||
|
query = IssueQuery.new(
|
||
|
:name => '_',
|
||
|
:filters => {
|
||
|
'any_searchable' => {:operator => '~', :values => ['issue']},
|
||
|
'project_id' => {:operator => '=', :values => ['bookmarks']}
|
||
|
}
|
||
|
)
|
||
|
result = find_issues_with_query(query)
|
||
|
assert_equal [6, 7, 8, 9, 10, 11, 12], result.map(&:id).sort
|
||
|
result.each {|issue| assert_includes [1, 5], issue.project_id}
|
||
|
end
|
||
|
def test_filter_updated_by
|
||
|
user = User.generate!
|
||
|
Journal.create!(:user_id => user.id, :journalized => Issue.find(2), :notes => 'Notes')
|
||
- « Previous
- 1
- …
- 6
- 7
- 8
- Next »