Show projects depending on their visibility in user's profile. #6100
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3935 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0cfa757db0
commit
e43f9fc21e
|
@ -53,10 +53,8 @@ class UsersController < ApplicationController
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@custom_values = @user.custom_values
|
@custom_values = @user.custom_values
|
||||||
|
|
||||||
# show only public projects and private projects that the logged in user is also a member of
|
# show projects based on current user visibility
|
||||||
@memberships = @user.memberships.select do |membership|
|
@memberships = @user.memberships.all(:conditions => Project.visible_by(User.current))
|
||||||
membership.project.is_public? || (User.current.member_of?(membership.project))
|
|
||||||
end
|
|
||||||
|
|
||||||
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
||||||
@events_by_day = events.group_by(&:event_date)
|
@events_by_day = events.group_by(&:event_date)
|
||||||
|
|
|
@ -97,6 +97,16 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
assert_not_nil assigns(:user)
|
assert_not_nil assigns(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_displays_memberships_based_on_project_visibility
|
||||||
|
@request.session[:user_id] = 1
|
||||||
|
get :show, :id => 2
|
||||||
|
assert_response :success
|
||||||
|
memberships = assigns(:memberships)
|
||||||
|
assert_not_nil memberships
|
||||||
|
project_ids = memberships.map(&:project_id)
|
||||||
|
assert project_ids.include?(2) #private project admin can see
|
||||||
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
post :edit, :id => 2, :user => {:firstname => 'Changed'}
|
post :edit, :id => 2, :user => {:firstname => 'Changed'}
|
||||||
|
|
Loading…
Reference in New Issue