#1414 Allow empty version
This commit is contained in:
parent
32c9ba1a4f
commit
0a3604630e
@ -58,7 +58,7 @@ module DmsfUploadHelper
|
||||
new_revision.description = commited_file[:description]
|
||||
new_revision.comment = commited_file[:comment]
|
||||
new_revision.major_version = commited_file[:version_major].present? ? DmsfUploadHelper::db_version(commited_file[:version_major]) : 1
|
||||
new_revision.minor_version = commited_file[:version_minor].present? ? DmsfUploadHelper::db_version(commited_file[:version_minor]) : 0
|
||||
new_revision.minor_version = commited_file[:version_minor].present? ? DmsfUploadHelper::db_version(commited_file[:version_minor]) : nil
|
||||
new_revision.patch_version = commited_file[:version_patch].present? ? DmsfUploadHelper::db_version(commited_file[:version_patch]) : nil
|
||||
new_revision.mime_type = commited_file[:mime_type]
|
||||
new_revision.size = commited_file[:size]
|
||||
|
||||
@ -58,7 +58,8 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
scope :deleted, -> { where(deleted: STATUS_DELETED) }
|
||||
|
||||
acts_as_customizable
|
||||
acts_as_event title: Proc.new { |o| (o.source_dmsf_file_revision_id.present? ? "#{l(:label_dmsf_updated)}" : "#{l(:label_created)}") +
|
||||
acts_as_event title: Proc.new { |o|
|
||||
(o.source_dmsf_file_revision_id.present? ? "#{l(:label_dmsf_updated)}" : "#{l(:label_created)}") +
|
||||
": #{o.dmsf_file.dmsf_path_str}"},
|
||||
url: Proc.new { |o| { controller: 'dmsf_files', action: 'show', id: o.dmsf_file } },
|
||||
datetime: Proc.new { |o| o.updated_at },
|
||||
@ -74,7 +75,6 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
|
||||
validates :title, presence: true
|
||||
validates :major_version, presence: true
|
||||
validates :minor_version, presence: true
|
||||
validates :dmsf_file, presence: true
|
||||
validates :name, dmsf_file_name: true
|
||||
validates :description, length: { maximum: 1.kilobyte }
|
||||
@ -155,13 +155,15 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.version(major_version, minor_version, patch_version)
|
||||
if major_version && minor_version
|
||||
if major_version
|
||||
ver = DmsfUploadHelper::gui_version(major_version).to_s
|
||||
if -minor_version != ' '.ord
|
||||
ver << ".#{DmsfUploadHelper::gui_version(minor_version)}"
|
||||
end
|
||||
if patch_version.present? && (-patch_version != ' '.ord)
|
||||
ver << ".#{DmsfUploadHelper::gui_version(patch_version)}"
|
||||
if minor_version
|
||||
if -minor_version != ' '.ord
|
||||
ver << ".#{DmsfUploadHelper::gui_version(minor_version)}"
|
||||
end
|
||||
if patch_version.present? && (-patch_version != ' '.ord)
|
||||
ver << ".#{DmsfUploadHelper::gui_version(patch_version)}"
|
||||
end
|
||||
end
|
||||
ver
|
||||
end
|
||||
|
||||
31
db/migrate/20230105082201_null_minor_version.rb
Normal file
31
db/migrate/20230105082201_null_minor_version.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
class NullMinorVersion < ActiveRecord::Migration[4.2]
|
||||
|
||||
def up
|
||||
change_column :dmsf_file_revisions, :minor_version, :integer, null: true
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :dmsf_file_revisions, :minor_version, :integer, null: false
|
||||
end
|
||||
|
||||
end
|
||||
@ -229,12 +229,6 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
||||
assert @revision1.errors.full_messages.to_sentence.include?(l(:error_file_is_locked))
|
||||
end
|
||||
|
||||
def test_minor_version_cannot_be_nil
|
||||
@revision1.minor_version = nil
|
||||
assert !@revision1.save
|
||||
assert @revision1.errors.full_messages.to_sentence.include?('Minor version cannot be blank')
|
||||
end
|
||||
|
||||
def test_major_version_cannot_be_nil
|
||||
@revision1.major_version = nil
|
||||
assert !@revision1.save
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user