From 293bda4397e4673332a482f3cc126a5e7ad48181 Mon Sep 17 00:00:00 2001 From: "karel.picman@lbcfree.net" Date: Tue, 18 May 2021 13:19:06 +0200 Subject: [PATCH] Unit test fixes --- app/controllers/dmsf_workflows_controller.rb | 4 ++-- .../dmsf_folder_permissions_controller_test.rb | 4 ++-- test/integration/rest_api/dmsf_api_test.rb | 2 +- test/integration/rest_api/dmsf_file_api_test.rb | 4 ++-- test/integration/rest_api/dmsf_folder_api_test.rb | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index b58ece29..9b1ea170 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -300,8 +300,8 @@ class DmsfWorkflowsController < ApplicationController def update if params[:dmsf_workflow] - res = @dmsf_workflow.update_attributes({ name: params[:dmsf_workflow][:name] }) if params[:dmsf_workflow][:name].present? - res = @dmsf_workflow.update_attributes({ status: params[:dmsf_workflow][:status] }) if params[:dmsf_workflow][:status].present? + res = @dmsf_workflow.update(name: params[:dmsf_workflow][:name]) if params[:dmsf_workflow][:name].present? + res = @dmsf_workflow.update(status: params[:dmsf_workflow][:status]) if params[:dmsf_workflow][:status].present? if res flash[:notice] = l(:notice_successful_update) if @project diff --git a/test/functional/dmsf_folder_permissions_controller_test.rb b/test/functional/dmsf_folder_permissions_controller_test.rb index aa4b3122..77aaedfa 100644 --- a/test/functional/dmsf_folder_permissions_controller_test.rb +++ b/test/functional/dmsf_folder_permissions_controller_test.rb @@ -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_equal 'text/javascript', response.content_type + assert @response.content_type.match?(/^text\/javascript/) end def test_autocomplete_for_user @@ -49,7 +49,7 @@ class DmsfFolderPermissionsControllerTest < RedmineDmsf::Test::TestCase xhr: true assert_response :success assert_template 'new' - assert_equal 'text/javascript', response.content_type + assert @response.content_type.match?(/^text\/javascript/) end end diff --git a/test/integration/rest_api/dmsf_api_test.rb b/test/integration/rest_api/dmsf_api_test.rb index 97102ef5..160fe479 100644 --- a/test/integration/rest_api/dmsf_api_test.rb +++ b/test/integration/rest_api/dmsf_api_test.rb @@ -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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # diff --git a/test/integration/rest_api/dmsf_file_api_test.rb b/test/integration/rest_api/dmsf_file_api_test.rb index d6551395..110b9f1b 100644 --- a/test/integration/rest_api/dmsf_file_api_test.rb +++ b/test/integration/rest_api/dmsf_file_api_test.rb @@ -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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # 1 @@ -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_equal 'application/xml', response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # 2.8bb2564936980e92ceec8a5759ec34a8 diff --git a/test/integration/rest_api/dmsf_folder_api_test.rb b/test/integration/rest_api/dmsf_folder_api_test.rb index 68f9e060..27809f32 100644 --- a/test/integration/rest_api/dmsf_folder_api_test.rb +++ b/test/integration/rest_api/dmsf_folder_api_test.rb @@ -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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # @@ -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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # @@ -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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # @@ -120,7 +120,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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # # @@ -152,7 +152,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_equal 'application/xml', @response.content_type + assert @response.content_type.match?(/^application\/xml/) # # #