Permalink
Browse files

Implement findQuery for getting user events

  • Loading branch information...
pangratz committed Jul 24, 2012
1 parent cb36ac5 commit efb0f5857e4cabbc662a7cfe6071003e58ad6d37
Showing with 19 additions and 1 deletion.
  1. +6 −0 app/lib/github_adapter.js
  2. +13 −1 app/tests/unit/github_adapter_test.js
@@ -48,9 +48,15 @@ Dashboard.GitHubAdpater = DS.Adapter.extend({
this.watchedRepositories(query.username, modelArray, 'load');
} else if (Dashboard.Event.detect(type) && query.username && query.repository) {
this.repositoryEvents(query.username, query.repository, modelArray, 'load');
} else if (Dashboard.Event.detect(type) && query.username && !query.repository) {
this.userEvents(query.username, modelArray, 'load');
}
},
userEvents: function(username, target, callback) {
this.ajax('/users/%@/events'.fmt(username), target, callback);
},
repositoryEvents: function(username, repository, target, callback) {
this.ajax('/repos/%@/%@/events'.fmt(username, repository), target, callback);
},
@@ -110,7 +110,7 @@ test("invokes ajax", function() {
deepEqual(ajaxCallback, 'callback', "the callback has been passed");
});
module("Dashboard.GitHubAdpater#findQuery for Dashboard.Event", setupDataSource);
module("Dashboard.GitHubAdpater#findQuery for repository events", setupDataSource);
test("invokes ajax", function() {
var target = {};
@@ -120,4 +120,16 @@ test("invokes ajax", function() {
deepEqual(ajaxUrl, '/repos/buster/bluth/events', "the passed url is correct");
deepEqual(ajaxTarget, target, "the target has been passed");
deepEqual(ajaxCallback, 'callback', "the callback has been passed");
});
module("Dashboard.GitHubAdpater#findQuery for user events", setupDataSource);
test("invokes ajax", function() {
var target = {};
dataSource.userEvents('buster', target, 'callback');
ok(ajaxCalled, 'ajax has been called');
deepEqual(ajaxUrl, '/users/buster/events', "the passed url is correct");
deepEqual(ajaxTarget, target, "the target has been passed");
deepEqual(ajaxCallback, 'callback', "the callback has been passed");
});

0 comments on commit efb0f58

Please sign in to comment.