Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Bugfix/multiple word auto #1002

Merged
merged 4 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion render/auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (htmlAutoRenderer) ContentType() string {
}

func (ir htmlAutoRenderer) Render(w io.Writer, data Data) error {
name := inflect.Name(strings.ToLower(ir.typeName()))
name := inflect.Name(inflect.Underscore(ir.typeName()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t inflect.Name.File() do what we want?

name = inflect.Name(name.Singular())
pname := inflect.Name(name.Plural())

Expand Down
26 changes: 26 additions & 0 deletions render/auto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@ func Test_Auto_HTML_List_Plural(t *testing.T) {
r.NoError(err)
}

func Test_Auto_HTML_List_Plural_MultiWord(t *testing.T) {
r := require.New(t)

type RoomProvider struct {
Name string
}

type RoomProviders []RoomProvider

err := withHTMLFile("room_providers/index.html", "INDEX: <%= len(room_providers) %>", func(e *render.Engine) {
app := buffalo.New(buffalo.Options{})
app.GET("/room_providers", func(c buffalo.Context) error {
return c.Render(200, e.Auto(c, RoomProviders{
RoomProvider{Name: "Ford"},
RoomProvider{Name: "Chevy"},
}))
})

w := willie.New(app)
res := w.HTML("/room_providers").Get()

r.Contains(res.Body.String(), "INDEX: 2")
})
r.NoError(err)
}

func Test_Auto_HTML_Show(t *testing.T) {
r := require.New(t)

Expand Down