|
| 1 | +component extends="org.lucee.cfml.test.LuceeTestCase" labels="internalRequest,cfcontent" { |
| 2 | + |
| 3 | + function run( testResults, testBox ) { |
| 4 | + describe( "LDEV-5952 - _internalRequest fails with 'Content was already flushed' after resetBuffer()", function() { |
| 5 | + |
| 6 | + it( "cfcontent should work after resetBuffer() is called", function() { |
| 7 | + var result = _internalRequest( |
| 8 | + template = createURI( "LDEV5952/resetBuffer.cfm" ), |
| 9 | + method = "GET", |
| 10 | + throwonerror = false |
| 11 | + ); |
| 12 | + |
| 13 | + expect( result ).toHaveKey( "filecontent" ); |
| 14 | + expect( result ).notToHaveKey( "error" ); |
| 15 | + expect( result.status_code ).toBe( 200 ); |
| 16 | + expect( result.headers[ "content-type" ] ).toInclude( "application/json" ); |
| 17 | + |
| 18 | + var content = deserializeJSON( result.filecontent ); |
| 19 | + expect( content.success ).toBeTrue(); |
| 20 | + }); |
| 21 | + |
| 22 | + it( "cfcontent should work after reset() is called", function() { |
| 23 | + var result = _internalRequest( |
| 24 | + template = createURI( "LDEV5952/reset.cfm" ), |
| 25 | + method = "GET", |
| 26 | + throwonerror = false |
| 27 | + ); |
| 28 | + |
| 29 | + expect( result ).toHaveKey( "filecontent" ); |
| 30 | + expect( result ).notToHaveKey( "error" ); |
| 31 | + expect( result.status_code ).toBe( 200 ); |
| 32 | + expect( result.headers[ "content-type" ] ).toInclude( "application/json" ); |
| 33 | + |
| 34 | + var content = deserializeJSON( result.filecontent ); |
| 35 | + expect( content.success ).toBeTrue(); |
| 36 | + }); |
| 37 | + |
| 38 | + it( "cfcontent should work without any buffer manipulation", function() { |
| 39 | + var result = _internalRequest( |
| 40 | + template = createURI( "LDEV5952/simple.cfm" ), |
| 41 | + method = "GET", |
| 42 | + throwonerror = false |
| 43 | + ); |
| 44 | + |
| 45 | + expect( result ).toHaveKey( "filecontent" ); |
| 46 | + expect( result ).notToHaveKey( "error" ); |
| 47 | + expect( result.status_code ).toBe( 200 ); |
| 48 | + expect( result.headers[ "content-type" ] ).toInclude( "application/json" ); |
| 49 | + |
| 50 | + var content = deserializeJSON( result.filecontent ); |
| 51 | + expect( content.success ).toBeTrue(); |
| 52 | + }); |
| 53 | + |
| 54 | + it( "resetBuffer() should fail after flushBuffer()", function() { |
| 55 | + var result = _internalRequest( |
| 56 | + template = createURI( "LDEV5952/resetBufferAfterFlush.cfm" ), |
| 57 | + method = "GET", |
| 58 | + throwonerror = false |
| 59 | + ); |
| 60 | + |
| 61 | + expect( result ).toHaveKey( "error" ); |
| 62 | + expect( result.error.message ).toInclude( "committed" ); |
| 63 | + }); |
| 64 | + |
| 65 | + it( "reset() should fail after flushBuffer()", function() { |
| 66 | + var result = _internalRequest( |
| 67 | + template = createURI( "LDEV5952/resetAfterFlush.cfm" ), |
| 68 | + method = "GET", |
| 69 | + throwonerror = false |
| 70 | + ); |
| 71 | + |
| 72 | + expect( result ).toHaveKey( "error" ); |
| 73 | + expect( result.error.message ).toInclude( "committed" ); |
| 74 | + }); |
| 75 | + |
| 76 | + }); |
| 77 | + } |
| 78 | + |
| 79 | + private string function createURI( string calledName ) { |
| 80 | + var baseURI = "/test/#listLast( getDirectoryFromPath( getCurrenttemplatepath() ), "\/" )#/"; |
| 81 | + return baseURI & calledName; |
| 82 | + } |
| 83 | + |
| 84 | +} |
0 commit comments