From 306ad159a760dc014d342cc9de7881531e51f994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 27 Mar 2019 14:19:54 +0100 Subject: [PATCH] Name convention of foreign keys columns --- app/controllers/dmsf_workflows_controller.rb | 4 +- app/models/dmsf_file.rb | 4 +- app/models/dmsf_file_revision.rb | 14 +- app/models/dmsf_mailer.rb | 2 +- app/views/dmsf_files/show.api.rsb | 4 +- .../_approval_workflow_button.html.erb | 2 +- app/views/dmsf_workflows/_log.html.erb | 6 +- .../20192703123101_workflow_started_by.rb | 30 ++ lib/redmine_dmsf/patches/user_patch.rb | 31 +- test/fixtures/dmsf_file_revisions.yml | 346 +++++++++--------- .../rest_api/dmsf_file_api_test.rb | 8 +- test/unit/dmsf_file_test.rb | 16 +- test/unit/user_patch_test.rb | 2 + 13 files changed, 253 insertions(+), 216 deletions(-) create mode 100644 db/migrate/20192703123101_workflow_started_by.rb diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index 505d1bf8..7bb78cab 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -90,7 +90,7 @@ class DmsfWorkflowsController < ApplicationController else # Just rejected recipients = @dmsf_workflow.participiants - recipients.push User.find_by(id: revision.dmsf_workflow_assigned_by) + recipients.push revision.dmsf_workflow_assigned_by_user recipients.uniq! recipients = recipients & DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true) DmsfMailer.deliver_workflow_notification( @@ -143,7 +143,7 @@ class DmsfWorkflowsController < ApplicationController :text_email_to_proceed) end end - to = User.find_by(id: revision.dmsf_workflow_assigned_by) + to = revision.dmsf_workflow_assigned_by_user if to && DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true).include?(to) DmsfMailer.deliver_workflow_notification( [to], diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index bbb6deb2..29a3f2a5 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -265,9 +265,9 @@ class DmsfFile < ActiveRecord::Base # Assign the same workflow if it's a global one or we are in the same project new_revision.workflow = nil new_revision.dmsf_workflow_id = nil - new_revision.dmsf_workflow_assigned_by = nil + new_revision.dmsf_workflow_assigned_by_user_id = nil new_revision.dmsf_workflow_assigned_at = nil - new_revision.dmsf_workflow_started_by = nil + new_revision.dmsf_workflow_started_by_user_id = nil new_revision.dmsf_workflow_started_at = nil wf = last_revision.dmsf_workflow if wf && (wf.project.nil? || (wf.project.id == project.id)) diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index e1a2f007..2ceb9718 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -24,12 +24,14 @@ require 'digest' class DmsfFileRevision < ActiveRecord::Base belongs_to :dmsf_file - belongs_to :source_revision, :class_name => 'DmsfFileRevision', :foreign_key => 'source_dmsf_file_revision_id' + belongs_to :source_revision, class_name: 'DmsfFileRevision', foreign_key: 'source_dmsf_file_revision_id' belongs_to :user - belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id' + belongs_to :deleted_by_user, class_name: 'User', foreign_key: 'deleted_by_user_id' + belongs_to :dmsf_workflow_started_by_user, class_name: 'User', foreign_key: 'dmsf_workflow_started_by_user_id' + belongs_to :dmsf_workflow_assigned_by_user, class_name: 'User', foreign_key: 'dmsf_workflow_assigned_by_user_id' belongs_to :dmsf_workflow - has_many :dmsf_file_revision_access, :dependent => :destroy - has_many :dmsf_workflow_step_assignment, :dependent => :destroy + has_many :dmsf_file_revision_access, dependent: :destroy + has_many :dmsf_workflow_step_assignment, dependent: :destroy STATUS_DELETED = 1 STATUS_ACTIVE = 0 @@ -248,11 +250,11 @@ class DmsfFileRevision < ActiveRecord::Base self.dmsf_workflow_id = dmsf_workflow_id if commit == 'start' self.workflow = DmsfWorkflow::STATE_WAITING_FOR_APPROVAL - self.dmsf_workflow_started_by = User.current.id if User.current + self.dmsf_workflow_started_by_user = User.current self.dmsf_workflow_started_at = DateTime.current else self.workflow = DmsfWorkflow::STATE_ASSIGNED - self.dmsf_workflow_assigned_by = User.current.id if User.current + self.dmsf_workflow_assigned_by_user = User.current self.dmsf_workflow_assigned_at = DateTime.current end end diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 7a2b0639..85fa720b 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -110,7 +110,7 @@ class DmsfMailer < Mailer @text1 = l(text1_id, :name => workflow.name, :filename => revision.dmsf_file.name, :notice => notice) @text2 = l(text2_id) @notice = notice - @author = User.find_by(id: revision.dmsf_workflow_assigned_by) + @author = revision.dmsf_workflow_assigned_by_user @author = User.anonymous unless @author mail :to => user.mail, :subject => "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)}" diff --git a/app/views/dmsf_files/show.api.rsb b/app/views/dmsf_files/show.api.rsb index 86e77053..04e57478 100644 --- a/app/views/dmsf_files/show.api.rsb +++ b/app/views/dmsf_files/show.api.rsb @@ -24,9 +24,9 @@ api.dmsf_file do api.created_at r.created_at api.updated_at r.updated_at api.dmsf_workflow_id r.dmsf_workflow_id - api.dmsf_workflow_assigned_by r.dmsf_workflow_assigned_by + api.dmsf_workflow_assigned_by_user_id r.dmsf_workflow_assigned_by_user_id api.dmsf_workflow_assigned_at r.dmsf_workflow_assigned_at - api.dmsf_workflow_started_by r.dmsf_workflow_started_by + api.dmsf_workflow_started_by_user_id r.dmsf_workflow_started_by_user_id api.dmsf_workflow_started_at r.dmsf_workflow_started_at api.digest r.digest end diff --git a/app/views/dmsf_workflows/_approval_workflow_button.html.erb b/app/views/dmsf_workflows/_approval_workflow_button.html.erb index b8a05756..7c514e9f 100644 --- a/app/views/dmsf_workflows/_approval_workflow_button.html.erb +++ b/app/views/dmsf_workflows/_approval_workflow_button.html.erb @@ -43,7 +43,7 @@ <% end %> <% when DmsfWorkflow::STATE_ASSIGNED %> - <% if User.current && (file.last_revision.dmsf_workflow_assigned_by == User.current.id) && wf %> + <% if User.current && (file.last_revision.dmsf_workflow_assigned_by_user == User.current) && wf %> <%= link_to('', start_dmsf_workflow_path( :id => file.last_revision.dmsf_workflow_id, diff --git a/app/views/dmsf_workflows/_log.html.erb b/app/views/dmsf_workflows/_log.html.erb index 096cefbb..aa7b3e09 100644 --- a/app/views/dmsf_workflows/_log.html.erb +++ b/app/views/dmsf_workflows/_log.html.erb @@ -63,7 +63,7 @@ - <%= link_to_user User.find_by(id: revision.dmsf_workflow_assigned_by) if revision.dmsf_workflow_assigned_by %> + <%= link_to_user revision.dmsf_workflow_assigned_by_user if revision.dmsf_workflow_assigned_by_user %> <%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %> <%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %> @@ -72,9 +72,9 @@ - <%= link_to_user User.find_by(id: revision.dmsf_workflow_started_by) if revision.dmsf_workflow_started_by %> + <%= link_to_user revision.dmsf_workflow_started_by_user if revision.dmsf_workflow_started_by_user %> <%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_START) %> - <%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_START) if revision.dmsf_workflow_started_by %> + <%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_START) if revision.dmsf_workflow_started_by_user %> <%= format_time(revision.dmsf_workflow_started_at) if revision.dmsf_workflow_started_at %> diff --git a/db/migrate/20192703123101_workflow_started_by.rb b/db/migrate/20192703123101_workflow_started_by.rb new file mode 100644 index 00000000..f2a901e0 --- /dev/null +++ b/db/migrate/20192703123101_workflow_started_by.rb @@ -0,0 +1,30 @@ +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-19 Karel Pičman +# +# 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 WorkflowStartedBy < ActiveRecord::Migration[5.2] + + def change + rename_column :dmsf_file_revisions, :dmsf_workflow_assigned_by, + :dmsf_workflow_assigned_by_user_id + rename_column :dmsf_file_revisions, :dmsf_workflow_started_by, + :dmsf_workflow_started_by_user_id + end + +end \ No newline at end of file diff --git a/lib/redmine_dmsf/patches/user_patch.rb b/lib/redmine_dmsf/patches/user_patch.rb index 46b8cb23..b1f4e5c4 100644 --- a/lib/redmine_dmsf/patches/user_patch.rb +++ b/lib/redmine_dmsf/patches/user_patch.rb @@ -34,19 +34,24 @@ module RedmineDmsf def remove_dmsf_references return if self.id.nil? substitute = User.anonymous - DmsfFileRevisionAccess.where(:user_id => id).update_all(:user_id => substitute.id) - DmsfFileRevision.where(:user_id => id).update_all(:user_id => substitute.id) - DmsfFile.where(:deleted_by_user_id => id).update_all(:deleted_by_user_id => substitute.id) - DmsfFolder.where(:user_id => id).update_all(:user_id => substitute.id) - DmsfFolder.where(:deleted_by_user_id => id).update_all(:deleted_by_user_id => substitute.id) - DmsfLink.where(:user_id => id).update_all(:user_id => substitute.id) - DmsfLink.where(:deleted_by_user_id => id).update_all(:deleted_by_user_id => substitute.id) - DmsfLock.where(:user_id => id).delete_all - DmsfWorkflowStepAction.where(:author_id => id).update_all(:author_id => substitute.id) - DmsfWorkflowStepAssignment.where(:user_id => id).update_all(:user_id => substitute.id) - DmsfWorkflowStep.where(:user_id => id).update_all(:user_id => substitute.id) - DmsfWorkflow.where(:author_id => id).update_all(:author_id => substitute.id) - DmsfFolderPermission.where(:object_id => id, :object_type => 'User').update_all(:object_id => substitute.id) + DmsfFileRevisionAccess.where(user_id: id).update_all(user_id: substitute.id) + DmsfFileRevision.where(user_id: id).update_all(user_id: substitute.id) + DmsfFileRevision.where(dmsf_workflow_assigned_by_user_id: id).update_all( + dmsf_workflow_assigned_by_user_id: substitute.id) + DmsfFileRevision.where(dmsf_workflow_started_by_user_id: id).update_all( + dmsf_workflow_started_by_user_id: substitute.id) + DmsfFileRevision.where(user_id: id).update_all(user_id: substitute.id) + DmsfFile.where(deleted_by_user_id: id).update_all(deleted_by_user_id: substitute.id) + DmsfFolder.where(user_id: id).update_all(user_id: substitute.id) + DmsfFolder.where(deleted_by_user_id: id).update_all(deleted_by_user_id: substitute.id) + DmsfLink.where(user_id: id).update_all(user_id: substitute.id) + DmsfLink.where(deleted_by_user_id: id).update_all(deleted_by_user_id: substitute.id) + DmsfLock.where(user_id: id).delete_all + DmsfWorkflowStepAction.where(author_id: id).update_all(author_id: substitute.id) + DmsfWorkflowStepAssignment.where(user_id: id).update_all(user_id: substitute.id) + DmsfWorkflowStep.where(user_id: id).update_all(user_id: substitute.id) + DmsfWorkflow.where(author_id: id).update_all(author_id: substitute.id) + DmsfFolderPermission.where(object_id: id, object_type: 'User').update_all(object_id: substitute.id) end end diff --git a/test/fixtures/dmsf_file_revisions.yml b/test/fixtures/dmsf_file_revisions.yml index c5702320..7b0c218c 100644 --- a/test/fixtures/dmsf_file_revisions.yml +++ b/test/fixtures/dmsf_file_revisions.yml @@ -1,194 +1,192 @@ --- dmsf_file_revisions_001: - id: 1 - dmsf_file_id: 1 - source_dmsf_file_revision_id: NULL - name: "test.txt" - disk_filename: "test.txt" - size: 4 - mime_type: text/plain - title: "Test File" - description: 'Some file :-)' - workflow: 1 # DmsfWorkflow::STATE_WAITING_FOR_APPROVAL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: 1 - dmsf_workflow_started_by: 1 - digest: '81dc9bdb52d04dc20036dbd8313ed055' - created_at: 2017-04-18 14:52:27 +02:00 + id: 1 + dmsf_file_id: 1 + source_dmsf_file_revision_id: NULL + name: "test.txt" + disk_filename: "test.txt" + size: 4 + mime_type: text/plain + title: "Test File" + description: 'Some file :-)' + workflow: 1 # DmsfWorkflow::STATE_WAITING_FOR_APPROVAL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: 1 + dmsf_workflow_started_by_user_id: 1 + digest: '81dc9bdb52d04dc20036dbd8313ed055' + created_at: 2017-04-18 14:52:27 +02:00 #revision for file on non-enabled project dmsf_file_revisions_002: - id: 2 - dmsf_file_id: 2 - source_dmsf_file_revision_id: NULL - name: "test2.txt" - disk_filename: "test2.txt" - size: 4 - mime_type: text/plain - title: "Test File" - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 + id: 2 + dmsf_file_id: 2 + source_dmsf_file_revision_id: NULL + name: "test2.txt" + disk_filename: "test2.txt" + size: 4 + mime_type: text/plain + title: "Test File" + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 #revision for deleted file on dmsf-enabled project dmsf_file_revisions_003: - id: 3 - dmsf_file_id: 3 - source_dmsf_file_revision_id: NULL - name: "deleted.txt" - disk_filename: "deleted.txt" - size: 4 - mime_type: text/plain - title: "Test File" - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 1 - deleted_by_user_id: 1 - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 + id: 3 + dmsf_file_id: 3 + source_dmsf_file_revision_id: NULL + name: "deleted.txt" + disk_filename: "deleted.txt" + size: 4 + mime_type: text/plain + title: "Test File" + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 1 + deleted_by_user_id: 1 + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 dmsf_file_revisions_004: - id: 4 - dmsf_file_id: 4 - source_dmsf_file_revision_id: NULL - name: 'test4.txt' - disk_filename: 'test4.txt' - size: 4 - mime_type: text/plain - title: 'Test File' - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 + id: 4 + dmsf_file_id: 4 + source_dmsf_file_revision_id: NULL + name: 'test4.txt' + disk_filename: 'test4.txt' + size: 4 + mime_type: text/plain + title: 'Test File' + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 dmsf_file_revisions_005: - id: 5 - dmsf_file_id: 1 - source_dmsf_file_revision_id: NULL - name: "test5.txt" - disk_filename: "test5.txt" - size: 4 - mime_type: text/plain - title: "Test File" - description: NULL - workflow: 1 # DmsfWorkflow::STATE_WAITING_FOR_APPROVAL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:28 +02:00 + id: 5 + dmsf_file_id: 1 + source_dmsf_file_revision_id: NULL + name: "test5.txt" + disk_filename: "test5.txt" + size: 4 + mime_type: text/plain + title: "Test File" + description: NULL + workflow: 1 # DmsfWorkflow::STATE_WAITING_FOR_APPROVAL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:28 +02:00 dmsf_file_revisions_006: - id: 6 - dmsf_file_id: 7 - source_dmsf_file_revision_id: NULL - name: "test.gif" - disk_filename: "test.gif" - size: 4 - mime_type: image/gif - title: "Image" - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 + id: 6 + dmsf_file_id: 7 + source_dmsf_file_revision_id: NULL + name: "test.gif" + disk_filename: "test.gif" + size: 4 + mime_type: image/gif + title: "Image" + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 dmsf_file_revisions_007: - id: 7 - dmsf_file_id: 8 - source_dmsf_file_revision_id: NULL - name: "test.pdf" - disk_filename: "test.pdf" - size: 4 - mime_type: application/pdf - title: "PDF" - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 + id: 7 + dmsf_file_id: 8 + source_dmsf_file_revision_id: NULL + name: "test.pdf" + disk_filename: "test.pdf" + size: 4 + mime_type: application/pdf + title: "PDF" + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 dmsf_file_revisions_008: - id: 8 - dmsf_file_id: 9 - source_dmsf_file_revision_id: NULL - name: "myfile.txt" - disk_filename: "myfile.txt" # The file is not physicaly present - size: 0 - mime_type: text/plain - title: "My File" - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 + id: 8 + dmsf_file_id: 9 + source_dmsf_file_revision_id: NULL + name: "myfile.txt" + disk_filename: "myfile.txt" # The file is not physicaly present + size: 0 + mime_type: text/plain + title: "My File" + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 dmsf_file_revisions_009: - id: 9 - dmsf_file_id: 10 - source_dmsf_file_revision_id: NULL - name: "zero.txt" - disk_filename: "zero.txt" - size: 0 - mime_type: text/plain - title: "Zero Size File" - description: NULL - workflow: NULL - minor_version: 0 - major_version: 1 - comment: NULL - deleted: 0 - deleted_by_user_id: NULL - user_id: 1 - dmsf_workflow_assigned_by: NULL - dmsf_workflow_started_by: NULL - created_at: 2017-04-18 14:52:27 +02:00 - - + id: 9 + dmsf_file_id: 10 + source_dmsf_file_revision_id: NULL + name: "zero.txt" + disk_filename: "zero.txt" + size: 0 + mime_type: text/plain + title: "Zero Size File" + description: NULL + workflow: NULL + minor_version: 0 + major_version: 1 + comment: NULL + deleted: 0 + deleted_by_user_id: NULL + user_id: 1 + dmsf_workflow_assigned_by_user_id: NULL + dmsf_workflow_started_by_user_id: NULL + created_at: 2017-04-18 14:52:27 +02:00 diff --git a/test/integration/rest_api/dmsf_file_api_test.rb b/test/integration/rest_api/dmsf_file_api_test.rb index 282f7aa1..f6f00177 100644 --- a/test/integration/rest_api/dmsf_file_api_test.rb +++ b/test/integration/rest_api/dmsf_file_api_test.rb @@ -87,9 +87,9 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest # 2017-04-18T12:52:28Z # 2019-01-15T15:56:15Z # - # + # # - # + # # # # @@ -109,9 +109,9 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest # 2017-04-18T12:52:27Z # 2019-01-15T15:56:15Z # - # 1 + # 1 # - # 1 + # 1 # # 81dc9bdb52d04dc20036dbd8313ed055 # diff --git a/test/unit/dmsf_file_test.rb b/test/unit/dmsf_file_test.rb index 84abc6d8..93b59ea0 100644 --- a/test/unit/dmsf_file_test.rb +++ b/test/unit/dmsf_file_test.rb @@ -161,9 +161,9 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest assert_equal new_file.dmsf_file_revisions.all.size, 1 assert_nil new_file.last_revision.workflow assert_nil new_file.last_revision.dmsf_workflow_id - assert_nil new_file.last_revision.dmsf_workflow_assigned_by + assert_nil new_file.last_revision.dmsf_workflow_assigned_by_user_id assert_nil new_file.last_revision.dmsf_workflow_assigned_at - assert_nil new_file.last_revision.dmsf_workflow_started_by + assert_nil new_file.last_revision.dmsf_workflow_started_by_user_id assert_nil new_file.last_revision.dmsf_workflow_started_at end end @@ -174,9 +174,9 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest new_file = @file1.copy_to_filename(@project2, nil, 'new_file.txt') assert_equal DmsfWorkflow::STATE_ASSIGNED, new_file.last_revision.workflow assert_equal @wf2.id, new_file.last_revision.dmsf_workflow_id - assert_equal User.current.id, new_file.last_revision.dmsf_workflow_assigned_by + assert_equal User.current, new_file.last_revision.dmsf_workflow_assigned_by_user assert new_file.last_revision.dmsf_workflow_assigned_at - assert_nil new_file.last_revision.dmsf_workflow_started_by + assert_nil new_file.last_revision.dmsf_workflow_started_by_user_id assert_nil new_file.last_revision.dmsf_workflow_started_at end @@ -186,9 +186,9 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest new_file = @file7.copy_to_filename(@project1, nil, 'new_file.txt') assert_equal DmsfWorkflow::STATE_ASSIGNED, new_file.last_revision.workflow assert_equal @wf1.id, new_file.last_revision.dmsf_workflow_id - assert_equal User.current.id, new_file.last_revision.dmsf_workflow_assigned_by + assert_equal User.current, new_file.last_revision.dmsf_workflow_assigned_by_user assert new_file.last_revision.dmsf_workflow_assigned_at - assert_nil new_file.last_revision.dmsf_workflow_started_by + assert_nil new_file.last_revision.dmsf_workflow_started_by_user_id assert_nil new_file.last_revision.dmsf_workflow_started_at end @@ -198,9 +198,9 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest new_file = @file7.copy_to_filename(@project2, nil, 'new_file.txt') assert_nil new_file.last_revision.workflow assert_nil new_file.last_revision.dmsf_workflow_id - assert_nil new_file.last_revision.dmsf_workflow_assigned_by + assert_nil new_file.last_revision.dmsf_workflow_assigned_by_user_id assert_nil new_file.last_revision.dmsf_workflow_assigned_at - assert_nil new_file.last_revision.dmsf_workflow_started_by + assert_nil new_file.last_revision.dmsf_workflow_started_by_user_id assert_nil new_file.last_revision.dmsf_workflow_started_at end diff --git a/test/unit/user_patch_test.rb b/test/unit/user_patch_test.rb index d7c29804..79fefc90 100644 --- a/test/unit/user_patch_test.rb +++ b/test/unit/user_patch_test.rb @@ -36,6 +36,8 @@ class UserPatchTest < RedmineDmsf::Test::UnitTest @user2.destroy assert_equal 0, DmsfFileRevisionAccess.where(user_id: id).all.size assert_equal 0, DmsfFileRevision.where(user_id: id).all.size + assert_equal 0, DmsfFileRevision.where(dmsf_workflow_assigned_by_user_id: id).all.size + assert_equal 0, DmsfFileRevision.where(dmsf_workflow_started_by_user_id: id).all.size assert_equal 0, DmsfFile.where(deleted_by_user_id: id).all.size assert_equal 0, DmsfFolder.where(user_id: id).all.size assert_equal 0, DmsfFolder.where(deleted_by_user_id: id).all.size