diff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rb index 4b80371b21f3..3be97f3d5cd0 100644 --- a/app/components/work_packages/activities_tab/index_component.rb +++ b/app/components/work_packages/activities_tab/index_component.rb @@ -78,7 +78,7 @@ def polling_interval end def adding_comment_allowed? - User.current.allowed_in_project?(:add_work_package_notes, @work_package.project) + User.current.allowed_in_work_package?(:add_work_package_notes, @work_package) end end end diff --git a/spec/features/activities/work_package/activities_spec.rb b/spec/features/activities/work_package/activities_spec.rb index 51adef83a422..0b00261c4d60 100644 --- a/spec/features/activities/work_package/activities_spec.rb +++ b/spec/features/activities/work_package/activities_spec.rb @@ -82,6 +82,14 @@ member_with_roles: { project => user_role_with_editing_permission }) end + let(:comment_work_package_role) { create(:comment_work_package_role) } + let(:user_with_commenting_permission_via_a_work_package_share) do + create(:user, + firstname: "A", + lastname: "Commenter", + member_with_roles: { work_package => comment_work_package_role }) + end + let(:work_package) { create(:work_package, project:, author: admin) } let(:first_comment) do create(:work_package_journal, user: admin, notes: "First comment by admin", journable: work_package, @@ -205,6 +213,22 @@ end end end + + context "when a user has been shared a work package with at least comment rights" do + current_user { user_with_commenting_permission_via_a_work_package_share } + + before do + wp_page.visit! + wp_page.wait_for_activity_tab + end + + it "allows commenting on the work package" do + activity_tab.expect_input_field + + activity_tab.add_comment(text: "First comment by user with commenting permission via a work package share") + activity_tab.expect_journal_notes(text: "First comment by user with commenting permission via a work package share") + end + end end context "when a workpackage is created and visited by the same user" do