Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 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
|
||||
|
@ -192,18 +194,23 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
def test_unarchive
|
||||
user = @ecookbook.members.first.user
|
||||
@ecookbook.archive
|
||||
# A subproject of an archived project can not be unarchived
|
||||
assert !@ecookbook_sub1.unarchive
|
||||
|
||||
# Unarchive project
|
||||
assert @ecookbook.unarchive
|
||||
@ecookbook.reload
|
||||
assert @ecookbook.active?
|
||||
assert !@ecookbook.archived?
|
||||
assert user.projects.include?(@ecookbook)
|
||||
# Subproject can now be unarchived
|
||||
end
|
||||
|
||||
def test_unarchive_child_project_should_unarchive_ancestors
|
||||
@ecookbook.archive
|
||||
@ecookbook_sub1.reload
|
||||
assert @ecookbook_sub1.unarchive
|
||||
assert_equal Project::STATUS_ARCHIVED, @ecookbook_sub1.status
|
||||
|
||||
@ecookbook_sub1.unarchive
|
||||
assert_equal Project::STATUS_ACTIVE, @ecookbook_sub1.status
|
||||
@ecookbook.reload
|
||||
assert_equal Project::STATUS_ACTIVE, @ecookbook.status
|
||||
end
|
||||
|
||||
def test_unarchive_a_child_of_a_closed_project_should_set_status_to_closed
|
||||
|
@ -315,15 +322,13 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_set_parent_should_add_roots_in_alphabetical_order
|
||||
ProjectCustomField.delete_all
|
||||
Project.delete_all
|
||||
Project.create!(:name => 'Project C', :identifier => 'project-c').set_parent!(nil)
|
||||
Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(nil)
|
||||
Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(nil)
|
||||
Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(nil)
|
||||
|
||||
assert_equal 4, Project.count
|
||||
assert_equal Project.all.sort_by(&:name), Project.all.sort_by(&:lft)
|
||||
projects = new_records(Project, 4) do
|
||||
Project.create!(:name => 'Project C', :identifier => 'project-c').set_parent!(nil)
|
||||
Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(nil)
|
||||
Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(nil)
|
||||
Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(nil)
|
||||
end
|
||||
assert_equal projects.sort_by(&:name), projects.sort_by(&:lft)
|
||||
end
|
||||
|
||||
def test_set_parent_should_add_children_in_alphabetical_order
|
||||
|
@ -462,6 +467,7 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
parent = Project.find(1)
|
||||
parent.trackers = Tracker.find([1,2])
|
||||
child = parent.children.find(3)
|
||||
child.trackers = Tracker.find([2,3])
|
||||
|
||||
assert_equal [1, 2], parent.tracker_ids
|
||||
assert_equal [2, 3], child.trackers.collect(&:id)
|
||||
|
@ -516,7 +522,7 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
parent_version_1 = Version.generate!(:project => project)
|
||||
parent_version_2 = Version.generate!(:project => project)
|
||||
assert_equal [parent_version_1, parent_version_2].sort,
|
||||
project.rolled_up_versions.sort
|
||||
project.rolled_up_versions.sort
|
||||
end
|
||||
|
||||
test "#rolled_up_versions should include versions for a subproject" do
|
||||
|
@ -527,7 +533,7 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
subproject_version = Version.generate!(:project => subproject)
|
||||
|
||||
assert_equal [parent_version_1, parent_version_2, subproject_version].sort,
|
||||
project.rolled_up_versions.sort
|
||||
project.rolled_up_versions.sort
|
||||
end
|
||||
|
||||
test "#rolled_up_versions should include versions for a sub-subproject" do
|
||||
|
@ -540,7 +546,7 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
project.reload
|
||||
|
||||
assert_equal [parent_version_1, parent_version_2, sub_subproject_version].sort,
|
||||
project.rolled_up_versions.sort
|
||||
project.rolled_up_versions.sort
|
||||
end
|
||||
|
||||
test "#rolled_up_versions should only check active projects" do
|
||||
|
@ -554,7 +560,7 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
|
||||
assert !subproject.active?
|
||||
assert_equal [parent_version_1, parent_version_2].sort,
|
||||
project.rolled_up_versions.sort
|
||||
project.rolled_up_versions.sort
|
||||
end
|
||||
|
||||
def test_shared_versions_none_sharing
|
||||
|
@ -705,28 +711,28 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
@project.enabled_module_names = []
|
||||
@project.reload
|
||||
assert_equal [], @project.enabled_module_names
|
||||
#with string
|
||||
# with string
|
||||
@project.enable_module!("issue_tracking")
|
||||
assert_equal ["issue_tracking"], @project.enabled_module_names
|
||||
#with symbol
|
||||
# with symbol
|
||||
@project.enable_module!(:gantt)
|
||||
assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
|
||||
#don't add a module twice
|
||||
# don't add a module twice
|
||||
@project.enable_module!("issue_tracking")
|
||||
assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
|
||||
end
|
||||
|
||||
test "enabled_modules should disable a module" do
|
||||
@project = Project.find(1)
|
||||
#with string
|
||||
# with string
|
||||
assert @project.enabled_module_names.include?("issue_tracking")
|
||||
@project.disable_module!("issue_tracking")
|
||||
assert ! @project.reload.enabled_module_names.include?("issue_tracking")
|
||||
#with symbol
|
||||
# with symbol
|
||||
assert @project.enabled_module_names.include?("gantt")
|
||||
@project.disable_module!(:gantt)
|
||||
assert ! @project.reload.enabled_module_names.include?("gantt")
|
||||
#with EnabledModule object
|
||||
# with EnabledModule object
|
||||
first_module = @project.enabled_modules.first
|
||||
@project.disable_module!(first_module)
|
||||
assert ! @project.reload.enabled_module_names.include?(first_module.name)
|
||||
|
@ -783,7 +789,6 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
assert_kind_of ActiveRecord::Relation, project.activities
|
||||
end
|
||||
|
||||
|
||||
def test_activities_should_use_the_project_specific_activities
|
||||
project = Project.find(1)
|
||||
overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project})
|
||||
|
@ -795,9 +800,11 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
|
||||
def test_activities_should_not_include_the_inactive_project_specific_activities
|
||||
project = Project.find(1)
|
||||
overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.first, :active => false})
|
||||
overridden_activity = TimeEntryActivity.new({:name => "Project",
|
||||
:project => project,
|
||||
:parent => TimeEntryActivity.first,
|
||||
:active => false})
|
||||
assert overridden_activity.save!
|
||||
|
||||
assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity found"
|
||||
end
|
||||
|
||||
|
@ -1006,18 +1013,27 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
assert_kind_of String, p.css_classes
|
||||
assert_not_include 'archived', p.css_classes.split
|
||||
assert_not_include 'closed', p.css_classes.split
|
||||
assert_include 'public', p.css_classes.split
|
||||
end
|
||||
|
||||
def test_css_classes_for_archived_project
|
||||
p = Project.new
|
||||
p.status = Project::STATUS_ARCHIVED
|
||||
assert_include 'archived', p.css_classes.split
|
||||
assert_include 'public', p.css_classes.split
|
||||
end
|
||||
|
||||
def test_css_classes_for_closed_project
|
||||
p = Project.new
|
||||
p.status = Project::STATUS_CLOSED
|
||||
assert_include 'closed', p.css_classes.split
|
||||
assert_include 'public', p.css_classes.split
|
||||
end
|
||||
|
||||
def test_css_classes_for_private_project
|
||||
p = Project.new
|
||||
p.is_public = false
|
||||
assert_not_include 'public', p.css_classes.split
|
||||
end
|
||||
|
||||
def test_combination_of_visible_and_distinct_scopes_in_case_anonymous_group_has_memberships_should_not_error
|
||||
|
@ -1028,4 +1044,28 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
Project.distinct.visible.to_a
|
||||
end
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_include_only_custom_fields_visible_to_user
|
||||
cf1 = ProjectCustomField.create!(:name => 'Visible field',
|
||||
:field_format => 'string',
|
||||
:visible => false, :role_ids => [1])
|
||||
cf2 = ProjectCustomField.create!(:name => 'Non visible field',
|
||||
:field_format => 'string',
|
||||
:visible => false, :role_ids => [3])
|
||||
user = User.find(2)
|
||||
project = Project.find(1)
|
||||
|
||||
project.send :safe_attributes=, {'custom_field_values' => {
|
||||
cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'
|
||||
}}, user
|
||||
assert_equal 'value1', project.custom_field_value(cf1)
|
||||
assert_nil project.custom_field_value(cf2)
|
||||
|
||||
project.send :safe_attributes=, {'custom_fields' => [
|
||||
{'id' => cf1.id.to_s, 'value' => 'valuea'},
|
||||
{'id' => cf2.id.to_s, 'value' => 'valueb'}
|
||||
]}, user
|
||||
assert_equal 'valuea', project.custom_field_value(cf1)
|
||||
assert_nil project.custom_field_value(cf2)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue