Run cargo fmt on the unit code and drop a quantity box's invalid mark when its line is removed
The new CI runs cargo fmt --check. QuantityInput also reported its validity only when it changed, so removing a line whose quantity box held bad text left that box counted as invalid and blocked issuing; it now reports valid when it unmounts, and no longer writes a ref during render. Claude-Session: https://claude.ai/code/session_01PZypiWDfMkDTeEPeXjRhW5
This commit is contained in:
+42
-5
@@ -1108,7 +1108,17 @@ CREATE INDEX IF NOT EXISTS idx_invoices_created ON invoices(created_at DESC);
|
||||
fn m12_rebuilds_item_presets_keeping_rows_and_allowing_new_units() {
|
||||
let mut conn = Connection::open_in_memory().unwrap();
|
||||
let v11 = vec![
|
||||
M::up(SCHEMA), M::up(M2), M::up(M3), M::up(M4), M::up(M5), M::up(M6), M::up(M7), M::up(M8), M::up(M9), M::up(M10), M::up(M11),
|
||||
M::up(SCHEMA),
|
||||
M::up(M2),
|
||||
M::up(M3),
|
||||
M::up(M4),
|
||||
M::up(M5),
|
||||
M::up(M6),
|
||||
M::up(M7),
|
||||
M::up(M8),
|
||||
M::up(M9),
|
||||
M::up(M10),
|
||||
M::up(M11),
|
||||
];
|
||||
Migrations::new(v11).to_latest(&mut conn).unwrap();
|
||||
assert_eq!(user_version(&conn), 11);
|
||||
@@ -1134,16 +1144,43 @@ CREATE INDEX IF NOT EXISTS idx_invoices_created ON invoices(created_at DESC);
|
||||
assert_eq!(
|
||||
rows,
|
||||
vec![
|
||||
(1, "Studio".into(), "998397".into(), "rate".into(), "hour".into(), 150050, 3, "then".into(), Some("ITEM-1".into())),
|
||||
(2, "Fee".into(), "".into(), "fixed".into(), "unit".into(), 500000, 0, "then".into(), None),
|
||||
(
|
||||
1,
|
||||
"Studio".into(),
|
||||
"998397".into(),
|
||||
"rate".into(),
|
||||
"hour".into(),
|
||||
150050,
|
||||
3,
|
||||
"then".into(),
|
||||
Some("ITEM-1".into())
|
||||
),
|
||||
(
|
||||
2,
|
||||
"Fee".into(),
|
||||
"".into(),
|
||||
"fixed".into(),
|
||||
"unit".into(),
|
||||
500000,
|
||||
0,
|
||||
"then".into(),
|
||||
None
|
||||
),
|
||||
]
|
||||
);
|
||||
// New units and custom text are allowed; an empty or over-long unit is not; ids keep counting up.
|
||||
conn.execute("INSERT INTO item_presets (description, unit, created_at) VALUES ('Travel', 'km', 'now')", []).unwrap();
|
||||
conn.execute("INSERT INTO item_presets (description, unit, created_at) VALUES ('Parcel', 'bundle', 'now')", []).unwrap();
|
||||
assert!(conn.execute("INSERT INTO item_presets (description, unit, created_at) VALUES ('X', '', 'now')", []).is_err());
|
||||
assert!(conn
|
||||
.execute(
|
||||
"INSERT INTO item_presets (description, unit, created_at) VALUES ('X', '', 'now')",
|
||||
[]
|
||||
)
|
||||
.is_err());
|
||||
assert!(conn.execute("INSERT INTO item_presets (description, unit, created_at) VALUES ('X', 'thirteen char', 'now')", []).is_err());
|
||||
let last: i64 = conn.query_row("SELECT MAX(id) FROM item_presets", [], |r| r.get(0)).unwrap();
|
||||
let last: i64 = conn
|
||||
.query_row("SELECT MAX(id) FROM item_presets", [], |r| r.get(0))
|
||||
.unwrap();
|
||||
assert_eq!(last, 4);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user