From b7845c59d341b732ad3989a4018881d5771dabce Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sun, 27 Mar 2016 14:54:08 -0400 Subject: [PATCH 1/2] Specify api user when retrieving twiddles --- app/adapters/gist.js | 8 ++++++++ app/twiddles/route.js | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/adapters/gist.js diff --git a/app/adapters/gist.js b/app/adapters/gist.js new file mode 100644 index 00000000..d27426ed --- /dev/null +++ b/app/adapters/gist.js @@ -0,0 +1,8 @@ +import ApplicationAdapter from './application'; + +export default ApplicationAdapter.extend({ + urlForQuery: function(query) { + const host = this.host || ""; + return `${host}/users/${query.user}/gists`; + } +}); diff --git a/app/twiddles/route.js b/app/twiddles/route.js index 32616568..6c81dbbd 100644 --- a/app/twiddles/route.js +++ b/app/twiddles/route.js @@ -12,7 +12,10 @@ export default Ember.Route.extend({ }, model() { - return this.get('store').query('gist', { per_page: 100 }); + return this.get('store').query('gist', { + user: this.get('session.currentUser.login'), + per_page: 100 + }); }, actions: { From 7cb9a4a7daf65ebf04ffd250848d163e3aeb8213 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sun, 27 Mar 2016 15:19:45 -0400 Subject: [PATCH 2/2] Fix tests --- app/adapters/gist.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/adapters/gist.js b/app/adapters/gist.js index d27426ed..8a35fdbe 100644 --- a/app/adapters/gist.js +++ b/app/adapters/gist.js @@ -3,6 +3,10 @@ import ApplicationAdapter from './application'; export default ApplicationAdapter.extend({ urlForQuery: function(query) { const host = this.host || ""; - return `${host}/users/${query.user}/gists`; + if (query.user) { + return `${host}/users/${query.user}/gists`; + } else { + return `${host}/gists`; + } } });