Skip to content

Commit

Permalink
Merge pull request #16260 from opf/feature/56651-meetings-tab-display…
Browse files Browse the repository at this point in the history
…-related-meetings-chronologically

[#56651] Display related meetings chronologically
  • Loading branch information
dombesz authored Jul 27, 2024
2 parents 3b33fdc + b5b4d57 commit a6b6536
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,20 @@ def get_agenda_items_of_work_package(direction)
.includes(:meeting)
.where(meeting_id: Meeting.visible(current_user))
.where(work_package_id: @work_package.id)
.order("meetings.start_time": :asc)
.order(sort_clause(direction))

comparison = direction == :past ? "<" : ">="
agenda_items.where("meetings.start_time + (interval '1 hour' * meetings.duration) #{comparison} ?", Time.zone.now)
end

def sort_clause(direction)
case direction
when :upcoming
"meetings.start_time ASC"
when :past
"meetings.start_time DESC"
else
raise ArgumentError, "Invalid direction: #{direction}. Must be one of :upcoming or :past."
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,15 @@
expect(page).to have_content(second_meeting.title)
expect(page).to have_content(meeting_agenda_item_of_second_meeting.notes)
end

meeting_containers = page.all("[data-test-selector^='op-meeting-container-']")
expect(meeting_containers[0]["data-test-selector"]).to eq("op-meeting-container-#{first_meeting.id}")
expect(meeting_containers[1]["data-test-selector"]).to eq("op-meeting-container-#{second_meeting.id}")
end
end

context "when the work_package was already referenced in past meetings" do
let!(:first_past_meeting) { create(:structured_meeting, project:, start_time: Date.yesterday - 10.hours) }
let!(:first_past_meeting) { create(:structured_meeting, project:, start_time: Date.yesterday - 11.hours) }
let!(:second_past_meeting) { create(:structured_meeting, project:, start_time: Date.yesterday - 10.hours) }

let!(:first_meeting_agenda_item_of_first_past_meeting) do
Expand All @@ -266,16 +270,20 @@

meetings_tab.switch_to_past_meetings_section

page.within_test_selector("op-meeting-container-#{second_past_meeting.id}") do
expect(page).to have_content(second_past_meeting.title)
expect(page).to have_content(meeting_agenda_item_of_second_past_meeting.notes)
end

page.within_test_selector("op-meeting-container-#{first_past_meeting.id}") do
expect(page).to have_content(first_past_meeting.title)
expect(page).to have_content(first_meeting_agenda_item_of_first_past_meeting.notes)
expect(page).to have_content(second_meeting_agenda_item_of_first_past_meeting.notes)
end

page.within_test_selector("op-meeting-container-#{second_past_meeting.id}") do
expect(page).to have_content(second_past_meeting.title)
expect(page).to have_content(meeting_agenda_item_of_second_past_meeting.notes)
end
meeting_containers = page.all("[data-test-selector^='op-meeting-container-']")
expect(meeting_containers[0]["data-test-selector"]).to eq("op-meeting-container-#{second_past_meeting.id}")
expect(meeting_containers[1]["data-test-selector"]).to eq("op-meeting-container-#{first_past_meeting.id}")
end
end

Expand Down

0 comments on commit a6b6536

Please sign in to comment.