Rails 6 compatibility
This commit is contained in:
parent
2a16856b1b
commit
f9629887ee
@ -55,7 +55,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
validates :name, presence: true, dmsf_file_name: true
|
||||
validates :project, presence: true
|
||||
validates_uniqueness_of :name, scope: [:dmsf_folder_id, :project_id, :deleted],
|
||||
conditions: -> { where(deleted: STATUS_ACTIVE) }
|
||||
conditions: -> { where(deleted: STATUS_ACTIVE) }, case_sensitive: true
|
||||
|
||||
acts_as_event title: Proc.new { |o| o.name },
|
||||
description: Proc.new { |o|
|
||||
|
||||
@ -56,10 +56,10 @@ 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 },
|
||||
datetime: Proc.new { |o| o.updated_at },
|
||||
description: Proc.new { |o| "#{o.description}\n#{o.comment}" },
|
||||
author: Proc.new { |o| o.user }
|
||||
|
||||
@ -67,8 +67,8 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
timestamp: "#{DmsfFileRevision.table_name}.updated_at",
|
||||
author_key: "#{DmsfFileRevision.table_name}.user_id",
|
||||
permission: :view_dmsf_file_revisions,
|
||||
scope: DmsfFileRevision.joins(:dmsf_file).
|
||||
joins("JOIN #{Project.table_name} ON #{Project.table_name}.id = #{DmsfFile.table_name}.project_id").visible
|
||||
scope: Proc.new { DmsfFileRevision.joins(:dmsf_file).
|
||||
joins("JOIN #{Project.table_name} ON #{Project.table_name}.id = #{DmsfFile.table_name}.project_id").visible }
|
||||
|
||||
validates :title, presence: true
|
||||
validates :major_version, presence: true
|
||||
|
||||
@ -45,8 +45,8 @@ class DmsfFileRevisionAccess < ActiveRecord::Base
|
||||
timestamp: "#{DmsfFileRevisionAccess.table_name}.updated_at",
|
||||
author_key: "#{DmsfFileRevisionAccess.table_name}.user_id",
|
||||
permission: :view_dmsf_file_revision_accesses,
|
||||
scope: DmsfFileRevisionAccess.
|
||||
scope: Proc.new { DmsfFileRevisionAccess.
|
||||
joins(:dmsf_file_revision).joins("JOIN #{DmsfFile.table_name} ON dmsf_files.id = dmsf_file_revisions.dmsf_file_id").
|
||||
joins("JOIN #{Project.table_name} on dmsf_files.project_id = projects.id").
|
||||
where(dmsf_files: { deleted: DmsfFile::STATUS_ACTIVE })
|
||||
where(dmsf_files: { deleted: DmsfFile::STATUS_ACTIVE }) }
|
||||
end
|
||||
|
||||
@ -94,7 +94,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
validates :title, presence: true, dmsf_file_name: true
|
||||
validates :project, presence: true
|
||||
validates_uniqueness_of :title, scope: [:dmsf_folder_id, :project_id, :deleted],
|
||||
conditions: -> { where(deleted: STATUS_ACTIVE) }
|
||||
conditions: -> { where(deleted: STATUS_ACTIVE) }, case_sensitive: true
|
||||
validates :description, length: { maximum: 65535 }
|
||||
validates :dmsf_folder, dmsf_folder_parent: true, if: Proc.new { |folder| !folder.new_record? }
|
||||
|
||||
@ -468,7 +468,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
# Attributes
|
||||
self.title = params[:dmsf_folder][:title].strip
|
||||
self.description = params[:dmsf_folder][:description].strip
|
||||
self.dmsf_folder_id = params[:dmsf_folder][:dmsf_folder_id]
|
||||
self.dmsf_folder_id = params[:parent_id].present? ? params[:parent_id] : params[:dmsf_folder][:dmsf_folder_id]
|
||||
# Custom fields
|
||||
if params[:dmsf_folder][:custom_field_values].present?
|
||||
i = 0
|
||||
|
||||
@ -30,7 +30,7 @@ class DmsfWorkflowStep < ActiveRecord::Base
|
||||
validates :step, presence: true
|
||||
validates :user, presence: true
|
||||
validates :operator, presence: true
|
||||
validates_uniqueness_of :user_id, scope: [:dmsf_workflow_id, :step]
|
||||
validates_uniqueness_of :user_id, scope: [:dmsf_workflow_id, :step], case_sensitive: true
|
||||
validates :name, length: { maximum: 30 }
|
||||
|
||||
OPERATOR_OR = 0
|
||||
|
||||
@ -29,7 +29,7 @@ class DmsfWorkflowStepAction < ActiveRecord::Base
|
||||
validates :author_id, presence: true
|
||||
validates :note, presence: true, unless: lambda { action == DmsfWorkflowStepAction::ACTION_APPROVE }
|
||||
validates_uniqueness_of :dmsf_workflow_step_assignment_id, scope: [:action],
|
||||
unless: lambda { action == DmsfWorkflowStepAction::ACTION_DELEGATE }
|
||||
unless: lambda { action == DmsfWorkflowStepAction::ACTION_DELEGATE }, case_sensitive: true
|
||||
|
||||
ACTION_APPROVE = 1
|
||||
ACTION_REJECT = 2
|
||||
|
||||
@ -29,7 +29,7 @@ class DmsfWorkflowStepAssignment < ActiveRecord::Base
|
||||
|
||||
validates :dmsf_workflow_step, presence: true
|
||||
validates :dmsf_file_revision, presence: true
|
||||
validates_uniqueness_of :dmsf_workflow_step_id, scope: [:dmsf_file_revision_id]
|
||||
validates_uniqueness_of :dmsf_workflow_step_id, scope: [:dmsf_file_revision_id], case_sensitive: true
|
||||
|
||||
def add?(dmsf_file_revision_id)
|
||||
if dmsf_file_revision_id == dmsf_file_revision_id
|
||||
|
||||
@ -246,7 +246,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
||||
def test_show_csv
|
||||
get :show, params: { id: @project1.id, format: 'csv' }
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^text\/csv/)
|
||||
assert @response.media_type.include?('text/csv')
|
||||
end
|
||||
|
||||
def test_show_folder_doesnt_correspond_the_project
|
||||
|
||||
@ -34,7 +34,7 @@ class DmsfFolderPermissionsControllerTest < RedmineDmsf::Test::TestCase
|
||||
get :new, params: { project_id: @project1, dmsf_folder_id: @folder7, format: 'js' }, xhr: true
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert @response.content_type.match?(/^text\/javascript/)
|
||||
assert @response.media_type.include?('text/javascript')
|
||||
end
|
||||
|
||||
def test_autocomplete_for_user
|
||||
|
||||
@ -36,7 +36,7 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
# curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/projects/12/dmsf.xml
|
||||
get "/projects/#{@project1.id}/dmsf.xml?key=#{@token.value}"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf>
|
||||
# <dmsf_nodes total_count="10" type="array">
|
||||
|
||||
@ -36,7 +36,7 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
#curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml
|
||||
get "/dmsf/files/#{@file1.id}.xml?key=#{@token.value}"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf_file>
|
||||
# <id>1</id>
|
||||
@ -113,7 +113,7 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
#curl --data-binary "@cat.gif" -H "Content-Type: application/octet-stream" -X POST -u ${1}:${2} http://localhost:3000/projects/12/dmsf/upload.xml?filename=cat.gif
|
||||
post "/projects/#{@project1.id}/dmsf/upload.xml?filename=test.txt&key=#{@token.value}", params: 'File content', headers: { "CONTENT_TYPE" => 'application/octet-stream' }
|
||||
assert_response :created
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
#<?xml version="1.0" encoding="UTF-8"?>
|
||||
# <upload>
|
||||
# <token>2.8bb2564936980e92ceec8a5759ec34a8</token>
|
||||
|
||||
@ -36,7 +36,7 @@ class DmsfFolderApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
#curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml
|
||||
get "/projects/#{@project1.identifier}/dmsf.xml?key=#{@token.value}"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf>
|
||||
# <dmsf_nodes total_count="7" type="array">
|
||||
@ -58,7 +58,7 @@ class DmsfFolderApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
#curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml
|
||||
get "/projects/#{@project1.identifier}/dmsf.xml?key=#{@token.value}"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf>
|
||||
# <dmsf_nodes total_count="9" type="array">
|
||||
@ -81,7 +81,7 @@ class DmsfFolderApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
#curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} "http://localhost:3000/dmsf/files/17216.xml?limit=1&offset=1"
|
||||
get "/projects/#{@project1.identifier}/dmsf.xml?key=#{@token.value}&limit=1&offset=2"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf>
|
||||
# <dmsf_nodes total_count="1" type="array">
|
||||
@ -139,7 +139,7 @@ class DmsfFolderApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: USERS_API_KEY" http://localhost:3000/projects/1/dmsf.json?folder_title=Updated%20title
|
||||
get "/projects/#{@project1.identifier}/dmsf.xml?key=#{@token.value}&folder_title=#{@folder1.title}"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf>
|
||||
# <dmsf_folders total_count="1" type="array">
|
||||
@ -171,7 +171,7 @@ class DmsfFolderApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: USERS_API_KE" http://localhost:3000/projects/1/dmsf.json?folder_id=3
|
||||
get "/projects/#{@project1.identifier}/dmsf.xml?key=#{@token.value}&folder_id=#{@folder1.id}"
|
||||
assert_response :success
|
||||
assert @response.content_type.match?(/^application\/xml/)
|
||||
assert @response.media_type.include?('application/xml')
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf>
|
||||
# <dmsf_folders total_count="1" type="array">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user