fix rubocop offences
This commit is contained in:
parent
a4a7805aa2
commit
9fc93f4dbf
@ -4,6 +4,6 @@ class AdditionalsMacrosController < ApplicationController
|
||||
before_action :require_login
|
||||
|
||||
def show
|
||||
@available_macros = AdditionalsMacro.all
|
||||
@available_macros = AdditionalsMacro.macros
|
||||
end
|
||||
end
|
||||
|
@ -65,7 +65,8 @@ module AdditionalsJournalsHelper
|
||||
end
|
||||
|
||||
# Returns the textual representation of a single journal detail
|
||||
def entity_show_detail(entity, detail, no_html = false, **options) # rubocop:disable Style/OptionalBooleanParameter:
|
||||
# rubocop: disable Style/OptionalBooleanParameter
|
||||
def entity_show_detail(entity, detail, no_html = false, **options)
|
||||
multiple = false
|
||||
no_detail = false
|
||||
show_diff = false
|
||||
@ -119,6 +120,7 @@ module AdditionalsJournalsHelper
|
||||
show_detail detail, no_html, options
|
||||
end
|
||||
end
|
||||
# rubocop: enable Style/OptionalBooleanParameter
|
||||
|
||||
def render_email_attributes(entry, html: false)
|
||||
items = send "email_#{entry.class.name.underscore}_attributes", entry, html
|
||||
|
@ -75,7 +75,7 @@ module AdditionalsMenuHelper
|
||||
url: 'https://www.redmine.org/projects/redmine/wiki/Security_Advisories',
|
||||
id: :security_advisories }]
|
||||
|
||||
Redmine::Plugin.all.each do |plugin|
|
||||
Redmine::Plugin.all.each do |plugin| # rubocop: disable Rails/FindEach
|
||||
next if plugin.id == :additionals
|
||||
|
||||
plugin_item_base = nil
|
||||
|
@ -154,7 +154,7 @@ class AdditionalsFontAwesome
|
||||
values = FONTAWESOME_ICONS[type][name]
|
||||
return {} if values.blank?
|
||||
|
||||
{ unicode: "&#x#{values[:unicode]};".html_safe, label: values[:label] } # rubocop:disable Rails/OutputSafety
|
||||
{ unicode: "&#x#{values[:unicode]};".html_safe, label: values[:label] } # rubocop: disable Rails/OutputSafety
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class AdditionalsMacro
|
||||
class << self
|
||||
def all(only_names: false, filtered: [], controller_only: nil)
|
||||
def macros(only_names: false, filtered: [], controller_only: nil)
|
||||
all = Redmine::WikiFormatting::Macros.available_macros
|
||||
macros = {}
|
||||
macro_list = []
|
||||
|
@ -6,7 +6,7 @@ br
|
||||
p
|
||||
= tag.label l(:label_hidden_macros_in_toolbar)
|
||||
= hidden_field_tag 'settings[hidden_macros_in_toolbar][]', ''
|
||||
- @available_macros = AdditionalsMacro.all(only_names: true).each do |m|
|
||||
- @available_macros = AdditionalsMacro.macros(only_names: true).each do |m|
|
||||
label.block
|
||||
- value = @settings[:hidden_macros_in_toolbar].present? ? @settings[:hidden_macros_in_toolbar].include?(m) : false
|
||||
= check_box_tag 'settings[hidden_macros_in_toolbar][]', m, value, id: nil
|
||||
|
@ -1,11 +1,11 @@
|
||||
ruby:
|
||||
case field_name
|
||||
when 'assigned_to_id'
|
||||
rows = if Setting.issue_group_assignment? # rubocop:disable Lint/UselessAssignment
|
||||
rows = if Setting.issue_group_assignment? # rubocop: disable Lint/UselessAssignment
|
||||
@project.visible_principals
|
||||
else
|
||||
@project.visible_users
|
||||
end + [User.new(firstname: "[#{l :label_none}]")]
|
||||
when 'author_id'
|
||||
rows = @project.visible_users # rubocop:disable Lint/UselessAssignment
|
||||
rows = @project.visible_users # rubocop: disable Lint/UselessAssignment
|
||||
end
|
||||
|
@ -14,9 +14,9 @@ module Additionals
|
||||
super
|
||||
return if @additionals_macro_list
|
||||
|
||||
@additionals_macro_list = AdditionalsMacro.all(filtered: Additionals.setting(:hidden_macros_in_toolbar).to_a,
|
||||
@additionals_macro_list = AdditionalsMacro.macros filtered: Additionals.setting(:hidden_macros_in_toolbar).to_a,
|
||||
only_names: true,
|
||||
controller_only: controller_name)
|
||||
controller_only: controller_name
|
||||
|
||||
return if @additionals_macro_list.count.zero?
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace :redmine do
|
||||
DESCRIPTION
|
||||
task reset_recently_dashboards: :environment do
|
||||
cnt = 0
|
||||
UserPreference.all.each do |pref|
|
||||
UserPreference.find_each do |pref|
|
||||
next if pref.others.blank? || pref.others[:recently_used_dashboards].blank?
|
||||
|
||||
pref.others.delete :recently_used_dashboards
|
||||
|
@ -20,19 +20,19 @@ module Additionals
|
||||
include Additionals::GlobalTestHelper
|
||||
|
||||
def prepare_tests
|
||||
Role.where(id: [1, 2]).each do |r|
|
||||
Role.where(id: [1, 2]).find_each do |r|
|
||||
r.permissions << :save_dashboards
|
||||
r.save
|
||||
end
|
||||
|
||||
Role.where(id: [1]).each do |r|
|
||||
Role.where(id: [1]).find_each do |r|
|
||||
r.permissions << :share_dashboards
|
||||
r.permissions << :set_system_dashboards
|
||||
r.permissions << :show_hidden_roles_in_memberbox
|
||||
r.save
|
||||
end
|
||||
|
||||
Project.where(id: [1, 2]).each do |project|
|
||||
Project.where(id: [1, 2]).find_each do |project|
|
||||
EnabledModule.create project: project, name: 'issue_tracking'
|
||||
end
|
||||
end
|
||||
|
@ -21,41 +21,41 @@ class AdditionalsMacroTest < Additionals::TestCase
|
||||
end
|
||||
|
||||
def test_all
|
||||
available_macros = AdditionalsMacro.all
|
||||
available_macros = AdditionalsMacro.macros
|
||||
|
||||
assert_not_equal 0, available_macros.count
|
||||
end
|
||||
|
||||
def test_all_with_only_names
|
||||
available_macros = AdditionalsMacro.all only_names: true
|
||||
available_macros = AdditionalsMacro.macros only_names: true
|
||||
|
||||
assert_includes available_macros, 'child_pages'
|
||||
end
|
||||
|
||||
def test_with_filter
|
||||
available_macros = AdditionalsMacro.all filtered: ['child_pages'], only_names: true
|
||||
available_macros = AdditionalsMacro.macros filtered: ['child_pages'], only_names: true
|
||||
|
||||
assert_not_includes available_macros, 'child_pages'
|
||||
|
||||
for_two_macros_selection = @all_macros - %w[child_pages collapse] + ['', 'nonexistingmacro']
|
||||
available_macros = AdditionalsMacro.all filtered: for_two_macros_selection, only_names: true
|
||||
available_macros = AdditionalsMacro.macros filtered: for_two_macros_selection, only_names: true
|
||||
|
||||
# -1 (hello world is always removed)
|
||||
assert_equal %w[child_pages collapse], available_macros
|
||||
end
|
||||
|
||||
def test_with_filter_all
|
||||
available_macros = AdditionalsMacro.all filtered: @all_macros, only_names: true
|
||||
available_macros = AdditionalsMacro.macros filtered: @all_macros, only_names: true
|
||||
|
||||
assert_equal 0, available_macros.count
|
||||
end
|
||||
|
||||
def test_with_controller_limit
|
||||
available_macros = AdditionalsMacro.all only_names: true, controller_only: 'issue'
|
||||
available_macros = AdditionalsMacro.macros only_names: true, controller_only: 'issue'
|
||||
|
||||
assert_not_includes available_macros, 'child_pages'
|
||||
|
||||
available_macros = AdditionalsMacro.all only_names: true, controller_only: 'wiki'
|
||||
available_macros = AdditionalsMacro.macros only_names: true, controller_only: 'wiki'
|
||||
|
||||
assert_includes available_macros, 'child_pages'
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user