1602 / 1602/compound

Scaffolding with case sensitivity causes issues.

オープン 初心者向け
#582 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
1.6k
フォーク
179
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, nodejs
領域
backend, tooling
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
70/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。