Version sharing (#465) + optional inclusion of subprojects in the roadmap view (#2666).

Each version of a project can be shared with:
* subprojects
* projects in the project hierarchy: ancestors + descendants (needs versions management permission on the root project)
* projects in the project tree: root project + all its descendants (same as above)
* all projects (can be set by admin users only)

Notes:
* when sharing a version of a private project with others projects, its name will be visible within the other projects
* a project with versions used by non descendant projects can not be archived

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3123 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2009-12-06 10:28:20 +00:00
parent e178123569
commit 5f8e9d7118
40 changed files with 659 additions and 75 deletions
+11 -10
View File
@@ -1,10 +1,11 @@
class Version < ActiveRecord::Base
generator_for :name, :method => :next_name
def self.next_name
@last_name ||= 'Version 1.0.0'
@last_name.succ!
@last_name
end
end
class Version < ActiveRecord::Base
generator_for :name, :method => :next_name
generator_for :status => 'open'
def self.next_name
@last_name ||= 'Version 1.0.0'
@last_name.succ!
@last_name
end
end
+12 -1
View File
@@ -133,4 +133,15 @@ attachments_011:
filename: picture.jpg
author_id: 2
content_type: image/jpeg
attachments_012:
created_on: 2006-07-19 21:07:27 +02:00
container_type: Version
container_id: 1
downloads: 0
disk_filename: 060719210727_version_file.zip
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
id: 12
filesize: 452
filename: version_file.zip
author_id: 2
content_type: application/octet-stream
+14
View File
@@ -189,3 +189,17 @@ issues_012:
status_id: 5
start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date:
issues_013:
created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 3
updated_on: <%= 2.days.ago.to_date.to_s(:db) %>
priority_id: 4
subject: Subproject issue two
id: 13
fixed_version_id:
category_id:
description: This is a second issue on a cookbook subproject
tracker_id: 1
assigned_to_id:
author_id: 2
status_id: 1
+7
View File
@@ -13,3 +13,10 @@ journal_details_002:
value: "30"
prop_key: done_ratio
journal_id: 1
journal_details_003:
old_value: nil
property: attr
id: 3
value: "6"
prop_key: fixed_version_id
journal_id: 4
+7 -1
View File
@@ -20,4 +20,10 @@ journals_003:
journalized_type: Issue
user_id: 2
journalized_id: 2
journals_004:
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
notes: "A comment with a private version."
id: 4
journalized_type: Issue
user_id: 1
journalized_id: 6
+6 -1
View File
@@ -42,4 +42,9 @@ members_007:
project_id: 5
user_id: 8
mail_notification: false
members_008:
created_on: 2006-07-19 19:35:33 +02:00
project_id: 5
id: 8
user_id: 1
mail_notification: true
+43 -1
View File
@@ -8,6 +8,7 @@ versions_001:
description: Beta
effective_date: 2006-07-01
status: closed
sharing: 'none'
versions_002:
created_on: 2006-07-19 21:00:33 +02:00
name: "1.0"
@@ -17,6 +18,7 @@ versions_002:
description: Stable release
effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>
status: locked
sharing: 'none'
versions_003:
created_on: 2006-07-19 21:00:33 +02:00
name: "2.0"
@@ -26,4 +28,44 @@ versions_003:
description: Future version
effective_date:
status: open
sharing: 'none'
versions_004:
created_on: 2006-07-19 21:00:33 +02:00
name: "2.0"
project_id: 3
updated_on: 2006-07-19 21:00:33 +02:00
id: 4
description: Future version on subproject
effective_date:
status: open
sharing: 'tree'
versions_005:
created_on: 2006-07-19 21:00:07 +02:00
name: "Alpha"
project_id: 2
updated_on: 2006-07-19 21:00:07 +02:00
id: 5
description: Private Alpha
effective_date: 2006-07-01
status: open
sharing: 'none'
versions_006:
created_on: 2006-07-19 21:00:07 +02:00
name: "Private Version of public subproject"
project_id: 5
updated_on: 2006-07-19 21:00:07 +02:00
id: 6
description: "Should be done any day now..."
effective_date:
status: open
sharing: 'tree'
versions_007:
created_on: 2006-07-19 21:00:07 +02:00
name: "Systemwide visible version"
project_id: 2
updated_on: 2006-07-19 21:00:07 +02:00
id: 7
description:
effective_date:
status: open
sharing: 'system'
+39
View File
@@ -925,6 +925,22 @@ class IssuesControllerTest < ActionController::TestCase
assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
end
def test_post_edit_should_allow_fixed_version_to_be_set_to_a_subproject
issue = Issue.find(2)
@request.session[:user_id] = 2
post :edit,
:id => issue.id,
:issue => {
:fixed_version_id => 4
}
assert_response :redirect
issue.reload
assert_equal 4, issue.fixed_version_id
assert_not_equal issue.project_id, issue.fixed_version.project_id
end
def test_get_bulk_edit
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 2]
@@ -1005,6 +1021,21 @@ class IssuesControllerTest < ActionController::TestCase
assert_nil Issue.find(2).assigned_to
end
def test_post_bulk_edit_should_allow_fixed_version_to_be_set_to_a_subproject
@request.session[:user_id] = 2
post :bulk_edit,
:ids => [1,2],
:fixed_version_id => 4
assert_response :redirect
issues = Issue.find([1,2])
issues.each do |issue|
assert_equal 4, issue.fixed_version_id
assert_not_equal issue.project_id, issue.fixed_version.project_id
end
end
def test_move_routing
assert_routing(
{:method => :get, :path => '/issues/1/move'},
@@ -1101,6 +1132,14 @@ class IssuesControllerTest < ActionController::TestCase
assert_tag :tag => 'a', :content => 'Immediate',
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
:class => '' }
# Versions
assert_tag :tag => 'a', :content => '2.0',
:attributes => { :href => '/issues/bulk_edit?fixed_version_id=3&amp;ids%5B%5D=1',
:class => '' }
assert_tag :tag => 'a', :content => 'eCookbook Subproject 1 - 2.0',
:attributes => { :href => '/issues/bulk_edit?fixed_version_id=4&amp;ids%5B%5D=1',
:class => '' }
assert_tag :tag => 'a', :content => 'Dave Lopper',
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
:class => '' }
@@ -364,6 +364,15 @@ class ProjectsControllerTest < ActionController::TestCase
assert_not_nil assigns(:versions)
end
def test_changelog_showing_subprojects_versions
get :changelog, :id => 1, :with_subprojects => 1
assert_response :success
assert_template 'changelog'
assert_not_nil assigns(:versions)
# Version on subproject appears
assert assigns(:versions).include?(Version.find(4))
end
def test_roadmap_routing
assert_routing(
{:method => :get, :path => 'projects/33/roadmap'},
@@ -392,6 +401,15 @@ class ProjectsControllerTest < ActionController::TestCase
# Completed version appears
assert assigns(:versions).include?(Version.find(1))
end
def test_roadmap_showing_subprojects_versions
get :roadmap, :id => 1, :with_subprojects => 1
assert_response :success
assert_template 'roadmap'
assert_not_nil assigns(:versions)
# Version on subproject appears
assert assigns(:versions).include?(Version.find(4))
end
def test_project_activity_routing
assert_routing(
+1 -1
View File
@@ -24,7 +24,7 @@ rescue
end
class AccountTest < ActionController::IntegrationTest
fixtures :users
fixtures :users, :roles
# Replace this with your real tests.
def test_login
+1
View File
@@ -49,6 +49,7 @@ class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
def log_user(login, password)
User.anonymous
get "/login"
assert_equal nil, session[:user_id]
assert_response :success
+2 -2
View File
@@ -25,7 +25,7 @@ class EnumerationTest < ActiveSupport::TestCase
def test_objects_count
# low priority
assert_equal 5, Enumeration.find(4).objects_count
assert_equal 6, Enumeration.find(4).objects_count
# urgent
assert_equal 0, Enumeration.find(7).objects_count
end
@@ -79,7 +79,7 @@ class EnumerationTest < ActiveSupport::TestCase
def test_destroy_with_reassign
Enumeration.find(4).destroy(Enumeration.find(6))
assert_nil Issue.find(:first, :conditions => {:priority_id => 4})
assert_equal 5, Enumeration.find(6).objects_count
assert_equal 6, Enumeration.find(6).objects_count
end
def test_should_be_customizable
+63
View File
@@ -0,0 +1,63 @@
# Redmine - project management software
# Copyright (C) 2006-2009 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.dirname(__FILE__) + '/../../test_helper'
class ProjectsHelperTest < HelperTestCase
include ApplicationHelper
include ProjectsHelper
fixtures :all
def setup
super
set_language_if_valid('en')
User.current = nil
end
def test_link_to_version_within_project
@project = Project.find(2)
User.current = User.find(1)
assert_equal '<a href="/versions/show/5">Alpha</a>', link_to_version(Version.find(5))
end
def test_link_to_version
User.current = User.find(1)
assert_equal '<a href="/versions/show/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
end
def test_link_to_private_version
assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
end
def test_link_to_version_invalid_version
assert_equal '', link_to_version(Object)
end
def test_format_version_name_within_project
@project = Project.find(1)
assert_equal "0.1", format_version_name(Version.find(1))
end
def test_format_version_name
assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
end
def test_format_version_name_for_system_version
assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
end
end
+1 -1
View File
@@ -26,7 +26,7 @@ class IssuePriorityTest < ActiveSupport::TestCase
def test_objects_count
# low priority
assert_equal 5, IssuePriority.find(4).objects_count
assert_equal 6, IssuePriority.find(4).objects_count
# urgent
assert_equal 0, IssuePriority.find(7).objects_count
end
+40
View File
@@ -329,6 +329,46 @@ class IssueTest < ActiveSupport::TestCase
assert_nil issue.category_id
end
def test_move_to_another_project_should_clear_fixed_version_when_not_shared
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 1)
assert issue.move_to(Project.find(2))
issue.reload
assert_equal 2, issue.project_id
# Cleared fixed_version
assert_equal nil, issue.fixed_version
end
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 4)
assert issue.move_to(Project.find(5))
issue.reload
assert_equal 5, issue.project_id
# Keep fixed_version
assert_equal 4, issue.fixed_version_id
end
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 1)
assert issue.move_to(Project.find(5))
issue.reload
assert_equal 5, issue.project_id
# Cleared fixed_version
assert_equal nil, issue.fixed_version
end
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 7)
assert issue.move_to(Project.find(2))
issue.reload
assert_equal 2, issue.project_id
# Keep fixed_version
assert_equal 7, issue.fixed_version_id
end
def test_copy_to_the_same_project
issue = Issue.find(1)
copy = nil
+101 -11
View File
@@ -18,10 +18,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class ProjectTest < ActiveSupport::TestCase
fixtures :projects, :enabled_modules,
:issues, :issue_statuses, :journals, :journal_details,
:users, :members, :member_roles, :roles, :projects_trackers, :trackers, :boards,
:queries
fixtures :all
def setup
@ecookbook = Project.find(1)
@@ -111,6 +108,17 @@ class ProjectTest < ActiveSupport::TestCase
assert @ecookbook.descendants.active.empty?
end
def test_archive_should_fail_if_versions_are_used_by_non_descendant_projects
# Assign an issue of a project to a version of a child project
Issue.find(4).update_attribute :fixed_version_id, 4
assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do
assert_equal false, @ecookbook.archive
end
@ecookbook.reload
assert @ecookbook.active?
end
def test_unarchive
user = @ecookbook.members.first.user
@ecookbook.archive
@@ -206,6 +214,38 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal 4, parent.children.size
assert_equal parent.children.sort_by(&:name), parent.children
end
def test_set_parent_should_update_issue_fixed_version_associations_when_a_fixed_version_is_moved_out_of_the_hierarchy
# Parent issue with a hierarchy project's fixed version
parent_issue = Issue.find(1)
parent_issue.update_attribute(:fixed_version_id, 4)
parent_issue.reload
assert_equal 4, parent_issue.fixed_version_id
# Should keep fixed versions for the issues
issue_with_local_fixed_version = Issue.find(5)
issue_with_local_fixed_version.update_attribute(:fixed_version_id, 4)
issue_with_local_fixed_version.reload
assert_equal 4, issue_with_local_fixed_version.fixed_version_id
# Local issue with hierarchy fixed_version
issue_with_hierarchy_fixed_version = Issue.find(13)
issue_with_hierarchy_fixed_version.update_attribute(:fixed_version_id, 6)
issue_with_hierarchy_fixed_version.reload
assert_equal 6, issue_with_hierarchy_fixed_version.fixed_version_id
# Move project out of the issue's hierarchy
moved_project = Project.find(3)
moved_project.set_parent!(Project.find(2))
parent_issue.reload
issue_with_local_fixed_version.reload
issue_with_hierarchy_fixed_version.reload
assert_equal 4, issue_with_local_fixed_version.fixed_version_id, "Fixed version was not keep on an issue local to the moved project"
assert_equal nil, issue_with_hierarchy_fixed_version.fixed_version_id, "Fixed version is still set after moving the Project out of the hierarchy where the version is defined in"
assert_equal nil, parent_issue.fixed_version_id, "Fixed version is still set after moving the Version out of the hierarchy for the issue."
end
def test_parent
p = Project.find(6).parent
@@ -277,13 +317,61 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal [1,2], parent.rolled_up_trackers.collect(&:id)
end
def test_shared_versions
parent = Project.find(1)
child = parent.children.find(3)
private_child = parent.children.find(5)
assert_equal [1,2,3], parent.version_ids.sort
assert_equal [4], child.version_ids
assert_equal [6], private_child.version_ids
assert_equal [7], Version.find_all_by_sharing('system').collect(&:id)
assert_equal 6, parent.shared_versions.size
parent.shared_versions.each do |version|
assert_kind_of Version, version
end
assert_equal [1,2,3,4,6,7], parent.shared_versions.collect(&:id).sort
end
def test_shared_versions_should_ignore_archived_subprojects
parent = Project.find(1)
child = parent.children.find(3)
child.archive
parent.reload
assert_equal [1,2,3], parent.version_ids.sort
assert_equal [4], child.version_ids
assert !parent.shared_versions.collect(&:id).include?(4)
end
def test_shared_versions_visible_to_user
user = User.find(3)
parent = Project.find(1)
child = parent.children.find(5)
assert_equal [1,2,3], parent.version_ids.sort
assert_equal [6], child.version_ids
versions = parent.shared_versions.visible(user)
assert_equal 4, versions.size
versions.each do |version|
assert_kind_of Version, version
end
assert !versions.collect(&:id).include?(6)
end
def test_next_identifier
ProjectCustomField.delete_all
Project.create!(:name => 'last', :identifier => 'p2008040')
assert_equal 'p2008041', Project.next_identifier
end
def test_next_identifier_first_project
Project.delete_all
assert_nil Project.next_identifier
@@ -429,13 +517,15 @@ class ProjectTest < ActiveSupport::TestCase
end
should "change the new issues to use the copied version" do
assigned_version = Version.generate!(:name => "Assigned Issues")
User.current = User.find(1)
assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open')
@source_project.versions << assigned_version
assert_equal 1, @source_project.versions.size
@source_project.issues << Issue.generate!(:fixed_version_id => assigned_version.id,
:subject => "change the new issues to use the copied version",
:tracker_id => 1,
:project_id => @source_project.id)
assert_equal 3, @source_project.versions.size
Issue.generate_for_project!(@source_project,
:fixed_version_id => assigned_version.id,
:subject => "change the new issues to use the copied version",
:tracker_id => 1,
:project_id => @source_project.id)
assert @project.copy(@source_project)
@project.reload
+8
View File
@@ -31,6 +31,14 @@ class QueryTest < ActiveSupport::TestCase
:include => [ :assigned_to, :status, :tracker, :project, :priority ],
:conditions => query.statement
end
def test_query_should_allow_shared_versions_for_a_project_query
subproject_version = Version.find(4)
query = Query.new(:project => Project.find(1), :name => '_')
query.add_filter('fixed_version_id', '=', [subproject_version.id.to_s])
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IN ('4')")
end
def test_query_with_multiple_custom_fields
query = Query.find(1)
+35
View File
@@ -104,6 +104,41 @@ class VersionTest < ActiveSupport::TestCase
assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent
assert_progress_equal 25.0/100.0*100, v.closed_pourcent
end
test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do
User.current = User.find(1) # Need the admin's permissions
@version = Version.find(7)
# Separate hierarchy
project_1_issue = Issue.find(1)
project_1_issue.fixed_version = @version
assert project_1_issue.save, project_1_issue.errors.full_messages
project_5_issue = Issue.find(6)
project_5_issue.fixed_version = @version
assert project_5_issue.save
# Project
project_2_issue = Issue.find(4)
project_2_issue.fixed_version = @version
assert project_2_issue.save
# Update the sharing
@version.sharing = 'none'
assert @version.save
# Project 1 now out of the shared scope
project_1_issue.reload
assert_equal nil, project_1_issue.fixed_version, "Fixed version is still set after changing the Version's sharing"
# Project 5 now out of the shared scope
project_5_issue.reload
assert_equal nil, project_5_issue.fixed_version, "Fixed version is still set after changing the Version's sharing"
# Project 2 issue remains
project_2_issue.reload
assert_equal @version, project_2_issue.fixed_version
end
private