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
Adds a migration test
Marcello Rocha0295ca6cb852
diff --git a/spec/migrations/adds_position_cache_to_hierarchy_items_spec.rb b/spec/migrations/adds_position_cache_to_hierarchy_items_spec.rbnew file mode 100644index 00000000000..f0299d3e0b0--- /dev/null+++ b/spec/migrations/adds_position_cache_to_hierarchy_items_spec.rb@@ -0,0 +1,30 @@+#-- copyright+#++++require "spec_helper"+require Rails.root.join("db/migrate/20250102161733_adds_position_cache_to_hierarchy_items.rb")++RSpec.describe AddsPositionCacheToHierarchyItems, type: :model do+ let(:custom_field) { create(:hierarchy_wp_custom_field) }+ let(:service) { CustomFields::Hierarchy::HierarchicalItemService.new }++ it "backfills the position_cache value on already existing hierarchy items" do+ ActiveRecord::Migration.suppress_messages { described_class.new.down }++ root = service.generate_root(custom_field).value!+ anakin = service.insert_item(label: "luke", parent: root).value!+ chewie = service.insert_item(label: "chewbacca", parent: root).value!+ luke = service.insert_item(label: "luke", parent: anakin).value!+ leia = service.insert_item(label: "leia", parent: anakin).value!++ expect(root.self_and_descendants_preordered).to eq([root, anakin, luke, leia, chewie])++ ActiveRecord::Migration.suppress_messages { described_class.new.up }++ expect(root.reload.position_cache).to eq(125)+ expect(anakin.reload.position_cache).to eq(150)+ expect(luke.reload.position_cache).to eq(155)+ expect(leia.reload.position_cache).to eq(160)+ expect(chewie.reload.position_cache).to eq(175)+ end+end