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 specs and copy service
Jonas Jabari9105759d8ff8
diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rbindex fc190c32fdd..d3249374006 100644--- a/modules/meeting/app/components/meeting_sections/show_component.rb+++ b/modules/meeting/app/components/meeting_sections/show_component.rb@@ -51,6 +51,14 @@ module MeetingSections@meeting_section.idend+ def insert_target_modified?+ true+ end++ def insert_target_modifier_id+ "meeting-agenda-items-new-item-#{@meeting_section.id}"+ end+def editable?@meeting_section.editable? && User.current.allowed_in_project?(:manage_agendas, @meeting_section.project)end@@ -93,13 +101,5 @@ module MeetingSections"target-allowed-drag-type": "agenda-item" # the type of dragged items which are allowed to be dropped in this target}end-- def insert_target_modified?- true- end-- def insert_target_modifier_id- "meeting-agenda-items-new-item"- endendenddiff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex accf2c901fc..005f8520744 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -91,16 +91,19 @@ module Meetingsenddef update_show_items_via_turbo_stream(meeting: @meeting)- # TODO: scope to specific section in cases where only one section is affected for less computationmeeting.sections.each do |meeting_section|- agenda_items = meeting_section.agenda_items.with_includes_to_render- first_and_last = [agenda_items.first, agenda_items.last]+ update_show_items_of_section_via_turbo_stream(meeting_section:)+ end+ end- agenda_items.each do |meeting_agenda_item|- update_via_turbo_stream(- component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)- )- end+ def update_show_items_of_section_via_turbo_stream(meeting_section: @meeting_section)+ agenda_items = meeting_section.agenda_items.with_includes_to_render+ first_and_last = [agenda_items.first, agenda_items.last]++ agenda_items.each do |meeting_agenda_item|+ update_via_turbo_stream(+ component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)+ )endend@@ -207,20 +210,24 @@ module Meetingstype: @agenda_item_type)else- # TODO: more specific UI update as before- update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)- # add_before_via_turbo_stream(- # component: MeetingAgendaItems::ItemComponent.new(- # state: :show,- # meeting_agenda_item:- # ),- # target_component: MeetingAgendaItems::ListComponent.new(meeting: @meeting)- # )+ update_section_header_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)++ add_before_via_turbo_stream(+ component: MeetingAgendaItems::ItemComponent.new(+ state: :show,+ meeting_agenda_item:+ ),+ target_component: MeetingSections::ShowComponent.new(+ meeting_section: @meeting_agenda_item.meeting_section+ )+ )+update_new_component_via_turbo_stream(hidden: false,meeting_section: meeting_agenda_item.meeting_section,type: @agenda_item_type)+update_show_items_via_turbo_streamendend@@ -229,7 +236,7 @@ module Meetingsif clear_slateupdate_list_via_turbo_streamelse- update_show_items_via_turbo_stream+ update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)if meeting_agenda_item.meeting_section.agenda_items.empty?# Show the empty section state by updating the whole section if items are emptyupdate_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)@@ -249,27 +256,24 @@ module Meetings# Note: The `remove_component` and the `component` are pointing to the same# component, but we still need to instantiate them separately, otherwise re-adding# of the item will render and empty component.- # remove_component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)- # remove_via_turbo_stream(component: remove_component)-- # component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)- # target_component =- # if @meeting_agenda_item.lower_item- # MeetingAgendaItems::ItemComponent.new(- # state: :show,- # meeting_agenda_item: @meeting_agenda_item.lower_item- # )- # else- # MeetingSections::ShowComponent.new(- # meeting_section: @meeting_agenda_item.meeting_section- # )- # # MeetingAgendaItems::ListComponent.new(meeting: @meeting)- # end- # add_before_via_turbo_stream(component:, target_component:)- # update_show_items_via_turbo_stream-- # TODO: review above implementation and adapt properly to section based approach- update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)+ remove_component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)+ remove_via_turbo_stream(component: remove_component)++ component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)++ target_component = if @meeting_agenda_item.lower_item+ MeetingAgendaItems::ItemComponent.new(+ state: :show,+ meeting_agenda_item: @meeting_agenda_item.lower_item+ )+ else+ MeetingSections::ShowComponent.new(+ meeting_section: @meeting_agenda_item.meeting_section+ )+ end++ add_before_via_turbo_stream(component:, target_component:)+ update_show_items_of_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)enddef render_base_error_in_flash_message_via_turbo_stream(errors)diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rbindex d69ae64c049..a6d83eb6934 100644--- a/modules/meeting/app/models/meeting_agenda_item.rb+++ b/modules/meeting/app/models/meeting_agenda_item.rb@@ -72,6 +72,8 @@ class MeetingAgendaItem < ApplicationRecord# after_destroy :delete_meeting_section_if_emptydef add_to_latest_meeting_section+ return if meeting.nil?+if meeting_section_id.nil?meeting_section = meeting.sections.order(position: :asc).lastdiff --git a/modules/meeting/app/services/meetings/copy_service.rb b/modules/meeting/app/services/meetings/copy_service.rbindex 1e40c87ea05..3585e91f805 100644--- a/modules/meeting/app/services/meetings/copy_service.rb+++ b/modules/meeting/app/services/meetings/copy_service.rb@@ -102,8 +102,14 @@ module Meetingsdef copy_meeting_agenda(copy)if meeting.is_a?(StructuredMeeting)- meeting.agenda_items.each do |agenda_item|- copy.agenda_items << agenda_item.dup+ meeting.sections.each do |section|+ copy.sections << section.dup+ copied_section = copy.reload.sections.last+ section.agenda_items.each do |agenda_item|+ copied_agenda_item = agenda_item.dup+ copied_agenda_item.meeting_id = copy.id+ copied_section.agenda_items << copied_agenda_item+ endendelseMeetingAgenda.create!(diff --git a/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb b/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rbindex 01d2e32a25e..b2f584bacd1 100644--- a/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb@@ -53,6 +53,7 @@ RSpec.describe "Upload attachment to meetings", :js doshow_page.visit!show_page.add_agenda_item(save: false) do+ sleep 1 # TODO: dynamically wait - without sleep running into timing issues locallyclick_on "Notes"enddiff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rbindex 184087f12b8..b242aa3e23e 100644--- a/modules/meeting/spec/features/structured_meetings/history_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb@@ -161,6 +161,10 @@ RSpec.describe "history",click_on "Save"end+ # dynamically wait for the item to be updated successfully+ # before checking the history modal, otherwise running into timing issues+ show_page.expect_agenda_item(title: "Updated title")+history_page.open_history_modalhistory_page.expect_event('Agenda item "Updated title"',@@ -202,6 +206,7 @@ RSpec.describe "history",show_page.remove_agenda_item(second)history_page.open_history_modal+item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: 'Agenda item "Second"')expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")@@ -221,6 +226,7 @@ RSpec.describe "history",expect(wp_item).to be_presenthistory_page.open_history_modal+item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: work_package.to_s.strip)expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")@@ -241,6 +247,7 @@ RSpec.describe "history",expect(wp_item).to be_presenthistory_page.open_history_modal+item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: changed_wp.to_s.strip)expect(item).to have_css(".op-activity-list--item-subtitle", text: "updated by")@@ -271,6 +278,7 @@ RSpec.describe "history",# Is visible for userhistory_page.open_history_modal+item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: other_wp.to_s.strip)expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")@@ -281,6 +289,7 @@ RSpec.describe "history",show_page.visit!history_page.open_history_modal+item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")@@ -289,6 +298,10 @@ RSpec.describe "history",login_as(user)show_page.visit!show_page.remove_agenda_item wp_item++ # dynamically wait for the item to be removed successfully+ show_page.expect_no_agenda_item(title: wp_item.to_s)+history_page.open_history_modalitem = history_page.first_item@@ -301,6 +314,7 @@ RSpec.describe "history",show_page.visit!history_page.open_history_modal+item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))expect(item).to have_css(".op-activity-list--item-subtitle", text: "removed by")@@ -318,7 +332,7 @@ RSpec.describe "history",show_page.expect_agenda_item(title: "My agenda item")item = MeetingAgendaItem.find_by(title: "My agenda item")- show_page.cancel_add_form+ show_page.cancel_add_form(item)show_page.select_action(item, "Add notes")editor.set_markdown "# Hello there"diff --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 a4985cf3f22..7811151dfcf 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@@ -90,15 +90,17 @@ RSpec.describe "Structured meetings CRUD",endshow_page.expect_agenda_item title: "My agenda item"- show_page.cancel_add_form-item = MeetingAgendaItem.find_by(title: "My agenda item")+ show_page.cancel_add_form(item)++ # can updateshow_page.edit_agenda_item(item) dofill_in "Title", with: "Updated title"click_on "Save"endshow_page.expect_no_agenda_item title: "My agenda item"+ show_page.expect_agenda_item title: "Updated title"# Can add multiple itemsshow_page.add_agenda_item do@@ -136,7 +138,7 @@ RSpec.describe "Structured meetings CRUD",# Can removeshow_page.remove_agenda_item firstshow_page.assert_agenda_order! "Updated title", "Second"- show_page.cancel_add_form+ show_page.cancel_add_form(second)# Can link work packagesshow_page.add_agenda_item(type: WorkPackage) do@@ -164,7 +166,7 @@ RSpec.describe "Structured meetings CRUD",endshow_page.select_action(item, I18n.t(:label_sort_lowest))- show_page.cancel_add_form+ show_page.cancel_add_form(item)show_page.add_agenda_item dofill_in "Title", with: "My agenda item"@@ -223,6 +225,16 @@ RSpec.describe "Structured meetings CRUD",click_on I18n.t(:label_icalendar_download)+ # dynamically wait for download to finish, otherwise expectation is too early+ seconds = 0+ while seconds < 5+ # don't use subject as it will not get reevaluated in the next iteration+ break if @download_list.refresh_from(page).latest_download.to_s != ""++ sleep 1+ seconds += 1+ end+expect(subject).to end_with ".ics"endend@@ -237,9 +249,10 @@ RSpec.describe "Structured meetings CRUD",endshow_page.expect_agenda_item title: "My agenda item"- show_page.cancel_add_form-item = MeetingAgendaItem.find_by!(title: "My agenda item")++ show_page.cancel_add_form(item)+show_page.edit_agenda_item(item) do# Side effect: update the itemitem.update!(title: "Updated title")@@ -261,7 +274,9 @@ RSpec.describe "Structured meetings CRUD",endshow_page.expect_agenda_item title: "My agenda item"- show_page.cancel_add_form+ item = MeetingAgendaItem.find_by!(title: "My agenda item")++ show_page.cancel_add_form(item)click_on("op-meetings-header-action-trigger")click_on "Copy"diff --git a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rbindex f0fcd27170b..4f42ac4ad93 100644--- a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb+++ b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb@@ -92,7 +92,7 @@ RSpec.describe Meetings::CopyService, "integration", type: :model doendit "copies the agenda item" do- expect(copy.agenda_items.length)+ expect(copy.reload.agenda_items.length).to eq 1expect(copy.agenda_items.first.notes)@@ -121,6 +121,7 @@ RSpec.describe Meetings::CopyService, "integration", type: :model docontext "when asking to copy attachments" dolet(:params) { { copy_attachments: true } }+it "copies the attachment" doexpect(copy.attachments.length).to eq 1diff --git a/modules/meeting/spec/support/pages/structured_meeting/history.rb b/modules/meeting/spec/support/pages/structured_meeting/history.rbindex a4df4a6f691..33bcabb2ad0 100644--- a/modules/meeting/spec/support/pages/structured_meeting/history.rb+++ b/modules/meeting/spec/support/pages/structured_meeting/history.rb@@ -37,6 +37,9 @@ module Pages::StructuredMeetingretry_block doclick_link_or_button "op-meetings-header-action-trigger"click_link_or_button "History"+ # dynamically wait for the modal to be loaded+ # otherwise running into timing issues with `item = history_page.first_item`+ expect(page).to have_css(".op-activity-list--item")endend@@ -66,9 +69,7 @@ module Pages::StructuredMeetingdef find_item(detail)detail = page.find("li.op-activity-list--item-detail", text: detail)- item = detail.ancestor(".op-activity-list--item-details").ancestor(".op-activity-list--item")-- item+ detail.ancestor(".op-activity-list--item-details").ancestor(".op-activity-list--item")endendenddiff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rbindex 8b3b2a6ae18..c29e6254e19 100644--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb@@ -48,8 +48,8 @@ module Pages::StructuredMeetingendend- def cancel_add_form- page.within("#meeting-agenda-items-new-component") do+ def cancel_add_form(item)+ page.within("#meeting-agenda-items-new-component-#{item.meeting_section_id}") doclick_on I18n.t(:button_cancel)expect(page).to have_no_link I18n.t(:button_cancel)end