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.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Sharpen the column picker specs of "Alle Meetings" against four surviving mutants
Guido Boyke6e78848265bd
diff --git a/spec/models/view_configuration_without_project_spec.rb b/spec/models/view_configuration_without_project_spec.rbindex 2dade12..685b86e 100644--- a/spec/models/view_configuration_without_project_spec.rb+++ b/spec/models/view_configuration_without_project_spec.rb@@ -24,11 +24,18 @@ RSpec.describe ViewConfiguration, 'without a project' doenddescribe 'validations' do- it 'accepts a meetings view without a project' do- expect(build_overview_config).to be_valid+ described_class::ORGANISATION_WIDE_VIEW_TYPES.each do |view_type|+ it "accepts a #{view_type} view without a project" do+ expect(build_overview_config(view_type: view_type)).to be_valid+ endend- %w[tickets notes documents].each do |view_type|+ # Every other list type the model knows, read from its own inclusion list:+ # a list type added later is refused without a project until it is added+ # to ORGANISATION_WIDE_VIEW_TYPES on purpose.+ known_view_types = described_class.validators_on(:view_type).grep(ActiveModel::Validations::InclusionValidator)+ .flat_map { |validator| Array(validator.options[:in]) }+ (known_view_types - described_class::ORGANISATION_WIDE_VIEW_TYPES).each do |view_type|it "refuses a #{view_type} view without a project" doconfig = build_overview_config(view_type: view_type)@@ -45,6 +52,14 @@ RSpec.describe ViewConfiguration, 'without a project' doexpect(duplicate.errors[:user_id]).to be_presentend+ it 'allows a row without a project for each user of one organisation, in the validation and the index' do+ build_overview_config.save!++ colleague_row = described_class.new(user: create(:user), organisation: organisation, project: nil, view_type: 'meetings')+ expect(colleague_row).to be_valid+ expect { colleague_row.save!(validate: false) }.not_to raise_error+ end+it 'allows the row without a project next to the row of a project' dodescribed_class.create!(user: user, organisation: organisation, project: project, view_type: 'meetings')@@ -116,6 +131,20 @@ RSpec.describe ViewConfiguration, 'without a project' doendend+ # Project#view_configurations is dependent: :destroy. Since project_id may be+ # NULL, a :nullify there would turn a project's rows into rows of "Alle+ # Meetings" without a word; the overview row itself must survive the project.+ describe 'when a project is destroyed' do+ it 'removes the rows of the project and keeps the row without a project' do+ described_class.create!(user: user, organisation: organisation, project: project, view_type: 'meetings',+ table_columns: %w[title creator])+ overview_row = build_overview_config.tap(&:save!)++ expect { project.destroy! }.to change(described_class, :count).by(-1)+ expect(described_class.where(project_id: nil).pluck(:id)).to eq([overview_row.id])+ end+ end+describe '.for_list' doit 'picks the row of the project when there is one, the organisation row otherwise' dowith_project = described_class.for_list(user: user, organisation: organisation, project: project, view_type: 'meetings')@@ -125,6 +154,17 @@ RSpec.describe ViewConfiguration, 'without a project' doexpect(without.project).to be_nilexpect(without.organisation).to eq(organisation)end++ # A caller outside a request (a job, the console) has no current tenant: the+ # row without a project must still name its organisation.+ it 'names the organisation of the row without a project even without a current tenant' do+ ActsAsTenant.without_tenant do+ config = described_class.for_list(user: user, organisation: organisation, project: nil, view_type: 'meetings')++ expect(config.organisation).to eq(organisation)+ expect(config.ordered_columns).to include('project')+ end+ endenddescribe 'columns' dodiff --git a/spec/requests/organisations/meetings_overview_columns_spec.rb b/spec/requests/organisations/meetings_overview_columns_spec.rbindex 657763e..468b02e 100644--- a/spec/requests/organisations/meetings_overview_columns_spec.rb+++ b/spec/requests/organisations/meetings_overview_columns_spec.rb@@ -102,6 +102,28 @@ RSpec.describe 'Organisations::MeetingsOverview columns', :ci_guard, type: :requexpect(picker_keys).to include('project')end+ it 'points "für alle Ansichten übernehmen" at the overview, and the project page at its project' do+ get overview_path+ expect(page_body).to have_css('#column-picker form.column-picker__apply', visible: :all)+ expect(page_body.find('#column-picker form.column-picker__apply', visible: :all)['action'])+ .to eq(apply_columns_to_all_organisation_meetings_view_configuration_path(organisation))++ get organisation_project_meetings_path(organisation, project)+ expect(page_body.find('#column-picker form.column-picker__apply', visible: :all)['action'])+ .to eq(apply_columns_to_all_organisation_project_view_configuration_path(organisation, project, view_type: 'meetings'))+ end++ it 'saves into the open view, not into the base view' do+ view = meeting_view(name: 'Meine', owner: reader)++ get overview_path, params: { smart_folder_id: view.id }++ expect(response).to have_http_status(:ok)+ picker = page_body.find('[data-controller~="column-picker"]')+ expect(picker['data-column-picker-save-url-value']).to eq(columns_organisation_smart_folder_path(organisation, view))+ expect(picker['data-column-picker-editable-value']).to eq('true')+ end+it 'renders the stored list with ranks and minimum widths, and the pinned values under the title' doActsAsTenant.with_tenant(organisation) doViewConfiguration.for_user_organisation(reader, organisation, 'meetings').tap do |config|@@ -158,6 +180,17 @@ RSpec.describe 'Organisations::MeetingsOverview columns', :ci_guard, type: :requexpect(project_config(reader).ordered_columns).to eq(%w[title occurred_at])end+ # Whether the route names a project is read from the path: a project_id in+ # the query of the organisation route is no project route.+ it 'stays the overview row with a project_id in the query' do+ sign_in reader+ patch base_columns_path, params: { cols: %w[title project], project_id: project.id }, headers: json++ expect(response).to have_http_status(:ok)+ expect(overview_config(reader).ordered_columns).to eq(%w[title project])+ expect(project_config(reader)).to be_nil+ end+it 'cannot be turned into a ticket view without a project' dosign_in readerpatch base_columns_path, params: { cols: %w[title], view_type: 'tickets' }, headers: json@@ -251,6 +284,7 @@ RSpec.describe 'Organisations::MeetingsOverview columns', :ci_guard, type: :requget overview_path, params: { smart_folder_id: own_view.id }expect(response).to have_http_status(:ok)expect(head_keys).to eq(%w[title occurred_at])+ expect(page_body.find('[data-controller~="column-picker"]')['data-column-picker-editable-value']).to eq('false')patch columns_organisation_smart_folder_path(organisation, own_view), params: { cols: %w[title project] }, headers: jsonexpect(response).to have_http_status(:found)