Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #51 #52

Merged
merged 2 commits into from
Apr 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();

});



});