Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngMock/$controller): respect $compileProvider.preAssignBindingsEnabled() #15395

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Nov 15, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.

What is the current behavior? (You can also link to an open issue here)
ngMock's $controller service always pre-assigns bindings (if available), regardless of the value of $compileProvider.preAssignBindingsEnabled(). This may cause false positives or negatives in tests.
See #15387.

What is the new behavior (if this is a feature change)?
ngMock's $controller service does not pre-assign bindings (if available), unless $compileProvider.preAssignBindingsEnabled() returns true.

Does this PR introduce a breaking change?
No.

Please check if the PR fulfills these requirements

Other information:
Fixes #15387

@petebacondarwin
Copy link
Contributor

LGTM as long as Travis is happy.
(Although I am not that keen on using forEach([true, false], function(enabled) { style tests. I would rather just duplicate. But not enough to force a change here.)

@gkalpak gkalpak force-pushed the fix-ngMock-respect-preAssignBindingsEnabled branch from b7889a5 to 3e354dd Compare November 15, 2016 20:48
@gkalpak
Copy link
Member Author

gkalpak commented Nov 15, 2016

It turned out forEach() is not available in modules test.Since I had to change the tests anyway, I took the opportunity to split them as well. I'll wait for Travis to be happy and merge.
(cc @petebacondarwin)

@petebacondarwin
Copy link
Contributor

Travis seems happy. Feel free to merge.

@gkalpak gkalpak closed this in 7d9a791 Nov 16, 2016
gkalpak added a commit that referenced this pull request Nov 16, 2016
@gkalpak gkalpak deleted the fix-ngMock-respect-preAssignBindingsEnabled branch November 16, 2016 10:36
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit that referenced this pull request Nov 23, 2016
petebacondarwin pushed a commit that referenced this pull request Nov 24, 2016
@arkaitzgarro
Copy link

This change ended up on 1.5.10 release. Is this correct? Because I can see here was assigned to 1.6.0-rc.1 milestone. Our unit tests are failing now if we use angular-mocks 1.5.10: TypeError: undefined is not a constructor (evaluating 'compileProvider.preAssignBindingsEnabled()')

@gkalpak
Copy link
Member Author

gkalpak commented Dec 16, 2016

Yes, this was intentional. This is complementary to the new $compileProvider.preAssignBindingsEnabled() .
Make sure you use matching versions of core angular (angular.js) and external modules (angular-mocks.js, angular-animate.js etc).

ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

preAssignBindingsEnabled behavior is not reflected in ngMock $controller
4 participants