diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7e09bfbe5..661129f85 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: - "ubuntu-latest" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Go ${{ matrix.go }} uses: actions/setup-go@v2 with: diff --git a/default_context.go b/default_context.go index 0aad92404..3f2eec99d 100644 --- a/default_context.go +++ b/default_context.go @@ -195,7 +195,6 @@ var mapType = reflect.ValueOf(map[string]interface{}{}).Type() // Redirect a request with the given status to the given URL. func (d *DefaultContext) Redirect(status int, url string, args ...interface{}) error { if d.Session() != nil { - d.Flash().Clear() d.Flash().persist(d.Session()) if err := d.Session().Save(); err != nil { return HTTPError{Status: http.StatusInternalServerError, Cause: err} diff --git a/error_templates.go b/error_templates.go index 2fb4d13d9..6ebbb3983 100644 --- a/error_templates.go +++ b/error_templates.go @@ -1,7 +1,7 @@ package buffalo import ( - _ "embed" + _ "embed" // needed to embed the templates. ) var ( diff --git a/flash_test.go b/flash_test.go index 25f863f47..bd3edb86a 100644 --- a/flash_test.go +++ b/flash_test.go @@ -3,6 +3,7 @@ package buffalo import ( "net/http" "testing" + "text/template" "github.com/gobuffalo/buffalo/render" "github.com/gobuffalo/httptest" @@ -120,4 +121,30 @@ func Test_FlashRenderCustomKeyNotDefined(t *testing.T) { const customKeyTPL = ` {{#each flash.other as |k value|}} {{value}} - {{/each}}` + {{/each}} +` + +func Test_FlashNotClearedOnRedirect(t *testing.T) { + r := require.New(t) + a := New(Options{}) + rr := render.New(render.Options{}) + + a.GET("/flash", func(c Context) error { + c.Flash().Add("success", "Antonio, you're welcome!") + return c.Redirect(http.StatusSeeOther, "/") + }) + + a.GET("/", func(c Context) error { + template := `Message: <%= flash["success"] %>` + return c.Render(http.StatusCreated, rr.String(template)) + }) + + w := httptest.New(a) + res := w.HTML("/flash").Get() + r.Equal(res.Code, http.StatusSeeOther) + r.Equal(res.Location(), "/") + + res = w.HTML("/").Get() + r.Contains(res.Body.String(), template.HTMLEscapeString("Antonio, you're welcome!")) + +} diff --git a/go.mod b/go.mod index ea5e1ba48..03271b4bd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/gobuffalo/buffalo go 1.16 require ( - github.com/BurntSushi/toml v0.4.1 + github.com/BurntSushi/toml v1.0.0 github.com/dustin/go-humanize v1.0.0 github.com/fatih/color v1.13.0 github.com/gobuffalo/envy v1.10.1 diff --git a/go.sum b/go.sum index 9939d5988..881a1e8fb 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,9 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= diff --git a/runtime/version.go b/runtime/version.go index 4bf2cc5c1..2f9316adb 100644 --- a/runtime/version.go +++ b/runtime/version.go @@ -1,4 +1,4 @@ package runtime // Version is the current version of the buffalo binary -var Version = "v0.18.3" +var Version = "v0.18.4"