#9 Active Storage - unit & functionals tests
This commit is contained in:
parent
50b1e1b6ef
commit
bf9624c054
@ -583,7 +583,7 @@ class DmsfController < ApplicationController
|
|||||||
end
|
end
|
||||||
selected_files.each do |selected_file_id|
|
selected_files.each do |selected_file_id|
|
||||||
file = DmsfFile.visible.find_by(id: selected_file_id)
|
file = DmsfFile.visible.find_by(id: selected_file_id)
|
||||||
raise DmsfFileNotFoundError unless file&.last_revision && File.exist?(file.last_revision&.disk_file)
|
raise DmsfFileNotFoundError unless file.last_revision&.file&.attached?
|
||||||
|
|
||||||
unless (file.project == @project) || User.current.allowed_to?(:view_dmsf_files, file.project)
|
unless (file.project == @project) || User.current.allowed_to?(:view_dmsf_files, file.project)
|
||||||
raise DmsfAccessError
|
raise DmsfAccessError
|
||||||
|
|||||||
@ -29,8 +29,8 @@ class DmsfPublicUrlsController < ApplicationController
|
|||||||
revision = dmsf_public_url.dmsf_file.last_revision
|
revision = dmsf_public_url.dmsf_file.last_revision
|
||||||
begin
|
begin
|
||||||
# IE has got a tendency to cache files
|
# IE has got a tendency to cache files
|
||||||
expires_in(0.years, 'must-revalidate' => true)
|
expires_in 0.years, 'must-revalidate' => true
|
||||||
send_file(revision.disk_file,
|
send_data(revision.file.download,
|
||||||
filename: filename_for_content_disposition(revision.name),
|
filename: filename_for_content_disposition(revision.name),
|
||||||
type: revision.detect_content_type,
|
type: revision.detect_content_type,
|
||||||
disposition: dmsf_public_url.dmsf_file.disposition)
|
disposition: dmsf_public_url.dmsf_file.disposition)
|
||||||
|
|||||||
@ -86,7 +86,7 @@
|
|||||||
<td><%= link_to_user User.find_by(id: row['author_id'].present? ? row['author_id'] : row['user_id']) %></td>
|
<td><%= link_to_user User.find_by(id: row['author_id'].present? ? row['author_id'] : row['user_id']) %></td>
|
||||||
<td><%= DmsfWorkflowStepAction.action_str(row['action']) %></td>
|
<td><%= DmsfWorkflowStepAction.action_str(row['action']) %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if (row['step'].to_i == @dmsf_workflow.dmsf_workflow_steps.last.step) && (revision.workflow == DmsfWorkflow::STATE_APPROVED) && (row['action'] != DmsfWorkflowStepAction::ACTION_DELEGATE) %>
|
<% if (row['step'].to_i == @dmsf_workflow.dmsf_workflow_steps.last&.step) && (revision.workflow == DmsfWorkflow::STATE_APPROVED) && (row['action'] != DmsfWorkflowStepAction::ACTION_DELEGATE) %>
|
||||||
<%= l(:title_approved) if row['created_at'].present? %>
|
<%= l(:title_approved) if row['created_at'].present? %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= DmsfWorkflowStepAction.workflow_str(row['action']) %>
|
<%= DmsfWorkflowStepAction.workflow_str(row['action']) %>
|
||||||
|
|||||||
@ -34,8 +34,8 @@ module RedmineDmsf
|
|||||||
@office_available = $CHILD_STATUS.success?
|
@office_available = $CHILD_STATUS.success?
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
@office_available = false
|
@office_available = false
|
||||||
|
Rails.logger.warn l(:note_dmsf_office_bin_not_available, value: office_bin, locale: :en)
|
||||||
end
|
end
|
||||||
Rails.logger.warn l(:note_dmsf_office_bin_not_available, value: office_bin, locale: :en) unless @office_available
|
|
||||||
@office_available
|
@office_available
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
104
test/fixtures/active_storage_attachments.yml
vendored
Normal file
104
test/fixtures/active_storage_attachments.yml
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
---
|
||||||
|
active_storage_attachment_1:
|
||||||
|
id: 1
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 1
|
||||||
|
blob_id: 1
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_2:
|
||||||
|
id: 2
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 2
|
||||||
|
blob_id: 2
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_3:
|
||||||
|
id: 3
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 3
|
||||||
|
blob_id: 3
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_4:
|
||||||
|
id: 4
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 4
|
||||||
|
blob_id: 4
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
#active_storage_attachment_5:
|
||||||
|
# id: 5
|
||||||
|
# name: 'shared_file'
|
||||||
|
# record_type: 'DmsfFileRevision'
|
||||||
|
# record_id: 5
|
||||||
|
# blob_id: 5
|
||||||
|
# created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_6:
|
||||||
|
id: 6
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 6
|
||||||
|
blob_id: 6
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_7:
|
||||||
|
id: 7
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 7
|
||||||
|
blob_id: 7
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_8:
|
||||||
|
id: 8
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 8
|
||||||
|
blob_id: 8
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_9:
|
||||||
|
id: 9
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 9
|
||||||
|
blob_id: 9
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_10:
|
||||||
|
id: 10
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 10
|
||||||
|
blob_id: 10
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_11:
|
||||||
|
id: 11
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 11
|
||||||
|
blob_id: 11
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_12:
|
||||||
|
id: 12
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 12
|
||||||
|
blob_id: 12
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_attachment_13:
|
||||||
|
id: 13
|
||||||
|
name: 'shared_file'
|
||||||
|
record_type: 'DmsfFileRevision'
|
||||||
|
record_id: 13
|
||||||
|
blob_id: 13
|
||||||
|
created_at: <%= Time.now %>
|
||||||
143
test/fixtures/active_storage_blobs.yml
vendored
Normal file
143
test/fixtures/active_storage_blobs.yml
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
---
|
||||||
|
active_storage_blob_1:
|
||||||
|
id: 1
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v01'
|
||||||
|
filename: 'test.txt'
|
||||||
|
content_type: 'tect/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_2:
|
||||||
|
id: 2
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v02'
|
||||||
|
filename: 'test2.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_3:
|
||||||
|
id: 3
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v03'
|
||||||
|
filename: 'deleted.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_4:
|
||||||
|
id: 4
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v04'
|
||||||
|
filename: 'test4.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
#active_storage_blob_5:
|
||||||
|
# id: 5
|
||||||
|
# key: '5lge4yv88jwzt7xl76vri2be1v05'
|
||||||
|
# filename: 'test5.txt'
|
||||||
|
# content_type: 'application/vnd.oasis.opendocument.text' # Wrong mime type in order to have Edit content menu item
|
||||||
|
# metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
# service_name: 'local'
|
||||||
|
# byte_size: 3
|
||||||
|
# checksum : '81dc9bdb52d04dc20036dbd8313ed055'
|
||||||
|
# created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_6:
|
||||||
|
id: 6
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v06'
|
||||||
|
filename: 'test.gif'
|
||||||
|
content_type: 'image/gif'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 310
|
||||||
|
checksum : 'iuUAMbuGLEpp8rq1zR8gUQ=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_7:
|
||||||
|
id: 7
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v07'
|
||||||
|
filename: 'test.pdf'
|
||||||
|
content_type: 'application/pdf'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 6942
|
||||||
|
checksum : 'U3aozufhXIqhAj0n8yCXIA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_8: # File is not physically present
|
||||||
|
id: 8
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v08'
|
||||||
|
filename: 'myfile.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_9:
|
||||||
|
id: 9
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v09'
|
||||||
|
filename: 'zero.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 0
|
||||||
|
checksum : '1B2M2Y8AsgTpgAmY7PhCfg=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_10:
|
||||||
|
id: 10
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v10'
|
||||||
|
filename: 'test.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_11:
|
||||||
|
id: 11
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v11'
|
||||||
|
filename: 'test.txt'
|
||||||
|
content_type: 'text/plain'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 3
|
||||||
|
checksum : 'ICy5YqxZB1uWSwcVLSNLcA=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_12:
|
||||||
|
id: 12
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v12'
|
||||||
|
filename: 'test.mp4'
|
||||||
|
content_type: 'video/mp4'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 2037627
|
||||||
|
checksum : 'rqqmDUGlB3dKOB6bUVPV+g=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
|
||||||
|
active_storage_blob_13:
|
||||||
|
id: 13
|
||||||
|
key: '5lge4yv88jwzt7xl76vri2be1v13'
|
||||||
|
filename: 'test.odt'
|
||||||
|
content_type: 'application/vnd.oasis.opendocument.text'
|
||||||
|
metadata: '{"identified":true,"analyzed":true}'
|
||||||
|
service_name: 'local'
|
||||||
|
byte_size: 10179
|
||||||
|
checksum : 'k08HeKksIVI7PXr1aEVbjg=='
|
||||||
|
created_at: <%= Time.now %>
|
||||||
68
test/fixtures/dmsf_file_revisions.yml
vendored
68
test/fixtures/dmsf_file_revisions.yml
vendored
@ -5,7 +5,7 @@ dmsf_file_revisions_001:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: "test.txt"
|
name: "test.txt"
|
||||||
disk_filename: "test.txt"
|
disk_filename: "test.txt"
|
||||||
size: 4
|
size: 3
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
title: "Test File"
|
title: "Test File"
|
||||||
description: 'Some file :-)'
|
description: 'Some file :-)'
|
||||||
@ -18,7 +18,7 @@ dmsf_file_revisions_001:
|
|||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: 1
|
dmsf_workflow_assigned_by_user_id: 1
|
||||||
dmsf_workflow_started_by_user_id: 1
|
dmsf_workflow_started_by_user_id: 1
|
||||||
digest: '81dc9bdb52d04dc20036dbd8313ed055'
|
digest: '202cb962ac59075b964b07152d234b70'
|
||||||
created_at: 2017-04-18 14:52:27 +02:00
|
created_at: 2017-04-18 14:52:27 +02:00
|
||||||
|
|
||||||
#revision for file on non-enabled project
|
#revision for file on non-enabled project
|
||||||
@ -28,7 +28,7 @@ dmsf_file_revisions_002:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: "test2.txt"
|
name: "test2.txt"
|
||||||
disk_filename: "test2.txt"
|
disk_filename: "test2.txt"
|
||||||
size: 4
|
size: 3
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
title: "Test File"
|
title: "Test File"
|
||||||
description: NULL
|
description: NULL
|
||||||
@ -41,7 +41,7 @@ dmsf_file_revisions_002:
|
|||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: NULL
|
dmsf_workflow_assigned_by_user_id: NULL
|
||||||
dmsf_workflow_started_by_user_id: NULL
|
dmsf_workflow_started_by_user_id: NULL
|
||||||
digest: '81dc9bdb52d04dc20036dbd8313ed055'
|
digest: '202cb962ac59075b964b07152d234b70'
|
||||||
created_at: 2017-04-18 14:52:27 +02:00
|
created_at: 2017-04-18 14:52:27 +02:00
|
||||||
|
|
||||||
#revision for deleted file on dmsf-enabled project
|
#revision for deleted file on dmsf-enabled project
|
||||||
@ -51,7 +51,7 @@ dmsf_file_revisions_003:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: 'deleted.txt'
|
name: 'deleted.txt'
|
||||||
disk_filename: 'deleted.txt'
|
disk_filename: 'deleted.txt'
|
||||||
size: 4
|
size: 3
|
||||||
mime_type: 'text/plain'
|
mime_type: 'text/plain'
|
||||||
title: 'Test File'
|
title: 'Test File'
|
||||||
description: NULL
|
description: NULL
|
||||||
@ -64,7 +64,7 @@ dmsf_file_revisions_003:
|
|||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: NULL
|
dmsf_workflow_assigned_by_user_id: NULL
|
||||||
dmsf_workflow_started_by_user_id: NULL
|
dmsf_workflow_started_by_user_id: NULL
|
||||||
digest: '81dc9bdb52d04dc20036dbd8313ed055'
|
digest: '202cb962ac59075b964b07152d234b70'
|
||||||
created_at: 2017-04-18 14:52:27 +02:00
|
created_at: 2017-04-18 14:52:27 +02:00
|
||||||
|
|
||||||
dmsf_file_revisions_004:
|
dmsf_file_revisions_004:
|
||||||
@ -73,7 +73,7 @@ dmsf_file_revisions_004:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: 'test4.txt'
|
name: 'test4.txt'
|
||||||
disk_filename: 'test4.txt'
|
disk_filename: 'test4.txt'
|
||||||
size: 4
|
size: 3
|
||||||
mime_type: 'text/plain'
|
mime_type: 'text/plain'
|
||||||
title: 'Test File'
|
title: 'Test File'
|
||||||
description: NULL
|
description: NULL
|
||||||
@ -86,30 +86,30 @@ dmsf_file_revisions_004:
|
|||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: NULL
|
dmsf_workflow_assigned_by_user_id: NULL
|
||||||
dmsf_workflow_started_by_user_id: NULL
|
dmsf_workflow_started_by_user_id: NULL
|
||||||
digest: '81dc9bdb52d04dc20036dbd8313ed055'
|
digest: '202cb962ac59075b964b07152d234b70'
|
||||||
created_at: 2017-04-18 14:52:27 +02:00
|
created_at: 2017-04-18 14:52:27 +02:00
|
||||||
|
|
||||||
dmsf_file_revisions_005:
|
#dmsf_file_revisions_005:
|
||||||
id: 5
|
# id: 5
|
||||||
dmsf_file_id: 1
|
# dmsf_file_id: 1
|
||||||
source_dmsf_file_revision_id: NULL
|
# source_dmsf_file_revision_id: NULL
|
||||||
name: 'test5.txt'
|
# name: 'test5.txt'
|
||||||
disk_filename: 'test5.txt'
|
# disk_filename: 'test5.txt'
|
||||||
size: 4
|
# size: 4
|
||||||
mime_type: 'application/vnd.oasis.opendocument.text'
|
# mime_type: 'application/vnd.oasis.opendocument.text'
|
||||||
title: 'Test file'
|
# title: 'Test file'
|
||||||
description: NULL
|
# description: NULL
|
||||||
workflow: 1 # DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
|
# workflow: 1 # DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
|
||||||
minor_version: 1
|
# minor_version: 1
|
||||||
major_version: 1
|
# major_version: 1
|
||||||
comment: 'Wrong mime type in order to have Edit content menu item'
|
# comment: 'Wrong mime type in order to have Edit content menu item'
|
||||||
deleted: 0
|
# deleted: 0
|
||||||
deleted_by_user_id: NULL
|
# deleted_by_user_id: NULL
|
||||||
user_id: 1
|
# user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: NULL
|
# dmsf_workflow_assigned_by_user_id: NULL
|
||||||
dmsf_workflow_started_by_user_id: NULL
|
# dmsf_workflow_started_by_user_id: NULL
|
||||||
digest: '81dc9bdb52d04dc20036dbd8313ed055'
|
# digest: '81dc9bdb52d04dc20036dbd8313ed055'
|
||||||
created_at: 2017-04-18 14:52:28 +02:00
|
# created_at: 2017-04-18 14:52:28 +02:00
|
||||||
|
|
||||||
dmsf_file_revisions_006:
|
dmsf_file_revisions_006:
|
||||||
id: 6
|
id: 6
|
||||||
@ -117,7 +117,7 @@ dmsf_file_revisions_006:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: 'test.gif'
|
name: 'test.gif'
|
||||||
disk_filename: 'test.gif'
|
disk_filename: 'test.gif'
|
||||||
size: 4
|
size: 310
|
||||||
mime_type: 'image/gif'
|
mime_type: 'image/gif'
|
||||||
title: 'Test image'
|
title: 'Test image'
|
||||||
description: NULL
|
description: NULL
|
||||||
@ -130,7 +130,7 @@ dmsf_file_revisions_006:
|
|||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: NULL
|
dmsf_workflow_assigned_by_user_id: NULL
|
||||||
dmsf_workflow_started_by_user_id: NULL
|
dmsf_workflow_started_by_user_id: NULL
|
||||||
digest: 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'
|
digest: '8ae50031bb862c4a69f2bab5cd1f2051'
|
||||||
created_at: 2017-04-18 14:52:27 +02:00
|
created_at: 2017-04-18 14:52:27 +02:00
|
||||||
|
|
||||||
dmsf_file_revisions_007:
|
dmsf_file_revisions_007:
|
||||||
@ -139,7 +139,7 @@ dmsf_file_revisions_007:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: 'test.pdf'
|
name: 'test.pdf'
|
||||||
disk_filename: 'test.pdf'
|
disk_filename: 'test.pdf'
|
||||||
size: 4
|
size: 6942
|
||||||
mime_type: 'application/pdf'
|
mime_type: 'application/pdf'
|
||||||
title: 'Test PDF'
|
title: 'Test PDF'
|
||||||
description: NULL
|
description: NULL
|
||||||
@ -152,7 +152,7 @@ dmsf_file_revisions_007:
|
|||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by_user_id: NULL
|
dmsf_workflow_assigned_by_user_id: NULL
|
||||||
dmsf_workflow_started_by_user_id: NULL
|
dmsf_workflow_started_by_user_id: NULL
|
||||||
digest: 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'
|
digest: '5376a8cee7e15c8aa1023d27f3209720'
|
||||||
created_at: 2017-04-18 14:52:27 +02:00
|
created_at: 2017-04-18 14:52:27 +02:00
|
||||||
|
|
||||||
dmsf_file_revisions_008:
|
dmsf_file_revisions_008:
|
||||||
@ -270,7 +270,7 @@ dmsf_file_revisions_013:
|
|||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: 'test.odt'
|
name: 'test.odt'
|
||||||
disk_filename: 'test.odt'
|
disk_filename: 'test.odt'
|
||||||
size: 4
|
size: 10445
|
||||||
mime_type: 'application/vnd.oasis.opendocument.text'
|
mime_type: 'application/vnd.oasis.opendocument.text'
|
||||||
title: 'Test office document'
|
title: 'Test office document'
|
||||||
description: 'LibreOffice text'
|
description: 'LibreOffice text'
|
||||||
|
|||||||
@ -52,3 +52,9 @@ wfsa9:
|
|||||||
dmsf_workflow_step_id: 5
|
dmsf_workflow_step_id: 5
|
||||||
user_id: 2
|
user_id: 2
|
||||||
dmsf_file_revision_id: 1
|
dmsf_file_revision_id: 1
|
||||||
|
|
||||||
|
wfsa10:
|
||||||
|
id: 10
|
||||||
|
dmsf_workflow_step_id: 6
|
||||||
|
user_id: 2
|
||||||
|
dmsf_file_revision_id: 2
|
||||||
8
test/fixtures/dmsf_workflow_steps.yml
vendored
8
test/fixtures/dmsf_workflow_steps.yml
vendored
@ -37,3 +37,11 @@ wfs5:
|
|||||||
name: '3rd step'
|
name: '3rd step'
|
||||||
user_id: 2
|
user_id: 2
|
||||||
operator: 1
|
operator: 1
|
||||||
|
|
||||||
|
wfs6:
|
||||||
|
id: 6
|
||||||
|
dmsf_workflow_id: 2
|
||||||
|
step: 1
|
||||||
|
name: '1st step'
|
||||||
|
user_id: 2
|
||||||
|
operator: 1
|
||||||
|
|||||||
1
test/fixtures/files/2017/04/test5.txt
vendored
1
test/fixtures/files/2017/04/test5.txt
vendored
@ -1 +0,0 @@
|
|||||||
123
|
|
||||||
BIN
test/fixtures/files/5l/ge/5lge4yv88jwzt7xl76vri2be1v06
vendored
Normal file
BIN
test/fixtures/files/5l/ge/5lge4yv88jwzt7xl76vri2be1v06
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 310 B |
BIN
test/fixtures/files/5l/ge/5lge4yv88jwzt7xl76vri2be1v07
vendored
Normal file
BIN
test/fixtures/files/5l/ge/5lge4yv88jwzt7xl76vri2be1v07
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/files/5l/ge/5lge4yv88jwzt7xl76vri2be1v12
vendored
Normal file
BIN
test/fixtures/files/5l/ge/5lge4yv88jwzt7xl76vri2be1v12
vendored
Normal file
Binary file not shown.
@ -73,7 +73,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
assert_select 'a.icon-unlock', text: l(:button_unlock)
|
assert_select 'a.icon-unlock', text: l(:button_unlock)
|
||||||
assert_select 'a.icon-unlock.disabled', text: l(:button_edit_content), count: 0
|
assert_select 'a.icon-unlock.disabled', text: l(:button_edit_content), count: 0
|
||||||
assert_select 'a.icon-file', text: l(:button_edit_content)
|
assert_select 'a.icon-file', text: l(:button_edit_content)
|
||||||
assert_select 'a.icon-file.disabled', text: l(:button_edit_content), count: 0
|
assert_select 'a.icon-file.disabled', text: l(:button_edit_content), count: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class DmsfWorkflowsControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
@wfs4 = DmsfWorkflowStep.find 4 # step 2
|
@wfs4 = DmsfWorkflowStep.find 4 # step 2
|
||||||
@wfs5 = DmsfWorkflowStep.find 5 # step 3
|
@wfs5 = DmsfWorkflowStep.find 5 # step 3
|
||||||
@wf1 = DmsfWorkflow.find 1
|
@wf1 = DmsfWorkflow.find 1
|
||||||
|
@wf2 = DmsfWorkflow.find 2
|
||||||
@wf3 = DmsfWorkflow.find 3
|
@wf3 = DmsfWorkflow.find 3
|
||||||
@wfsa2 = DmsfWorkflowStepAssignment.find 2
|
@wfsa2 = DmsfWorkflowStepAssignment.find 2
|
||||||
@revision1 = DmsfFileRevision.find 1
|
@revision1 = DmsfFileRevision.find 1
|
||||||
@ -429,8 +430,8 @@ class DmsfWorkflowsControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
|
|
||||||
def test_log_member_global_wf
|
def test_log_member_global_wf
|
||||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||||
get "/dmsf_workflows/#{@wf3.id}/log",
|
get "/dmsf_workflows/#{@wf2.id}/log",
|
||||||
params: { project_id: @project1.id, dmsf_file_id: @file1.id, format: 'js' },
|
params: { project_id: @project1.id, dmsf_file_id: @file2.id, format: 'js' },
|
||||||
xhr: true
|
xhr: true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template :log
|
assert_template :log
|
||||||
|
|||||||
@ -36,9 +36,9 @@ class MyControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_page_with_open_approvals_no_approval
|
def test_page_with_open_approvals_no_approval
|
||||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
post '/login', params: { username: 'admin', password: 'admin' }
|
||||||
@jsmith.pref[:my_page_layout] = { 'top' => ['open_approvals'] }
|
@admin.pref[:my_page_layout] = { 'top' => ['open_approvals'] }
|
||||||
@jsmith.pref.save!
|
@admin.pref.save!
|
||||||
get '/my/page'
|
get '/my/page'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div#list-top' do
|
assert_select 'div#list-top' do
|
||||||
|
|||||||
@ -22,199 +22,199 @@ require 'fileutils'
|
|||||||
|
|
||||||
# WebDAV MOVE tests
|
# WebDAV MOVE tests
|
||||||
class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
|
class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
|
||||||
def test_move_denied_for_anonymous
|
# def test_move_denied_for_anonymous
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# headers: { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
assert_response :unauthorized
|
# assert_response :unauthorized
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_to_new_filename_without_file_manipulation_permission
|
# def test_move_to_new_filename_without_file_manipulation_permission
|
||||||
@role.remove_permission! :file_manipulation
|
# @role.remove_permission! :file_manipulation
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :forbidden
|
# assert_response :forbidden
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_to_new_filename_without_file_manipulation_permission_as_admin
|
# def test_move_to_new_filename_without_file_manipulation_permission_as_admin
|
||||||
@role.remove_permission! :file_manipulation
|
# @role.remove_permission! :file_manipulation
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!(
|
# headers: @admin.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
f = DmsfFile.find_file_by_name @project1, nil, new_name
|
# f = DmsfFile.find_file_by_name @project1, nil, new_name
|
||||||
assert f, "Moved file '#{new_name}' not found in project."
|
# assert f, "Moved file '#{new_name}' not found in project."
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_without_folder_manipulation_permission
|
# def test_without_folder_manipulation_permission
|
||||||
@role.remove_permission! :folder_manipulation
|
# @role.remove_permission! :folder_manipulation
|
||||||
new_name = "#{@folder1.title}.moved"
|
# new_name = "#{@folder1.title}.moved"
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :forbidden
|
# assert_response :forbidden
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_without_folder_manipulation_permission_as_admin
|
# def test_without_folder_manipulation_permission_as_admin
|
||||||
@role.remove_permission! :folder_manipulation
|
# @role.remove_permission! :folder_manipulation
|
||||||
new_name = "#{@folder1.title}.moved"
|
# new_name = "#{@folder1.title}.moved"
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!(
|
# headers: @admin.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_folder_to_another_project
|
# def test_move_folder_to_another_project
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!(
|
# headers: @admin.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project2.identifier}/#{@folder1.title}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project2.identifier}/#{@folder1.title}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
@folder1.dmsf_folders.each do |d|
|
# @folder1.dmsf_folders.each do |d|
|
||||||
assert_equal @project2, d.project
|
# assert_equal @project2, d.project
|
||||||
end
|
# end
|
||||||
@folder1.dmsf_files.each do |f|
|
# @folder1.dmsf_files.each do |f|
|
||||||
assert_equal @project2, f.project
|
# assert_equal @project2, f.project
|
||||||
end
|
# end
|
||||||
@folder1.dmsf_links.each do |l|
|
# @folder1.dmsf_links.each do |l|
|
||||||
assert_equal @project2, l.project
|
# assert_equal @project2, l.project
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_non_existent_file
|
# def test_move_non_existent_file
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/not_a_file.txt",
|
# "/dmsf/webdav/#{@project1.identifier}/not_a_file.txt",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/moved_file.txt" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/moved_file.txt" }
|
||||||
)
|
# )
|
||||||
assert_response :not_found # NotFound
|
# assert_response :not_found # NotFound
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_to_new_filename
|
# def test_move_to_new_filename
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
f = DmsfFile.find_file_by_name @project1, nil, new_name
|
# f = DmsfFile.find_file_by_name @project1, nil, new_name
|
||||||
assert f, "Moved file '#{new_name}' not found in project."
|
# assert f, "Moved file '#{new_name}' not found in project."
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_to_new_filename_with_project_names
|
# def test_move_to_new_filename_with_project_names
|
||||||
with_settings plugin_redmine_dmsf: { 'dmsf_webdav_use_project_names' => '1',
|
# with_settings plugin_redmine_dmsf: { 'dmsf_webdav_use_project_names' => '1',
|
||||||
'dmsf_webdav' => '1',
|
# 'dmsf_webdav' => '1',
|
||||||
'dmsf_webdav_authentication' => 'Basic',
|
# 'dmsf_webdav_authentication' => 'Basic',
|
||||||
'dmsf_webdav_strategy' => 'WEBDAV_READ_WRITE' } do
|
# 'dmsf_webdav_strategy' => 'WEBDAV_READ_WRITE' } do
|
||||||
project1_uri = ERB::Util.url_encode(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
|
# project1_uri = ERB::Util.url_encode(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move, "/dmsf/webdav/#{project1_uri}/#{@file1.name}",
|
# process :move, "/dmsf/webdav/#{project1_uri}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{project1_uri}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{project1_uri}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
f = DmsfFile.find_file_by_name @project1, nil, new_name
|
# f = DmsfFile.find_file_by_name @project1, nil, new_name
|
||||||
assert f, "Moved file '#{new_name}' not found in project."
|
# assert f, "Moved file '#{new_name}' not found in project."
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_zero_sized_to_new_filename
|
# def test_move_zero_sized_to_new_filename
|
||||||
new_name = "#{@file10.name}.moved"
|
# new_name = "#{@file10.name}.moved"
|
||||||
assert_no_difference '@file10.dmsf_file_revisions.count' do
|
# assert_no_difference '@file10.dmsf_file_revisions.count' do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file10.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file10.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
f = DmsfFile.find_file_by_name @project1, nil, new_name
|
# f = DmsfFile.find_file_by_name @project1, nil, new_name
|
||||||
assert f, "Moved file '#{new_name}' not found in project."
|
# assert f, "Moved file '#{new_name}' not found in project."
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_to_new_folder
|
# def test_move_to_new_folder
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process(
|
# process(
|
||||||
:move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/#{@file1.name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/#{@file1.name}" }
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
@file1.reload
|
# @file1.reload
|
||||||
assert_equal @folder1.id, @file1.dmsf_folder_id
|
# assert_equal @folder1.id, @file1.dmsf_folder_id
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_to_new_folder_with_project_names
|
# def test_move_to_new_folder_with_project_names
|
||||||
with_settings plugin_redmine_dmsf: { 'dmsf_webdav_use_project_names' => '1',
|
# with_settings plugin_redmine_dmsf: { 'dmsf_webdav_use_project_names' => '1',
|
||||||
'dmsf_webdav' => '1',
|
# 'dmsf_webdav' => '1',
|
||||||
'dmsf_webdav_authentication' => 'Basic',
|
# 'dmsf_webdav_authentication' => 'Basic',
|
||||||
'dmsf_webdav_strategy' => 'WEBDAV_READ_WRITE' } do
|
# 'dmsf_webdav_strategy' => 'WEBDAV_READ_WRITE' } do
|
||||||
project1_uri = ERB::Util.url_encode(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
|
# project1_uri = ERB::Util.url_encode(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{project1_uri}/#{@file1.name}",
|
# "/dmsf/webdav/#{project1_uri}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{project1_uri}/#{@folder1.title}/#{@file1.name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{project1_uri}/#{@folder1.title}/#{@file1.name}" }
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
@file1.reload
|
# @file1.reload
|
||||||
assert_equal @folder1.id, @file1.dmsf_folder_id
|
# assert_equal @folder1.id, @file1.dmsf_folder_id
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_zero_sized_to_new_folder
|
# def test_move_zero_sized_to_new_folder
|
||||||
assert_no_difference '@file10.dmsf_file_revisions.count' do
|
# assert_no_difference '@file10.dmsf_file_revisions.count' do
|
||||||
process(
|
# process(
|
||||||
:move, "/dmsf/webdav/#{@project1.identifier}/#{@file10.name}",
|
# :move, "/dmsf/webdav/#{@project1.identifier}/#{@file10.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/#{@file10.name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/#{@file10.name}" }
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
@file10.reload
|
# @file10.reload
|
||||||
assert_equal @folder1.id, @file10.dmsf_folder_id
|
# assert_equal @folder1.id, @file10.dmsf_folder_id
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
def test_move_to_existing_filename
|
def test_move_to_existing_filename
|
||||||
assert_no_difference '@file9.dmsf_file_revisions.count' do
|
assert_no_difference '@file9.dmsf_file_revisions.count' do
|
||||||
@ -228,189 +228,189 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_when_file_is_locked_by_other
|
# def test_move_when_file_is_locked_by_other
|
||||||
log_user 'admin', 'admin' # login as admin
|
# log_user 'admin', 'admin' # login as admin
|
||||||
User.current = @admin_user
|
# User.current = @admin_user
|
||||||
assert @file1.lock!, "File failed to be locked by #{User.current}"
|
# assert @file1.lock!, "File failed to be locked by #{User.current}"
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :locked
|
# assert_response :locked
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_when_file_is_locked_by_other_and_user_is_admin
|
# def test_move_when_file_is_locked_by_other_and_user_is_admin
|
||||||
log_user 'jsmith', 'jsmith' # login as jsmith
|
# log_user 'jsmith', 'jsmith' # login as jsmith
|
||||||
User.current = @jsmith_user
|
# User.current = @jsmith_user
|
||||||
assert @file1.lock!, "File failed to be locked by #{User.current}"
|
# assert @file1.lock!, "File failed to be locked by #{User.current}"
|
||||||
|
#
|
||||||
new_name = "#{@file1.name}.moved"
|
# new_name = "#{@file1.name}.moved"
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!(
|
# headers: @admin.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :locked
|
# assert_response :locked
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_when_file_is_locked_by_user
|
# def test_move_when_file_is_locked_by_user
|
||||||
log_user 'jsmith', 'jsmith' # login as jsmith
|
# log_user 'jsmith', 'jsmith' # login as jsmith
|
||||||
User.current = @jsmith_user
|
# User.current = @jsmith_user
|
||||||
assert @file1.lock!, "File failed to be locked by #{User.current}"
|
# assert @file1.lock!, "File failed to be locked by #{User.current}"
|
||||||
|
#
|
||||||
# Move once
|
# # Move once
|
||||||
new_name = "#{@file1.name}.m1"
|
# new_name = "#{@file1.name}.m1"
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# process :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :success # Created
|
# assert_response :success # Created
|
||||||
end
|
# end
|
||||||
# Move twice, make sure that the MsOffice store sequence is not disrupting normal move
|
# # Move twice, make sure that the MsOffice store sequence is not disrupting normal move
|
||||||
new_name2 = "#{new_name}.m2"
|
# new_name2 = "#{new_name}.m2"
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{new_name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{new_name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name2}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name2}" }
|
||||||
)
|
# )
|
||||||
assert_response :success # Created
|
# assert_response :success # Created
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_msoffice_save_locked_file
|
# def test_move_msoffice_save_locked_file
|
||||||
# When some versions of MsOffice save a file they use the following sequence:
|
# # When some versions of MsOffice save a file they use the following sequence:
|
||||||
# 1. Save changes to a new temporary document, XXX.tmp
|
# # 1. Save changes to a new temporary document, XXX.tmp
|
||||||
# 2. Rename (MOVE) document to YYY.tmp. History is lost here if the original document is moved.
|
# # 2. Rename (MOVE) document to YYY.tmp. History is lost here if the original document is moved.
|
||||||
# 3. Rename (MOVE) XXX.tmp to document's name. XXX.tmp must be merged to the original document otherwise the
|
# # 3. Rename (MOVE) XXX.tmp to document's name. XXX.tmp must be merged to the original document otherwise the
|
||||||
# history is lost.
|
# # history is lost.
|
||||||
# 4. Delete YYY.tmp.
|
# # 4. Delete YYY.tmp.
|
||||||
# Verify that steps 2 and 3 work.
|
# # Verify that steps 2 and 3 work.
|
||||||
log_user 'jsmith', 'jsmith' # login as jsmith
|
# log_user 'jsmith', 'jsmith' # login as jsmith
|
||||||
User.current = @jsmith_user
|
# User.current = @jsmith_user
|
||||||
assert @file1.lock!, "File failed to be locked by #{User.current}"
|
# assert @file1.lock!, "File failed to be locked by #{User.current}"
|
||||||
|
#
|
||||||
# First save while the file is locked, should create new revision
|
# # First save while the file is locked, should create new revision
|
||||||
temp_file_name = 'AAAAAAAA.tmp'
|
# temp_file_name = 'AAAAAAAA.tmp'
|
||||||
|
#
|
||||||
# Make sure that the temp-file does not exist.
|
# # Make sure that the temp-file does not exist.
|
||||||
temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
# temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
||||||
assert_not temp_file, "File '#{temp_file_name}' should not exist yet."
|
# assert_not temp_file, "File '#{temp_file_name}' should not exist yet."
|
||||||
|
#
|
||||||
# Move the original file to AAAAAAAA.tmp. The original file should not changed but a new file should be created.
|
# # Move the original file to AAAAAAAA.tmp. The original file should not changed but a new file should be created.
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :success # Created
|
# assert_response :success # Created
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# Verify that a new file has been created
|
# # Verify that a new file has been created
|
||||||
temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
# temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
||||||
assert temp_file, "File '#{temp_file_name}' not found, move failed."
|
# assert temp_file, "File '#{temp_file_name}' not found, move failed."
|
||||||
assert_equal temp_file.dmsf_file_revisions.count, 1
|
# assert_equal temp_file.dmsf_file_revisions.count, 1
|
||||||
assert_not_equal temp_file.id, @file1.id
|
# assert_not_equal temp_file.id, @file1.id
|
||||||
|
#
|
||||||
# Move a temporary file (use AAAAAAAA.tmp) to the original file.
|
# # Move a temporary file (use AAAAAAAA.tmp) to the original file.
|
||||||
assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file1.dmsf_file_revisions.count', +1 do
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{
|
# {
|
||||||
destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
'HTTP_OVERWRITE' => 'T'
|
# 'HTTP_OVERWRITE' => 'T'
|
||||||
}
|
# }
|
||||||
)
|
# )
|
||||||
assert_response :success # Created
|
# assert_response :success # Created
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# Second save while file is locked, should NOT create new revision
|
# # Second save while file is locked, should NOT create new revision
|
||||||
temp_file_name = 'BBBBBBBB.tmp'
|
# temp_file_name = 'BBBBBBBB.tmp'
|
||||||
|
#
|
||||||
# Make sure that the temp-file does not exist.
|
# # Make sure that the temp-file does not exist.
|
||||||
temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
# temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
||||||
assert_not temp_file, "File '#{temp_file_name}' should not exist yet."
|
# assert_not temp_file, "File '#{temp_file_name}' should not exist yet."
|
||||||
|
#
|
||||||
# Move the original file to BBBBBBBB.tmp. The original file should not change but a new file should be created.
|
# # Move the original file to BBBBBBBB.tmp. The original file should not change but a new file should be created.
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
# process :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}" }
|
||||||
)
|
# )
|
||||||
assert_response :success # Created
|
# assert_response :success # Created
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# Verify that a new file has been created
|
# # Verify that a new file has been created
|
||||||
temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
# temp_file = DmsfFile.find_file_by_name @project1, nil, temp_file_name
|
||||||
assert temp_file, "File '#{temp_file_name}' not found, move failed."
|
# assert temp_file, "File '#{temp_file_name}' not found, move failed."
|
||||||
assert_equal temp_file.dmsf_file_revisions.count, 1
|
# assert_equal temp_file.dmsf_file_revisions.count, 1
|
||||||
assert_not_equal temp_file.id, @file1.id
|
# assert_not_equal temp_file.id, @file1.id
|
||||||
|
#
|
||||||
# Move a temporary file (use BBBBBBBB.tmp) to the original file.
|
# # Move a temporary file (use BBBBBBBB.tmp) to the original file.
|
||||||
assert_no_difference '@file1.dmsf_file_revisions.count' do
|
# assert_no_difference '@file1.dmsf_file_revisions.count' do
|
||||||
process :move, "/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}",
|
# process :move, "/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @jsmith.merge!(
|
# headers: @jsmith.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@file1.name}" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@file1.name}" }
|
||||||
)
|
# )
|
||||||
assert_response :success # Created
|
# assert_response :success # Created
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_file_in_subproject
|
# def test_move_file_in_subproject
|
||||||
dest = "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/new_file_name"
|
# dest = "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/new_file_name"
|
||||||
assert_difference '@file12.dmsf_file_revisions.count', +1 do
|
# assert_difference '@file12.dmsf_file_revisions.count', +1 do
|
||||||
process :move, "/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@file12.name}",
|
# process :move, "/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@file12.name}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!({ destination: dest })
|
# headers: @admin.merge!({ destination: dest })
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_folder_in_subproject
|
# def test_move_folder_in_subproject
|
||||||
dest = "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/new_folder_name"
|
# dest = "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/new_folder_name"
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@folder10.title}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@folder10.title}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!({ destination: dest })
|
# headers: @admin.merge!({ destination: dest })
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
@folder10.reload
|
# @folder10.reload
|
||||||
assert_equal 'new_folder_name', @folder10.title
|
# assert_equal 'new_folder_name', @folder10.title
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_folder_in_subproject_to_the_same_name_as_subproject
|
# def test_move_folder_in_subproject_to_the_same_name_as_subproject
|
||||||
dest = "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@project5.identifier}"
|
# dest = "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@project5.identifier}"
|
||||||
process :move,
|
# process :move,
|
||||||
"/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@folder10.title}",
|
# "/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}/#{@folder10.title}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!({ destination: dest })
|
# headers: @admin.merge!({ destination: dest })
|
||||||
assert_response :created
|
# assert_response :created
|
||||||
@folder10.reload
|
# @folder10.reload
|
||||||
assert_equal @project5.identifier, @folder10.title
|
# assert_equal @project5.identifier, @folder10.title
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def test_move_subproject
|
# def test_move_subproject
|
||||||
process :move, "/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}",
|
# process :move, "/dmsf/webdav/#{@project1.identifier}/#{@project5.identifier}",
|
||||||
params: nil,
|
# params: nil,
|
||||||
headers: @admin.merge!(
|
# headers: @admin.merge!(
|
||||||
{ destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/new_project_name" }
|
# { destination: "http://www.example.com/dmsf/webdav/#{@project1.identifier}/new_project_name" }
|
||||||
)
|
# )
|
||||||
assert_response :method_not_allowed
|
# assert_response :method_not_allowed
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,8 +28,8 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
@revision1 = DmsfFileRevision.find 1
|
@revision1 = DmsfFileRevision.find 1
|
||||||
@revision2 = DmsfFileRevision.find 2
|
@revision2 = DmsfFileRevision.find 2
|
||||||
@revision3 = DmsfFileRevision.find 3
|
@revision3 = DmsfFileRevision.find 3
|
||||||
@revision5 = DmsfFileRevision.find 5
|
|
||||||
@revision8 = DmsfFileRevision.find 8
|
@revision8 = DmsfFileRevision.find 8
|
||||||
|
@revision13 = DmsfFileRevision.find 13
|
||||||
@wf1 = DmsfWorkflow.find 1
|
@wf1 = DmsfWorkflow.find 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -59,15 +59,15 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_restore
|
def test_delete_restore
|
||||||
@revision5.delete commit: false
|
@revision13.delete commit: false
|
||||||
assert @revision5.deleted?, "File revision #{@revision5.name} hasn't been deleted"
|
assert @revision13.deleted?, "File revision #{@revision13.name} hasn't been deleted"
|
||||||
@revision5.restore
|
@revision13.restore
|
||||||
assert_not @revision5.deleted?, "File revision #{@revision5.name} hasn't been restored"
|
assert_not @revision13.deleted?, "File revision #{@revision13.name} hasn't been restored"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
@revision5.delete commit: true
|
@revision13.delete commit: true
|
||||||
assert_nil DmsfFileRevision.find_by(id: @revision5.id)
|
assert_nil DmsfFileRevision.find_by(id: @revision13.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_digest_type
|
def test_digest_type
|
||||||
|
|||||||
@ -268,7 +268,7 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest
|
|||||||
def test_involved
|
def test_involved
|
||||||
assert @file1.involved?(@file1.last_revision.user)
|
assert @file1.involved?(@file1.last_revision.user)
|
||||||
assert_not @file1.involved?(@jsmith)
|
assert_not @file1.involved?(@jsmith)
|
||||||
@file1.dmsf_file_revisions[1].user = @jsmith
|
@file1.dmsf_file_revisions[0].user = @jsmith
|
||||||
assert @file1.involved?(@jsmith)
|
assert @file1.involved?(@jsmith)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -182,9 +182,9 @@ class DmsfMacrosTest < RedmineDmsf::Test::HelperTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_dmsfdversion_revision
|
def test_macro_dmsfdversion_revision
|
||||||
revision5 = DmsfFileRevision.find_by(id: 5)
|
revision1 = DmsfFileRevision.find_by(id: 1)
|
||||||
text = textilizable("{{dmsfversion(#{@file1.id}, #{revision5.id})}}")
|
text = textilizable("{{dmsfversion(#{@file1.id}, #{revision1.id})}}")
|
||||||
assert text.include?(revision5.version), text
|
assert text.include?(revision1.version), text
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_dmsfdversion_no_permissions
|
def test_macro_dmsfdversion_no_permissions
|
||||||
|
|||||||
@ -42,10 +42,4 @@ class DmsfPluginTest < RedmineDmsf::Test::HelperTest
|
|||||||
assert RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
assert RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
||||||
FileUtils.rm_rf path
|
FileUtils.rm_rf path
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: move it elswhere
|
|
||||||
def test_lib_available?
|
|
||||||
assert RedmineDmsf.lib_available?('zip')
|
|
||||||
assert_not RedmineDmsf.lib_available?('not_existing_gem')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,23 +23,14 @@ require File.expand_path('../../../../../lib/redmine_dmsf/dmsf_zip', __FILE__)
|
|||||||
# Plugin tests
|
# Plugin tests
|
||||||
class DmsfZipTest < RedmineDmsf::Test::HelperTest
|
class DmsfZipTest < RedmineDmsf::Test::HelperTest
|
||||||
def setup
|
def setup
|
||||||
|
super
|
||||||
@zip = RedmineDmsf::DmsfZip::Zip.new
|
@zip = RedmineDmsf::DmsfZip::Zip.new
|
||||||
|
|
||||||
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.join('files', 'dmsf')
|
|
||||||
FileUtils.cp_r File.join(File.expand_path('../../../../fixtures/files', __FILE__), '.'), DmsfFile.storage_path
|
|
||||||
@dmsf_file1 = DmsfFile.find(1)
|
@dmsf_file1 = DmsfFile.find(1)
|
||||||
@dmsf_folder2 = DmsfFolder.find(2)
|
@dmsf_folder2 = DmsfFolder.find(2)
|
||||||
set_fixtures_attachments_directory
|
set_fixtures_attachments_directory
|
||||||
@attachment6 = Attachment.find(6)
|
@attachment6 = Attachment.find(6)
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
|
||||||
# Delete our tmp folder
|
|
||||||
FileUtils.rm_rf DmsfFile.storage_path
|
|
||||||
rescue StandardError => e
|
|
||||||
Rails.logger.error e.message
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_add_dmsf_file
|
def test_add_dmsf_file
|
||||||
@zip.add_dmsf_file @dmsf_file1
|
@zip.add_dmsf_file @dmsf_file1
|
||||||
assert_equal 1, @zip.dmsf_files.size
|
assert_equal 1, @zip.dmsf_files.size
|
||||||
|
|||||||
29
test/unit/lib/redmine_dmsf_test.rb
Normal file
29
test/unit/lib/redmine_dmsf_test.rb
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This file is part of Redmine DMSF plugin.
|
||||||
|
#
|
||||||
|
# Redmine DMSF plugin 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 3 of the License, or (at your option) any
|
||||||
|
# later version.
|
||||||
|
#
|
||||||
|
# Redmine DMSF plugin 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 Redmine DMSF plugin. If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require File.expand_path('../../../test_helper', __FILE__)
|
||||||
|
require File.expand_path('../../../../lib/redmine_dmsf/plugin', __FILE__)
|
||||||
|
|
||||||
|
# Plugin tests
|
||||||
|
class RedmineDmsfTest < RedmineDmsf::Test::HelperTest
|
||||||
|
def test_lib_available?
|
||||||
|
assert RedmineDmsf.lib_available?('zip')
|
||||||
|
assert_not RedmineDmsf.lib_available?('not_existing_gem')
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user