Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

added and refactore permission specs

Jonas Jabari9f121c8df416
diff --git a/spec/permissions/edit_own_work_package_notes.rb b/spec/permissions/edit_own_work_package_notes.rb
new file mode 100644
index 00000000000..5ec44eb585d
--- /dev/null
+++ b/spec/permissions/edit_own_work_package_notes.rb
@@ -0,0 +1,38 @@
+#-- 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"
+require File.expand_path("../support/permission_specs", __dir__)
+
+RSpec.describe WorkPackages::ActivitiesTabController, "edit_own_work_package_notes permission", type: :controller do
+ include PermissionSpecs
+
+ check_permission_required_for("work_packages/activities_tab#edit", :edit_work_package_notes)
+ check_permission_required_for("work_packages/activities_tab#cancel_edit", :edit_work_package_notes)
+ check_permission_required_for("work_packages/activities_tab#update", :edit_work_package_notes)
+end
diff --git a/spec/permissions/manage_project_custom_values_spec.rb b/spec/permissions/edit_project_attributes_spec.rb
similarity index 86%
rename from spec/permissions/manage_project_custom_values_spec.rb
rename to spec/permissions/edit_project_attributes_spec.rb
index 19461ef958f..b0fadf7cba2 100644
--- a/spec/permissions/manage_project_custom_values_spec.rb
+++ b/spec/permissions/edit_project_attributes_spec.rb
@@ -29,13 +29,10 @@
require "spec_helper"
require File.expand_path("../support/permission_specs", __dir__)
-RSpec.describe Overviews::OverviewsController, "manage_project_custom_values permission",
+RSpec.describe Overviews::OverviewsController, "edit_project_attributes permission",
type: :controller do
include PermissionSpecs
- # render sidebar on project overview page with view_project permission
- check_permission_required_for("overviews/overviews#project_custom_fields_sidebar", :view_project_attributes)
-
# render dialog with inputs for editing project attributes with edit_project permission
check_permission_required_for("overviews/overviews#project_custom_field_section_dialog", :edit_project_attributes)
diff --git a/spec/permissions/edit_work_package_notes.rb b/spec/permissions/edit_work_package_notes.rb
new file mode 100644
index 00000000000..c40309dbc6c
--- /dev/null
+++ b/spec/permissions/edit_work_package_notes.rb
@@ -0,0 +1,38 @@
+#-- 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"
+require File.expand_path("../support/permission_specs", __dir__)
+
+RSpec.describe WorkPackages::ActivitiesTabController, "edit_work_package_notes permission", type: :controller do
+ include PermissionSpecs
+
+ check_permission_required_for("work_packages/activities_tab#edit", :edit_work_package_notes)
+ check_permission_required_for("work_packages/activities_tab#cancel_edit", :edit_work_package_notes)
+ check_permission_required_for("work_packages/activities_tab#update", :edit_work_package_notes)
+end
diff --git a/spec/permissions/manage_project_custom_field_mappings_spec.rb b/spec/permissions/select_project_custom_fields_spec.rb
similarity index 97%
rename from spec/permissions/manage_project_custom_field_mappings_spec.rb
rename to spec/permissions/select_project_custom_fields_spec.rb
index 0ed856ecad8..13f5d6974e7 100644
--- a/spec/permissions/manage_project_custom_field_mappings_spec.rb
+++ b/spec/permissions/select_project_custom_fields_spec.rb
@@ -29,7 +29,7 @@
require "spec_helper"
require File.expand_path("../support/permission_specs", __dir__)
-RSpec.describe Projects::Settings::ProjectCustomFieldsController, "manage_project_custom_field mappings permission",
+RSpec.describe Projects::Settings::ProjectCustomFieldsController, "select_project_custom_fields mappings permission",
type: :controller do
include PermissionSpecs
diff --git a/spec/permissions/view_project_attributes_spec.rb b/spec/permissions/view_project_attributes_spec.rb
new file mode 100644
index 00000000000..d1121041cdd
--- /dev/null
+++ b/spec/permissions/view_project_attributes_spec.rb
@@ -0,0 +1,38 @@
+#-- 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"
+require File.expand_path("../support/permission_specs", __dir__)
+
+RSpec.describe Overviews::OverviewsController, "view_project_attributes permission",
+ type: :controller do
+ include PermissionSpecs
+
+ # render sidebar on project overview page with view_project permission
+ check_permission_required_for("overviews/overviews#project_custom_fields_sidebar", :view_project_attributes)
+end
diff --git a/spec/permissions/view_work_packages_spec.rb b/spec/permissions/view_work_packages_spec.rb
index 63a444c4da7..05358d38b44 100644
--- a/spec/permissions/view_work_packages_spec.rb
+++ b/spec/permissions/view_work_packages_spec.rb
@@ -35,3 +35,12 @@ RSpec.describe WorkPackagesController, "view_work_packages permission", type: :c
check_permission_required_for("work_packages#show", :view_work_packages)
check_permission_required_for("work_packages#index", :view_work_packages)
end
+
+RSpec.describe WorkPackages::ActivitiesTabController, "view_work_packages permission", type: :controller do
+ include PermissionSpecs
+
+ check_permission_required_for("work_packages/activities_tab#index", :view_work_packages)
+ check_permission_required_for("work_packages/activities_tab#update_streams", :view_work_packages)
+ check_permission_required_for("work_packages/activities_tab#update_sorting", :view_work_packages)
+ check_permission_required_for("work_packages/activities_tab#update_filter", :view_work_packages)
+end