Remove user tab patch

pull/6827/head
Oliver Günther 7 years ago
parent f82e3bc8c4
commit 85b7b6ac53
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 9
      lib/open_project/avatars/engine.rb
  2. 38
      lib/open_project/avatars/patches/users_helper_patch.rb
  3. 25
      spec/lib/users_helper_spec.rb

@ -46,6 +46,12 @@ module OpenProject::Avatars
require_dependency 'project'
end
add_tab_entry :user,
name: 'avatar',
partial: 'avatars/users/avatar_tab',
label: :label_avatar,
only_if: ->(*) { ::OpenProject::Avatars::AvatarManager.avatars_enabled? }
initializer 'patch avatar helper' do
# This is required to be an initializer,
# since the helpers are included as soon as the ApplicationController
@ -53,7 +59,6 @@ module OpenProject::Avatars
require_relative 'patches/avatar_helper_patch'
end
patches %i[User
UsersHelper]
patches %i[User]
end
end

@ -1,38 +0,0 @@
# OpenProject Avatars plugin
#
# Copyright (C) 2017 OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module OpenProject::Avatars
module Patches
module UsersHelperPatch
def self.included(base) # :nodoc:
base.prepend(InstanceMethods)
end
module InstanceMethods
def user_settings_tabs
tabs = super
if ::OpenProject::Avatars::AvatarManager.avatars_enabled?
tabs << { name: 'avatar', partial: 'avatars/users/avatar_tab', label: :label_avatar }
end
tabs
end
end
end
end
end

@ -1,25 +0,0 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
class UsersHelperTest
include UsersHelper
end
describe UsersHelperTest do
describe "#user_settings_tabs" do
subject { UsersHelperTest.new.user_settings_tabs }
context 'when enabled' do
before do
allow(::OpenProject::Avatars::AvatarManager).to receive(:avatars_enabled?).and_return true
end
it { is_expected.to include(name: 'avatar', partial: 'avatars/users/avatar_tab', label: :label_avatar) }
end
context 'when disabled' do
before do
allow(::OpenProject::Avatars::AvatarManager).to receive(:avatars_enabled?).and_return false
end
it { is_expected.not_to include(name: 'avatar', partial: 'avatars/users/avatar_tab', label: :label_avatar) }
end
end
end
Loading…
Cancel
Save