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

Updates tests

Marcello Rocha716fb673747f
diff --git a/spec/models/custom_field/order_statements_spec.rb b/spec/models/custom_field/order_statements_spec.rb
index c999399528c..9286cc3a9b2 100644
--- a/spec/models/custom_field/order_statements_spec.rb
+++ b/spec/models/custom_field/order_statements_spec.rb
@@ -47,43 +47,18 @@ RSpec.describe CustomField::OrderStatements do
end
describe "#order_join_statement" do
- # rubocop:disable RSpec/ExampleLength
it "must be equal" do
- expect(custom_field.order_join_statement).to eq(
- <<-SQL.squish
- LEFT OUTER JOIN (
- SELECT DISTINCT ON (cv.customized_id) cv.customized_id , item.position "value" , cv.value ids
- FROM "custom_values" cv
- INNER JOIN (SELECT hi.id,
- hi.parent_id,
- SUM((1 + anc.sort_order) * power(2, 2 - depths.generations)) AS position,
- hi.label,
- hi.short,
- hi.is_deleted,
- hi.created_at,
- hi.updated_at,
- hi.custom_field_id
- FROM hierarchical_items hi
- INNER JOIN hierarchical_item_hierarchies hih
- ON hi.id = hih.descendant_id
- JOIN hierarchical_item_hierarchies anc_h
- ON anc_h.descendant_id = hih.descendant_id
- JOIN hierarchical_items anc
- ON anc.id = anc_h.ancestor_id
- JOIN hierarchical_item_hierarchies depths
- ON depths.ancestor_id = #{item.id} AND depths.descendant_id = anc.id
- WHERE hih.ancestor_id = #{item.id}
- GROUP BY hi.id) item ON item.id = cv.value::bigint
- WHERE cv.customized_type = 'WorkPackage'
- AND cv.custom_field_id = #{custom_field.id}
- AND cv.value IS NOT NULL
- AND cv.value != ''
- ORDER BY cv.customized_id, cv.id
- ) cf_order_#{custom_field.id} ON cf_order_#{custom_field.id}.customized_id = "work_packages".id
- SQL
- )
+ expect(custom_field.order_join_statement).to eq(<<-SQL.squish)
+ LEFT OUTER JOIN (
+ SELECT DISTINCT ON (cv.customized_id) cv.customized_id
+ , item.position_cache "value"
+ , cv.value ids
+ FROM "custom_values" cv INNER JOIN "hierarchical_items" item ON item.id = cv.value::bigint
+ WHERE cv.customized_type = 'WorkPackage' AND cv.custom_field_id = #{custom_field.id}
+ AND cv.value IS NOT NULL AND cv.value != '' ORDER BY cv.customized_id, cv.id
+ ) cf_order_#{custom_field.id} ON cf_order_#{custom_field.id}.customized_id = "work_packages".id
+ SQL
end
- # rubocop:enable RSpec/ExampleLength
end
end
end