Commit e8663ac5 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Remove hardcoded ID from spec

Having a hardcoded ID means this spec would fail when there are
preceding specs that already created a design. We roll back and clear
the DB after specs are run but the sequence isn't reset so we cannot
guarantee the IDs for the designs created in this spec.
parent 15199b2f
...@@ -32,17 +32,19 @@ RSpec.describe CapDesignsFilenameLengthToNewLimit, :migration, schema: 202005281 ...@@ -32,17 +32,19 @@ RSpec.describe CapDesignsFilenameLengthToNewLimit, :migration, schema: 202005281
end end
it 'correctly sets filenames that are above the limit' do it 'correctly sets filenames that are above the limit' do
[ designs = [
filename_below_limit, filename_below_limit,
filename_at_limit, filename_at_limit,
filename_above_limit filename_above_limit
].each(&method(:create_design)) ].map(&method(:create_design))
migrate! migrate!
expect(designs.find(1).filename).to eq(filename_below_limit) designs.each(&:reload)
expect(designs.find(2).filename).to eq(filename_at_limit)
expect(designs.find(3).filename).to eq([described_class::MODIFIED_NAME, 3, described_class::MODIFIED_EXTENSION].join) expect(designs[0].filename).to eq(filename_below_limit)
expect(designs[1].filename).to eq(filename_at_limit)
expect(designs[2].filename).to eq([described_class::MODIFIED_NAME, designs[2].id, described_class::MODIFIED_EXTENSION].join)
end end
it 'runs after filename limit has been set' do it 'runs after filename limit has been set' 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