From 329ec41b133c73d848d2c7572472b6cf03c0ae32 Mon Sep 17 00:00:00 2001 From: Danil Tashkinov Date: Tue, 13 May 2014 17:18:32 +0400 Subject: respect version sharing options when generating links to issues from version overview --- app/helpers/application_helper.rb | 13 ++++++++++ app/views/versions/_overview.html.erb | 24 ++++++++----------- test/unit/helpers/application_helper_test.rb | 36 +++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9cb5b96..1f1dfa7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1339,6 +1339,19 @@ module ApplicationHelper end end + def version_issues_cpath(version, options = {}) + options = { :fixed_version_id => version, :set_filter => 1 }.merge(options) + project = case version.sharing + when 'hierarchy', 'tree' + version.project.root if version.project.root.visible? + when 'system' + nil + else + version.project + end + project ? project_issues_path(project, options) : issues_path(options) + end + private def wiki_helper diff --git a/app/views/versions/_overview.html.erb b/app/views/versions/_overview.html.erb index 4a7d429..1abd6ac 100644 --- a/app/views/versions/_overview.html.erb +++ b/app/views/versions/_overview.html.erb @@ -19,20 +19,16 @@ <%= progress_bar([version.closed_percent, version.completed_percent], :width => '40em', :legend => ('%0.0f%' % version.completed_percent)) %>

- <%= link_to(l(:label_x_issues, :count => version.issues_count), - project_issues_path(version.project, - :status_id => '*', :fixed_version_id => version, - :set_filter => 1)) %> -   - (<%= link_to_if(version.closed_issues_count > 0, - l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), - project_issues_path(version.project, :status_id => 'c', - :fixed_version_id => version, :set_filter => 1)) %> - — - <%= link_to_if(version.open_issues_count > 0, - l(:label_x_open_issues_abbr, :count => version.open_issues_count), - project_issues_path(version.project, :status_id => 'o', - :fixed_version_id => version, :set_filter => 1)) %>) + <%= link_to(l(:label_x_issues, :count => version.issues_count), + version_issues_cpath(version, :status_id => '*')) %> +   + (<%= link_to_if(version.closed_issues_count > 0, + l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), + version_issues_cpath(version, :status_id => 'c')) %> + — + <%= link_to_if(version.open_issues_count > 0, + l(:label_x_open_issues_abbr, :count => version.open_issues_count), + version_issues_cpath(version, :status_id => 'o')) %>)

<% else %>

<%= l(:label_roadmap_no_issues) %>

diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 58b19f0..bb80f98 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -291,7 +291,7 @@ RAW board_url = {:controller => 'boards', :action => 'show', :id => 2, :project_id => 'ecookbook'} message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4} - + news_url = {:controller => 'news', :action => 'show', :id => 1} project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'} @@ -933,12 +933,12 @@ EXPECTED def test_pre_content_should_not_parse_wiki_and_redmine_links raw = <<-RAW [[CookBook documentation]] - + #1
 [[CookBook documentation]]
-  
+
 #1
 
RAW @@ -1513,4 +1513,34 @@ RAW assert_equal "#{ja} #{ja}...", result assert !result.html_safe? end + + def test_version_issues_cpath_sharing_none + version = Version.new(:name => 'test', :sharing => 'none') + version.project = Project.find(5) + assert_match '/projects/private-child/issues?', version_issues_cpath(version) + end + + def test_version_issues_cpath_sharing_descendants + version = Version.new(:name => 'test', :sharing => 'descendants') + version.project = Project.find(5) + assert_match '/projects/private-child/issues?', version_issues_cpath(version) + end + + def test_version_issues_cpath_sharing_hierarchy + version = Version.new(:name => 'test', :sharing => 'hierarchy') + version.project = Project.find(5) + assert_match '/projects/ecookbook/issues?', version_issues_cpath(version) + end + + def test_version_issues_cpath_sharing_tree + version = Version.new(:name => 'test', :sharing => 'tree') + version.project = Project.find(5) + assert_match '/projects/ecookbook/issues?', version_issues_cpath(version) + end + + def test_version_issues_cpath_sharing_system + version = Version.new(:name => 'test', :sharing => 'system') + version.project = Project.find(5) + assert_match /^\/issues\?/, version_issues_cpath(version) + end end -- 1.8.4.2