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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix permission checks
Mir Bhatia70d8e48df241
diff --git a/modules/meeting/app/components/meetings/index/dialog_component.rb b/modules/meeting/app/components/meetings/index/dialog_component.rbindex c32905bd176..c2204cfb1fc 100644--- a/modules/meeting/app/components/meetings/index/dialog_component.rb+++ b/modules/meeting/app/components/meetings/index/dialog_component.rb@@ -45,11 +45,8 @@ module Meetingsprivatedef render?- if @project- User.current.allowed_in_project?(:create_meetings, @project)- else- User.current.allowed_in_any_project?(:create_meetings)- end+ permission = @meeting.persisted? ? :edit_meetings : :create_meetings+ @project ? User.current.allowed_in_project?(permission, @project) : User.current.allowed_in_any_project?(permission)enddef titlediff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erbindex 958977cfccf..8497812fa17 100644--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb@@ -8,16 +8,16 @@header.with_description { page_description }header.with_breadcrumbs(breadcrumb_items)- if render_create_button?- header.with_action_menu(- menu_arguments: { anchor_align: :end },- button_arguments: { icon: "kebab-horizontal",- classes: "hide-when-print",- "aria-label": "Menu",- data: {- "test-selector": "recurring-meeting-action-menu"- } }- ) do |menu, _button|+ header.with_action_menu(+ menu_arguments: { anchor_align: :end },+ button_arguments: { icon: "kebab-horizontal",+ classes: "hide-when-print",+ "aria-label": "Menu",+ data: {+ "test-selector": "recurring-meeting-action-menu"+ } }+ ) do |menu, _button|+ if edit_meeting?menu.with_item(label: I18n.t(:label_recurring_meeting_series_edit),icon: :gear,@@ -31,49 +31,49 @@) do |item|item.with_leading_visual_icon(icon: :pencil)end+ end++ menu.with_item(+ label: t(:label_icalendar_download),+ href: download_ics_project_recurring_meeting_path(@project, @meeting)+ ) do |item|+ item.with_leading_visual_icon(icon: :calendar)+ end+ if send_emails?menu.with_item(- label: t(:label_icalendar_download),- href: download_ics_project_recurring_meeting_path(@project, @meeting)+ label: t("meeting.label_mail_all_participants"),+ href: notify_project_recurring_meeting_path(@project, @meeting),+ form_arguments: { method: :post }) do |item|- item.with_leading_visual_icon(icon: :calendar)- end-- if send_emails?- menu.with_item(- label: t("meeting.label_mail_all_participants"),- href: notify_project_recurring_meeting_path(@project, @meeting),- form_arguments: { method: :post }- ) do |item|- item.with_leading_visual_icon(icon: :mail)- end+ item.with_leading_visual_icon(icon: :mail)end+ end- if [email protected]_ended? && @meeting.start_time.to_date < Time.zone.today- menu.with_item(- label: t(:label_recurring_meeting_series_end),- href: end_series_dialog_project_recurring_meeting_path(@project, @meeting),- tag: :a,- content_arguments: {- data: { controller: "async-dialog" }- }- ) do |item|- item.with_leading_visual_icon(icon: :"x-circle")- end+ if end_meeting?+ menu.with_item(+ label: t(:label_recurring_meeting_series_end),+ href: end_series_dialog_project_recurring_meeting_path(@project, @meeting),+ tag: :a,+ content_arguments: {+ data: { controller: "async-dialog" }+ }+ ) do |item|+ item.with_leading_visual_icon(icon: :"x-circle")end+ end- if User.current.allowed_in_project?(:delete_meetings, @project)- menu.with_item(- label: I18n.t(:label_recurring_meeting_series_delete),- href: delete_dialog_project_recurring_meeting_path(@project, @meeting),- scheme: :danger,- tag: :a,- content_arguments: {- data: { controller: "async-dialog" }- }- ) do |item|- item.with_leading_visual_icon(icon: :trash)- end+ if delete_meeting?+ menu.with_item(+ label: I18n.t(:label_recurring_meeting_series_delete),+ href: delete_dialog_project_recurring_meeting_path(@project, @meeting),+ scheme: :danger,+ tag: :a,+ content_arguments: {+ data: { controller: "async-dialog" }+ }+ ) do |item|+ item.with_leading_visual_icon(icon: :trash)endendenddiff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.rbindex 69f10958854..4edfd6ce2df 100644--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb@@ -41,14 +41,22 @@ module RecurringMeetings@project = meeting.projectend- def render_create_button?+ def edit_meeting?if @project- User.current.allowed_in_project?(:create_meetings, @project)+ User.current.allowed_in_project?(:edit_meetings, @project)else- User.current.allowed_in_any_project?(:create_meetings)+ User.current.allowed_in_any_project?(:edit_meetings)endend+ def end_meeting?+ [email protected]_ended? && @meeting.start_time.to_date < Time.zone.today && edit_meeting?+ end++ def delete_meeting?+ User.current.allowed_in_project?(:delete_meetings, @project)+ end+def send_emails?@meeting.notify? &&User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)diff --git a/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb b/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rbindex 93321610283..6bd1469aa55 100644--- a/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb+++ b/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb@@ -1,10 +1,9 @@# frozen_string_literal: truemodule RecurringMeetingsclass ScheduleController < ApplicationController- authorize_with_permission :create_meetings, global: true-around_action :with_user_time_zone- before_action :build_meeting+ before_action :require_login, :build_meeting+ no_authorization_required! :humanize_scheduledef humanize_scheduletext = @recurring_meeting.human_frequency_schedulediff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rbindex 362a047985a..3ad084fbad3 100644--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb@@ -210,7 +210,7 @@ RSpec.describe "Recurring meetings CRUD",context "with view permissions only" dolet(:current_user) { other_user }- it "does not allow to act on the recurring meeting" do+ it "does not allow to act on the recurring meeting, except for downloading the ical event" doshow_page.visit!expect(page).to have_no_button "Open"@@ -229,7 +229,11 @@ RSpec.describe "Recurring meetings CRUD",show_page.expect_planned_meeting date: "01/07/2025 01:30 PM"show_page.expect_planned_meeting date: "01/14/2025 01:30 PM"- expect(page).not_to have_test_selector "recurring-meeting-action-menu"+ page.find_test_selector("recurring-meeting-action-menu").click+ page.find(".Overlay")+ page.within(".Overlay") do+ expect(page).to have_css(".ActionListItem-label", count: 1)+ endendendenddiff --git a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_schedule_spec.rb b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_schedule_spec.rbindex 979ce4250dd..735aef9720b 100644--- a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_schedule_spec.rb+++ b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_schedule_spec.rb@@ -57,60 +57,60 @@ RSpec.describe "Recurring meetings schedule text",responseend- before do- login_as(current_user)- end-- describe "setting schedule" do- it "returns the update text" do- expect(subject).to have_http_status(:ok)- expect(subject.body).to include("Every day at 10:00 AM")+ describe "when logged in" do+ before do+ login_as(current_user)end- context "when changing the frequency and interval" do- let(:frequency) { "weekly" }- let(:interval) { "2" }-+ describe "setting schedule" doit "returns the update text" doexpect(subject).to have_http_status(:ok)- expect(subject.body).to include("Every 2 weeks on Thursday at 10:00 AM")+ expect(subject.body).to include("Every day at 10:00 AM")end- end- context "when changing the interval" do- let(:interval) { "2" }+ context "when changing the frequency and interval" do+ let(:frequency) { "weekly" }+ let(:interval) { "2" }- it "returns the update text" do- expect(subject).to have_http_status(:ok)- expect(subject.body).to include("Every 2 days at 10:00 AM")+ it "returns the update text" do+ expect(subject).to have_http_status(:ok)+ expect(subject.body).to include("Every 2 weeks on Thursday at 10:00 AM")+ endend- end- context "when leaving the interval empty" do- let(:interval) { "" }+ context "when changing the interval" do+ let(:interval) { "2" }- it "falls back to the default" do- expect(subject).to have_http_status(:ok)- expect(subject.body).to include("Every day at 10:00 AM")+ it "returns the update text" do+ expect(subject).to have_http_status(:ok)+ expect(subject.body).to include("Every 2 days at 10:00 AM")+ endend- end- context "when requesting with turbo" do- let(:format) { :turbo_stream }+ context "when leaving the interval empty" do+ let(:interval) { "" }- it "returns an update turbo stream" do- expect(subject).to have_http_status(:ok)- expect(subject.body).to include("turbo-stream")- expect(subject.body).to include("Every day at 10:00 AM")+ it "falls back to the default" do+ expect(subject).to have_http_status(:ok)+ expect(subject.body).to include("Every day at 10:00 AM")+ end+ end++ context "when requesting with turbo" do+ let(:format) { :turbo_stream }++ it "returns an update turbo stream" do+ expect(subject).to have_http_status(:ok)+ expect(subject.body).to include("turbo-stream")+ expect(subject.body).to include("Every day at 10:00 AM")+ endendendend- context "when user has no permissions to access" do- let(:current_user) { create(:user) }-+ context "when not logged in" doit "does not allow to request it" do- expect(subject).to have_http_status(:forbidden)+ expect(subject).to have_http_status(:found)endendend