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
Add and update specs
Mir Bhatia6d554a6a3ef8
diff --git a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb b/modules/meeting/app/components/meetings/side_panel/details_component.html.erbindex 9cd9b9d5de4..64432c543d1 100644--- a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/details_component.html.erb@@ -136,18 +136,20 @@endend- people.with_column(mr: 2) do- render(- Primer::Beta::Button.new(- scheme: :link,- underline: false,- tag: :a,- href: manage_participants_dialog_meeting_participants_path(@meeting),- classes: "hide-when-print",- data: { controller: "async-dialog" }- )- ) do- t("label_meeting_show_all_participants")+ if @meeting.editable?+ people.with_column(mr: 2) do+ render(+ Primer::Beta::Button.new(+ scheme: :link,+ underline: false,+ tag: :a,+ href: manage_participants_dialog_meeting_participants_path(@meeting),+ classes: "hide-when-print",+ data: { controller: "async-dialog" }+ )+ ) do+ t("label_meeting_show_all_participants")+ endendendenddiff --git a/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rb b/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rbindex 82a79171877..f22f0ea894b 100644--- a/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rb+++ b/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rb@@ -40,7 +40,6 @@ module Meetings@meeting = meeting@participant = participant- # binding.pryenddef call@@ -48,7 +47,10 @@ module MeetingsPrimer::Beta::Button.new(tag: :a,href: toggle_attendance_meeting_participant_path(@meeting, @participant),- data: { turbo_method: :post },+ data: {+ turbo_method: :post,+ test_selector: "attendance_button_#{@participant.user_id}"+ },align_self: :center)) do |button|diff --git a/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erb b/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erbindex 0c622e7ee3a..611ea1641e3 100644--- a/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erb@@ -1,84 +1,96 @@<%=component_wrapper do- render(border_box_container) do |box|- box.with_header(color: :muted) do- flex_layout(align_items: :center, justify_content: :space_between) do |flex|- flex.with_column do- flex_layout(align_items: :center) do |participants|- participants.with_column do- render(Primer::Beta::Text.new(font_weight: :bold)) { "Participants" }- end- participants.with_column(ml: 2) do- render(Primer::Beta::Counter.new(count: @meeting.invited_participants.count, round: true, scheme: :primary))+ flex_layout do |container|+ if @meeting.errors[:base].present?+ container.with_row(mb: 3) do+ render(Primer::Alpha::Banner.new(mb: 3, icon: :stop, scheme: :danger)) { @meeting.errors[:base].join("\n") }+ end+ end+ container.with_row do+ render(border_box_container) do |box|+ box.with_header(color: :muted) do+ flex_layout(align_items: :center, justify_content: :space_between) do |flex|+ flex.with_column do+ flex_layout(align_items: :center) do |participants|+ participants.with_column do+ render(Primer::Beta::Text.new(font_weight: :bold)) { "Participants" }+ end+ participants.with_column(ml: 2) do+ render(Primer::Beta::Counter.new(count: @meeting.invited_participants.count, round: true, scheme: :primary))+ end+ endend- end- end- if show_mark_all_attended?- flex.with_column do- render(- Primer::Beta::Button.new(- tag: :a,- href: mark_all_attended_meeting_participants_path(@meeting),- align_self: :center,- data: { "turbo-method": :post }- )- ) do |button|- button.with_leading_visual_icon(icon: :"op-person-assigned")- "Mark all as attended"+ if show_mark_all_attended?+ flex.with_column do+ render(+ Primer::Beta::Button.new(+ tag: :a,+ href: mark_all_attended_meeting_participants_path(@meeting),+ align_self: :center,+ data: { "turbo-method": :post }+ )+ ) do |button|+ button.with_leading_visual_icon(icon: :"op-person-assigned")+ "Mark all as attended"+ end+ endendendend- end- end- if @meeting.invited_participants.none?- box.with_row do- render(Primer::Beta::Blankslate.new) do |blankslate|- blankslate.with_visual_icon(icon: :people, size: :medium)- blankslate.with_heading(tag: :h2).with_content("No participants")- blankslate.with_description do- flex_layout do |flex|- flex.with_row(mb: 2) do- render(Primer::Beta::Text.new(color: :subtle)) { "There are no participants yet." }+ if @meeting.invited_participants.none?+ box.with_row do+ render(Primer::Beta::Blankslate.new) do |blankslate|+ blankslate.with_visual_icon(icon: :people, size: :medium)+ blankslate.with_heading(tag: :h2).with_content("No participants")+ blankslate.with_description do+ flex_layout do |flex|+ flex.with_row(mb: 2) do+ render(Primer::Beta::Text.new(color: :subtle)) { "There are no participants yet." }+ end+ endendendend- end- end- else- render(Primer::BaseComponent.new(tag: :div, classes: "participants-list")) do- @meeting.all_changeable_participants.sort.each do |user|- if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }- box.with_row do- flex_layout(align_items: :center, justify_content: :space_between) do |row|- row.with_column(flex: 1, classes: "ellipsis") do- render(- Users::AvatarComponent.new(- user: participant.user,- classes: "op-principal_flex",- hover_card: { active: true, target: :custom }- )- )- end- row.with_column do- flex_layout(align_items: :center, justify_content: :space_between) do |actions|- if @meeting.in_progress?- actions.with_column(ml: 2) do- render(Meetings::SidePanel::Participants::AttendedToggleButtonComponent.new(meeting: @meeting, participant:))- end- end- actions.with_column(ml: 2) do+ else+ render(Primer::BaseComponent.new(tag: :div, classes: "participants-list")) do+ @meeting.all_changeable_participants.sort.each do |user|+ if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }+ box.with_row do+ flex_layout(align_items: :center, justify_content: :space_between) do |row|+ row.with_column(flex: 1, classes: "ellipsis") dorender(- Primer::Beta::IconButton.new(- scheme: :invisible,- tag: :a,- href: meeting_participant_path(@meeting, participant),- data: { turbo_method: :delete },- icon: :x,- aria: { label: "Remove participant" }+ Users::AvatarComponent.new(+ user: participant.user,+ classes: "op-principal_flex",+ hover_card: { active: true, target: :custom }))end+ row.with_column do+ flex_layout(align_items: :center, justify_content: :space_between) do |actions|+ if @meeting.in_progress?+ actions.with_column(ml: 2) do+ render(Meetings::SidePanel::Participants::AttendedToggleButtonComponent.new(meeting: @meeting, participant:))+ end+ end+ actions.with_column(ml: 2) do+ render(+ Primer::Beta::IconButton.new(+ scheme: :invisible,+ tag: :a,+ href: meeting_participant_path(@meeting, participant),+ icon: :x,+ aria: { label: "Remove participant" },+ data: {+ turbo_method: :delete,+ test_selector: "remove_button_#{participant.user_id}"+ }+ )+ )+ end+ end+ endendendenddiff --git a/modules/meeting/app/components/meetings/side_panel/participants/list_component.rb b/modules/meeting/app/components/meetings/side_panel/participants/list_component.rbindex f288b6c5ddc..6e603b8caa7 100644--- a/modules/meeting/app/components/meetings/side_panel/participants/list_component.rb+++ b/modules/meeting/app/components/meetings/side_panel/participants/list_component.rb@@ -39,7 +39,6 @@ module Meetingssuper@meeting = meeting- # binding.pryendprivatediff --git a/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erb b/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erbindex 41fbbffe5ca..d6fc628e276 100644--- a/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erb@@ -12,6 +12,12 @@d.with_body doflex_layout do |container|+ if @meeting.errors[:base].present?+ container.with_row(mb: 3) do+ render(Primer::Alpha::Banner.new(mb: 3, icon: :stop, scheme: :danger)) { @meeting.errors[:base].join("\n") }+ end+ end+container.with_row(mb: 3) dorender(Meetings::EmailUpdatesBannerComponent.new(@meeting))enddiff --git a/modules/meeting/app/controllers/meeting_participants_controller.rb b/modules/meeting/app/controllers/meeting_participants_controller.rbindex 2946fa8897f..e04c61e42d9 100644--- a/modules/meeting/app/controllers/meeting_participants_controller.rb+++ b/modules/meeting/app/controllers/meeting_participants_controller.rb@@ -30,6 +30,7 @@class MeetingParticipantsController < ApplicationControllerinclude OpTurbo::ComponentStream+ include OpTurbo::FlashStreamHelperinclude Meetings::AgendaComponentStreamsbefore_action :authorize@@ -47,20 +48,10 @@ class MeetingParticipantsController < ApplicationControllerreturnend- if MeetingParticipant.create(- meeting: @meeting,- user_id:,- invited: true,- attended: false- )- update_add_user_form_component_via_turbo_stream- update_list_component_via_turbo_stream- update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)+ create_new_participant(user_id)- respond_with_turbo_streams- else- respond_with_flash_error(message: "Error!")- end+ update_list_component_via_turbo_stream+ respond_with_turbo_streamsenddef mark_all_attended@@ -86,13 +77,12 @@ class MeetingParticipantsController < ApplicationControllerenddef destroy- if @participant.destroy+ if @participant.destroy!update_add_user_form_component_via_turbo_streamupdate_list_component_via_turbo_streamupdate_sidebar_participants_component_via_turbo_stream(meeting: @meeting)+respond_with_turbo_streams- else- respond_with_flash_error(message: "Error!")endend@@ -109,4 +99,30 @@ class MeetingParticipantsController < ApplicationControllerdef set_participant@participant = MeetingParticipant.find(params[:id])end++ def send_notification(user)+ if Journal::NotificationConfiguration.active? && [email protected]? && @meeting.notify?+ MeetingMailer.invited(@meeting, user, User.current).deliver_later+ end+ end++ def create_new_participant(user_id)+ participant = MeetingParticipant.create(+ meeting: @meeting,+ user_id:,+ invited: true,+ attended: false+ )++ if participant.persisted?+ send_notification(User.find(user_id))++ update_add_user_form_component_via_turbo_stream+ update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)+ else+ participant.errors.full_messages.each do |msg|+ @meeting.errors.add(:base, msg)+ end+ end+ endenddiff --git a/modules/meeting/app/forms/meeting/participant.rb b/modules/meeting/app/forms/meeting/participant.rbindex 5ebc11333fb..28e2733f513 100644--- a/modules/meeting/app/forms/meeting/participant.rb+++ b/modules/meeting/app/forms/meeting/participant.rb@@ -45,7 +45,10 @@ class Meeting::Participant < ApplicationFormmultiple: false,isOpenedInModal: true,hoverCards: true,- placeholder: I18n.t("activerecord.attributes.meeting_agenda_item.presenter")+ placeholder: I18n.t("activerecord.attributes.meeting_agenda_item.presenter"),+ data: {+ "test-selector": "participants-dialog-autocomplete"+ }})enddiff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rbindex 77d87002176..8d9b710017b 100644--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb@@ -103,17 +103,14 @@ RSpec.describe "Recurring meetings creation",# Add participantstemplate_page.open_participant_formtemplate_page.in_participant_form do- template_page.expect_participant_invited(user, invited: true)- template_page.expect_participant_invited(other_user, invited: false)- template_page.expect_available_participants(count: 2)- expect(page).to have_button("Save")-- template_page.invite_participant(other_user)+ template_page.expect_participant(user, editable: false)+ template_page.expect_available_participants(count: 1)- template_page.expect_participant_invited(user, invited: true)- template_page.expect_participant_invited(other_user, invited: true)+ template_page.select_participant(other_user)+ template_page.expect_participant(other_user, editable: false)+ template_page.expect_available_participants(count: 2)- click_on("Save")+ click_on "Cancel"endwait_for_network_idlediff --git a/modules/meeting/spec/features/structured_meetings/mobile_structure_meeting_spec.rb b/modules/meeting/spec/features/structured_meetings/mobile_structure_meeting_spec.rbindex d82483a7868..bbadecafdc0 100644--- a/modules/meeting/spec/features/structured_meetings/mobile_structure_meeting_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/mobile_structure_meeting_spec.rb@@ -61,6 +61,7 @@ RSpec.describe "Meetings CRUD",create(:meeting,:author_participates,project:,+ state: :in_progress,author: user)end@@ -80,41 +81,40 @@ RSpec.describe "Meetings CRUD",show_page.open_participant_formshow_page.in_participant_form do- show_page.expect_participant(user, invited: true, attended: false)- show_page.expect_participant(other_user, invited: false, attended: false)- show_page.expect_available_participants(count: 2)- expect(page).to have_button("Save")-- check(id: "checkbox_invited_#{other_user.id}")- click_on("Save")- end-- show_page.expect_participants(count: 2)+ show_page.expect_participant(user)- # when meeting is closed, can view but not edit- show_page.close_meeting+ show_page.toggle_attendance(user)+ show_page.expect_participant(user, attended: true)+ show_page.expect_available_participants(count: 1)- show_page.open_participant_form- show_page.in_participant_form do- show_page.expect_participant(user, invited: true, attended: false, editable: false)- show_page.expect_participant(other_user, invited: true, attended: false, editable: false)+ show_page.select_participant(other_user)+ show_page.expect_participant(other_user)show_page.expect_available_participants(count: 2)- expect(page).to have_no_button("Save")end- show_page.close_dialog-- show_page.reopen_meeting- # other_use can view, but not edit+ # other_user cannot manage participantslogin_as other_usershow_page.visit!+ show_page.expect_no_participants_form++ # when meeting is closed, cannot manage participants+ login_as user+ show_page.visit!+ show_page.close_meeting_from_in_progress++ show_page.expect_no_participants_form++ # when meeting is open, can add/remove participants but not mark as attended+ show_page.reopen_meeting+show_page.open_participant_formshow_page.in_participant_form do- show_page.expect_participant(user, invited: true, attended: false, editable: false)- show_page.expect_participant(other_user, invited: true, attended: false, editable: false)- show_page.expect_available_participants(count: 2)- expect(page).to have_no_button("Save")+ show_page.expect_participant(user, editable: false)+ show_page.expect_participant(other_user, editable: false)++ show_page.remove_participant(other_user)+ show_page.expect_available_participants(count: 1)endendenddiff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rbindex 46e2d9e7b01..a08126c85d2 100644--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb@@ -298,10 +298,9 @@ RSpec.describe "Meetings CRUD",show_page.open_participant_formshow_page.in_participant_form do- check(id: "checkbox_invited_#{other_user.id}")- check(id: "checkbox_attended_#{other_user.id}")+ show_page.select_participant(other_user)- click_on("Save")+ click_on "Cancel"endwait_for_network_idle@@ -327,16 +326,20 @@ RSpec.describe "Meetings CRUD",click_on "Create meeting"new_meeting = Meeting.last+ copied_meeting_page = Pages::Meetings::Show.new(new_meeting)expect(page).to have_current_path "/projects/#{project.identifier}/meetings/#{new_meeting.id}"# check for copied agenda items- expect(page).to have_content "My agenda item"+ copied_meeting_page.expect_agenda_item title: "My agenda item"++ copied_meeting_page.start_meeting# check for copied participants with attended status reset- page.find_test_selector("manage-participants-button").click- expect(page).to have_modal("Participants")- expect(page).to have_field(id: "checkbox_invited_#{other_user.id}", checked: true)- expect(page).to have_field(id: "checkbox_attended_#{other_user.id}", checked: false)+ copied_meeting_page.open_participant_form+ copied_meeting_page.in_participant_form do+ copied_meeting_page.expect_participant(user)+ copied_meeting_page.expect_participant(other_user)+ end# check for email notifications for both participantsperform_enqueued_jobsdiff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_participant_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_participant_spec.rbindex 6e8c60b9f9f..d9cb0ff1139 100644--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_participant_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_participant_spec.rb@@ -61,6 +61,7 @@ RSpec.describe "Meetings participants",create(:meeting,:author_participates,project:,+ state: :in_progress,author: user)end@@ -77,13 +78,15 @@ RSpec.describe "Meetings participants",show_page.open_participant_formshow_page.in_participant_form do- show_page.expect_participant(user, invited: true, attended: false)- show_page.expect_participant(other_user, invited: false, attended: false)- show_page.expect_available_participants(count: 2)- expect(page).to have_button("Save")+ show_page.expect_participant(user)+ show_page.expect_available_participants(count: 1)++ show_page.toggle_attendance(user)+ show_page.expect_participant(user, attended: true)- check(id: "checkbox_invited_#{other_user.id}")- click_on("Save")+ show_page.select_participant(other_user)+ show_page.expect_participant(other_user)+ show_page.expect_available_participants(count: 2)endexpect(page).to have_css("#meetings-side-panel-participants-component", text: 2)diff --git a/modules/meeting/spec/support/pages/meetings/mobile/show.rb b/modules/meeting/spec/support/pages/meetings/mobile/show.rbindex 0b81b0f9323..7f3ff6674c5 100644--- a/modules/meeting/spec/support/pages/meetings/mobile/show.rb+++ b/modules/meeting/spec/support/pages/meetings/mobile/show.rb@@ -39,11 +39,17 @@ module Pages::Meetings::Mobileendend+ def expect_no_participants_form+ within(meeting_details_container) do+ expect(page).to have_no_link("Show all")+ end+ end+def open_participant_formwithin(meeting_details_container) doclick_link_or_button "Show all"end- expect(page).to have_modal("Participants")+ expect(page).to have_modal("Manage participants")endendenddiff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rbindex fae3af6fdf7..64c8cfebd71 100644--- a/modules/meeting/spec/support/pages/meetings/show.rb+++ b/modules/meeting/spec/support/pages/meetings/show.rb@@ -448,17 +448,28 @@ module Pages::Meetingsdef open_participant_formpage.find_test_selector("manage-participants-button").click- expect_modal("Participants")+ expect_modal("Manage participants")enddef in_participant_form(&)- page.within_modal("Participants", &)+ page.within_modal("Manage participants", &)end- def expect_participant(participant, invited: false, attended: false, editable: true)+ def expect_participant(participant, attended: false, editable: true)expect(page).to have_text(participant.name)- expect(page).to have_field(id: "checkbox_invited_#{participant.id}", checked: invited, disabled: !editable)- expect(page).to have_field(id: "checkbox_attended_#{participant.id}", checked: attended, disabled: !editable)++ if !editable+ expect(page).to have_no_selector("[data-test-selector='attendance_button_#{participant.id}']", text: "Attended")+ expect(page).to have_no_selector("[data-test-selector='attendance_button_#{participant.id}']", text: "Mark as attended")++ return+ end++ if attended+ expect(page).to have_css("[data-test-selector='attendance_button_#{participant.id}']", text: "Attended")+ else+ expect(page).to have_css("[data-test-selector='attendance_button_#{participant.id}']", text: "Mark as attended")+ endenddef expect_participant_invited(participant, invited: true)@@ -474,6 +485,25 @@ module Pages::Meetingsendend+ def toggle_attendance(participant)+ expect(page).to have_text(participant.name)+ click_link_or_button("attendance_button_#{participant.id}")+ end++ def select_participant(participant)+ select_autocomplete page.find('[data-test-selector="participants-dialog-autocomplete"]'),+ query: participant.firstname,+ select_text: participant.name,+ results_selector: "body"++ click_on "Add"+ end++ def remove_participant(participant)+ expect(page).to have_text(participant.name)+ click_link_or_button("remove_button_#{participant.id}")+ end+def expect_available_participants(count:)expect(page).to have_link(class: "op-principal--name", count:)enddiff --git a/modules/meeting/spec/workers/meetings/pdf/default/exporter_spec.rb b/modules/meeting/spec/workers/meetings/pdf/default/exporter_spec.rbindex 21ddd0b44dc..974b892ebed 100644--- a/modules/meeting/spec/workers/meetings/pdf/default/exporter_spec.rb+++ b/modules/meeting/spec/workers/meetings/pdf/default/exporter_spec.rb@@ -145,7 +145,7 @@ RSpec.describe Meetings::PDF::Default::Exporter dotitle: "Agenda Item in Backlog", presenter: user, notes: "# yeah")endlet(:invited) { create(:meeting_participant, user: other_user, meeting:, invited: true) }- let(:attended) { create(:meeting_participant, :attendee, user: user, meeting:) }+ let(:attended) { create(:meeting_participant, user: user, meeting:, invited: true, attended: true) }before doUser.current = user@@ -156,6 +156,7 @@ RSpec.describe Meetings::PDF::Default::Exporter domeeting_backlog_item # create the backlog itemattended # create the attended participantinvited # create the invited participant+ meeting.reload # ensure participants are accessibleendcontext "with bells and whistles options" do