Skip to content

Commit

Permalink
Fix issue of onUpdate being called when no updates are provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
grantcopley committed Sep 16, 2024
1 parent 5796c55 commit 9956db3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions models/Component.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ component output="true" {
* @return void
*/
function _applyUpdates( updates ) {
if ( !updates.count() ) return;
// Capture old values
local.oldValues = duplicate( data );
// Array to track which array props were updated
Expand Down
17 changes: 17 additions & 0 deletions test-harness/tests/specs/CBWIRESpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,23 @@ component extends="coldbox.system.testing.BaseTestCase" {
expect( response.components[1].effects.html ).toInclude( "onUpdateCalled: true" );
} );

it( "should not call onupdate if no updates are actually passed", function() {
var payload = incomingRequest(
memo = {
"name": "test.should_call_onupdate",
"id": "Z1Ruz1tGMPXSfw7osBW2",
"children": []
},
data = {
"cbwireVersion": 3
},
calls = [],
updates = {}
);
var response = cbwireController.handleRequest( payload, event );
expect( response.components[1].effects.html ).toInclude( "onUpdateCalled: false" );
} );

it( "should call onUpdate[Property] if it exists", function() {
var payload = incomingRequest(
memo = {
Expand Down

0 comments on commit 9956db3

Please sign in to comment.