1602 / 1602/compound

Scaffolding with case sensitivity causes issues.

Aperta Adatta ai principianti
#582 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
1.6k
Fork
179
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

When I use case sensitivity in my scaffolding, I get errors when trying to access the respective pages (new, show, and edit). To recreate these issues, I did the following:
1. `compound init blah --db mongodb && cd blah`
2. `npm install`
3. `compound g s testBlah id:int name:string`

The errors say **testblah is not defined**, so I figured it had something to do with case sensitivity, so I did some poking around. To get the app working, I made these changes:

**app/views/testblahs/_form.ejs**
Line 1, `errorMessagesFor(testblah)` should be `errorMessagesFor(testBlah)`.

**app/views/testblahs/new.ejs**
Line 11, `formFor(testblah, ...` should be `formFor(testBlah, ...`.

**app/views/testblahs/edit.ejs**
Line 11, `formFor(testblah, ...` should be `formFor(testBlah, ...` and `pathTo.testblah(testblah)...` should be `pathTo.testblah(testBlah)...`
Line 16, `pathTo.testblah(testblah)...` should be `pathTo.testblah(testBlah)...`

**app/views/testblahs/show.ejs**
Line 13, `testblah.id` should be `testBlah.id`
Line 15, `testblah.name` should be `testBlah.name`
Line 20, `pathTo.edit_testblah(testblah)...` should be `pathTo.edit_testblah(testBlah)...`
Line 21, `pathTo.testblah(testblah)...` should be `pathTo.testblah(testBlah)...`

That solves the issue of showing the pages, however, testing is another issue. I get 6 initial errors when running the test... they are as follows:
1. TestblahController should access Testblah#find and render "edit" template on GET /testblahs/:id/edit:

**TypeError: Cannot set property 'find' of undefined**
2. TestblahController should access Testblah#find and render "show" template on GET /testblahs/:id :

**TypeError: Cannot set property 'find' of undefined**
3. TestblahController should access Testblah#create on POST /testblahs with a valid Testblah:

**TypeError: Cannot set property 'create' of undefined**
4. TestblahController should fail on POST /testblahs when Testblah#create returns an error:

**TypeError: Cannot set property 'create' of undefined**
5. TestblahController should redirect on PUT /testblahs/:id with a valid Testblah:

**TypeError: Cannot set property 'find' of undefined**
6. TestblahController should fail / not redirect on PUT /testblahs/:id with an invalid Testblah:

**TypeError: Cannot set property 'find' of undefined**

I can get rid of 1, 2, and 6 by changing all occurrences of `app.models.Testblah` to `app.models.TestBlah`. However, I'm a bit unsure how to fix the other 3. If I had done `compound g s testblah id:int name:string`, all pages and testing are kosher, so clearly the case is messing up the rest of the testing elsewhere... I just can't figure it out. Either way, I figured this was a bug and should be reported.

Let me know if you need any further information.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

The issue is in the scaffolding generator. Look at the generator code that creates views and tests, likely in a `generators/` directory. The bug is that variable names are lowercased incorrectly when the model name has mixed case (like 'testBlah'). Check how the model name is transformed for view templates and test files. Run the failing tests after making changes to verify the fix.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, nodejs
Ambito
backend, tooling
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
70/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.