)]}'
{"openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/keypair/import-keypair.controller.spec.js":[{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"4376f3788b7a743c34b313fc738c4646c8db4ef2","unresolved":false,"context_lines":[{"line_number":27,"context_line":"      beforeEach(module(function ($provide) {"},{"line_number":28,"context_line":"        $provide.value(\u0027$modalInstance\u0027, $modalInstance);"},{"line_number":29,"context_line":"        $provide.value(\u0027horizon.app.core.openstack-service-api.nova\u0027, nova);"},{"line_number":30,"context_line":"        $provide.value(\u0027horizon.framework.widgets.toast.service\u0027, toastServiceMock);"},{"line_number":31,"context_line":"      }));"},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"      beforeEach(module(\u0027horizon.dashboard.project\u0027));"}],"source_content_type":"text/javascript","patch_set":1,"id":"9aed3d3a_6bc19f80","line":30,"updated":"2016-02-25 23:42:44.000000000","message":"I see no reason to create a mock where when we just need to inject the service and spyOn the add method. Saves one line, yes, but also removes the unnecessary mock code.","commit_id":"9cadfa6b5775e4c8a1ab45db749914bc78e9c22f"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"a449c54508ee5ea061d73caebf5bff5c66a20e75","unresolved":false,"context_lines":[{"line_number":52,"context_line":"      });"},{"line_number":53,"context_line":""},{"line_number":54,"context_line":"      it(\u0027successful submit calls the successCallback\u0027, function() {"},{"line_number":55,"context_line":"        var successFunc \u003d {success: angular.noop};"},{"line_number":56,"context_line":"        spyOn(nova, \u0027createKeypair\u0027).and.returnValue(successFunc);"},{"line_number":57,"context_line":"        spyOn(successFunc, \u0027success\u0027);"},{"line_number":58,"context_line":"        ctrl.submit();"}],"source_content_type":"text/javascript","patch_set":2,"id":"9aed3d3a_2989f175","side":"PARENT","line":55,"updated":"2016-02-29 05:32:17.000000000","message":"I would prefer to either see:\n\n1. the submit() and successCallback() methods be tested separately (two it() cases) if you\u0027re going to structure the code like this, or\n2. use an actual promise to test the code here, rather than poke around inside the successFunc.success.calls.argsFor... stuff which is pretty deep poking.\n\nAn example of using an actual promise in the unit testing of API calls like this can be seen in:\n\nhttps://review.openstack.org/#/c/259236/41/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js\n\n(sorry for the horrid link). Three of those tests create the deferred promise which is resolved in order to have the callback invoked, which I think is cleaner than the form present in this test, though the code does end up longer.\n\nHappy to be disagreed with!","commit_id":"0207d07a091d508262b24156d539e6803bf01b25"},{"author":{"_account_id":9576,"name":"Thai Tran","email":"tqtran@us.ibm.com","username":"tqtran"},"change_message_id":"dbd281fb54bc13860b94d93120c0b6e6b9b68a1f","unresolved":false,"context_lines":[{"line_number":52,"context_line":"      });"},{"line_number":53,"context_line":""},{"line_number":54,"context_line":"      it(\u0027successful submit calls the successCallback\u0027, function() {"},{"line_number":55,"context_line":"        var successFunc \u003d {success: angular.noop};"},{"line_number":56,"context_line":"        spyOn(nova, \u0027createKeypair\u0027).and.returnValue(successFunc);"},{"line_number":57,"context_line":"        spyOn(successFunc, \u0027success\u0027);"},{"line_number":58,"context_line":"        ctrl.submit();"}],"source_content_type":"text/javascript","patch_set":2,"id":"9aed3d3a_28f7068c","side":"PARENT","line":55,"in_reply_to":"9aed3d3a_2989f175","updated":"2016-02-29 17:48:34.000000000","message":"I agree with Richard. The submit call is tested in the it(...) above, looks like this one was trying to test for successCallback.","commit_id":"0207d07a091d508262b24156d539e6803bf01b25"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"ba0b76b352156a9dbf10112382a93574e52542dc","unresolved":false,"context_lines":[{"line_number":60,"context_line":"        var successFunc \u003d {success: angular.noop};"},{"line_number":61,"context_line":"        spyOn(successFunc, \u0027success\u0027);"},{"line_number":62,"context_line":"        spyOn(nova, \u0027createKeypair\u0027).and.returnValue(successFunc);"},{"line_number":63,"context_line":"        spyOn(toastService, \u0027add\u0027).and.returnValue({ add: angular.noop });"},{"line_number":64,"context_line":"        ctrl.submit();"},{"line_number":65,"context_line":"        var successCallback \u003d successFunc.success.calls.argsFor(0)[0];"},{"line_number":66,"context_line":"        var data \u003d {name: \u0027newKeypair\u0027};"}],"source_content_type":"text/javascript","patch_set":2,"id":"9aed3d3a_891e3d5d","line":63,"updated":"2016-02-29 05:26:31.000000000","message":"toast.add() shouldn\u0027t be returning an object here, and the code being tested doesn\u0027t do anything with the return from add(). It\u0027s enough to just have this here:\n\n  spyOn(toastService, \u0027add\u0027);","commit_id":"d92226bff35292f43759e5e9da293a146299e60f"},{"author":{"_account_id":9576,"name":"Thai Tran","email":"tqtran@us.ibm.com","username":"tqtran"},"change_message_id":"dbd281fb54bc13860b94d93120c0b6e6b9b68a1f","unresolved":false,"context_lines":[{"line_number":64,"context_line":"        ctrl.submit();"},{"line_number":65,"context_line":"        var successCallback \u003d successFunc.success.calls.argsFor(0)[0];"},{"line_number":66,"context_line":"        var data \u003d {name: \u0027newKeypair\u0027};"},{"line_number":67,"context_line":"        successCallback(data);"},{"line_number":68,"context_line":"        expect(toastService.add).toHaveBeenCalledWith("},{"line_number":69,"context_line":"            \u0027success\u0027,"},{"line_number":70,"context_line":"            \u0027Successfully imported key pair newKeypair.\u0027"}],"source_content_type":"text/javascript","patch_set":2,"id":"9aed3d3a_a32cd999","line":67,"updated":"2016-02-29 17:48:34.000000000","message":"Manually calling successCallback does not make sense. ctrl.submit() should invoke the success handler automatically. All we need to do is check that it was invoked.","commit_id":"d92226bff35292f43759e5e9da293a146299e60f"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"058d9399da8ef85de73dc92e670bf913694dbfe2","unresolved":false,"context_lines":[{"line_number":25,"context_line":"      close: angular.noop,"},{"line_number":26,"context_line":"      dismiss: angular.noop"},{"line_number":27,"context_line":"    };"},{"line_number":28,"context_line":"    var toastServiceMock \u003d {add: angular.noop};"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"    beforeEach(module(\u0027horizon.app.core.openstack-service-api\u0027));"},{"line_number":31,"context_line":"    beforeEach(module(\u0027horizon.dashboard.project\u0027));"}],"source_content_type":"text/javascript","patch_set":5,"id":"7af24918_037abe87","line":28,"updated":"2016-03-04 00:09:07.000000000","message":"We should be injecting the modal and toast services, rather than mocking them.","commit_id":"0f8574d9d7ff99aea694b32734b0b24b0a8d42a3"},{"author":{"_account_id":9622,"name":"Cindy Lu","email":"clu@us.ibm.com","username":"clu14"},"change_message_id":"f05b9ae781624d6f63b9b729c6a321494880d7c3","unresolved":false,"context_lines":[{"line_number":24,"context_line":"    var modalInstanceMock \u003d {"},{"line_number":25,"context_line":"      close: angular.noop,"},{"line_number":26,"context_line":"      dismiss: angular.noop"},{"line_number":27,"context_line":"    };"},{"line_number":28,"context_line":""},{"line_number":29,"context_line":"    beforeEach(module(\u0027horizon.app.core.openstack-service-api\u0027));"},{"line_number":30,"context_line":"    beforeEach(module(\u0027horizon.dashboard.project\u0027));"}],"source_content_type":"text/javascript","patch_set":6,"id":"7af24918_e9da1316","line":27,"updated":"2016-03-04 01:34:22.000000000","message":"Thanks Richard!! I don\u0027t think there\u0027s a mocked version of $modalInstance to inject or maybe I\u0027m mistaken? :\\","commit_id":"351c9eb2b22a5a7dcdc2e08f05a714fb31d5e9ca"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"537cdba0c13f869ab4cb7472e2dd68dce38a5325","unresolved":false,"context_lines":[{"line_number":24,"context_line":"    var modalInstanceMock \u003d {"},{"line_number":25,"context_line":"      close: angular.noop,"},{"line_number":26,"context_line":"      dismiss: angular.noop"},{"line_number":27,"context_line":"    };"},{"line_number":28,"context_line":""},{"line_number":29,"context_line":"    beforeEach(module(\u0027horizon.app.core.openstack-service-api\u0027));"},{"line_number":30,"context_line":"    beforeEach(module(\u0027horizon.dashboard.project\u0027));"}],"source_content_type":"text/javascript","patch_set":6,"id":"7af24918_698283c9","line":27,"in_reply_to":"7af24918_e9da1316","updated":"2016-03-04 01:43:18.000000000","message":"Oh! Yes, indeed. I do have one suggestion then, rather than using $provide to supply it, perhaps semantically bind the mock closer to the controller then, like below?","commit_id":"351c9eb2b22a5a7dcdc2e08f05a714fb31d5e9ca"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"537cdba0c13f869ab4cb7472e2dd68dce38a5325","unresolved":false,"context_lines":[{"line_number":36,"context_line":""},{"line_number":37,"context_line":"    beforeEach(inject(function($injector, $controller, _$q_, _$rootScope_) {"},{"line_number":38,"context_line":"      novaAPI \u003d $injector.get(\u0027horizon.app.core.openstack-service-api.nova\u0027);"},{"line_number":39,"context_line":"      ctrl \u003d $controller(\u0027LaunchInstanceImportKeyPairController\u0027);"},{"line_number":40,"context_line":"      toastServiceMock \u003d $injector.get(\u0027horizon.framework.widgets.toast.service\u0027);"},{"line_number":41,"context_line":"      $q \u003d _$q_;"},{"line_number":42,"context_line":"      $scope \u003d _$rootScope_.$new();"}],"source_content_type":"text/javascript","patch_set":6,"id":"7af24918_c98d97d4","line":39,"updated":"2016-03-04 01:43:18.000000000","message":"Maybe instead of the $provide, which separates the mock from its use and also spreads the name further and wider, bind it directly to the controller creation? Like so:\n\n   $controller(\n      \u0027LaunchInstanceImportKeyPairController\u0027,\n      {$modalInstance: modalInstanceMock}\n   );\n\n(wow, that controller name is crazy long ;-)","commit_id":"351c9eb2b22a5a7dcdc2e08f05a714fb31d5e9ca"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"537cdba0c13f869ab4cb7472e2dd68dce38a5325","unresolved":false,"context_lines":[{"line_number":39,"context_line":"      ctrl \u003d $controller(\u0027LaunchInstanceImportKeyPairController\u0027);"},{"line_number":40,"context_line":"      toastServiceMock \u003d $injector.get(\u0027horizon.framework.widgets.toast.service\u0027);"},{"line_number":41,"context_line":"      $q \u003d _$q_;"},{"line_number":42,"context_line":"      $scope \u003d _$rootScope_.$new();"},{"line_number":43,"context_line":"    }));"},{"line_number":44,"context_line":""},{"line_number":45,"context_line":"    it(\u0027defines a model with an empty name and public key\u0027, function() {"}],"source_content_type":"text/javascript","patch_set":6,"id":"7af24918_e9a97325","line":42,"updated":"2016-03-04 01:43:18.000000000","message":"You shouldn\u0027t need to create a new $scope if you\u0027re just going to be calling $apply to kick off promise resolution. It\u0027s OK to invoke that on the $rootScope. The code being tested certainly doesn\u0027t care about $scope.","commit_id":"351c9eb2b22a5a7dcdc2e08f05a714fb31d5e9ca"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"72f9e07b6c07f77d8ab6f508325c6fcc5fb0c8b3","unresolved":false,"context_lines":[{"line_number":35,"context_line":"      ctrl \u003d $controller(\u0027LaunchInstanceImportKeyPairController\u0027, {"},{"line_number":36,"context_line":"        $modalInstance: modalInstanceMock"},{"line_number":37,"context_line":"      });"},{"line_number":38,"context_line":"      toastServiceMock \u003d $injector.get(\u0027horizon.framework.widgets.toast.service\u0027);"},{"line_number":39,"context_line":"      $q \u003d _$q_;"},{"line_number":40,"context_line":"      $rootScope \u003d _$rootScope_;"},{"line_number":41,"context_line":"    }));"}],"source_content_type":"text/javascript","patch_set":7,"id":"7af24918_feea96ab","line":38,"updated":"2016-03-04 21:31:37.000000000","message":"This is really a nit, but this should just be called toastService (or just toast) because it\u0027s not a mock, it\u0027s the actual service.","commit_id":"21c34cd5022823cd24293c4af73eff86e31908ba"}]}
