Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Pin the decision points of "Alle Meetings" that no spec held

Guido Boyke1b1d574877ff
diff --git a/app/controllers/organisations/meetings_overview_controller.rb b/app/controllers/organisations/meetings_overview_controller.rb
index 2fc8cc1..f017c98 100644
--- a/app/controllers/organisations/meetings_overview_controller.rb
+++ b/app/controllers/organisations/meetings_overview_controller.rb
@@ -104,8 +104,8 @@ module Organisations
end
helper_method :meeting_filter_projects
- # No readable meeting anywhere yet: the page shows its first-time state and
- # no filter bar, like the project page before its first meeting.
+ # No readable meeting anywhere yet: the list shows its first-time state. The
+ # filter bar stands anyway (_list_head explains why).
def meetings_overview_first_use?
return @meetings_overview_first_use if defined?(@meetings_overview_first_use)
diff --git a/spec/requests/organisations/meetings_overview_create_spec.rb b/spec/requests/organisations/meetings_overview_create_spec.rb
index 5bc3512..be03614 100644
--- a/spec/requests/organisations/meetings_overview_create_spec.rb
+++ b/spec/requests/organisations/meetings_overview_create_spec.rb
@@ -326,6 +326,22 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request do
end
end
+ describe 'pages of the refreshed list' do
+ it 'point to the overview, not to the project the meeting went into' do
+ 2.times { |index| create_meeting(project: project_a, title: "Alt #{index}", creator: writer_a) }
+ sign_in writer_a
+
+ post organisation_project_meetings_path(organisation, project_a),
+ params: { context: 'overview_modal', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current }, items: 2 },
+ as: :turbo_stream
+
+ next_link = Nokogiri::HTML(response.body).at_css("a[title='#{I18n.t('views.shared.pagination_compact.next_page')}']")
+ expect(next_link).to be_present
+ expect(URI.parse(next_link['href']).path).to eq(overview_path)
+ expect(Rack::Utils.parse_nested_query(URI.parse(next_link['href']).query)).to include('page' => '2', 'items' => '2')
+ end
+ end
+
describe 'POST create from the modal without turbo (no JavaScript)' do
it 'sends a successful save back to the overview it started from' do
sign_in writer_a
@@ -336,6 +352,18 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request do
expect(response).to redirect_to(organisation_meetings_path(organisation))
end
+ it 'keeps the list state on the way back' do
+ sign_in writer_a
+
+ post organisation_project_meetings_path(organisation, project_a),
+ params: { context: 'overview_modal', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current },
+ filter: { project: [project_a.id] }, sort: { column: 'title', direction: 'asc' } }
+
+ expect(URI.parse(response.location).path).to eq(overview_path)
+ expect(Rack::Utils.parse_nested_query(URI.parse(response.location).query))
+ .to include('filter' => { 'project' => [project_a.id] }, 'sort' => { 'column' => 'title', 'direction' => 'asc' })
+ end
+
it 'renders the modal frame again on an invalid save' do
sign_in writer_a
diff --git a/spec/requests/organisations/meetings_overview_spec.rb b/spec/requests/organisations/meetings_overview_spec.rb
index 1c48743..d89c087 100644
--- a/spec/requests/organisations/meetings_overview_spec.rb
+++ b/spec/requests/organisations/meetings_overview_spec.rb
@@ -158,6 +158,21 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
ActsAsTenant.with_tenant(organisation) { alpha.update!(notes: 'Retro im Text') }
expect(titles(list(search: 'Retro', search_mode: 'title_only'))).to eq(['Beta Retro'])
end
+
+ it 'offers "Projekt" with "or" and "not", the two the list applies' do
+ categories = JSON.parse(list.find('[data-controller="filter-bar"]')['data-filter-bar-categories-value'])
+ expect(categories.find { |category| category['key'] == 'project' }['allowed_operators']).to eq(%w[or not])
+ end
+
+ it 'reads an empty or malformed project value as no condition' do
+ all = ['Beta Retro', 'Alpha Kickoff', 'Gamma Sync']
+ expect(titles(list(filter: { project: [''] }))).to eq(all)
+ expect(titles(list(filter: { project: [{ 'a' => project_a.id }] }))).to eq(all)
+ end
+
+ it 'reads a search of the wrong shape as no search' do
+ expect(titles(list(search: { 'a' => 'Retro' }))).to eq(['Beta Retro', 'Alpha Kickoff', 'Gamma Sync'])
+ end
end
describe 'old addresses' do
@@ -179,6 +194,11 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
get overview_path, params: { project_id: { 'a' => '1' } }
expect(response).to redirect_to(overview_path)
end
+
+ it 'lets a condition the address already carries win over the old parameter' do
+ get overview_path, params: { project_id: project_a.id, filter: { project: [project_b.id] } }
+ expect(response).to redirect_to(organisation_meetings_path(organisation, filter: { project: [project_b.id] }))
+ end
end
describe 'columns, sort and pages' do
@@ -224,6 +244,18 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
expect(titles(list(items: 2, page: 2, filter: { project: [project_a.id] }))).to eq(['Seite 2'])
end
+ it 'carries only the list state into the page links, not every word of the address' do
+ Prosopite.pause do
+ 3.times { |index| create_meeting(project: project_a, title: "Seite #{index}", occurred_at: index.days.ago) }
+ end
+
+ page = list(items: 2, utm_source: 'newsletter')
+ next_link = page.find("#meetings_overview_results a[title='#{I18n.t('views.shared.pagination_compact.next_page')}']")
+ query = Rack::Utils.parse_nested_query(URI.parse(next_link[:href]).query)
+ expect(query).to include('page' => '2', 'items' => '2')
+ expect(query).not_to have_key('utm_source')
+ end
+
it 'lets the address follow the list frame, so the bar reads sort and page from it' do
create_meeting(project: project_a, title: 'Alpha Kickoff')
page = list
@@ -241,6 +273,30 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
expect(response.body).to include('<turbo-frame id="meetings_overview_results"', 'Alpha Kickoff')
expect(response.body).not_to include('data-controller="filter-bar"')
end
+
+ # The bar reloads its chip sentence through a frame of its own after every
+ # change; a full page in its place would put a second list into the head.
+ it 'answers the sentence frame of the bar alone' do
+ create_meeting(project: project_a, title: 'Alpha Kickoff')
+ get overview_path, params: { filter: { project: [project_a.id] } },
+ headers: { 'Turbo-Frame' => 'meetings_overview_results_sentence' }
+
+ expect(response).to have_http_status(:ok)
+ expect(page_body).to have_css('turbo-frame#meetings_overview_results_sentence', text: 'Projekt Alpha')
+ expect(response.body).not_to include('<turbo-frame id="meetings_overview_results"')
+ end
+ end
+
+ describe 'the project page next to it' do
+ it 'lists only the meetings of its own project, also for a reader of both' do
+ alpha = create_meeting(project: project_a, title: 'Alpha Kickoff')
+ create_meeting(project: project_b, title: 'Beta Retro')
+ sign_in reader
+ get organisation_project_meetings_path(organisation, project_a)
+
+ expect(response).to have_http_status(:ok)
+ expect(page_body.all('#meetings_results tr[data-meeting-id]').map { |row| row['data-meeting-id'] }).to eq([alpha.id])
+ end
end
describe 'row navigation' do
diff --git a/spec/requests/organisations/meetings_overview_views_spec.rb b/spec/requests/organisations/meetings_overview_views_spec.rb
index 99cce37..c7ae0cf 100644
--- a/spec/requests/organisations/meetings_overview_views_spec.rb
+++ b/spec/requests/organisations/meetings_overview_views_spec.rb
@@ -103,6 +103,16 @@ RSpec.describe 'Organisations::MeetingsOverview saved views', :ci_guard, type: :
expect(overview_titles(page_at(overview_path, smart_folder_id: both.id))).to contain_exactly('Alpha Kickoff', 'Beta Retro')
end
+ # The people of a creator condition are looked up in the organisation; a
+ # view without a project has no project to ask for it.
+ it 'stores a creator condition without a project' do
+ save_from_filters(smart_folder_name: 'Von mir', filter: { creator: [user.id] })
+
+ mine = SmartFolder.find_by!(name: 'Von mir')
+ expect(mine.project_id).to be_nil
+ expect(SmartFolderDissolver.new(mine, user).call.ad_hoc_filters).to eq('creator' => [user.id])
+ end
+
it 'refuses a project the reader cannot read, without a folder' do
expect { save_from_filters(smart_folder_name: 'Geheim', filter: { project: [project_hidden.id] }) }
.not_to change(SmartFolder, :count)
@@ -134,6 +144,14 @@ RSpec.describe 'Organisations::MeetingsOverview saved views', :ci_guard, type: :
on_project = page_at(organisation_project_meetings_path(organisation, project_a), smart_folder_id: overview_view.id)
expect(on_project.find('[data-controller="filter-bar"]')['data-filter-bar-smart-folder-id-value']).to be_blank
end
+
+ it 'opens no view from an id of the wrong shape' do
+ record('Alpha Kickoff', project: project_a)
+
+ page = page_at(overview_path, smart_folder_id: [overview_view.id])
+ expect(overview_titles(page)).to eq(['Alpha Kickoff'])
+ expect(page.find('[data-controller="filter-bar"]')['data-filter-bar-smart-folder-id-value']).to be_blank
+ end
end
describe 'changing, renaming, duplicating, sharing and deleting' do
@@ -156,6 +174,16 @@ RSpec.describe 'Organisations::MeetingsOverview saved views', :ci_guard, type: :
expect(saved.project_id).to be_nil
end
+ # The view's own project (none) decides its list, not a project_id the
+ # request brings along.
+ it 'keeps a view without a project on the overview, whatever project the request names' do
+ patch update_from_filters_organisation_smart_folder_path(organisation, saved),
+ params: { filter: { project: [project_b.id] }, project_id: project_a.id, return_to: 'meetings' }
+
+ expect(URI.parse(response.location).path).to eq(overview_path)
+ expect(saved.reload.project_id).to be_nil
+ end
+
it 'refuses a change to a project the reader cannot read' do
patch update_from_filters_organisation_smart_folder_path(organisation, saved),
params: { filter: { project: [project_hidden.id] } }, as: :json
diff --git a/spec/services/actors/save_smart_folder_from_filters_spec.rb b/spec/services/actors/save_smart_folder_from_filters_spec.rb
index 2f21ebb..c0ed764 100644
--- a/spec/services/actors/save_smart_folder_from_filters_spec.rb
+++ b/spec/services/actors/save_smart_folder_from_filters_spec.rb
@@ -63,6 +63,19 @@ RSpec.describe Actors::SaveSmartFolderFromFilters do
expect(folder.smart_folder_rule_groups.count).to eq(2)
end
+ # A view of "Alle Meetings" has no project to take its organisation from; the
+ # one named here owns it, also where no tenant is set (a job, the console).
+ it 'gives a folder without a project the organisation it was handed' do
+ result = ActsAsTenant.without_tenant do
+ described_class.call(project: nil, organisation: organisation, current_user: user,
+ filter_params: { 'creator' => [user.id] }, operator_params: {},
+ name: 'Von mir', target_object_type: 'Meeting')
+ end
+
+ expect(result).to be_success
+ expect(result.resource).to have_attributes(project: nil, organisation: organisation, target_object_type: 'Meeting')
+ end
+
it 'fails without persisting when the folder is invalid (blank name)' do
expect do
result = described_class.call(