Skip to content

Commit

Permalink
Mix Ember.Routable into Ember.Route instead of Ember.State
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Jun 13, 2012
1 parent 927cf87 commit d8383b6
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 107 deletions.
6 changes: 3 additions & 3 deletions packages/ember-application/tests/system/action_url_test.js
Expand Up @@ -67,8 +67,8 @@ test("it sets an URL with a context", function() {
setURL: Ember.K setURL: Ember.K
}, },
namespace: namespace, namespace: namespace,
root: Ember.State.create({ root: Ember.Route.create({
index: Ember.State.create({ index: Ember.Route.create({
route: '/', route: '/',


showDashboard: function(router) { showDashboard: function(router) {
Expand All @@ -80,7 +80,7 @@ test("it sets an URL with a context", function() {
} }
}), }),


dashboard: Ember.State.create({ dashboard: Ember.Route.create({
route: '/dashboard/:component_id' route: '/dashboard/:component_id'
}) })
}) })
Expand Down
16 changes: 8 additions & 8 deletions packages/ember-application/tests/system/application_test.js
Expand Up @@ -131,8 +131,8 @@ test('initialized application go to initial route', function() {
onUpdateURL: function() {} onUpdateURL: function() {}
}, },


root: Ember.State.extend({ root: Ember.Route.extend({
index: Ember.State.extend({ index: Ember.Route.extend({
route: '/' route: '/'
}) })
}) })
Expand Down Expand Up @@ -166,8 +166,8 @@ test("initialize application with stateManager via initialize call", function()
app.Router = Ember.Router.extend({ app.Router = Ember.Router.extend({
location: 'none', location: 'none',


root: Ember.State.extend({ root: Ember.Route.extend({
index: Ember.State.extend({ index: Ember.Route.extend({
route: '/' route: '/'
}) })
}) })
Expand All @@ -190,8 +190,8 @@ test("initialize application with stateManager via initialize call from Router c
app.Router = Ember.Router.extend({ app.Router = Ember.Router.extend({
location: 'none', location: 'none',


root: Ember.State.extend({ root: Ember.Route.extend({
index: Ember.State.extend({ index: Ember.Route.extend({
route: '/' route: '/'
}) })
}) })
Expand Down Expand Up @@ -263,8 +263,8 @@ test("ApplicationView is inserted into the page", function() {
app.Router = Ember.Router.extend({ app.Router = Ember.Router.extend({
location: 'none', location: 'none',


root: Ember.State.extend({ root: Ember.Route.extend({
index: Ember.State.extend({ index: Ember.Route.extend({
route: '/' route: '/'
}) })
}) })
Expand Down
1 change: 1 addition & 0 deletions packages/ember-states/lib/main.js
Expand Up @@ -7,4 +7,5 @@
require('ember-runtime'); require('ember-runtime');
require('ember-states/state_manager'); require('ember-states/state_manager');
require('ember-states/state'); require('ember-states/state');
require('ember-states/route');
require('ember-states/router'); require('ember-states/router');
2 changes: 0 additions & 2 deletions packages/ember-states/lib/routable.js
Expand Up @@ -321,5 +321,3 @@ Ember.Routable = Ember.Mixin.create({
*/ */
connectOutlets: Ember.K connectOutlets: Ember.K
}); });

Ember.State.reopen(Ember.Routable);
7 changes: 7 additions & 0 deletions packages/ember-states/lib/route.js
@@ -0,0 +1,7 @@
require('ember-states/state');
require('ember-states/routable');

/**
@class
*/
Ember.Route = Ember.State.extend(Ember.Routable);
111 changes: 43 additions & 68 deletions packages/ember-states/tests/routable_test.js
Expand Up @@ -8,7 +8,7 @@ test("it should have its updateRoute method called when it is entered", function


expect(2); expect(2);


var state = Ember.State.create({ var state = Ember.Route.create({
route: 'foo', route: 'foo',
updateRoute: function(manager, location) { updateRoute: function(manager, location) {
ok(true, "updateRoute was called"); ok(true, "updateRoute was called");
Expand All @@ -18,7 +18,7 @@ test("it should have its updateRoute method called when it is entered", function


var router = Ember.Router.create({ var router = Ember.Router.create({
location: locationStub, location: locationStub,
root: Ember.State.create({ root: Ember.Route.create({
ready: function(manager) { ready: function(manager) {
manager.transitionTo('initial'); manager.transitionTo('initial');
}, },
Expand Down Expand Up @@ -80,39 +80,14 @@ test("a RouteMatcher generates routes with dynamic segments", function() {
}); });


test("route repeatedly descends into a nested hierarchy", function() { test("route repeatedly descends into a nested hierarchy", function() {
var state = Ember.State.create({ var state = Ember.Route.create({
fooChild: Ember.State.create({ fooChild: Ember.Route.create({
route: 'foo', route: 'foo',


barChild: Ember.State.create({ barChild: Ember.Route.create({
route: 'bar', route: 'bar',


bazChild: Ember.State.create({ bazChild: Ember.Route.create({
route: 'baz'
})
})
})
});

var router = Ember.Router.create({
location: 'none',
root: state
});

router.route("/foo/bar/baz");

equal(router.getPath('currentState.path'), 'root.fooChild.barChild.bazChild');
});

test("route repeatedly descends into a nested hierarchy", function() {
var state = Ember.State.create({
fooChild: Ember.State.create({
route: 'foo',

barChild: Ember.State.create({
route: 'bar',

bazChild: Ember.State.create({
route: 'baz' route: 'baz'
}) })
}) })
Expand All @@ -130,18 +105,18 @@ test("route repeatedly descends into a nested hierarchy", function() {
}); });


test("when you descend into a state, the route is set", function() { test("when you descend into a state, the route is set", function() {
var state = Ember.State.create({ var state = Ember.Route.create({
ready: function(manager) { ready: function(manager) {
manager.transitionTo('fooChild.barChild.bazChild'); manager.transitionTo('fooChild.barChild.bazChild');
}, },


fooChild: Ember.State.create({ fooChild: Ember.Route.create({
route: 'foo', route: 'foo',


barChild: Ember.State.create({ barChild: Ember.Route.create({
route: 'bar', route: 'bar',


bazChild: Ember.State.create({ bazChild: Ember.Route.create({
route: 'baz' route: 'baz'
}) })
}) })
Expand Down Expand Up @@ -185,7 +160,7 @@ module("Routing Serialization and Deserialization", {
setup: function() { setup: function() {
router = Ember.Router.create({ router = Ember.Router.create({
location: locationMock, location: locationMock,
root: Ember.State.create({ root: Ember.Route.create({
ready: function(manager, post) { ready: function(manager, post) {
manager.transitionTo('post.show', { post: post }); manager.transitionTo('post.show', { post: post });
}, },
Expand All @@ -194,18 +169,18 @@ module("Routing Serialization and Deserialization", {
manager.transitionTo('post.index'); manager.transitionTo('post.index');
}, },


post: Ember.State.create({ post: Ember.Route.create({
route: '/posts', route: '/posts',


index: Ember.State.create({ index: Ember.Route.create({
route: '/', route: '/',


showPost: function(manager, post) { showPost: function(manager, post) {
manager.transitionTo('post.show', { post: post }); manager.transitionTo('post.show', { post: post });
} }
}), }),


show: Ember.State.create({ show: Ember.Route.create({
route: "/:post_id", route: "/:post_id",


connectOutlets: function(manager, context) { connectOutlets: function(manager, context) {
Expand Down Expand Up @@ -281,8 +256,8 @@ module("default serialize and deserialize with modelType", {
} }
}, },


root: Ember.State.extend({ root: Ember.Route.extend({
post: Ember.State.extend({ post: Ember.Route.extend({
route: '/posts/:post_id', route: '/posts/:post_id',
modelType: 'TestApp.Post', modelType: 'TestApp.Post',


Expand All @@ -291,7 +266,7 @@ module("default serialize and deserialize with modelType", {
} }
}), }),


user: Ember.State.extend({ user: Ember.Route.extend({
route: '/users/:user_id', route: '/users/:user_id',
modelType: window.TestApp.User, modelType: window.TestApp.User,


Expand Down Expand Up @@ -355,8 +330,8 @@ module("default serialize and deserialize without modelType", {
} }
}, },


root: Ember.State.extend({ root: Ember.Route.extend({
post: Ember.State.extend({ post: Ember.Route.extend({
route: '/posts/:post_id', route: '/posts/:post_id',


connectOutlets: function(router, post) { connectOutlets: function(router, post) {
Expand Down Expand Up @@ -390,14 +365,14 @@ module("redirectsTo");
test("if a leaf state has a redirectsTo, it automatically transitions into that state", function() { test("if a leaf state has a redirectsTo, it automatically transitions into that state", function() {
var router = Ember.Router.create({ var router = Ember.Router.create({
location: 'none', location: 'none',
root: Ember.State.create({ root: Ember.Route.create({


index: Ember.State.create({ index: Ember.Route.create({
route: '/', route: '/',
redirectsTo: 'someOtherState' redirectsTo: 'someOtherState'
}), }),


someOtherState: Ember.State.create({ someOtherState: Ember.Route.create({
route: '/other' route: '/other'
}) })
}) })
Expand All @@ -414,8 +389,8 @@ test("you cannot define connectOutlets AND redirectsTo", function() {
raises(function() { raises(function() {
Ember.Router.create({ Ember.Router.create({
location: 'none', location: 'none',
root: Ember.State.create({ root: Ember.Route.create({
index: Ember.State.create({ index: Ember.Route.create({
route: '/', route: '/',
redirectsTo: 'someOtherState', redirectsTo: 'someOtherState',
connectOutlets: function() {} connectOutlets: function() {}
Expand All @@ -429,10 +404,10 @@ test("you cannot have a redirectsTo in a non-leaf state", function () {
raises(function() { raises(function() {
Ember.Router.create({ Ember.Router.create({
location: 'none', location: 'none',
root: Ember.State.create({ root: Ember.Route.create({
redirectsTo: 'someOtherState', redirectsTo: 'someOtherState',


index: Ember.State.create() index: Ember.Route.create()
}) })
}); });
}); });
Expand All @@ -457,8 +432,8 @@ test("urlFor returns an absolute route", function() {


var router = Ember.Router.create({ var router = Ember.Router.create({
location: locationStub, location: locationStub,
root: Ember.State.create({ root: Ember.Route.create({
dashboard: Ember.State.create({ dashboard: Ember.Route.create({
route: '/dashboard' route: '/dashboard'
}) })
}) })
Expand All @@ -472,8 +447,8 @@ test("urlFor returns an absolute route", function() {
test("urlFor raises an error when route property is not defined", function() { test("urlFor raises an error when route property is not defined", function() {
var router = Ember.Router.create({ var router = Ember.Router.create({
location: locationStub, location: locationStub,
root: Ember.State.create({ root: Ember.Route.create({
dashboard: Ember.State.create({}) // state without route property dashboard: Ember.Route.create({}) // state without route property
}) })
}); });


Expand All @@ -486,11 +461,11 @@ test("urlFor supports dynamic segments", function() {
var router = Ember.Router.create({ var router = Ember.Router.create({
location: locationStub, location: locationStub,


root: Ember.State.create({ root: Ember.Route.create({
dashboard: Ember.State.create({ dashboard: Ember.Route.create({
route: '/dashboard', route: '/dashboard',


posts: Ember.State.create({ posts: Ember.Route.create({
route: '/posts/:post_id' route: '/posts/:post_id'
}) })
}) })
Expand All @@ -512,18 +487,18 @@ test("urlFor supports using the current information for dynamic segments", funct
} }
}, },


root: Ember.State.create({ root: Ember.Route.create({
dashboard: Ember.State.create({ dashboard: Ember.Route.create({
route: '/dashboard', route: '/dashboard',


posts: Ember.State.create({ posts: Ember.Route.create({
route: '/posts/:post_id', route: '/posts/:post_id',


index: Ember.State.create({ index: Ember.Route.create({
route: '/' route: '/'
}), }),


manage: Ember.State.create({ manage: Ember.Route.create({
route: '/manage' route: '/manage'
}) })
}) })
Expand Down Expand Up @@ -555,18 +530,18 @@ test("urlFor supports merging the current information for dynamic segments", fun
} }
}, },


root: Ember.State.create({ root: Ember.Route.create({
dashboard: Ember.State.create({ dashboard: Ember.Route.create({
route: '/dashboard', route: '/dashboard',


posts: Ember.State.create({ posts: Ember.Route.create({
route: '/posts/:post_id', route: '/posts/:post_id',


index: Ember.State.create({ index: Ember.Route.create({
route: '/' route: '/'
}), }),


manage: Ember.State.create({ manage: Ember.Route.create({
route: '/manage/:widget_id' route: '/manage/:widget_id'
}) })
}) })
Expand Down

0 comments on commit d8383b6

Please sign in to comment.