Skip to content

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

[#58160] fix existing sort helper specs

Tobias Dillmannb4ea19015497
diff --git a/spec/helpers/sort_helper_spec.rb b/spec/helpers/sort_helper_spec.rb
index 1c4e9b2ff5f..5b5dec2210c 100644
--- a/spec/helpers/sort_helper_spec.rb
+++ b/spec/helpers/sort_helper_spec.rb
@@ -281,11 +281,7 @@ RSpec.describe SortHelper do
end
describe "#sort_header_with_action_menu" do
- subject(:output) do
- helper.sort_header_with_action_menu("id",
- %w[name id description], {}, **options)
- end
-
+ let(:id_column) { Queries::Projects::Selects::Default.new "id" }
let(:options) { { param: :json, sortable: true } }
let(:sort_criteria) { SortHelper::SortCriteria.new }
@@ -295,6 +291,11 @@ RSpec.describe SortHelper do
Nokogiri::HTML(output).at_css("th .generic-table--sort-header action-menu")
end
+ subject(:output) do
+ helper.sort_header_with_action_menu(id_column,
+ %w[name id description], {}, **options)
+ end
+
before do
# helper relies on this instance var
@sort_criteria = sort_criteria
@@ -343,7 +344,7 @@ RSpec.describe SortHelper do
context "with the current column being the leftmost one" do
subject(:output) do
- helper.sort_header_with_action_menu("id",
+ helper.sort_header_with_action_menu(id_column,
%w[id name description], {}, **options)
end
@@ -359,7 +360,7 @@ RSpec.describe SortHelper do
context "with the current column being the rightmost one" do
subject(:output) do
- helper.sort_header_with_action_menu("id",
+ helper.sort_header_with_action_menu(id_column,
%w[name description id], {}, **options)
end
@@ -397,7 +398,7 @@ RSpec.describe SortHelper do
context "with a filter mapping for the column" do
subject(:output) do
- helper.sort_header_with_action_menu("id",
+ helper.sort_header_with_action_menu(id_column,
%w[name id description], { "id" => "id_code" }, **options)
end
@@ -413,7 +414,7 @@ RSpec.describe SortHelper do
context "with the filter mapping specifying there is no filter for the column" do
subject(:output) do
# With the filter name mapped to nil, we expect no filter action to be present.
- helper.sort_header_with_action_menu("id",
+ helper.sort_header_with_action_menu(id_column,
%w[name id description], { "id" => nil }, **options)
end
@@ -422,5 +423,22 @@ RSpec.describe SortHelper do
expect(filter_by).to be_nil
end
end
+
+ context "with a life cycle column" do
+ let(:life_cycle_step) { create(:project_gate_definition) }
+ let(:life_cycle_column) { Queries::Projects::Selects::LifeCycleStep.new("lcsd_#{life_cycle_step.id}") }
+
+ subject(:output) do
+ # Not setting any filter column mappings here, so for other column types, this should use the default filter
+ helper.sort_header_with_action_menu(life_cycle_column,
+ %W[name lcsd_#{life_cycle_step.id}], {}, **options)
+ end
+
+ it "never offers a filter by action" do
+ # But a life cycle column never offers a filter (until #59183 is implemented)
+ filter_by = action_menu.at_css("action-list .ActionListItem button[data-test-selector='id-filter-by']")
+ expect(filter_by).to be_nil
+ end
+ end
end
end