Easy tests
This commit is contained in:
parent
09ace4d5ff
commit
a2eeac3897
12
Gemfile
12
Gemfile
@ -19,17 +19,19 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
source 'https://rubygems.org' do
|
source 'https://rubygems.org' do
|
||||||
gem 'active_record_union'
|
|
||||||
gem 'ox' # Dav4Rack
|
gem 'ox' # Dav4Rack
|
||||||
gem 'rake' unless Dir.exist?(File.expand_path('../../redmine_dashboard', __FILE__))
|
gem 'rake' unless Dir.exist?(File.expand_path('../../redmine_dashboard', __FILE__))
|
||||||
gem 'uuidtools'
|
gem 'uuidtools'
|
||||||
group :xapian do
|
|
||||||
gem 'xapian-ruby'
|
|
||||||
end
|
|
||||||
gem 'zip-zip' unless Dir.exist?(File.expand_path('../../vault', __FILE__))
|
gem 'zip-zip' unless Dir.exist?(File.expand_path('../../vault', __FILE__))
|
||||||
|
|
||||||
# Redmine extensions
|
# Redmine extensions
|
||||||
gem 'simple_enum' unless Dir.exist?(File.expand_path('../../easyproject', __FILE__))
|
unless Dir.exist?(File.expand_path('../../easyproject', __FILE__))
|
||||||
|
gem 'active_record_union'
|
||||||
|
gem 'simple_enum'
|
||||||
|
group :xapian do
|
||||||
|
gem 'xapian-ruby'
|
||||||
|
end
|
||||||
|
end
|
||||||
unless %w[easyproject easy_gantt custom_tables]
|
unless %w[easyproject easy_gantt custom_tables]
|
||||||
.any? { |plugin| Dir.exist?(File.expand_path("../../#{plugin}", __FILE__)) }
|
.any? { |plugin| Dir.exist?(File.expand_path("../../#{plugin}", __FILE__)) }
|
||||||
group :test do
|
group :test do
|
||||||
|
|||||||
@ -109,7 +109,7 @@ def dmsf_init
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Redmine::Plugin.installed?('easy_extensions')
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
ActiveSupport.on_load(:easyproject, yield: true) do
|
Rails.application.config.after_initialize do
|
||||||
dmsf_init
|
dmsf_init
|
||||||
|
|
||||||
# Register panels for My page
|
# Register panels for My page
|
||||||
|
|||||||
@ -39,7 +39,6 @@ require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/queries_controller_patch
|
|||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/pdf_patch"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/pdf_patch"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/access_control_patch"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/access_control_patch"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/search_patch"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/search_patch"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/search_controller_patch"
|
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/custom_field_patch"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/custom_field_patch"
|
||||||
|
|
||||||
# A workaround for obsolete 'alias_method' usage in RedmineUp's plugins
|
# A workaround for obsolete 'alias_method' usage in RedmineUp's plugins
|
||||||
@ -53,12 +52,6 @@ if defined?(EasyExtensions)
|
|||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/easy_crm_case_patch"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/easy_crm_case_patch"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/attachable_patch"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/attachable_patch"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/easy_crm_cases_controller_patch.rb"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/easy_crm_cases_controller_patch.rb"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/xapian_easy_search_helper_patch.rb"
|
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/application_helper_patch.rb"
|
|
||||||
|
|
||||||
# Mappers
|
|
||||||
require "#{File.dirname(__FILE__)}/xapian_easy_search/dmsf_file_mapper.rb"
|
|
||||||
require "#{File.dirname(__FILE__)}/xapian_easy_search/dmsf_folder_mapper.rb"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Load up classes that make up our WebDAV solution ontop of Dav4rack
|
# Load up classes that make up our WebDAV solution ontop of Dav4rack
|
||||||
@ -78,18 +71,24 @@ require "#{File.dirname(__FILE__)}/redmine_dmsf/errors/dmsf_lock_error"
|
|||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/errors/dmsf_zip_max_files_error"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/errors/dmsf_zip_max_files_error"
|
||||||
|
|
||||||
# Hooks
|
# Hooks
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/account_controller_hooks"
|
def require_hooks
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/search_controller_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/issues_controller_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/issues_controller_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/view_projects_form_hook"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/view_projects_form_hook"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/base_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/base_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/custom_field_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/custom_field_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/issue_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/issue_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/my_account_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/my_account_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/search_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/search_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/issues_helper_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/issues_helper_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/search_helper_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/search_helper_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/project_helper_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/project_helper_hooks"
|
end
|
||||||
|
|
||||||
|
if defined?(EasyExtensions)
|
||||||
|
Rails.application.config.to_prepare { require_hooks }
|
||||||
|
else
|
||||||
|
require_hooks
|
||||||
|
end
|
||||||
|
|
||||||
# Macros
|
# Macros
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/macros"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/macros"
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
|
||||||
#
|
|
||||||
# Karel Pičman <karel.picman@kontron.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
module RedmineDmsf
|
|
||||||
module Patches
|
|
||||||
# ApplicationHelper patch
|
|
||||||
module ApplicationHelperPatch
|
|
||||||
##################################################################################################################
|
|
||||||
# Overridden methods
|
|
||||||
|
|
||||||
def xapian_link_to_entity(entity, html_options = {})
|
|
||||||
if entity.is_a?(DmsfFolder)
|
|
||||||
link_to h(entity.to_s), dmsf_folder_path(id: entity.project_id, folder_id: entity), class: 'icon icon-folder'
|
|
||||||
elsif entity.is_a?(DmsfFile)
|
|
||||||
link_to h(entity.to_s), dmsf_file_path(id: entity), class: 'icon icon-file'
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Apply the patch
|
|
||||||
ApplicationHelper.prepend RedmineDmsf::Patches::ApplicationHelperPatch if Redmine::Plugin.installed?('easy_extensions')
|
|
||||||
@ -34,7 +34,7 @@ module RedmineDmsf
|
|||||||
def remove_dmsf_references
|
def remove_dmsf_references
|
||||||
return unless id
|
return unless id
|
||||||
|
|
||||||
substitute = User.anonymous
|
substitute = Role.anonymous
|
||||||
DmsfFolderPermission.where(object_id: id, object_type: 'Role').update_all object_id: substitute.id
|
DmsfFolderPermission.where(object_id: id, object_type: 'Role').update_all object_id: substitute.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
|
||||||
#
|
|
||||||
# Karel Pičman <karel.picman@kontron.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
module RedmineDmsf
|
|
||||||
module Patches
|
|
||||||
# Search controller patch
|
|
||||||
module SearchControllerPatch
|
|
||||||
##################################################################################################################
|
|
||||||
# New methods
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def query_params
|
|
||||||
p = super
|
|
||||||
p[:dmsf_files] = params[:dmsf_files].present?
|
|
||||||
p[:dmsf_folders] = params[:dmsf_folders].present?
|
|
||||||
p
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Apply the patch
|
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
|
||||||
EasyPatchManager.register_controller_patch 'SearchController', 'RedmineDmsf::Patches::SearchControllerPatch',
|
|
||||||
prepend: true
|
|
||||||
end
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
|
||||||
#
|
|
||||||
# Karel Pičman <karel.picman@kontron.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
module RedmineDmsf
|
|
||||||
module Patches
|
|
||||||
# XapianEasySearchHelper patch
|
|
||||||
module XapianEasySearchHelperPatch
|
|
||||||
##################################################################################################################
|
|
||||||
# Overridden methods
|
|
||||||
|
|
||||||
def xapian_entity_path(xapian_doc)
|
|
||||||
if xapian_doc.values[:source_type] == 'dmsf_folder'
|
|
||||||
dmsf_folder_path id: xapian_doc.values[:project_id], folder_id: xapian_doc.values[:source_id]
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Apply the patch
|
|
||||||
if Redmine::Plugin.installed?('easy_extensions')
|
|
||||||
XapianEasySearchHelper.prepend RedmineDmsf::Patches::XapianEasySearchHelperPatch
|
|
||||||
end
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
|
||||||
#
|
|
||||||
# Vít Jonáš <vit.jonas@gmail.com>, Daniel Munn <dan.munn@munnster.co.uk>, Karel Pičman <karel.picman@kontron.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
if defined?(EasyExtensions)
|
|
||||||
require 'xapian_easy_search/base_mapper'
|
|
||||||
else
|
|
||||||
module XapianEasySearch
|
|
||||||
# Foo class
|
|
||||||
class BaseMapper
|
|
||||||
def foo; end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
|
||||||
#
|
|
||||||
# Vít Jonáš <vit.jonas@gmail.com>, Daniel Munn <dan.munn@munnster.co.uk>, Karel Pičman <karel.picman@kontron.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
require('xapian_easy_search/base_mapper') if defined?(EasyExtensions)
|
|
||||||
|
|
||||||
module XapianEasySearch
|
|
||||||
# DmsfFile mapper
|
|
||||||
class DmsfFileMapper < XapianEasySearch::BaseMapper
|
|
||||||
class << self
|
|
||||||
def default_index_options
|
|
||||||
super.merge(
|
|
||||||
title: :name,
|
|
||||||
updated_at: ->(dmsf_file) { dmsf_file&.last_revision&.updated_at },
|
|
||||||
content: ->(dmsf_file) { dmsf_file&.content }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def extend_query_filter
|
|
||||||
proc do |query|
|
|
||||||
# TODO: we filter the results with all files visible for the user. It's the worst way how to filter them.
|
|
||||||
files = DmsfFile.visible
|
|
||||||
.joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id')
|
|
||||||
.joins(:project)
|
|
||||||
.where(Project.allowed_to_condition(User.current, :view_dmsf_files)).to_a
|
|
||||||
files.delete_if { |f| !DmsfFolder.permissions?(f.dmsf_folder) }
|
|
||||||
ids = files.map(&:id)
|
|
||||||
Xapian::Query.new Xapian::Query::OP_AND, query, boolean_filter_query(:source_id, ids)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
|
||||||
#
|
|
||||||
# Vít Jonáš <vit.jonas@gmail.com>, Daniel Munn <dan.munn@munnster.co.uk>, Karel Pičman <karel.picman@kontron.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
require('xapian_easy_search/base_mapper') if defined?(EasyExtensions)
|
|
||||||
|
|
||||||
module XapianEasySearch
|
|
||||||
# DmsfFolder mapper
|
|
||||||
class DmsfFolderMapper < XapianEasySearch::BaseMapper
|
|
||||||
class << self
|
|
||||||
def default_index_options
|
|
||||||
super.merge title: :title, updated_at: :updated_at, content: :description
|
|
||||||
end
|
|
||||||
|
|
||||||
def extend_query_filter
|
|
||||||
proc do |query|
|
|
||||||
# TODO: we filter the results with all folders visible for the user. It's the worst way how to filter them.
|
|
||||||
ids = DmsfFolder.visible.ids
|
|
||||||
Xapian::Query.new Xapian::Query::OP_AND, query, boolean_filter_query(:source_id, ids)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user