|
|
|
@ -446,14 +446,14 @@ describe Project, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should short description returns shortened description' do |
|
|
|
|
@project = Project.generate! |
|
|
|
|
@project = FactoryGirl.create(:project) |
|
|
|
|
@project.description = ('Abcd ' * 5 + "\n") * 11 |
|
|
|
|
@project.summary = '' |
|
|
|
|
assert_equal (('Abcd ' * 5 + "\n") * 10)[0..-2] + '...', @project.short_description |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should short description returns summary' do |
|
|
|
|
@project = Project.generate! |
|
|
|
|
@project = FactoryGirl.create(:project) |
|
|
|
|
@project.description = ('Abcd ' * 5 + "\n") * 11 |
|
|
|
|
@project.summary = 'In short' |
|
|
|
|
assert_equal 'In short', @project.short_description |
|
|
|
@ -462,9 +462,9 @@ describe Project, type: :model do |
|
|
|
|
|
|
|
|
|
context '#rolled_up_versions' do |
|
|
|
|
before do |
|
|
|
|
@project = Project.generate! |
|
|
|
|
@parent_version_1 = Version.generate!(project: @project) |
|
|
|
|
@parent_version_2 = Version.generate!(project: @project) |
|
|
|
|
@project = FactoryGirl.create(:project) |
|
|
|
|
@parent_version_1 = FactoryGirl.create(:version, project: @project) |
|
|
|
|
@parent_version_2 = FactoryGirl.create(:version, project: @project) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should include the versions for the current project' do |
|
|
|
@ -472,9 +472,9 @@ describe Project, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should include versions for a subproject' do |
|
|
|
|
@subproject = Project.generate! |
|
|
|
|
@subproject = FactoryGirl.create(:project) |
|
|
|
|
@subproject.set_parent!(@project) |
|
|
|
|
@subproject_version = Version.generate!(project: @subproject) |
|
|
|
|
@subproject_version = FactoryGirl.create(:version, project: @subproject) |
|
|
|
|
|
|
|
|
|
assert_same_elements [ |
|
|
|
|
@parent_version_1, |
|
|
|
@ -484,11 +484,11 @@ describe Project, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should include versions for a sub-subproject' do |
|
|
|
|
@subproject = Project.generate! |
|
|
|
|
@subproject = FactoryGirl.create(:project) |
|
|
|
|
@subproject.set_parent!(@project) |
|
|
|
|
@sub_subproject = Project.generate! |
|
|
|
|
@sub_subproject = FactoryGirl.create(:project) |
|
|
|
|
@sub_subproject.set_parent!(@subproject) |
|
|
|
|
@sub_subproject_version = Version.generate!(project: @sub_subproject) |
|
|
|
|
@sub_subproject_version = FactoryGirl.create(:version, project: @sub_subproject) |
|
|
|
|
|
|
|
|
|
@project.reload |
|
|
|
|
|
|
|
|
@ -500,9 +500,9 @@ describe Project, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should only check active projects' do |
|
|
|
|
@subproject = Project.generate! |
|
|
|
|
@subproject = FactoryGirl.create(:project) |
|
|
|
|
@subproject.set_parent!(@project) |
|
|
|
|
@subproject_version = Version.generate!(project: @subproject) |
|
|
|
|
@subproject_version = FactoryGirl.create(:version, project: @subproject) |
|
|
|
|
assert @subproject.archive |
|
|
|
|
|
|
|
|
|
@project.reload |
|
|
|
@ -726,7 +726,7 @@ describe Project, type: :model do |
|
|
|
|
project = Project.find(1) |
|
|
|
|
system_activity = TimeEntryActivity.find_by(name: 'Design') |
|
|
|
|
assert system_activity.active? |
|
|
|
|
overridden_activity = TimeEntryActivity.generate!(project: project, parent: system_activity, active: false) |
|
|
|
|
overridden_activity = FactoryGirl.create(:time_entry_activity, project: project, parent: system_activity, active: false) |
|
|
|
|
assert overridden_activity.save! |
|
|
|
|
|
|
|
|
|
assert !project.activities.include?(overridden_activity), 'Inactive Project specific Activity not found' |
|
|
|
@ -760,11 +760,14 @@ describe Project, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should copy work units' do |
|
|
|
|
@source_project.work_packages << WorkPackage.generate!(status: Status.find_by(name: 'Closed'), |
|
|
|
|
subject: 'copy issue status', |
|
|
|
|
type_id: 1, |
|
|
|
|
assigned_to_id: 2, |
|
|
|
|
project_id: @source_project.id) |
|
|
|
|
work_package = FactoryGirl.create( :work_package, |
|
|
|
|
status: Status.find_by_name('Closed'), |
|
|
|
|
subject: 'copy issue status', |
|
|
|
|
type_id: 1, |
|
|
|
|
assigned_to_id: 2, |
|
|
|
|
project_id: @source_project.id) |
|
|
|
|
|
|
|
|
|
@source_project.work_packages << work_package |
|
|
|
|
assert @project.valid? |
|
|
|
|
assert @project.work_packages.empty? |
|
|
|
|
assert @project.copy(@source_project) |
|
|
|
@ -784,7 +787,7 @@ describe Project, type: :model do |
|
|
|
|
|
|
|
|
|
it 'should change the new issues to use the copied version' do |
|
|
|
|
User.current = User.find(1) |
|
|
|
|
assigned_version = Version.generate!(name: 'Assigned Issues', status: 'open') |
|
|
|
|
assigned_version = FactoryGirl.create(:version, name: 'Assigned Issues', status: 'open') |
|
|
|
|
@source_project.versions << assigned_version |
|
|
|
|
assert_equal 3, @source_project.versions.size |
|
|
|
|
FactoryGirl.create(:work_package, project: @source_project, |
|
|
|
@ -805,7 +808,7 @@ describe Project, type: :model do |
|
|
|
|
|
|
|
|
|
it 'should change the new issues to use the copied closed version' do |
|
|
|
|
User.current = User.find(1) |
|
|
|
|
assigned_version = Version.generate!(name: 'Assigned Issues', status: 'open') |
|
|
|
|
assigned_version = FactoryGirl.create(:version, name: 'Assigned Issues', status: 'open') |
|
|
|
|
@source_project.versions << assigned_version |
|
|
|
|
assert_equal 3, @source_project.versions.size |
|
|
|
|
FactoryGirl.create(:work_package, project: @source_project, |
|
|
|
@ -828,15 +831,15 @@ describe Project, type: :model do |
|
|
|
|
it 'should copy issue relations' do |
|
|
|
|
Setting.cross_project_work_package_relations = '1' |
|
|
|
|
|
|
|
|
|
second_issue = WorkPackage.generate!(status_id: 5, |
|
|
|
|
second_issue = FactoryGirl.create(:work_package, status_id: 5, |
|
|
|
|
subject: 'copy issue relation', |
|
|
|
|
type_id: 1, |
|
|
|
|
assigned_to_id: 2, |
|
|
|
|
project_id: @source_project.id) |
|
|
|
|
source_relation = Relation.generate!(from: WorkPackage.find(4), |
|
|
|
|
source_relation = FactoryGirl.create(:relation, from: WorkPackage.find(4), |
|
|
|
|
to: second_issue, |
|
|
|
|
relation_type: 'relates') |
|
|
|
|
source_relation_cross_project = Relation.generate!(from: WorkPackage.find(1), |
|
|
|
|
source_relation_cross_project = FactoryGirl.create(:relation, from: WorkPackage.find(1), |
|
|
|
|
to: second_issue, |
|
|
|
|
relation_type: 'duplicates') |
|
|
|
|
|
|
|
|
@ -908,8 +911,8 @@ describe Project, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should copy versions' do |
|
|
|
|
@source_project.versions << Version.generate! |
|
|
|
|
@source_project.versions << Version.generate! |
|
|
|
|
@source_project.versions << FactoryGirl.create(:version) |
|
|
|
|
@source_project.versions << FactoryGirl.create(:version) |
|
|
|
|
|
|
|
|
|
assert @project.versions.empty? |
|
|
|
|
assert @project.copy(@source_project) |
|
|
|
@ -998,8 +1001,8 @@ describe Project, type: :model do |
|
|
|
|
context '#start_date' do |
|
|
|
|
before do |
|
|
|
|
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests |
|
|
|
|
@project = Project.generate!(identifier: 'test0') |
|
|
|
|
@project.types << ::Type.generate! |
|
|
|
|
@project = FactoryGirl.create(:project, identifier: 'test0') |
|
|
|
|
@project.types << FactoryGirl.create(:type) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should be nil if there are no issues on the project' do |
|
|
|
@ -1020,8 +1023,8 @@ describe Project, type: :model do |
|
|
|
|
context '#due_date' do |
|
|
|
|
before do |
|
|
|
|
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests |
|
|
|
|
@project = Project.generate!(identifier: 'test0') |
|
|
|
|
@project.types << ::Type.generate! |
|
|
|
|
@project = FactoryGirl.create(:project, identifier: 'test0') |
|
|
|
|
@project.types << FactoryGirl.create(:type) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should be nil if there are no issues on the project' do |
|
|
|
@ -1040,8 +1043,8 @@ describe Project, type: :model do |
|
|
|
|
|
|
|
|
|
it "should be the latest due date of it's versions" do |
|
|
|
|
future = 7.days.from_now.to_date |
|
|
|
|
@project.versions << Version.generate!(effective_date: future) |
|
|
|
|
@project.versions << Version.generate!(effective_date: Date.today) |
|
|
|
|
@project.versions << FactoryGirl.create(:version, effective_date: future) |
|
|
|
|
@project.versions << FactoryGirl.create(:version, effective_date: Date.today) |
|
|
|
|
|
|
|
|
|
assert_equal future, @project.due_date |
|
|
|
|
end |
|
|
|
@ -1050,7 +1053,7 @@ describe Project, type: :model do |
|
|
|
|
future = 7.days.from_now.to_date |
|
|
|
|
far_future = 14.days.from_now.to_date |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, due_date: far_future) |
|
|
|
|
@project.versions << Version.generate!(effective_date: future) |
|
|
|
|
@project.versions << FactoryGirl.create(:version, effective_date: future) |
|
|
|
|
|
|
|
|
|
assert_equal far_future, @project.due_date |
|
|
|
|
end |
|
|
|
@ -1059,8 +1062,8 @@ describe Project, type: :model do |
|
|
|
|
context 'Project#completed_percent' do |
|
|
|
|
before do |
|
|
|
|
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests |
|
|
|
|
@project = Project.generate!(identifier: 'test0') |
|
|
|
|
@project.types << ::Type.generate! |
|
|
|
|
@project = FactoryGirl.create(:project, identifier: 'test0') |
|
|
|
|
@project.types << FactoryGirl.create(:type) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'no versions' do |
|
|
|
@ -1071,26 +1074,26 @@ describe Project, type: :model do |
|
|
|
|
|
|
|
|
|
context 'with versions' do |
|
|
|
|
it 'should return 0 if the versions have no issues' do |
|
|
|
|
Version.generate!(project: @project) |
|
|
|
|
Version.generate!(project: @project) |
|
|
|
|
FactoryGirl.create(:version, project: @project) |
|
|
|
|
FactoryGirl.create(:version, project: @project) |
|
|
|
|
|
|
|
|
|
assert_equal 0, @project.completed_percent |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should return 100 if the version has only closed issues' do |
|
|
|
|
v1 = Version.generate!(project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by(name: 'Closed'), fixed_version: v1) |
|
|
|
|
v2 = Version.generate!(project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by(name: 'Closed'), fixed_version: v2) |
|
|
|
|
v1 = FactoryGirl.create(:version, project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('Closed'), fixed_version: v1) |
|
|
|
|
v2 = FactoryGirl.create(:version, project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('Closed'), fixed_version: v2) |
|
|
|
|
|
|
|
|
|
assert_equal 100, @project.completed_percent |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'should return the averaged completed percent of the versions (not weighted)' do |
|
|
|
|
v1 = Version.generate!(project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by(name: 'New'), estimated_hours: 10, done_ratio: 50, fixed_version: v1) |
|
|
|
|
v2 = Version.generate!(project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by(name: 'New'), estimated_hours: 10, done_ratio: 50, fixed_version: v2) |
|
|
|
|
v1 = FactoryGirl.create(:version, project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('New'), estimated_hours: 10, done_ratio: 50, fixed_version: v1) |
|
|
|
|
v2 = FactoryGirl.create(:version, project: @project) |
|
|
|
|
FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('New'), estimated_hours: 10, done_ratio: 50, fixed_version: v2) |
|
|
|
|
|
|
|
|
|
assert_equal 50, @project.completed_percent |
|
|
|
|
end |
|
|
|
@ -1099,35 +1102,35 @@ describe Project, type: :model do |
|
|
|
|
|
|
|
|
|
context '#notified_users' do |
|
|
|
|
before do |
|
|
|
|
@project = Project.generate! |
|
|
|
|
@role = Role.generate! |
|
|
|
|
@project = FactoryGirl.create(:project) |
|
|
|
|
@role = FactoryGirl.create(:role) |
|
|
|
|
|
|
|
|
|
@user_with_membership_notification = User.generate!(mail_notification: 'selected') |
|
|
|
|
@user_with_membership_notification = FactoryGirl.create(:user, mail_notification: 'selected') |
|
|
|
|
Member.create!(project: @project, principal: @user_with_membership_notification, mail_notification: true) do |member| |
|
|
|
|
member.role_ids = [@role.id] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@all_events_user = User.generate!(mail_notification: 'all') |
|
|
|
|
@all_events_user = FactoryGirl.create(:user, mail_notification: 'all') |
|
|
|
|
Member.create!(project: @project, principal: @all_events_user) do |member| |
|
|
|
|
member.role_ids = [@role.id] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@no_events_user = User.generate!(mail_notification: 'none') |
|
|
|
|
@no_events_user = FactoryGirl.create(:user, mail_notification: 'none') |
|
|
|
|
Member.create!(project: @project, principal: @no_events_user) do |member| |
|
|
|
|
member.role_ids = [@role.id] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@only_my_events_user = User.generate!(mail_notification: 'only_my_events') |
|
|
|
|
@only_my_events_user = FactoryGirl.create(:user, mail_notification: 'only_my_events') |
|
|
|
|
Member.create!(project: @project, principal: @only_my_events_user) do |member| |
|
|
|
|
member.role_ids = [@role.id] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@only_assigned_user = User.generate!(mail_notification: 'only_assigned') |
|
|
|
|
@only_assigned_user = FactoryGirl.create(:user, mail_notification: 'only_assigned') |
|
|
|
|
Member.create!(project: @project, principal: @only_assigned_user) do |member| |
|
|
|
|
member.role_ids = [@role.id] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@only_owned_user = User.generate!(mail_notification: 'only_owner') |
|
|
|
|
@only_owned_user = FactoryGirl.create(:user, mail_notification: 'only_owner') |
|
|
|
|
Member.create!(project: @project, principal: @only_owned_user) do |member| |
|
|
|
|
member.role_ids = [@role.id] |
|
|
|
|
end |
|
|
|
|