From f9765c5af12204e97c7a922ced8a4c69c3b3a9b5 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 9 Feb 2017 12:12:38 +0100 Subject: [PATCH] v1.5.9 tests --- .../dmsf_public_urls_controller.rb | 2 +- test/functional/dmsf_files_controller_test.rb | 39 ++++++++++--------- .../dmsf_public_urls_controller_test.rb | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/controllers/dmsf_public_urls_controller.rb b/app/controllers/dmsf_public_urls_controller.rb index 039c48b6..dd16e5c2 100644 --- a/app/controllers/dmsf_public_urls_controller.rb +++ b/app/controllers/dmsf_public_urls_controller.rb @@ -26,7 +26,7 @@ class DmsfPublicUrlsController < ApplicationController skip_before_filter :check_if_login_required, :only => [:show] def show - dmsf_public_url = DmsfPublicUrl.where("token = ? AND expire_at >= ?", params[:token], DateTime.now).first + dmsf_public_url = DmsfPublicUrl.where('token = ? AND expire_at >= ?', params[:token], DateTime.now).first if dmsf_public_url revision = dmsf_public_url.dmsf_file.last_revision begin diff --git a/test/functional/dmsf_files_controller_test.rb b/test/functional/dmsf_files_controller_test.rb index b776454e..0e109e56 100644 --- a/test/functional/dmsf_files_controller_test.rb +++ b/test/functional/dmsf_files_controller_test.rb @@ -34,59 +34,60 @@ class DmsfFilesControllerTest < RedmineDmsf::Test::TestCase @role = Role.find_by_id 1 User.current = nil @request.session[:user_id] = 2 + DmsfFile.storage_path = File.expand_path '../../fixtures/files', __FILE__ end - def test_truth + def test_truth assert_kind_of DmsfFile, @file - assert_kind_of Role, @role + assert_kind_of Role, @role end - + def test_show_file_ok # Permissions OK - @role.add_permission! :view_dmsf_files + @role.add_permission! :view_dmsf_files get :show, :id => @file.id assert_response :success end - + def test_show_file_forbidden - # Missing permissions + # Missing permissions get :show, :id => @file.id - assert_response :forbidden - end + assert_response :forbidden + end def test_view_file_ok # Permissions OK @role.add_permission! :view_dmsf_files get :view, :id => @file.id - assert_response :missing # The file is physicaly not present + assert_response :success end def test_view_file_forbidden - # Missing permissions + # Missing permissions get :view, :id => @file.id - assert_response :forbidden - end + assert_response :forbidden + end def delete_forbidden # Missing permissions delete @file, :commit => false assert_response :forbidden end - - def delete_locked - # Permissions OK but the file is locked + + def delete_locked + # Permissions OK but the file is locked @role.add_permission! :file_delete delete @file, :commit => false - assert_response :redirect + assert_response :redirect assert_include l(:error_file_is_locked), flash[:error] end - + def delete_ok # Permissions OK and not locked - flash[:error].clear + flash[:error].clear @file.unlock! delete @file, :commit => false - assert_response :redirect + assert_response :redirect assert_equal 0, flash[:error].size end diff --git a/test/functional/dmsf_public_urls_controller_test.rb b/test/functional/dmsf_public_urls_controller_test.rb index d83bacae..4fa5b259 100644 --- a/test/functional/dmsf_public_urls_controller_test.rb +++ b/test/functional/dmsf_public_urls_controller_test.rb @@ -30,7 +30,7 @@ class DmsfPublicUrlsControllerTest < RedmineDmsf::Test::TestCase def test_show_valid_url get :show, :token => 'd8d33e21914a433b280fdc94450ee212' - assert_response :success + assert_response :success, "#{DmsfFile.find_by_id(1).last_revision.disk_file} probably not found" end def test_show_url_width_invalid_token