diff --git a/test_app/spec/javascripts/controller_builder_spec.js b/test_app/spec/javascripts/controller_builder_spec.js index a2badea..b99e2ec 100644 --- a/test_app/spec/javascripts/controller_builder_spec.js +++ b/test_app/spec/javascripts/controller_builder_spec.js @@ -31,7 +31,7 @@ describe('Paloma.ControllerBuilder', function(){ expect(controller instanceof TestController).toBeTruthy(); }); - it("initializes controller instance's params", function(){ + it("initializes controller instance's params property", function(){ var expectedParams = {a: 1, b: 2}; var correct = true; @@ -43,6 +43,14 @@ describe('Paloma.ControllerBuilder', function(){ expect(correct).toBeTruthy(); }); + + it("initializes controller instance's controller property", function(){ + expect(controller.controller).toEqual('Test'); + }); + + it("initializes controller instance's action property", function(){ + expect(controller.action).toEqual('show'); + }); }); }); diff --git a/vendor/assets/javascripts/paloma/controller_builder.js b/vendor/assets/javascripts/paloma/controller_builder.js index 482b385..74ca00e 100644 --- a/vendor/assets/javascripts/paloma/controller_builder.js +++ b/vendor/assets/javascripts/paloma/controller_builder.js @@ -11,7 +11,12 @@ Paloma.ControllerBuilder.prototype = { var ControllerClass = this._controllerClass(); if ( !ControllerClass ) return null; - return new ControllerClass( this._buildParams() ); + var controller = new ControllerClass( this._buildParams() ); + + controller.controller = this.options.controller; + controller.action = this.options.action; + + return controller; }, _controllerClass: function(){ @@ -20,7 +25,7 @@ Paloma.ControllerBuilder.prototype = { _buildParams: function(){ var params = {}; - + for (var k in this.options.params) if (this.options.params.hasOwnProperty(k)) params[k] = this.options.params[k];