summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-29 12:57:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-29 12:57:38 +0000
commit1b6da80e16dd0cb200588422dfc5a655cb3b94f0 (patch)
tree5a4bedc3760b89680f96e989fa606fcba92e6250 /test
parent69b8931e92e37feceb7353d5baa6be6a51492bf0 (diff)
downloadredmine-1b6da80e16dd0cb200588422dfc5a655cb3b94f0.tar.gz
redmine-1b6da80e16dd0cb200588422dfc5a655cb3b94f0.zip
Makes related issues available for display and filtering on the issue list (#3239, #3265).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10513 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb40
-rw-r--r--test/unit/query_test.rb70
2 files changed, 108 insertions, 2 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 8f8f1e27b..e5079b5a6 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -766,7 +766,7 @@ class IssuesControllerTest < ActionController::TestCase
end
end
- def test_index_with_done_ratio
+ def test_index_with_done_ratio_column
Issue.find(1).update_attribute :done_ratio, 40
get :index, :set_filter => 1, :c => %w(done_ratio)
@@ -792,12 +792,48 @@ class IssuesControllerTest < ActionController::TestCase
assert_no_tag 'td', :attributes => {:class => /spent_hours/}
end
- def test_index_with_fixed_version
+ def test_index_with_fixed_version_column
get :index, :set_filter => 1, :c => %w(fixed_version)
assert_tag 'td', :attributes => {:class => /fixed_version/},
:child => {:tag => 'a', :content => '1.0', :attributes => {:href => '/versions/2'}}
end
+ def test_index_with_relations_column
+ IssueRelation.delete_all
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(7))
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(8), :issue_to => Issue.find(1))
+ IssueRelation.create!(:relation_type => "blocks", :issue_from => Issue.find(1), :issue_to => Issue.find(11))
+ IssueRelation.create!(:relation_type => "blocks", :issue_from => Issue.find(12), :issue_to => Issue.find(2))
+
+ get :index, :set_filter => 1, :c => %w(subject relations)
+ assert_response :success
+ assert_select "tr#issue-1 td.relations" do
+ assert_select "span", 3
+ assert_select "span", :text => "Related to #7"
+ assert_select "span", :text => "Related to #8"
+ assert_select "span", :text => "Blocks #11"
+ end
+ assert_select "tr#issue-2 td.relations" do
+ assert_select "span", 1
+ assert_select "span", :text => "Blocked by #12"
+ end
+ assert_select "tr#issue-3 td.relations" do
+ assert_select "span", 0
+ end
+
+ get :index, :set_filter => 1, :c => %w(relations), :format => 'csv'
+ assert_response :success
+ assert_equal 'text/csv; header=present', response.content_type
+ lines = response.body.chomp.split("\n")
+ assert_include '1,"Related to #7, Related to #8, Blocks #11"', lines
+ assert_include '2,Blocked by #12', lines
+ assert_include '3,""', lines
+
+ get :index, :set_filter => 1, :c => %w(subject relations), :format => 'pdf'
+ assert_response :success
+ assert_equal 'application/pdf', response.content_type
+ end
+
def test_index_send_html_if_query_is_invalid
get :index, :f => ['start_date'], :op => {:start_date => '='}
assert_equal 'text/html', @response.content_type
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 5f639a84f..fac5b97dc 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -624,6 +624,76 @@ class QueryTest < ActiveSupport::TestCase
assert_equal [2], find_issues_with_query(query).map(&:fixed_version_id).uniq.sort
end
+ def test_filter_on_relations_with_a_specific_issue
+ IssueRelation.delete_all
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '=', :values => ['1']}}
+ assert_equal [2, 3], find_issues_with_query(query).map(&:id).sort
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '=', :values => ['2']}}
+ assert_equal [1], find_issues_with_query(query).map(&:id).sort
+ end
+
+ def test_filter_on_relations_with_any_issues_in_a_project
+ IssueRelation.delete_all
+ with_settings :cross_project_issue_relations => '1' do
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Project.find(2).issues.first)
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(2), :issue_to => Project.find(2).issues.first)
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Project.find(3).issues.first)
+ end
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '=p', :values => ['2']}}
+ assert_equal [1, 2], find_issues_with_query(query).map(&:id).sort
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '=p', :values => ['3']}}
+ assert_equal [1], find_issues_with_query(query).map(&:id).sort
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '=p', :values => ['4']}}
+ assert_equal [], find_issues_with_query(query).map(&:id).sort
+ end
+
+ def test_filter_on_relations_with_any_issues_not_in_a_project
+ IssueRelation.delete_all
+ with_settings :cross_project_issue_relations => '1' do
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Project.find(2).issues.first)
+ #IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(2), :issue_to => Project.find(1).issues.first)
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Project.find(3).issues.first)
+ end
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '=!p', :values => ['1']}}
+ assert_equal [1], find_issues_with_query(query).map(&:id).sort
+ end
+
+ def test_filter_on_relations_with_no_issues
+ IssueRelation.delete_all
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '!*', :values => ['']}}
+ ids = find_issues_with_query(query).map(&:id)
+ assert_equal [], ids & [1, 2, 3]
+ assert_include 4, ids
+ end
+
+ def test_filter_on_relations_with_any_issue
+ IssueRelation.delete_all
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
+ IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
+
+ query = Query.new(:name => '_')
+ query.filters = {"relates" => {:operator => '*', :values => ['']}}
+ assert_equal [1, 2, 3], find_issues_with_query(query).map(&:id)
+ end
+
def test_statement_should_be_nil_with_no_filters
q = Query.new(:name => '_')
q.filters = {}