Fix rubocop offenses

This commit is contained in:
Alexander Meindl 2024-08-31 17:24:40 +02:00
parent fc9001404b
commit ae51eb366b
11 changed files with 32 additions and 12 deletions

View File

@ -132,7 +132,7 @@ module AdditionalsMenuHelper
s << if item[:title] == '-' s << if item[:title] == '-'
tag.li tag.hr tag.li tag.hr
else else
html_options = { class: +"help_item_#{id}" } html_options = { class: "help_item_#{id}" }
if item[:url].include? '://' if item[:url].include? '://'
html_options[:class] << ' external' html_options[:class] << ' external'
html_options[:target] = '_blank' html_options[:target] = '_blank'

View File

@ -38,7 +38,7 @@ module Additionals
end end
def render_query_block_columns(query, entry, tr_classes:, with_buttons: false, with_checkbox: true) def render_query_block_columns(query, entry, tr_classes:, with_buttons: false, with_checkbox: true)
td_colspan = query.inline_columns.size + 1 td_colspan = query.inline_columns.size
td_colspan += 1 if with_buttons td_colspan += 1 if with_buttons
content = [] content = []

View File

@ -26,7 +26,7 @@ module Additionals
class_methods do class_methods do
def join_issue_status(is_closed: nil) def join_issue_status(is_closed: nil)
sql = +"JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{table_name}.status_id" sql = "JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{table_name}.status_id"
return sql if is_closed.nil? return sql if is_closed.nil?
sql << " AND #{IssueStatus.table_name}.is_closed = #{is_closed ? connection.quoted_true : connection.quoted_false}" sql << " AND #{IssueStatus.table_name}.is_closed = #{is_closed ? connection.quoted_true : connection.quoted_false}"

View File

@ -37,7 +37,7 @@ module Additionals
if user.admin? || AdditionalsPlugin.active_hrm? && user.hrm_allowed_to?(:view_hrm) if user.admin? || AdditionalsPlugin.active_hrm? && user.hrm_allowed_to?(:view_hrm)
all all
else else
view_all_active = if user.memberships.to_a.any? view_all_active = if user.memberships.any?
user.memberships user.memberships
.includes([:roles]) .includes([:roles])
.any? { |m| m.roles.any? { |r| r.users_visibility == 'all' } } .any? { |m| m.roles.any? { |r| r.users_visibility == 'all' } }

View File

@ -98,9 +98,9 @@ module Additionals
" HAVING #{options[:aggr]}(#{options[:having_table]}.#{options[:field]})" " HAVING #{options[:aggr]}(#{options[:having_table]}.#{options[:field]})"
null_all_sql = if options[:use_sub_query_for_all] null_all_sql = if options[:use_sub_query_for_all]
+"#{options[:sub_query]} AND" "#{options[:sub_query]} AND"
else else
+"#{options[:sub_table]} WHERE" "#{options[:sub_table]} WHERE"
end end
null_all_sql << " #{options[:sub_table]}.#{options[:group_field]} = #{queried_table_name}.#{options[:join_field]})" null_all_sql << " #{options[:sub_table]}.#{options[:group_field]} = #{queried_table_name}.#{options[:join_field]})"

View File

@ -78,7 +78,7 @@ module Additionals
raise 'The correct usage is {{gmap([q=QUERY, mode=MODE, widths=x, height=y])}}' raise 'The correct usage is {{gmap([q=QUERY, mode=MODE, widths=x, height=y])}}'
end end
src = +"https://www.google.com/maps/embed/v1/#{mode}?key=" + Additionals.setting(:google_maps_api_key) src = "https://www.google.com/maps/embed/v1/#{mode}?key=" + Additionals.setting(:google_maps_api_key)
if options[:q].present? if options[:q].present?
src << "&q=#{ERB::Util.url_encode options[:q]}" src << "&q=#{ERB::Util.url_encode options[:q]}"
elsif mode == 'search' elsif mode == 'search'

View File

@ -98,7 +98,7 @@ module Additionals
end end
def self.meteoblue_flag(options, name, default = tue) def self.meteoblue_flag(options, name, default = tue)
flag = +"#{name}=" flag = "#{name}="
flag << if RedminePluginKit.true?(options[name]) || default flag << if RedminePluginKit.true?(options[name]) || default
'1' '1'
else else

View File

@ -35,7 +35,7 @@ module Additionals
raise 'The correct usage is {{slideshare(<key>[, width=x, height=y, slide=number])}}' if args.empty? raise 'The correct usage is {{slideshare(<key>[, width=x, height=y, slide=number])}}' if args.empty?
v = args[0] v = args[0]
src = +"//www.slideshare.net/slideshow/embed_code/#{v}" src = "//www.slideshare.net/slideshow/embed_code/#{v}"
src += "?startSlide=#{slide}" if slide.positive? src += "?startSlide=#{slide}" if slide.positive?
tag.iframe width:, height:, src:, frameborder: 0, allowfullscreen: 'true' tag.iframe width:, height:, src:, frameborder: 0, allowfullscreen: 'true'

18
test/fixtures/hrm_user_types.yml vendored Normal file
View File

@ -0,0 +1,18 @@
internal_everybody:
is_default: true
name: Internal
is_internal: true
view_hrm: false
view_superiors: false
view_user_type_icon: false
view_attendance: false
view_groups: false
manage_users: false
manage_groups: false
manage_holidays: false
manage_working_calendars: false
with_help_menu: true
with_mypage_menu: true
with_watched_projects: true
icon: fas_car
custom_menu_items:

View File

@ -84,7 +84,7 @@ module Additionals
.gsub('user.cf', 'user_cf') .gsub('user.cf', 'user_cf')
.tr('.', '-') .tr('.', '-')
spec = +"td.#{c}" spec = "td.#{c}"
spec << "[colspan='#{colspan}']" if colspan spec << "[colspan='#{colspan}']" if colspan
assert_select spec assert_select spec
@ -112,8 +112,8 @@ module Additionals
end end
end end
colspan = inline_columns.count + 2 colspan = inline_columns.count
colspan -= 1 unless with_checkbox colspan += 1 if with_checkbox
assert_select block_tr_select do assert_select block_tr_select do
block_columns.each do |column_name| block_columns.each do |column_name|
assert_select_td_column column_name, colspan: assert_select_td_column column_name, colspan:

View File

@ -10,6 +10,8 @@ class QueryTest < Additionals::TestCase
:roles, :roles,
:repositories :repositories
fixtures :hrm_user_types if AdditionalsPlugin.active_hrm?
def setup def setup
User.current = nil User.current = nil
end end