Skip to content

Commit

Permalink
set accountable spec
Browse files Browse the repository at this point in the history
  • Loading branch information
EinLama committed Oct 23, 2024
1 parent 9799391 commit 1bd1ae2
Showing 1 changed file with 40 additions and 30 deletions.
70 changes: 40 additions & 30 deletions spec/features/work_packages/edit_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,25 +265,29 @@ def visit!
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 }
Expand All @@ -293,6 +297,23 @@ def visit!
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,
Expand All @@ -302,23 +323,12 @@ def visit!
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
Expand Down

0 comments on commit 1bd1ae2

Please sign in to comment.