@@ -411,6 +411,10 class Project < ActiveRecord::Base | |||
|
411 | 411 | |
|
412 | 412 | # Returns a scope of the Versions used by the project |
|
413 | 413 | def shared_versions |
|
414 | if new_record? | |
|
415 | Version.scoped(:include => :project, | |
|
416 | :conditions => "#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND #{Version.table_name}.sharing = 'system'") | |
|
417 | else | |
|
414 | 418 | @shared_versions ||= begin |
|
415 | 419 | r = root? ? self : root |
|
416 | 420 | Version.scoped(:include => :project, |
@@ -423,6 +427,7 class Project < ActiveRecord::Base | |||
|
423 | 427 | "))") |
|
424 | 428 | end |
|
425 | 429 | end |
|
430 | end | |
|
426 | 431 | |
|
427 | 432 | # Returns a hash of project users grouped by role |
|
428 | 433 | def users_by_role |
@@ -598,6 +598,13 class ProjectTest < ActiveSupport::TestCase | |||
|
598 | 598 | assert !versions.collect(&:id).include?(6) |
|
599 | 599 | end |
|
600 | 600 | |
|
601 | def test_shared_versions_for_new_project_should_include_system_shared_versions | |
|
602 | p = Project.find(5) | |
|
603 | v = Version.create!(:name => 'system_sharing', :project => p, :sharing => 'system') | |
|
604 | ||
|
605 | assert_include v, Project.new.shared_versions | |
|
606 | end | |
|
607 | ||
|
601 | 608 | def test_next_identifier |
|
602 | 609 | ProjectCustomField.delete_all |
|
603 | 610 | Project.create!(:name => 'last', :identifier => 'p2008040') |
General Comments 0
You need to be logged in to leave comments.
Login now