Skip to content

Commit

Permalink
Fix projects helper patch
Browse files Browse the repository at this point in the history
  • Loading branch information
arturtr committed Feb 21, 2017
1 parent b544e62 commit 7274a18
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ Style/LineEndConcatenation:
line end.
Enabled: true

Style/MethodCallParentheses:
Style/MethodCallWithoutArgsParentheses:
Description: 'Do not use parentheses for method calls with no arguments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
Enabled: true
Expand Down
35 changes: 23 additions & 12 deletions lib/intouch/patches/projects_helper_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@
module Intouch
module Patches
module ProjectsHelperPatch
def project_settings_tabs
tabs = super
def self.included(base)
base.send(:include, MethodsPatch)

return tabs unless User.current.allowed_to?(:manage_intouch_settings, @project)
base.class_eval do
unloadable

tabs.push(
name: 'intouch_settings',
action: :manage_intouch_settings,
partial: 'projects/settings/intouch/settings',
label: 'intouch.label.settings'
)
alias_method_chain :project_settings_tabs, :intouch
end
end

module MethodsPatch
def project_settings_tabs_with_intouch
tabs = project_settings_tabs_without_intouch

return tabs unless User.current.allowed_to?(:manage_intouch_settings, @project)

tabs
tabs.push(
name: 'intouch_settings',
action: :manage_intouch_settings,
partial: 'projects/settings/intouch/settings',
label: 'intouch.label.settings'
)

tabs
end
end
end
end
end


ProjectsHelper.send(:prepend, Intouch::Patches::ProjectsHelperPatch)
ProjectsHelper.send(:include, Intouch::Patches::ProjectsHelperPatch)
ProjectsHelper.send(:include, IntouchHelper)
14 changes: 7 additions & 7 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$VERBOSE = nil # for hide ruby warnings

# Load the Redmine helper
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
require "minitest/reporters"

Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
$VERBOSE = nil # for hide ruby warnings

# Load the Redmine helper
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
require 'minitest/reporters'

Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new

0 comments on commit 7274a18

Please sign in to comment.