summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-04-11 09:11:40 +0000
committerGo MAEDA <maeda@farend.jp>2023-04-11 09:11:40 +0000
commit9546dfa5e3aac247db62ea3a0d8e09672ed8196b (patch)
treee6a8d55193cc05f4470836502ea13fd6abe7fef5 /test
parent87f3352d3a64e2b6a89aa7036852627eb3953e6f (diff)
downloadredmine-9546dfa5e3aac247db62ea3a0d8e09672ed8196b.tar.gz
redmine-9546dfa5e3aac247db62ea3a0d8e09672ed8196b.zip
Add Parent task filter and column to Spent time (#37623).
Patch by Mizuki ISHIKAWA. git-svn-id: https://svn.redmine.org/redmine/trunk@22177 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/timelog_controller_test.rb46
-rw-r--r--test/unit/query_test.rb26
2 files changed, 72 insertions, 0 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 2ccbf56f4..79e543253 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -1387,6 +1387,52 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_select 'td.issue-category', :text => 'Printing'
end
+ def test_index_with_issue_parent_filter
+ issue1 = Issue.generate!(project_id: 'ecookbook', parent_id: 2)
+ entry1 = TimeEntry.generate!(issue: issue1, hours: 2.5)
+ issue2 = Issue.generate!(project_id: 'ecookbook', parent_id: 5)
+ entry2 = TimeEntry.generate!(issue: issue2, hours: 5.0)
+
+ get :index, params: {
+ project_id: 'ecookbook',
+ f: ['issue.parent_id'],
+ op: {'issue.parent_id' => '='},
+ v: {'issue.parent_id' => ['2,5']}
+ }
+ assert_response :success
+ assert_equal [entry1.id, entry2.id].sort, css_select('input[name="ids[]"]').map {|e| e.attr(:value).to_i}.sort
+ end
+
+ def test_index_with_issue_parent_column
+ issue = Issue.generate!(project_id: 'ecookbook', parent_id: 2)
+ entry = TimeEntry.generate!(issue: issue, hours: 2.5)
+
+ get :index, params: {
+ project_id: 'ecookbook',
+ c: %w(project spent_on issue comments hours issue.parent)
+ }
+
+ assert_response :success
+ assert_select 'td.issue-parent', text: "#{issue.parent.tracker} ##{issue.parent.id}"
+ end
+
+ def test_index_with_issue_parent_sort
+ issue1 = Issue.generate!(project_id: 'ecookbook', parent_id: 2)
+ entry1 = TimeEntry.generate!(issue: issue1, hours: 2.5)
+ issue2 = Issue.generate!(project_id: 'ecookbook', parent_id: 5)
+ entry2 = TimeEntry.generate!(issue: issue2, hours: 5.0)
+
+ get :index, :params => {
+ :c => ["hours", 'issue.parent'],
+ :sort => 'issue.parent'
+ }
+ assert_response :success
+
+ # Make sure that values are properly sorted
+ values = css_select("td.issue-parent").map(&:text).reject(&:blank?)
+ assert_equal ["#{issue1.parent.tracker} ##{issue1.parent.id}", "#{issue2.parent.tracker} ##{issue2.parent.id}"].sort, values.sort
+ end
+
def test_index_with_issue_fixed_version_column
issue = Issue.find(1)
issue.fixed_version = Version.find(3)
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 607679e83..55500ff13 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -504,6 +504,32 @@ class QueryTest < ActiveSupport::TestCase
find_issues_with_query(query)
end
+ def test_time_entry_operator_is_on_issue_parent_id_should_accept_comma_separated_values
+ issue1 = Issue.generate!(project_id: 'ecookbook', parent_id: 2)
+ entry1 = TimeEntry.generate!(issue: issue1)
+ issue2 = Issue.generate!(project_id: 'ecookbook', parent_id: 5)
+ entry2 = TimeEntry.generate!(issue: issue2)
+
+ query = TimeEntryQuery.new(:name => '_')
+ query.add_filter("issue.parent_id", '=', ['2,5'])
+ entries = TimeEntry.where(query.statement).to_a
+ assert_equal 2, entries.size
+ assert_equal [entry1.id, entry2.id].sort, entries.map(&:id).sort
+ end
+
+ def test_time_entry_contains_operator_is_on_issue_parent_id
+ issue1 = Issue.generate!(project_id: 'ecookbook', parent_id: 2)
+ entry1 = TimeEntry.generate!(issue: issue1)
+ issue2 = Issue.generate!(project_id: 'ecookbook', parent_id: issue1.id)
+ entry2 = TimeEntry.generate!(issue: issue2)
+
+ query = TimeEntryQuery.new(:name => '_')
+ query.add_filter("issue.parent_id", '~', ['2'])
+ entries = TimeEntry.where(query.statement).to_a
+ assert_equal 2, entries.size
+ assert_equal [entry1.id, entry2.id].sort, entries.map(&:id).sort
+ end
+
def test_date_filter_should_not_accept_non_date_values
query = IssueQuery.new(:name => '_')
query.add_filter('created_on', '=', ['a'])