Skip to content

Commit 0aee768

Browse files
committed
Set sample item_tag position to 1
Without an explicit position, the sample row gets NULL, which Postgres sorts last by default — surprising for a single-row first-run state and fragile once a client adds more items without managing position themselves. Setting position 1 gives the sample a definite slot and keeps the (:position, :name) sort meaningful for clients that don't implement reordering.
1 parent a739a44 commit 0aee768

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

app/models/shop.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def create_sample_item_tag
1717
account: account,
1818
name: "Sample",
1919
description: "This is a sample. You can update or delete it.",
20+
position: 1,
2021
created_by: created_by
2122
)
2223
rescue => e

test/models/shop_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def setup
3636
sample = shop.item_tags.first
3737
assert_equal "Sample", sample.name
3838
assert sample.description.start_with?("This is a sample")
39+
assert_equal 1, sample.position
3940
assert sample.idled?
4041
end
4142
end

0 commit comments

Comments
 (0)