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
[#58160] spec for project index page
Tobias Dillmann2dacd2a473f9
diff --git a/.lefthook-local/prepare-commit-msg/commit-msg-prefix-from-branch.sh b/.lefthook-local/prepare-commit-msg/commit-msg-prefix-from-branch.shnew file mode 100755index 00000000000..4aa68151346--- /dev/null+++ b/.lefthook-local/prepare-commit-msg/commit-msg-prefix-from-branch.sh@@ -0,0 +1,35 @@+#!/bin/bash+# Looks at the current branch name and tries to extract the correct work package number from it.+# If found, the commit message will automatically be prefixed with the work package number, following this format:+#+# [#58160] <your text here>+#++# File path for the commit message+COMMIT_MSG_FILE=$1++# Branch name+BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)++# Debugging logs+#echo "Hook triggered for branch: $BRANCH_NAME" >> /tmp/hook_debug.log+#echo "Commit message file: $COMMIT_MSG_FILE" >> /tmp/hook_debug.log++# Extract work package number from branch name (e.g., feature/58160 or bug/59977)+if [[ $BRANCH_NAME =~ (feature|bug)/([0-9]+) ]]; then+ WP_NUMBER=${BASH_REMATCH[2]}+ PREFIX="[#$WP_NUMBER] "+# echo "Detected issue number: $WP_NUMBER" >> /tmp/hook_debug.log++ # Filter out comment lines and leading whitespace for the check+ FILTERED_MESSAGE=$(grep -v '^#' "$COMMIT_MSG_FILE" | sed 's/^[[:space:]]*//')++ # Log filtered message for debugging+# echo "Filtered commit message:" >> /tmp/hook_debug.log+# echo "$FILTERED_MESSAGE" >> /tmp/hook_debug.log++ # Check if the prefix is present in the actual commit message+ if [[ "$FILTERED_MESSAGE" != "$PREFIX"* ]]; then+ echo "$PREFIX$(cat "$COMMIT_MSG_FILE")" > "$COMMIT_MSG_FILE"+ fi+fidiff --git a/app/models/project/life_cycle_step.rb b/app/models/project/life_cycle_step.rbindex dfa4b11efda..d4ffcf43842 100644--- a/app/models/project/life_cycle_step.rb+++ b/app/models/project/life_cycle_step.rb@@ -46,4 +46,9 @@ class Project::LifeCycleStep < ApplicationRecordsuperend++ def column_name+ # The id of the associated definition is relevant for displaying the correct column headers+ "lcsd_#{definition_id}"+ endenddiff --git a/app/models/project/life_cycle_step_definition.rb b/app/models/project/life_cycle_step_definition.rbindex 48e8e00d94b..5f1181f326d 100644--- a/app/models/project/life_cycle_step_definition.rb+++ b/app/models/project/life_cycle_step_definition.rb@@ -55,4 +55,8 @@ class Project::LifeCycleStepDefinition < ApplicationRecorddef step_classraise NotImplementedErrorend++ def column_name+ "lcsd_#{id}"+ endenddiff --git a/app/models/queries/projects/selects/life_cycle_step.rb b/app/models/queries/projects/selects/life_cycle_step.rbindex a756695d4f4..7a055a7d30f 100644--- a/app/models/queries/projects/selects/life_cycle_step.rb+++ b/app/models/queries/projects/selects/life_cycle_step.rb@@ -60,7 +60,15 @@ class Queries::Projects::Selects::LifeCycleStep < Queries::Selects::Basedef action_menu_header(button)# Show the proper icon for the definition with the correct color.- icon = life_cycle_step.is_a?(Project::StageDefinition) ? :"git-commit" : :diamond+ icon = case life_cycle_step+ when Project::StageDefinition+ :"git-commit"+ when Project::GateDefinition+ :diamond+ else+ raise "Unknown life cycle step: #{life_cycle_step}"+ end+classes = helpers.hl_inline_class("life_cycle_step_definition", life_cycle_step)button.with_leading_visual_icon(icon:, classes:)diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rbindex 5e375ac252b..522998574e3 100644--- a/spec/features/projects/projects_index_spec.rb+++ b/spec/features/projects/projects_index_spec.rb@@ -329,6 +329,77 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { loginendend+ context "with life cycle columns" do+ shared_let(:life_cycle_gate) { create(:project_gate, date: Date.new(2024, 12, 13)) }+ shared_let(:life_cycle_stage) do+ create(:project_stage,+ start_date: Date.new(2024, 12, 1),+ end_date: Date.new(2024, 12, 13))+ end+ shared_let(:inactive_life_cycle_gate) { create(:project_gate, active: false) }+ shared_let(:inactive_life_cycle_stage) { create(:project_stage, active: false) }++ specify "life cycle columns do not show up by default" do+ login_as(admin)+ projects_page.visit!++ expect(page).to have_no_text(life_cycle_gate.definition.name.upcase)+ expect(page).to have_no_text(life_cycle_stage.definition.name.upcase)+ expect(page).to have_no_text(inactive_life_cycle_gate.definition.name.upcase)+ expect(page).to have_no_text(inactive_life_cycle_stage.definition.name.upcase)+ end++ specify "life cycle columns show up when configured to do so" do+ login_as(admin)+ projects_page.visit!++ projects_page.expect_columns("Name")+ projects_page.set_columns(life_cycle_gate.definition.name)++ expect(page).to have_text(life_cycle_gate.definition.name.upcase)+ end++ specify "inactive life cycle columns have no cell content" do+ login_as(admin)+ projects_page.visit!++ projects_page.expect_columns("Name")++ col_names = [life_cycle_gate, life_cycle_stage,+ inactive_life_cycle_gate,+ inactive_life_cycle_stage].map { |l| l.definition.name }++ projects_page.set_columns(*col_names)+ # Inactive columns are still displayed in the header:+ projects_page.expect_columns("Name", *col_names)++ gate_project = life_cycle_gate.project+ projects_page.within_row(gate_project) do+ expect(page).to have_css(".name", text: gate_project.name)+ expect(page).to have_css(".lcsd_#{life_cycle_gate.definition.id}", text: "12/13/2024")+ # life cycle assigned to other project, no text here+ expect(page).to have_css(".lcsd_#{life_cycle_stage.definition.id}", text: "")+ # inactive life cycles, no text here+ expect(page).to have_css(".lcsd_#{inactive_life_cycle_stage.definition.id}", text: "")+ expect(page).to have_css(".lcsd_#{inactive_life_cycle_gate.definition.id}", text: "")+ end++ stage_project = life_cycle_stage.project+ projects_page.within_row(stage_project) do+ expect(page).to have_css(".name", text: stage_project.name)+ expect(page).to have_css(".lcsd_#{life_cycle_stage.definition.id}", text: "12/01/2024 - 12/13/2024")+ # life cycle assigned to other project, no text here+ expect(page).to have_css(".lcsd_#{life_cycle_gate.definition.id}", text: "")+ end++ # Inactive life cycle steps never show their date values+ other_proj = inactive_life_cycle_stage.project+ projects_page.within_row(other_proj) do+ expect(page).to have_css(".lcsd_#{inactive_life_cycle_stage.definition.id}", text: "")+ end+ end+ end+context "with valid Enterprise token" doshared_let(:long_text_custom_field) { create(:text_project_custom_field) }specify "CF columns and filters are not visible by default" do