"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/unit/query_test.rb" between
redmine-4.1.0.tar.gz and redmine-4.1.1.tar.gz

About: Redmine is a flexible project management and bug-tracking web application (using the Ruby on Rails framework). It supports also project wikis and forums, documents management, and multiple version control systems.

query_test.rb  (redmine-4.1.0):query_test.rb  (redmine-4.1.1)
skipping to change at line 946 skipping to change at line 946
end end
def test_filter_my_bookmarks_for_user_without_bookmarked_projects def test_filter_my_bookmarks_for_user_without_bookmarked_projects
User.current = User.find(2) User.current = User.find(2)
query = ProjectQuery.new(:name => '_') query = ProjectQuery.new(:name => '_')
filter = query.available_filters['id'] filter = query.available_filters['id']
assert_not_include 'bookmarks', filter[:values].map{|v| v[1]} assert_not_include 'bookmarks', filter[:values].map{|v| v[1]}
end end
def test_filter_project_parent_id_with_my_projects
User.current = User.find(1)
query = ProjectQuery.new(:name => '_')
filter = query.available_filters['parent_id']
assert_not_nil filter
assert_include 'mine', filter[:values].map{|v| v[1]}
query.filters = { 'parent_id' => {:operator => '=', :values => ['mine']}}
result = query.results_scope
my_projects = User.current.memberships.map(&:project_id)
assert_equal Project.where(parent_id: my_projects).ids, result.map(&:id).sor
t
end
def test_filter_project_parent_id_with_my_bookmarks
User.current = User.find(1)
query = ProjectQuery.new(:name => '_')
filter = query.available_filters['parent_id']
assert_not_nil filter
assert_include 'bookmarks', filter[:values].map{|v| v[1]}
query.filters = { 'parent_id' => {:operator => '=', :values => ['bookmarks']
}}
result = query.results_scope
bookmarks = User.current.bookmarked_project_ids
assert_equal Project.where(parent_id: bookmarks).ids, result.map(&:id).sort
end
def test_filter_watched_issues def test_filter_watched_issues
User.current = User.find(1) User.current = User.find(1)
query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operato r => '=', :values => ['me']}}) query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operato r => '=', :values => ['me']}})
result = find_issues_with_query(query) result = find_issues_with_query(query)
assert_not_nil result assert_not_nil result
assert !result.empty? assert !result.empty?
assert_equal Issue.visible.watched_by(User.current).sort_by(&:id), result.so rt_by(&:id) assert_equal Issue.visible.watched_by(User.current).sort_by(&:id), result.so rt_by(&:id)
User.current = nil User.current = nil
end end
skipping to change at line 1613 skipping to change at line 1641
end end
def test_default_sort def test_default_sort
q = IssueQuery.new q = IssueQuery.new
assert_equal [['id', 'desc']], q.sort_criteria assert_equal [['id', 'desc']], q.sort_criteria
end end
def test_sort_criteria_should_have_only_first_three_elements def test_sort_criteria_should_have_only_first_three_elements
q = IssueQuery.new q = IssueQuery.new
q.sort_criteria = [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'a sc'], ['id', 'asc'], ['project', 'asc'], ['subject', 'asc']] q.sort_criteria = [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'a sc'], ['id', 'asc'], ['project', 'asc'], ['subject', 'asc']]
assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']] , q.sort_criteria assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['id', 'asc']], q.so rt_criteria
end end
def test_sort_criteria_should_remove_blank_keys def test_sort_criteria_should_remove_blank_or_duplicate_keys
q = IssueQuery.new q = IssueQuery.new
q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['proje ct', 'asc']] q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['prior ity', 'asc'], ['project', 'asc']]
assert_equal [['priority', 'desc'], ['project', 'asc']], q.sort_criteria assert_equal [['priority', 'desc'], ['project', 'asc']], q.sort_criteria
end end
def test_set_sort_criteria_with_hash def test_set_sort_criteria_with_hash
q = IssueQuery.new q = IssueQuery.new
q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']} q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']}
assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria
end end
def test_set_sort_criteria_with_array def test_set_sort_criteria_with_array
skipping to change at line 1678 skipping to change at line 1706
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col .custom_field.field_format == 'float' } c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col .custom_field.field_format == 'float' }
assert c assert c
assert c.sortable assert c.sortable
q.sort_criteria = [[c.name.to_s, 'asc']] q.sort_criteria = [[c.name.to_s, 'asc']]
issues = q.issues issues = q.issues
values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom _field).to_s); rescue; nil; end}.compact values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom _field).to_s); rescue; nil; end}.compact
assert !values.empty? assert !values.empty?
assert_equal values.sort, values assert_equal values.sort, values
end end
def test_sort_with_group_by_timestamp_query_column_should_sort_after_date_valu
e
User.current = User.find(1)
# Touch Issue#10 in order to be the last updated issue
Issue.find(10).update_attribute(:updated_on, Issue.find(10).updated_on + 1)
q = IssueQuery.new(
:name => '_',
:filters => { 'updated_on' => {:operator => 't', :values => ['']} },
:group_by => 'updated_on',
:sort_criteria => [['subject', 'asc']]
)
# The following 3 issues are updated today (ordered by updated_on):
# Issue#10: Issue Doing the Blocking
# Issue#9: Blocked Issue
# Issue#6: Issue of a private subproject
# When we group by a timestamp query column, all the issues in the group hav
e the same date value (today)
# and the time of the value should not be taken into consideration when sort
ing
#
# For the same issues after subject ascending should return the following:
# Issue#9: Blocked Issue
# Issue#10: Issue Doing the Blocking
# Issue#6: Issue of a private subproject
assert_equal [9, 10, 6], q.issues.map(&:id)
end
def test_sort_by_total_for_estimated_hours def test_sort_by_total_for_estimated_hours
# Prepare issues # Prepare issues
parent = issues(:issues_001) parent = issues(:issues_001)
child = issues(:issues_002) child = issues(:issues_002)
private_child = issues(:issues_003) private_child = issues(:issues_003)
other = issues(:issues_007) other = issues(:issues_007)
User.current = users(:users_001) User.current = users(:users_001)
parent.safe_attributes = {:estimated_hours => 1} parent.safe_attributes = {:estimated_hours => 1}
 End of changes. 5 change blocks. 
3 lines changed or deleted 64 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)