Skip to content

Commit

Permalink
Merge pull request #52 from oskbor/master
Browse files Browse the repository at this point in the history
Fix for issue #51
  • Loading branch information
geekdave committed Apr 29, 2015
2 parents 34c17b1 + 7c3f9da commit 8837dfc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backbone.subroute.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// grab the full URL
var hash;
if (Backbone.history.fragment) {
hash = Backbone.history.getFragment();
hash = Backbone.history.getFragment(Backbone.history.fragment);
} else {
hash = Backbone.history.getHash();
}
Expand Down
2 changes: 1 addition & 1 deletion dist/backbone.subroute.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"grunt-template-jasmine-requirejs": "^0.2.0",
"grunt-version": "^0.3.0",
"jasmine-sinon": "^0.4.0",
"sinon": "^1.10.3",
"sinon": "~1.10.3",
"underscore": "^1.6.0"
},
"keywords": [
Expand Down
40 changes: 39 additions & 1 deletion spec/js/load-url-on-init-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,31 @@ describe("When an initial URL hash is provided at subroute initialization time",
routes: {
"": "handleRootRoute",
"foo": "handleRootFooRoute",
"user/:user": "handleRootUserRoute"
"user/:user": "handleRootUserRoute",
"subroute*args": "initSubRoute"
},
initSubRoute: function(args) {


var testRouter = Backbone.SubRoute.extend({
routes: {
"": "handleDefaultRoute",
"foo": "handleFooRoute",
"profile": "handleProfileRoute"
},
handleDefaultRoute: function() {
that.defaultRouteSpy();
},
handleFooRoute: function() {
that.fooRouteSpy();
},
handleProfileRoute: function() {
that.profileRouteSpy();
}
});

this.baseRouter = new testRouter("subroute");

}
});

Expand Down Expand Up @@ -136,5 +160,19 @@ describe("When an initial URL hash is provided at subroute initialization time",
expect(this.loadUrlSpy).toHaveBeenCalledOnce();
});

it('triggers the "foo" route if the loadURL matches the route', function() {


Backbone.history.loadUrl("subroute/foo");

expect(this.fooRouteSpy).toHaveBeenCalledOnce();
expect(this.fooRouteSpy).toHaveBeenCalledWith();

//Once in this test and once in the implementation
expect(this.loadUrlSpy).toHaveBeenCalledTwice();

});



});

0 comments on commit 8837dfc

Please sign in to comment.