From 969e76e0f7780cfb62eefb16ef36a6576100f8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Thu, 23 Mar 2023 12:25:04 +0100 Subject: [PATCH] #1434 duplicited code --- .github/workflows/rubyonrails.yml | 2 +- lib/redmine_dmsf/macros.rb | 3 --- test/functional/dmsf_files_controller_test.rb | 8 +++++--- test/functional/my_controller_test.rb | 6 ++++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 478e7eb7..44c2083d 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -127,7 +127,7 @@ jobs: cp /opt/redmine/config/additional_environment.rb.example /opt/redmine/config/additional_environment.rb echo "config.log_level = :info" >> /opt/redmine/config/additional_environment.rb echo "# Redmine DMSF's WebDAV" >> /opt/redmine/config/additional_environment.rb - echo "require File.dirname(__FILE__) + '/plugins/redmine_dmsf/lib/redmine_dmsf/webdav/custom_middleware'" >> /opt/redmine/config/additional_environment.rb + echo "require 'plugins/redmine_dmsf/lib/redmine_dmsf/webdav/custom_middleware'" >> /opt/redmine/config/additional_environment.rb echo "config.middleware.insert_before ActionDispatch::Cookies, RedmineDmsf::Webdav::CustomMiddleware" >> /opt/redmine/config/additional_environment.rb - name: Standard tests # Run the tests diff --git a/lib/redmine_dmsf/macros.rb b/lib/redmine_dmsf/macros.rb index 70a4cd09..86a52ddb 100644 --- a/lib/redmine_dmsf/macros.rb +++ b/lib/redmine_dmsf/macros.rb @@ -43,9 +43,6 @@ module RedmineDmsf raise ActiveRecord::RecordNotFound end end - unless User.current&.allowed_to?(:view_dmsf_files, file.project, { id: file.id }) - raise l(:notice_not_authorized) - end title = args[1].present? ? args[1] : file.title title.gsub! /\A"|"\z/, '' # Remove apostrophes title.gsub! /\A'|'\z/, '' diff --git a/test/functional/dmsf_files_controller_test.rb b/test/functional/dmsf_files_controller_test.rb index ea154bcb..f34746f2 100644 --- a/test/functional/dmsf_files_controller_test.rb +++ b/test/functional/dmsf_files_controller_test.rb @@ -79,9 +79,11 @@ class DmsfFilesControllerTest < RedmineDmsf::Test::TestCase def test_view_preview get :view, params: { id: @file13.id } - assert_response :success - assert_equal 'application/pdf', @response.media_type - assert @response.body.starts_with?('%PDF') + if RedmineDmsf::Preview.office_available? + assert_response :success + assert_equal 'application/pdf', @response.media_type + assert @response.body.starts_with?('%PDF') + end end def delete_forbidden diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index 62598a13..8668206c 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -80,8 +80,10 @@ class MyControllerTest < RedmineDmsf::Test::TestCase @project1.add_watcher @jsmith get :page assert_response :success - assert_select 'div#list-top' do - assert_select 'h3', { text: "#{l(:label_dmsf_watched)} (2/1)" } + unless defined?(EasyExtensions) + assert_select 'div#list-top' do + assert_select 'h3', { text: "#{l(:label_dmsf_watched)} (2/1)" } + end end end