From 716598f125d1d4da5c23759ca9caccfcdd5e508e Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Thu, 22 Oct 2020 10:38:28 +0100 Subject: [PATCH] Fixed revision comments not saving on document versions. Fixes #446 --- app/controllers/documents_controller.rb | 2 +- test/functional/documents_controller_test.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 6d1b7cc644..48dc0c66f3 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -19,7 +19,7 @@ class DocumentsController < ApplicationController def new_version if handle_upload_data(true) - comments = params[:revision_comment] + comments = params[:revision_comments] respond_to do |format| if @document.save_as_new_version(comments) diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index 9f8e3e3a9b..46d4abb336 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -104,6 +104,26 @@ def edit_max_object(document) assert_redirected_to document_path(assigns(:document)) end + test 'should create document version' do + document = Factory(:document) + login_as(document.contributor) + + assert_difference('ActivityLog.count') do + assert_no_difference('Document.count') do + assert_difference('Document::Version.count') do + assert_difference('ContentBlob.count') do + post :new_version, params: { id: document.id, content_blobs: [{ data: fixture_file_upload('files/little_file.txt') }], revision_comments: 'new version!' } + end + end + end + end + + assert_redirected_to document_path(assigns(:document)) + assert_equal 2, assigns(:document).version + assert_equal 2, assigns(:document).versions.count + assert_equal 'new version!', assigns(:document).latest_version.revision_comments + end + test 'should create and link to event' do person = Factory(:person) login_as(person)