This commit is contained in:
Karel Pičman 2025-09-30 15:20:44 +02:00
parent 5fcede685a
commit cf7f67e1fb
11 changed files with 19 additions and 30 deletions

View File

@ -18,7 +18,6 @@
AllCops:
TargetRubyVersion: 3.2
TargetRailsVersion: 7.1
SuggestExtensions: false
NewCops: enable
@ -26,10 +25,6 @@ AllCops:
Exclude:
- '**/vendor/**/*'
plugins:
- rubocop-performance
- rubocop-rails
# Rules for DMSF
Layout/LineLength:
Exclude:
@ -81,7 +76,7 @@ Naming/AccessorMethodName:
Exclude:
- lib/dav4rack/resource.rb
Naming/PredicateName:
Naming/PredicatePrefix:
Exclude:
- patches/attachable_patch.rb

View File

@ -22,10 +22,10 @@ class DmsfFileExtensionValidator < ActiveModel::EachValidator
include Redmine::I18n
def validate_each(record, attribute, value)
return true unless attribute.to_s == 'name'
return unless attribute.to_s == 'name'
extension = File.extname(value)
return true if Attachment.valid_extension?(extension)
return if Attachment.valid_extension?(extension)
record.errors.add(:base, l(:error_attachment_extension_not_allowed, extension: extension))
end

View File

@ -25,10 +25,9 @@ class DmsfFolderParentValidator < ActiveModel::EachValidator
while folder
if folder == record
record.errors.add attribute, :invalid
return false
return
end
folder = folder.dmsf_folder
end
true
end
end

View File

@ -22,14 +22,11 @@ class DmsfMaxFileSizeValidator < ActiveModel::EachValidator
include Redmine::I18n
def validate_each(record, attribute, value)
if value && (value > Setting.attachment_max_size.to_i.kilobytes)
return unless value && (value > Setting.attachment_max_size.to_i.kilobytes)
record.errors.add attribute,
l(:error_attachment_too_big, max_size: ActiveSupport::NumberHelper.number_to_human_size(
Setting.attachment_max_size.to_i.kilobytes
))
false
else
true
end
end
end

View File

@ -34,7 +34,7 @@ module RedmineDmsf
html = +''
container = context[:container]
# Radio buttons
if allowed_to_attach_documents(container)
if allowed_to_attach_documents?(container)
html << '<p>'
classes = +'inline'
html << "<label class=\"#{classes}\">"
@ -64,7 +64,7 @@ module RedmineDmsf
end
end
# Upload form
html << attach_documents_form(context, label: false) if allowed_to_attach_documents(container)
html << attach_documents_form(context, label: false) if allowed_to_attach_documents?(container)
html
end
@ -94,7 +94,7 @@ module RedmineDmsf
def view_issues_edit_notes_bottom_style(context = {})
if User.current.pref.dmsf_attachments_upload_choice == 'Attachments' ||
!allowed_to_attach_documents(context[:container])
!allowed_to_attach_documents?(context[:container])
''
else
'display: none'
@ -103,7 +103,7 @@ module RedmineDmsf
private
def allowed_to_attach_documents(container)
def allowed_to_attach_documents?(container)
return false unless container.respond_to?(:project) && container.respond_to?(:saved_dmsf_attachments) &&
RedmineDmsf.dmsf_act_as_attachable?
@ -147,7 +147,7 @@ module RedmineDmsf
# Add Dmsf upload form
container = context[:container]
return unless allowed_to_attach_documents(container)
return unless allowed_to_attach_documents?(container)
html = +'<p'
html << ' style="display: none;"' if User.current.pref.dmsf_attachments_upload_choice == 'Attachments'

View File

@ -22,7 +22,7 @@ module RedmineDmsf
# Helper test
class HelperTest < ActiveSupport::TestCase
def initialize(name)
super(name)
super
# Load all plugin's fixtures
dir = File.join(File.dirname(__FILE__), 'fixtures')
ext = '.yml'

View File

@ -21,7 +21,6 @@ require File.expand_path('../../../test_helper', __FILE__)
# WebDAV HEAD tests
class DmsfWebdavHeadTest < RedmineDmsf::Test::IntegrationTest
def test_head_requires_authentication
head "/dmsf/webdav/#{@project1.identifier}"
assert_response :unauthorized

View File

@ -22,7 +22,6 @@ require 'fileutils'
# WebDAV LOCK test
class DmsfWebdavLockTest < RedmineDmsf::Test::IntegrationTest
def setup
super
@xml = %(<?xml version="1.0" encoding="utf-8" ?>

View File

@ -22,7 +22,7 @@ module RedmineDmsf
# Integration test
class IntegrationTest < Redmine::IntegrationTest
def initialize(name)
super(name)
super
# Load all plugin's fixtures
dir = File.join(File.dirname(__FILE__), 'fixtures')
ext = '.yml'

View File

@ -22,7 +22,7 @@ module RedmineDmsf
# Test case
class TestCase < ActionDispatch::IntegrationTest
def initialize(name)
super(name)
super
# Load all plugin's fixtures
dir = File.join(File.dirname(__FILE__), 'fixtures')
ext = '.yml'

View File

@ -22,7 +22,7 @@ module RedmineDmsf
# Unit test
class UnitTest < ActiveSupport::TestCase
def initialize(name)
super(name)
super
# Load all plugin's fixtures
dir = File.join(File.dirname(__FILE__), 'fixtures')
ext = '.yml'