Skip to content

Commit

Permalink
Merge pull request #3 from kestutis-stalmokas/fix-definition
Browse files Browse the repository at this point in the history
fix module definition
  • Loading branch information
paulfalgout committed Nov 28, 2015
2 parents b122018 + 81bcf8f commit f52c32d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,19 @@ _.extend(Module.prototype, Backbone.Events, {
if (!definition) { return; }

// build the correct list of arguments for the module definition

// make flattening consistent
// in lodash (v3) it's flatten(collection, deep)
// and in underscore it's flatten(collection, shallow)
var deepFlag = !_.flattenDeep;
var args = _.flatten([
this,
this.app,
Backbone,
Marionette,
Backbone.$, _,
customArgs
]);
], deepFlag);

definition.apply(this, args);
},
Expand Down
12 changes: 9 additions & 3 deletions test/module.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ describe('application modules', function() {

describe('and the define function is provided', function() {
beforeEach(function() {
this.additionalParam = {};
this.module = this.app.module('Mod', this.defineSpy, this.additionalParam);
this.additionalParam1 = [[1], 2];
this.additionalParam2 = {};
this.module = this.app.module('Mod',
this.defineSpy,
this.additionalParam1,
this.additionalParam2
);
});

it('it should add module to the app', function() {
Expand All @@ -71,7 +76,8 @@ describe('application modules', function() {
Marionette,
Backbone.$,
_,
this.additionalParam
this.additionalParam1,
this.additionalParam2
);
});
});
Expand Down

0 comments on commit f52c32d

Please sign in to comment.