From 7faaddca720caf4a109fc8455c03058374a3519a Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 4 Aug 2016 15:43:56 -0300 Subject: [PATCH] Fix task list in profile editor controller --- app/controllers/my_profile/profile_editor_controller.rb | 2 +- test/functional/profile_editor_controller_test.rb | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index eb402fb..0ad0328 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -12,7 +12,7 @@ class ProfileEditorController < MyProfileController include CategoriesHelper def index - @pending_tasks = Task.to(profile).pending.without_spam.select{|i| user.has_permission?(i.permission, profile)} + @pending_tasks = Task.to(profile).pending.without_spam @show_appearance_option = user.is_admin?(environment) || environment.enabled?('enable_appearance') @show_header_footer_option = user.is_admin?(environment) || (!profile.enterprise? && !environment.enabled?('disable_header_and_footer')) end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 9e62a6e..ae7cd54 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -391,8 +391,6 @@ class ProfileEditorControllerTest < ActionController::TestCase user2 = create_user('usertwo').person AddFriend.create!(:person => user1, :friend => user2) @controller.stubs(:user).returns(user2) - user2.stubs(: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' } @@ -400,11 +398,11 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'not show task if user has no permission' do user1 = profile + community = fast_create(Community) user2 = create_user('usertwo').person - task = AddFriend.create!(:person => user1, :friend => user2) + task = AddMember.create!(person: user1, organization: community) @controller.stubs(:user).returns(user2) - user2.stubs(:has_permission?).with('edit_profile', anything).returns(true) - user2.expects(:has_permission?).with(:manage_friends, anything).returns(false) + give_permission(user2, 'invite_members', community) login_as('usertwo') get :index, :profile => 'usertwo' assert_no_tag :tag => 'div', :attributes => { :class => 'pending-tasks' } -- libgit2 0.21.2