diff options
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | test/fixtures/members.yml | 6 | ||||
-rw-r--r-- | test/fixtures/projects.yml | 14 | ||||
-rw-r--r-- | test/functional/projects_controller_test.rb | 15 | ||||
-rw-r--r-- | test/unit/project_test.rb | 2 |
5 files changed, 36 insertions, 3 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b71ec1ecd..34ce734a5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -87,7 +87,7 @@ class ProjectsController < ApplicationController def show @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position") @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} - @subprojects = @project.active_children + @subprojects = @project.children.find(:all, :conditions => Project.visible_by(User.current)) @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") @trackers = @project.rolled_up_trackers diff --git a/test/fixtures/members.yml b/test/fixtures/members.yml index 2c9209131..32c65c673 100644 --- a/test/fixtures/members.yml +++ b/test/fixtures/members.yml @@ -24,4 +24,10 @@ members_004: role_id: 2
# Locked user
user_id: 5
+members_005:
+ id: 5
+ created_on: 2006-07-19 19:35:33 +02:00
+ project_id: 5
+ role_id: 1
+ user_id: 2
\ No newline at end of file diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml index ad5cf4aa2..8e1b3fe1d 100644 --- a/test/fixtures/projects.yml +++ b/test/fixtures/projects.yml @@ -3,7 +3,7 @@ projects_001: created_on: 2006-07-19 19:13:59 +02:00
name: eCookbook
updated_on: 2006-07-19 22:53:01 +02:00
- projects_count: 2
+ projects_count: 3
id: 1
description: Recipes management application
homepage: http://ecookbook.somenet.foo/
@@ -43,3 +43,15 @@ projects_004: is_public: true
identifier: subproject2
parent_id: 1
+projects_005:
+ created_on: 2006-07-19 19:15:51 +02:00
+ name: Private child of eCookbook
+ updated_on: 2006-07-19 19:17:07 +02:00
+ projects_count: 0
+ id: 5
+ description: This is a private subproject of a public project
+ homepage: ""
+ is_public: false
+ identifier: private_child
+ parent_id: 1
+
\ No newline at end of file diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index eb5795152..5af7b5572 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -63,6 +63,21 @@ class ProjectsControllerTest < Test::Unit::TestCase assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) end + def test_private_subprojects_hidden + get :show, :id => 'ecookbook' + assert_response :success + assert_template 'show' + assert_no_tag :tag => 'a', :content => /Private child/ + end + + def test_private_subprojects_visible + @request.session[:user_id] = 2 # manager who is a member of the private subproject + get :show, :id => 'ecookbook' + assert_response :success + assert_template 'show' + assert_tag :tag => 'a', :content => /Private child/ + end + def test_settings @request.session[:user_id] = 2 # manager get :settings, :id => 1 diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 9af68c231..f24e7d44f 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -101,7 +101,7 @@ class ProjectTest < Test::Unit::TestCase assert sub.save
assert_equal @ecookbook.id, sub.parent.id
@ecookbook.reload
- assert_equal 3, @ecookbook.children.size
+ assert_equal 4, @ecookbook.children.size
end
def test_subproject_invalid
|