]> source.dussan.org Git - redmine.git/commitdiff
Don't prepend project name if the version is not shared.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Jul 2014 11:26:29 +0000 (11:26 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Jul 2014 11:26:29 +0000 (11:26 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13325 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
app/models/version.rb
test/functional/issues_controller_test.rb
test/unit/helpers/projects_helper_test.rb

index 135551e81a590de34b5a5282d6ed6011084f15ba..f344f169b5966a6cb62e46f507507f4e3884a940 100644 (file)
@@ -247,7 +247,7 @@ module ApplicationHelper
   end
 
   def format_version_name(version)
-    if version.project == @project
+    if !version.shared? || version.project == @project
       h(version)
     else
       h("#{version.project} - #{version}")
index b80f0f2d175ce6611cc878da997bb27366ae574d..76853e4b03ff524a357aee35c079764819f429a6 100644 (file)
@@ -226,6 +226,11 @@ class Version < ActiveRecord::Base
     end
   end
 
+  # Returns true if the version is shared, otherwise false
+  def shared?
+    sharing != 'none'
+  end
+
   private
 
   def load_issue_counts
index 77f2ed5a898f8f514d912aedc27bc3d4c4a5cdab..9f3542e013e7c07605ea8bf59c6205779997d560 100644 (file)
@@ -816,7 +816,7 @@ class IssuesControllerTest < ActionController::TestCase
   def test_index_with_fixed_version_column
     get :index, :set_filter => 1, :c => %w(fixed_version)
     assert_select 'table.issues td.fixed_version' do
-      assert_select 'a[href=?]', '/versions/2', :text => 'eCookbook - 1.0'
+      assert_select 'a[href=?]', '/versions/2', :text => '1.0'
     end
   end
 
index a11cc6d9e0ca84c499d24315496228ce331175a1..b4db5d42f31b378cd891ef09a3bd4c4e8a104d20 100644 (file)
@@ -47,18 +47,18 @@ class ProjectsHelperTest < ActionView::TestCase
 
   def test_link_to_version
     User.current = User.find(1)
-    assert_equal '<a href="/versions/5" title="07/01/2006">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
+    assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
   end
 
   def test_link_to_version_without_effective_date
     User.current = User.find(1)
     version = Version.find(5)
     version.effective_date = nil
-    assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(version)
+    assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(version)
   end
 
   def test_link_to_private_version
-    assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
+    assert_equal 'Alpha', link_to_version(Version.find(5))
   end
 
   def test_link_to_version_invalid_version
@@ -71,11 +71,20 @@ class ProjectsHelperTest < ActionView::TestCase
   end
 
   def test_format_version_name
-    assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
+    assert_equal "0.1", format_version_name(Version.find(1))
+  end
+
+  def test_format_version_name_for_shared_version_within_project_should_not_display_project_name
+    @project = Project.find(1)
+    version = Version.find(1)
+    version.sharing = 'system'
+    assert_equal "0.1", format_version_name(version)
   end
 
-  def test_format_version_name_for_system_version
-    assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
+  def test_format_version_name_for_shared_version_should_display_project_name
+    version = Version.find(1)
+    version.sharing = 'system'
+    assert_equal "eCookbook - 0.1", format_version_name(version)
   end
 
   def test_version_options_for_select_with_no_versions