Commit 68b5c1da73c375391c44d19d4d0a9956e0cde8aa
1 parent
b3cf98f7
Exists in
staging
and in
42 other branches
ActionItem378: fixing tests for tasks in profile_editor
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1885 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
25 additions
and
0 deletions
Show diff stats
test/functional/profile_editor_controller_test.rb
... | ... | @@ -40,6 +40,7 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
40 | 40 | @controller.expects(:profile).returns(ze).at_least_once |
41 | 41 | tasks = mock |
42 | 42 | pending = [] |
43 | + pending.expects(:select).returns(pending) | |
43 | 44 | pending.expects(:empty?).returns(false) # force the display of the pending tasks list |
44 | 45 | tasks.expects(:pending).returns(pending) |
45 | 46 | ze.expects(:tasks).returns(tasks) |
... | ... | @@ -304,4 +305,28 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
304 | 305 | assert_no_tag :tag => 'a', :content => 'Manage Members' |
305 | 306 | end |
306 | 307 | |
308 | + should 'show task if user has permission' do | |
309 | + user1 = create_user('userone').person | |
310 | + user2 = create_user('usertwo').person | |
311 | + AddFriend.create!(:person => user1, :friend => user2) | |
312 | + @controller.stubs(:user).returns(user2) | |
313 | + user2.expects(:has_permission?).with('edit_profile', anything).returns(true) | |
314 | + user2.expects(:has_permission?).with(:manage_friends, anything).returns(true) | |
315 | + login_as('usertwo') | |
316 | + get :index, :profile => 'usertwo' | |
317 | + assert_tag :tag => 'div', :attributes => { :class => 'pending-tasks' } | |
318 | + end | |
319 | + | |
320 | + should 'not show task if user has no permission' do | |
321 | + user1 = create_user('userone').person | |
322 | + user2 = create_user('usertwo').person | |
323 | + task = AddFriend.create!(:person => user1, :friend => user2) | |
324 | + @controller.stubs(:user).returns(user2) | |
325 | + user2.expects(:has_permission?).with('edit_profile', anything).returns(true) | |
326 | + user2.expects(:has_permission?).with(:manage_friends, anything).returns(false) | |
327 | + login_as('usertwo') | |
328 | + get :index, :profile => 'usertwo' | |
329 | + assert_no_tag :tag => 'div', :attributes => { :class => 'pending-tasks' } | |
330 | + end | |
331 | + | |
307 | 332 | end | ... | ... |