Skip to content

Commit

Permalink
Merge branch 'fix_is_aborted_method' of https://github.com/adwinsky/gin
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jul 2, 2015
2 parents a20984c + 050a55b commit 16b08c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (c *Context) Next() {

// Returns if the currect context was aborted.
func (c *Context) IsAborted() bool {
return c.index == AbortIndex
return c.index >= AbortIndex
}

// Stops the system to continue calling the pending handlers in the chain.
Expand Down
14 changes: 14 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,20 @@ func TestContextNegotiationFormatCustum(t *testing.T) {
assert.Equal(t, c.NegotiateFormat(MIMEJSON), MIMEJSON)
}

func TestContextIsAborted(t *testing.T) {
c, _, _ := createTestContext()

assert.False(t, c.IsAborted())

c.Abort()

assert.True(t, c.IsAborted())

c.Next()

assert.True(t, c.IsAborted())
}

// TestContextData tests that the response can be written from `bytesting`
// with specified MIME type
func TestContextAbortWithStatus(t *testing.T) {
Expand Down

0 comments on commit 16b08c4

Please sign in to comment.