Skip to content

Commit 570e50d

Browse files
committed
Add ID_GENERATION spec
1 parent bede353 commit 570e50d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

ID_GENERATION.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
We're going to add a new page to the admin-only pages of this system
2+
3+
It's going to be a "Unit ID generation" page.
4+
5+
Check out the code we use for generating IDs of Inspections and Units.
6+
7+
The new page is going to pre-generate these IDs for Units. We're going to refer to unit IDs as "Badges" because that's how they're going to be represented in the real world, but for our purposes they're just the IDs of Units, generated in advance.
8+
9+
For now, we're just going to focus on the tables for this pre-generation - we won't change the Unit model at all yet.
10+
11+
There will be two tables:
12+
13+
- "Badges", containing a random string ID, batch ID, and note string
14+
- "BadgeBatches", containing a normal integer ID, creation date, and note string
15+
16+
When creating the "Badges" table you should look at the way we do IDs on Inspections and Units - we don't have an integer ID column.
17+
18+
You'll see that there are notes attached to both batches and badges.
19+
20+
The admin controller - badges_controller.rb - will list existing batches on its index page, in a table - "ID", "Number of Badges", "Date Created", "Notes".
21+
22+
Clicking through into a batch will list the badges within that batch, in a table - "ID", "Note".
23+
You'll then be able to click on an individual batch and edit its note.
24+
25+
Aside from viewing the existing batches and badges, and editing their notes, there'll be a "new"endpoint in badges_controller.rb for creating a new batch. The user will specify the number of IDs, and the note to attach. The system will then create a batch with that note, and then will create that amount of badges (efficiently, by generating a list of IDs up front and creating them in a batch), linked to that batch.
26+
27+
When writing any of this code, you will re-use existing ways of handling forms via the ChobbleForms controllers. You won't need to create any new CSS classes. Your error handling should not be over-cautious.
28+
29+
We'll write tests to go alongside all of this, following the format of the existing tests.

0 commit comments

Comments
 (0)