Permalink
Browse files

Adapt findQuery to get events for a repository

  • Loading branch information...
pangratz committed Jul 24, 2012
1 parent 78f26ce commit 3aabe05b047e46737b44c077d0ecc4dd5603f762
Showing with 18 additions and 0 deletions.
  1. +6 −0 app/lib/github_adapter.js
  2. +12 −0 app/tests/unit/github_adapter_test.js
@@ -42,9 +42,15 @@ Dashboard.GitHubAdpater = DS.Adapter.extend({
findQuery: function(store, type, query, modelArray) {
if (Dashboard.Repository.detect(type) && 'watched' === query.type) {
this.watchedRepositories(query.username, modelArray, 'load');
+ } else if (Dashboard.Event.detect(type) && query.username && query.repository) {
+ this.repositoryEvents(query.username, query.repository, modelArray, 'load');
}
},
+ repositoryEvents: function(username, repository, target, callback) {
+ this.ajax('/repos/%@/%@/events'.fmt(username, repository), target, callback);
+ },
+
watchedRepositories: function(username, target, callback) {
this.ajax('/users/%@/watched'.fmt(username), target, callback);
}
@@ -98,4 +98,16 @@ test("invokes ajax", function() {
deepEqual(ajaxUrl, '/users/buster/watched', "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 Dashboard.Event", setupDataSource);
+
+test("invokes ajax", function() {
+ var target = {};
+ dataSource.repositoryEvents('buster', 'bluth', target, 'callback');
+
+ ok(ajaxCalled, 'ajax has been called');
+ 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");
});

0 comments on commit 3aabe05

Please sign in to comment.