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

set accountable spec

Tobias Dillmann3d60c2363490
diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rb
index d5eada94fe7..b65a43c705f 100644
--- a/spec/features/work_packages/edit_work_package_spec.rb
+++ b/spec/features/work_packages/edit_work_package_spec.rb
@@ -265,25 +265,29 @@ RSpec.describe "edit work package", :js do
end
context "when using the user auto completer" do
- let(:dev_role) do
- create(:project_role,
- permissions: %i[view_work_packages
- edit_work_packages
- work_package_assigned])
- end
+ RSpec.shared_examples "without permission" do |field_name|
+ it "does not show you the email of other users" do
+ wp_page.open_user_auto_completer(field_name)
+ options = wp_page.visible_user_auto_completer_options
- let(:logged_in_user) { dev }
+ expected_options = [
+ { name: manager.name, email: nil }, # Manager's email should not be visible
+ { name: dev.name, email: dev.mail } # Developer's email should be visible
+ ]
- context "when assigning" do
- it "does not show you the email of other users" do
- # Click on assignee
- wp_page.open_user_auto_completer
+ expect(options).to eq(expected_options)
+ end
+ end
+
+ RSpec.shared_examples "with permission" do |field_name|
+ it "does show you the email of other users" do
+ wp_page.open_user_auto_completer(field_name)
options = wp_page.visible_user_auto_completer_options
expected_options = [
- # The current user lacks permission to see other users email address
+ # With the right permissions, you can see other users email address
{ name: manager.name,
- email: nil },
+ email: manager.mail },
# The current user can always see their own email
{ name: dev.name,
email: dev.mail }
@@ -293,6 +297,23 @@ RSpec.describe "edit work package", :js do
end
end
+ let(:dev_role) do
+ create(:project_role,
+ permissions: %i[view_work_packages
+ edit_work_packages
+ work_package_assigned])
+ end
+
+ let(:logged_in_user) { dev }
+
+ context "when assigning people to a work package" do
+ include_examples "without permission", "assignee"
+ end
+
+ context "when setting accountable person for a work package" do
+ include_examples "without permission", "responsible"
+ end
+
context "with permission to see emails" do
let(:dev_role) do
create(:project_role,
@@ -302,23 +323,12 @@ RSpec.describe "edit work package", :js do
work_package_assigned])
end
- context "when assigning" do
- it "does show you the email of other users" do
- # Click on assignee
- wp_page.open_user_auto_completer
- options = wp_page.visible_user_auto_completer_options
-
- expected_options = [
- # With the right permissions, you can see other users email address
- { name: manager.name,
- email: manager.mail },
- # The current user can always see their own email
- { name: dev.name,
- email: dev.mail }
- ]
-
- expect(options).to eq(expected_options)
- end
+ context "when assigning people to a work package" do
+ include_examples "with permission", "assignee"
+ end
+
+ context "when setting accountable person for a work package" do
+ include_examples "with permission", "responsible"
end
end
end