Commit 29d84461 authored by Markus Koller's avatar Markus Koller

Insert new designs at the end

This is not behind a feature flag, to ensure any newly created designs
will have a position set.
parent ca1aafee
......@@ -12,7 +12,9 @@ module DesignManagement
def find_or_create_design!(filename:)
designs.find { |design| design.filename == filename } ||
designs.safe_find_or_create_by!(project: project, filename: filename)
designs.safe_find_or_create_by!(project: project, filename: filename) do |design|
design.move_to_end
end
end
def versions
......
......@@ -34,6 +34,13 @@ RSpec.describe DesignManagement::DesignCollection do
collection.find_or_create_design!(filename: 'world.jpg')
end.not_to exceed_query_limit(1)
end
it 'inserts the design after any existing designs' do
design1 = collection.find_or_create_design!(filename: 'design1.jpg')
design2 = collection.find_or_create_design!(filename: 'design2.jpg')
expect(design1.relative_position).to be < design2.relative_position
end
end
describe "#versions" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment