diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index e6f886734..91dec8e91 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -19,6 +19,14 @@ module VersionsHelper + def version_anchor(version) + if @project == version.project + anchor version.name + else + anchor "#{version.project.try(:identifier)}-#{version.name}" + end + end + STATUS_BY_CRITERIAS = %w(tracker status priority author assigned_to category) def render_issue_status_by(version, criteria) diff --git a/app/views/versions/index.html.erb b/app/views/versions/index.html.erb index b79bdb045..a4b0e3669 100644 --- a/app/views/versions/index.html.erb +++ b/app/views/versions/index.html.erb @@ -9,7 +9,7 @@ <% else %>
<% @versions.each do |version| %> -

<%= link_to_version version, :name => anchor(version.name) %>

+

<%= link_to_version version, :name => version_anchor(version) %>

<%= render :partial => 'versions/overview', :locals => {:version => version} %> <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> @@ -49,7 +49,7 @@

<%= l(:label_version_plural) %>

<% @versions.each do |version| %> -<%= link_to format_version_name(version), "##{anchor(version.name)}" %>
+<%= link_to format_version_name(version), "##{version_anchor(version)}" %>
<% end %> <% if @completed_versions.present? %>

diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb index 87fd966b6..c6906ca5b 100644 --- a/test/functional/versions_controller_test.rb +++ b/test/functional/versions_controller_test.rb @@ -80,6 +80,20 @@ class VersionsControllerTest < ActionController::TestCase assert assigns(:versions).include?(@subproject_version), "Subproject version not found" end + def test_index_should_prepend_shared_versions + get :index, :project_id => 1 + assert_response :success + + assert_select '#sidebar' do + assert_select 'a[href=?]', '#2.0', :text => '2.0' + assert_select 'a[href=?]', '#subproject1-2.0', :text => 'eCookbook Subproject 1 - 2.0' + end + assert_select '#content' do + assert_select 'a[name=?]', '2.0', :text => '2.0' + assert_select 'a[name=?]', 'subproject1-2.0', :text => 'eCookbook Subproject 1 - 2.0' + end + end + def test_show get :show, :id => 2 assert_response :success