From 68b5c1da73c375391c44d19d4d0a9956e0cde8aa Mon Sep 17 00:00:00 2001 From: JoenioCosta Date: Thu, 5 Jun 2008 22:24:12 +0000 Subject: [PATCH] ActionItem378: fixing tests for tasks in profile_editor --- test/functional/profile_editor_controller_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+), 0 deletions(-) diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index c9e2fac..2642a16 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -40,6 +40,7 @@ class ProfileEditorControllerTest < Test::Unit::TestCase @controller.expects(:profile).returns(ze).at_least_once tasks = mock pending = [] + pending.expects(:select).returns(pending) pending.expects(:empty?).returns(false) # force the display of the pending tasks list tasks.expects(:pending).returns(pending) ze.expects(:tasks).returns(tasks) @@ -304,4 +305,28 @@ class ProfileEditorControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'a', :content => 'Manage Members' end + should 'show task if user has permission' do + user1 = create_user('userone').person + user2 = create_user('usertwo').person + AddFriend.create!(:person => user1, :friend => user2) + @controller.stubs(:user).returns(user2) + user2.expects(:has_permission?).with('edit_profile', anything).returns(true) + user2.expects(:has_permission?).with(:manage_friends, anything).returns(true) + login_as('usertwo') + get :index, :profile => 'usertwo' + assert_tag :tag => 'div', :attributes => { :class => 'pending-tasks' } + end + + should 'not show task if user has no permission' do + user1 = create_user('userone').person + user2 = create_user('usertwo').person + task = AddFriend.create!(:person => user1, :friend => user2) + @controller.stubs(:user).returns(user2) + user2.expects(:has_permission?).with('edit_profile', anything).returns(true) + user2.expects(:has_permission?).with(:manage_friends, anything).returns(false) + login_as('usertwo') + get :index, :profile => 'usertwo' + assert_no_tag :tag => 'div', :attributes => { :class => 'pending-tasks' } + end + end -- libgit2 0.21.2