mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Merge pull request #21119 from opf/implementation/69261-deprecate-document-categories-admin-ui
Implementation/69261 deprecate document categories admin UI
This commit is contained in:
@@ -39,6 +39,8 @@ disable_password_login:
|
||||
docker_installation:
|
||||
href: https://www.openproject.org/docs/installation-and-operations/installation/docker/
|
||||
label: Docker installation
|
||||
documents_docs:
|
||||
href: https://www.openproject.org/docs/user-guide/documents/
|
||||
enterprise_features:
|
||||
attribute_highlighting:
|
||||
href: https://www.openproject.org/docs/user-guide/work-packages/work-package-table-configuration/#attribute-highlighting-enterprise-add-on
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace :migrations do
|
||||
include Tasks::Shared::UserFeedback
|
||||
|
||||
# rubocop:disable Rails/ApplicationRecord
|
||||
class TemporaryDocument < ActiveRecord::Base
|
||||
class TemporaryDocument < ActiveRecord::Base # rubocop:disable Lint/ConstantDefinitionInBlock
|
||||
belongs_to :project
|
||||
belongs_to :category, class_name: "DocumentCategory"
|
||||
belongs_to :type, class_name: "DocumentType", optional: true
|
||||
end
|
||||
# rubocop:enable Rails/ApplicationRecord
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ RSpec.describe RootSeeder,
|
||||
end
|
||||
|
||||
include_examples "it creates records", model: Color, expected_count: 148
|
||||
include_examples "it creates records", model: DocumentCategory, expected_count: 3
|
||||
include_examples "it creates records", model: DocumentType, expected_count: 6
|
||||
include_examples "it creates records", model: IssuePriority, expected_count: 4
|
||||
include_examples "it creates records", model: Status, expected_count: 4
|
||||
include_examples "it creates records", model: TimeEntryActivity, expected_count: 3
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<%#
|
||||
-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 3.
|
||||
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
Copyright (C) 2010-2013 the ChiliProject Team
|
||||
|
||||
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.
|
||||
|
||||
See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#
|
||||
%>
|
||||
|
||||
<%= render(
|
||||
Primer::Beta::Blankslate.new(border: true, test_selector: "documents-categories-deprecation-notice")
|
||||
) do |component|
|
||||
component.with_visual_icon(icon: :"op-file-doc")
|
||||
component.with_heading(tag: :h2).with_content(I18n.t("documents.document_categories_deprecation_notice.heading"))
|
||||
|
||||
component.with_description { I18n.t("documents.document_categories_deprecation_notice.description") }
|
||||
component.with_primary_action(
|
||||
scheme: :primary,
|
||||
label: I18n.t("documents.document_categories_deprecation_notice.primary_action"),
|
||||
tag: :a,
|
||||
href: admin_settings_document_types_path
|
||||
).with_content(I18n.t("documents.document_categories_deprecation_notice.primary_action"))
|
||||
|
||||
component.with_secondary_action(
|
||||
scheme: :secondary,
|
||||
label: I18n.t("documents.document_categories_deprecation_notice.secondary_action"),
|
||||
tag: :a,
|
||||
href: OpenProject::Static::Links.url_for(:documents_docs)
|
||||
).with_content(I18n.t("documents.document_categories_deprecation_notice.secondary_action"))
|
||||
end %>
|
||||
+6
-4
@@ -28,9 +28,11 @@
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
FactoryBot.define do
|
||||
factory :document_category do
|
||||
project
|
||||
sequence(:name) { |n| "I am Category No. #{n}" }
|
||||
module Documents
|
||||
module Admin
|
||||
module DocumentCategories
|
||||
class DeprecationNoticeComponent < ApplicationComponent
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -30,14 +30,14 @@
|
||||
|
||||
module Admin
|
||||
module Settings
|
||||
class DocumentCategoriesController < EnumerationsControllerBase
|
||||
class DocumentCategoriesController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
before_action :require_admin
|
||||
|
||||
menu_item :document_categories
|
||||
|
||||
private
|
||||
|
||||
def enumeration_class
|
||||
DocumentCategory
|
||||
end
|
||||
def index; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ class DocumentsController < ApplicationController
|
||||
|
||||
def index
|
||||
@documents = list_documents_query
|
||||
.includes(:category)
|
||||
.includes(:type)
|
||||
.paginate(page: page_param, per_page: per_page_param)
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ class Document < ApplicationRecord
|
||||
collaborative: "collaborative"
|
||||
}
|
||||
|
||||
belongs_to :category, class_name: "DocumentCategory", optional: true
|
||||
belongs_to :project
|
||||
belongs_to :type, class_name: "DocumentType", optional: true, counter_cache: :documents_count
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
class DocumentCategory < Enumeration
|
||||
has_many :documents, foreign_key: "category_id"
|
||||
|
||||
OptionName = :enumeration_doc_categories
|
||||
|
||||
def option_name
|
||||
OptionName
|
||||
end
|
||||
|
||||
def objects_count
|
||||
documents.count
|
||||
end
|
||||
|
||||
def transfer_relations(to)
|
||||
documents.update_all("category_id = #{to.id}")
|
||||
end
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
module BasicData
|
||||
module Documents
|
||||
class EnumerationSeeder < ModelSeeder
|
||||
self.model_class = DocumentCategory
|
||||
self.seed_data_model_key = "document_categories"
|
||||
|
||||
def model_attributes(category_data)
|
||||
{
|
||||
name: category_data["name"]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -36,14 +36,6 @@ modules_permissions:
|
||||
add:
|
||||
- :view_documents
|
||||
|
||||
document_categories:
|
||||
- t_name: Documentation
|
||||
position: 1
|
||||
- t_name: Specification
|
||||
position: 2
|
||||
- t_name: Other
|
||||
position: 3
|
||||
|
||||
document_types:
|
||||
- reference: doc_type_note
|
||||
t_name: Note
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<%#-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 3.
|
||||
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
Copyright (C) 2010-2013 the ChiliProject Team
|
||||
|
||||
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.v
|
||||
See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#%>
|
||||
|
||||
<% html_title t(:label_administration), t("documents.label_categories") %>
|
||||
|
||||
<%=
|
||||
render(Primer::OpenProject::PageHeader.new) do |header|
|
||||
header.with_title { @enumeration.name }
|
||||
header.with_breadcrumbs(
|
||||
[
|
||||
{ href: admin_index_path, text: t("label_administration") },
|
||||
{ href: admin_settings_storages_path, text: t("project_module_storages") },
|
||||
{ href: url_for(action: :index), text: t("documents.label_categories") },
|
||||
@enumeration.name
|
||||
]
|
||||
)
|
||||
end
|
||||
%>
|
||||
|
||||
<% content_controller "admin--enumerations" %>
|
||||
|
||||
<%= settings_primer_form_with(model: @enumeration, scope: :enumeration, url: url_for(action: :update, id: @enumeration)) do |f| %>
|
||||
<%= render(Admin::Enumerations::ItemForm.new(f)) %>
|
||||
<% end %>
|
||||
@@ -1,45 +1,45 @@
|
||||
<%#-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
<%#
|
||||
-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 3.
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 3.
|
||||
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
Copyright (C) 2010-2013 the ChiliProject Team
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
Copyright (C) 2010-2013 the ChiliProject Team
|
||||
|
||||
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 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.
|
||||
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.
|
||||
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.
|
||||
|
||||
See COPYRIGHT and LICENSE files for more details.
|
||||
See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#%>
|
||||
++#
|
||||
%>
|
||||
|
||||
<% html_title t(:label_administration), t("documents.label_categories") %>
|
||||
|
||||
<%=
|
||||
render(Primer::OpenProject::PageHeader.new) do |header|
|
||||
header.with_title { t("documents.label_categories") }
|
||||
header.with_breadcrumbs(
|
||||
[
|
||||
{ href: admin_index_path, text: t("label_administration") },
|
||||
{ href: admin_settings_storages_path, text: t("project_module_storages") },
|
||||
t("documents.label_categories")
|
||||
]
|
||||
)
|
||||
end
|
||||
%>
|
||||
<%= render(Primer::OpenProject::PageHeader.new) do |header|
|
||||
header.with_title { t("documents.label_categories") }
|
||||
header.with_breadcrumbs(
|
||||
[
|
||||
{ href: admin_index_path, text: t("label_administration") },
|
||||
{ href: admin_settings_storages_path, text: t("project_module_storages") },
|
||||
t("documents.label_categories")
|
||||
]
|
||||
)
|
||||
end %>
|
||||
|
||||
<%= render(index_component_class.new(enumerations: @enumerations)) %>
|
||||
<%= render(Documents::Admin::DocumentCategories::DeprecationNoticeComponent.new) %>
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<%#-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 3.
|
||||
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
Copyright (C) 2010-2013 the ChiliProject Team
|
||||
|
||||
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.v
|
||||
See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#%>
|
||||
|
||||
<% html_title t(:label_administration), t("documents.new_category") %>
|
||||
|
||||
<%=
|
||||
render(Primer::OpenProject::PageHeader.new) do |header|
|
||||
header.with_title { I18n.t("documents.new_category") }
|
||||
header.with_breadcrumbs(
|
||||
[
|
||||
{ href: admin_index_path, text: t("label_administration") },
|
||||
{ href: admin_settings_storages_path, text: t("project_module_storages") },
|
||||
t("documents.new_category")
|
||||
]
|
||||
)
|
||||
end
|
||||
%>
|
||||
|
||||
<% content_controller "admin--enumerations" %>
|
||||
|
||||
<%= primer_form_with(model: @enumeration, scope: :enumeration, url: url_for(action: :create)) do |f| %>
|
||||
<%= render(Admin::Enumerations::ItemForm.new(f)) %>
|
||||
<% end %>
|
||||
@@ -1,47 +0,0 @@
|
||||
<%#-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 3.
|
||||
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
Copyright (C) 2010-2013 the ChiliProject Team
|
||||
|
||||
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.v
|
||||
See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#%>
|
||||
|
||||
<% html_title t(:label_administration), t("documents.categories") %>
|
||||
|
||||
<%=
|
||||
render(Primer::OpenProject::PageHeader.new) do |header|
|
||||
header.with_title { @enumeration.name }
|
||||
header.with_breadcrumbs(
|
||||
[
|
||||
{ href: admin_index_path, text: t("label_administration") },
|
||||
{ href: admin_settings_storages_path, text: t("project_module_storages") },
|
||||
{ href: url_for(action: :index), text: t("documents.categories") },
|
||||
@enumeration.name
|
||||
]
|
||||
)
|
||||
end
|
||||
%>
|
||||
|
||||
<%= primer_form_with(model: @enumeration, scope: :enumeration, url: url_for(action: :destroy, id: @enumeration), method: :delete) do |f| %>
|
||||
<%= render(Admin::Enumerations::ReassignForm.new(f, other_enumerations: @other_enumerations)) %>
|
||||
<% end %>
|
||||
@@ -70,6 +70,14 @@ en:
|
||||
heading: "There are no documents yet"
|
||||
description: "There are no documents in this view. You can click the button below to add one."
|
||||
|
||||
document_categories_deprecation_notice:
|
||||
heading: File categories are now called 'Document types'
|
||||
description: |-
|
||||
Your existing file categories have been converted to document types with the introduction of the new Documents module.
|
||||
All existing documents have also been migrated to these new types.
|
||||
primary_action: Configure document types
|
||||
secondary_action: Learn more about the Documents module
|
||||
|
||||
document_type_actions: "Document type actions"
|
||||
|
||||
index_page:
|
||||
|
||||
@@ -117,10 +117,5 @@ module OpenProject::Documents
|
||||
|
||||
# Add documents to allowed search params
|
||||
additional_permitted_attributes search: %i(documents)
|
||||
|
||||
config.to_prepare do
|
||||
# Load Enumeration descendants due to STI
|
||||
DocumentCategory
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
FactoryBot.define do
|
||||
factory :document do
|
||||
project
|
||||
category factory: :document_category
|
||||
type factory: :document_type
|
||||
sequence(:description) { |n| "I am a document's description No. #{n}" }
|
||||
sequence(:title) { |n| "I am the document No. #{n}" }
|
||||
|
||||
@@ -31,34 +31,38 @@
|
||||
require "spec_helper"
|
||||
|
||||
RSpec.describe "Document categories", :js do
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
shared_let(:admin) { create(:admin) }
|
||||
|
||||
before do
|
||||
login_as(admin)
|
||||
end
|
||||
|
||||
it "allows creating new document categories" do
|
||||
it "renders a deprecation notice" do
|
||||
visit admin_settings_document_categories_path
|
||||
|
||||
page.find_test_selector("add-enumeration-button").click
|
||||
expect(page).to have_heading("File categories are now called 'Document types'")
|
||||
expect(page).to have_content("Your existing file categories have been converted to document types " \
|
||||
"with the introduction of the new Documents module. " \
|
||||
"All existing documents have also been migrated to these new types.")
|
||||
|
||||
fill_in "Name", with: "Documentation"
|
||||
click_on("Save")
|
||||
expect(page).to have_link("Configure document types", href: admin_settings_document_types_path)
|
||||
expect(page).to have_link("Learn more about the Documents module",
|
||||
href: "https://www.openproject.org/docs/user-guide/documents/?go_to_locale=en")
|
||||
end
|
||||
|
||||
# we are redirected back to the index page
|
||||
expect(page).to have_current_path(admin_settings_document_categories_path)
|
||||
expect(page).to have_content("Documentation")
|
||||
context "as non-admin" do
|
||||
shared_let(:non_admin) { create(:user) }
|
||||
|
||||
# It allows editing (Regression #62459)
|
||||
click_link "Documentation"
|
||||
before do
|
||||
login_as(non_admin)
|
||||
end
|
||||
|
||||
fill_in "Name", with: "Specification"
|
||||
click_on("Save")
|
||||
it "denies access" do
|
||||
visit admin_settings_document_categories_path
|
||||
|
||||
expect(page).to have_current_path(admin_settings_document_categories_path)
|
||||
expect(page).to have_content("Specification")
|
||||
|
||||
expect(DocumentCategory).to exist(name: "Specification")
|
||||
expect(DocumentCategory).not_to exist(name: "Documentation")
|
||||
expect(page).to have_content("You are not authorized to access this page.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
require_relative "../spec_helper"
|
||||
|
||||
require Rails.root.join("spec/models/enumerations/shared_enumeration_examples").to_s
|
||||
|
||||
RSpec.describe DocumentCategory do
|
||||
let(:project) { create(:project) }
|
||||
|
||||
it "is an enumeration" do
|
||||
expect(DocumentCategory.ancestors).to include Enumeration
|
||||
end
|
||||
|
||||
it "orders documents by the category they are created with" do
|
||||
uncategorized = create(:document_category, name: "Uncategorized", project:)
|
||||
user_documentation = create(:document_category, name: "User documentation")
|
||||
|
||||
create_list(:document, 2, category: uncategorized, project:)
|
||||
|
||||
expect(DocumentCategory.find_by_name(uncategorized.name).objects_count).to be 2
|
||||
expect(DocumentCategory.find_by_name(user_documentation.name).objects_count).to be 0
|
||||
end
|
||||
|
||||
it "files the categorizations under the option name :enumeration_doc_categories" do
|
||||
expect(DocumentCategory.new.option_name).to be :enumeration_doc_categories
|
||||
end
|
||||
|
||||
it "onlies allow one category to be the default-category" do
|
||||
old_default = create(:document_category, name: "old default", project:, is_default: true)
|
||||
|
||||
expect do
|
||||
create(:document_category, name: "new default", project:, is_default: true)
|
||||
old_default.reload
|
||||
end.to change { old_default.is_default? }.from(true).to(false)
|
||||
end
|
||||
|
||||
it_behaves_like "enumeration#active handling", true do
|
||||
let(:enumeration) { described_class.new(attributes_for(:document_category)) }
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,6 @@ require "spec_helper"
|
||||
require_module_spec_helper
|
||||
|
||||
RSpec.describe Document do
|
||||
let(:documentation_category) { create(:document_category, name: "User documentation") }
|
||||
let(:project) { create(:project) }
|
||||
let(:user) { create(:user) }
|
||||
let(:admin) { create(:admin) }
|
||||
@@ -52,7 +51,6 @@ RSpec.describe Document do
|
||||
end
|
||||
|
||||
describe "Associations" do
|
||||
it { is_expected.to belong_to(:category).class_name("DocumentCategory").optional }
|
||||
it { is_expected.to belong_to(:project) }
|
||||
it { is_expected.to belong_to(:type).class_name("DocumentType").optional }
|
||||
end
|
||||
@@ -71,7 +69,7 @@ RSpec.describe Document do
|
||||
end
|
||||
|
||||
describe "create with a valid document" do
|
||||
let(:valid_document) { build(:document, title: "Test", project:, category: documentation_category) }
|
||||
let(:valid_document) { build(:document, title: "Test", project:) }
|
||||
|
||||
it "adds a document" do
|
||||
expect do
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
RSpec.describe "Document categories",
|
||||
:aggregate_failures,
|
||||
:skip_csrf,
|
||||
type: :rails_request do
|
||||
shared_let(:admin) { create(:admin) }
|
||||
shared_let(:category) { create(:document_category, name: "Technical") }
|
||||
shared_let(:other_category) { create(:document_category, name: "Other") }
|
||||
|
||||
before do
|
||||
login_as(admin)
|
||||
end
|
||||
|
||||
describe "GET /admin/settings/document_categories" do
|
||||
it "renders the index template" do
|
||||
get admin_settings_document_categories_path
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include "Technical"
|
||||
expect(response.body).to include "Other"
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /admin/settings/document_categories/:id" do
|
||||
let(:params) { {} }
|
||||
|
||||
context "without documents assigned" do
|
||||
it "redirects to the categories index" do
|
||||
delete(admin_settings_document_category_path(category), params:)
|
||||
expect(response).to redirect_to admin_settings_document_categories_path
|
||||
expect { category.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context "with documents assigned" do
|
||||
shared_let(:document) { create(:document, category:) }
|
||||
|
||||
it "renders the reassign template" do
|
||||
delete(admin_settings_document_category_path(category), params:)
|
||||
expect(response).to redirect_to reassign_admin_settings_document_category_path(category)
|
||||
expect { category.reload }.not_to raise_error
|
||||
expect(document.reload.category).to eq category
|
||||
end
|
||||
|
||||
context "with documents assigned and reassigning" do
|
||||
let(:params) do
|
||||
{
|
||||
enumeration: { reassign_to_id: other_category.id }
|
||||
}
|
||||
end
|
||||
|
||||
it "reassigns the category" do
|
||||
delete(admin_settings_document_category_path(category), params:)
|
||||
expect(response).to redirect_to admin_settings_document_categories_path
|
||||
expect { category.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(document.reload.category).to eq other_category
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /admin/settings/document_categories/:id/move" do
|
||||
it "moves the category to the bottom" do
|
||||
put move_admin_settings_document_category_path(category), params: { move_to: "lowest" }, as: :turbo_stream
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(category.reload.position).to be > other_category.reload.position
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,65 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
RSpec.describe Admin::Settings::DocumentCategoriesController, "routing" do
|
||||
describe "document categories" do
|
||||
it {
|
||||
expect(subject).to route(:get, "admin/settings/document_categories")
|
||||
.to(controller: "admin/settings/document_categories", action: "index")
|
||||
}
|
||||
|
||||
it {
|
||||
expect(subject).to route(:get, "admin/settings/document_categories/new")
|
||||
.to(controller: "admin/settings/document_categories", action: "new")
|
||||
}
|
||||
|
||||
it {
|
||||
expect(subject).to route(:post, "admin/settings/document_categories")
|
||||
.to(controller: "admin/settings/document_categories", action: "create")
|
||||
}
|
||||
|
||||
it {
|
||||
expect(subject).to route(:get, "admin/settings/document_categories/1/edit")
|
||||
.to(controller: "admin/settings/document_categories", action: "edit", id: "1")
|
||||
}
|
||||
|
||||
it {
|
||||
expect(subject).to route(:put, "admin/settings/document_categories/1")
|
||||
.to(controller: "admin/settings/document_categories", action: "update", id: "1")
|
||||
}
|
||||
|
||||
it {
|
||||
expect(subject).to route(:delete, "admin/settings/document_categories/1")
|
||||
.to(controller: "admin/settings/document_categories", action: "destroy", id: "1")
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -144,7 +144,7 @@ RSpec.describe RootSeeder,
|
||||
end
|
||||
|
||||
include_examples "it creates records", model: Color, expected_count: 148
|
||||
include_examples "it creates records", model: DocumentCategory, expected_count: 3
|
||||
include_examples "it creates records", model: DocumentType, expected_count: 6
|
||||
include_examples "it creates records", model: GlobalRole, expected_count: 2
|
||||
include_examples "it creates records", model: WorkPackageRole, expected_count: 3
|
||||
include_examples "it creates records", model: ProjectRole, expected_count: 5
|
||||
|
||||
Reference in New Issue
Block a user