Permalink
Browse files

Add Dashboard.RepositoriesController and corresponding tests

  • Loading branch information...
pangratz committed Jul 22, 2012
1 parent 26d869b commit 5c203a1ee330ac800aae17f2efdfd4568f7cd243
Showing with 40 additions and 0 deletions.
  1. +8 −0 app/lib/controller.js
  2. +32 −0 app/tests/controller_tests.js
View
@@ -0,0 +1,8 @@
require('dashboard/core');
Dashboard.RepositoriesController = Ember.ArrayController.extend({
sortProperties: 'full_name'.w(),
loadWatchedRepositories: function(username) {
this.get('dataSource').watchedRepositories(username, this, 'addObjects');
}
});
@@ -0,0 +1,32 @@
require('dashboard/controller');
var controller;
module("Dashboard.RepositoriesController", {
setup: function() {
controller = Dashboard.RepositoriesController.create();
},
teardowm: function() {
controller.destroy();
}
});
test("it exists", function() {
ok(Dashboard.RepositoriesController, "it exists");
});
test("loadWatchedRepositories invokes watchedRepositories on dataSource", function() {
var watchedRepositoriesCalled, usernameParameter;
var dataSource = {
watchedRepositories: function(username) {
watchedRepositoriesCalled = true;
usernameParameter = username;
}
};
Ember.run(function() { controller.set('dataSource', dataSource); });
controller.loadWatchedRepositories('buster');
ok(watchedRepositoriesCalled, "loadWatchedRepositories on dataSource has been called");
equal(usernameParameter, 'buster', "supplied username has been passed to dataSource");
});

0 comments on commit 5c203a1

Please sign in to comment.