{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/comments/49238723","id":49238723,"diff_hunk":"@@ -0,0 +1,172 @@\n+define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {\n+    'use strict';\n+\n+    var fakeRequests, expectRequest, expectJsonRequest, expectPostRequest, expectRequestURL,\n+        respondWithJson, respondWithError, respondWithTextError, respondWithNoContent;\n+\n+    /* These utility methods are used by Jasmine tests to create a mock server or\n+     * get reference to mock requests. In either case, the cleanup (restore) is done with\n+     * an after function.\n+     *\n+     * This pattern is being used instead of the more common beforeEach/afterEach pattern\n+     * because we were seeing sporadic failures in the afterEach restore call. The cause of the\n+     * errors were that one test suite was incorrectly being linked as the parent of an unrelated\n+     * test suite (causing both suites' afterEach methods to be called). No solution for the root\n+     * cause has been found, but initializing sinon and cleaning it up on a method-by-method\n+     * basis seems to work. For more details, see STUD-1264.\n+     */\n+\n+    /**\n+     * Get a reference to the mocked server, and respond\n+     * to all requests with the specified statusCode.\n+     *\n+     * TODO (pfogg): removing this for now. Jasmine 2.0 removes the\n+     * `after` hook (as well as the ability to get a reference to the\n+     * current spec). As a result this function is broken, and it's\n+     * not used anywhere regardless. Fixing this is likely as simple\n+     * as converting it to work as a decorator/HOF like `fakeRequests`\n+     * below.\n+     */\n+    // fakeServer = function (that, response) {\n+    //     var server = sinon.fakeServer.create();\n+    //     that.after(function() {\n+    //         server.restore();\n+    //     });\n+    //     server.respondWith(response);\n+    //     return server;\n+    // };\n+\n+    /**\n+     * Keep track of all requests to a fake server, and call `spec`\n+     * with a reference to the server. Allows tests to respond to\n+     * individual requests.\n+     */\n+    fakeRequests = function (spec) {\n+        return function () {\n+            var requests = [],\n+                xhr = sinon.useFakeXMLHttpRequest(),\n+                args = Array.prototype.slice.call(arguments);\n+            xhr.onCreate = function(request) {\n+                requests.push(request);\n+            };\n+            spec.apply(null, args.concat([requests]));\n+            xhr.restore();\n+        };\n+    };\n+\n+    expectRequest = function(requests, method, url, body, requestIndex) {\n+        var request;\n+        if (_.isUndefined(requestIndex)) {\n+            requestIndex = requests.length - 1;\n+        }\n+        request = requests[requestIndex];\n+        expect(request.url).toEqual(url);\n+        expect(request.method).toEqual(method);\n+        expect(request.requestBody).toEqual(body);\n+    };\n+\n+    expectJsonRequest = function(requests, method, url, jsonRequest, requestIndex) {\n+        var request;\n+        if (_.isUndefined(requestIndex)) {\n+            requestIndex = requests.length - 1;\n+        }\n+        request = requests[requestIndex];\n+        expect(request.url).toEqual(url);\n+        expect(request.method).toEqual(method);\n+        expect(JSON.parse(request.requestBody)).toEqual(jsonRequest);\n+    };\n+\n+    /**\n+     * Expect that a JSON request be made with the given URL and parameters.\n+     * @param requests The collected requests\n+     * @param expectedUrl The expected URL excluding the parameters\n+     * @param expectedParameters An object representing the URL parameters\n+     * @param requestIndex An optional index for the request (by default, the last request is used)\n+     */\n+    expectRequestURL = function(requests, expectedUrl, expectedParameters, requestIndex) {\n+        var request, parameters;\n+        if (_.isUndefined(requestIndex)) {\n+            requestIndex = requests.length - 1;\n+        }\n+        request = requests[requestIndex];\n+        expect(new URI(request.url).path()).toEqual(expectedUrl);\n+        parameters = new URI(request.url).query(true);\n+        delete parameters._;  // Ignore the cache-busting argument\n+        expect(parameters).toEqual(expectedParameters);\n+    };\n+\n+    /**\n+     * Intended for use with POST requests using application/x-www-form-urlencoded.\n+     */\n+    expectPostRequest = function(requests, url, body, requestIndex) {\n+        var request;\n+        if (_.isUndefined(requestIndex)) {\n+            requestIndex = requests.length - 1;\n+        }\n+        request = requests[requestIndex];\n+        expect(request.url).toEqual(url);\n+        expect(request.method).toEqual('POST');\n+        expect(_.difference(request.requestBody.split('&'), body.split('&'))).toEqual([]);\n+    };\n+\n+    respondWithJson = function(requests, jsonResponse, requestIndex) {","path":"test/utils/ajax_helpers.js","position":112,"original_position":112,"commit_id":"7a6a31fe52e4ebc739bd537f701380330c00c8eb","original_commit_id":"7a6a31fe52e4ebc739bd537f701380330c00c8eb","user":{"login":"andy-armstrong","id":5985072,"avatar_url":"https://avatars.githubusercontent.com/u/5985072?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-armstrong","html_url":"https://github.com/andy-armstrong","followers_url":"https://api.github.com/users/andy-armstrong/followers","following_url":"https://api.github.com/users/andy-armstrong/following{/other_user}","gists_url":"https://api.github.com/users/andy-armstrong/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-armstrong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-armstrong/subscriptions","organizations_url":"https://api.github.com/users/andy-armstrong/orgs","repos_url":"https://api.github.com/users/andy-armstrong/repos","events_url":"https://api.github.com/users/andy-armstrong/events{/privacy}","received_events_url":"https://api.github.com/users/andy-armstrong/received_events","type":"User","site_admin":false},"body":"Another missing doc string.","created_at":"2016-01-08T21:13:22Z","updated_at":"2016-01-08T21:13:22Z","html_url":"https://github.com/edx/edx-ui-toolkit/pull/2#discussion_r49238723","pull_request_url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/comments/49238723"},"html":{"href":"https://github.com/edx/edx-ui-toolkit/pull/2#discussion_r49238723"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2","id":45344750,"html_url":"https://github.com/edx/edx-ui-toolkit/pull/2","diff_url":"https://github.com/edx/edx-ui-toolkit/pull/2.diff","patch_url":"https://github.com/edx/edx-ui-toolkit/pull/2.patch","issue_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/2","number":2,"state":"open","locked":false,"title":"[WIP] Introduce pagination components","user":{"login":"andy-armstrong","id":5985072,"avatar_url":"https://avatars.githubusercontent.com/u/5985072?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-armstrong","html_url":"https://github.com/andy-armstrong","followers_url":"https://api.github.com/users/andy-armstrong/followers","following_url":"https://api.github.com/users/andy-armstrong/following{/other_user}","gists_url":"https://api.github.com/users/andy-armstrong/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-armstrong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-armstrong/subscriptions","organizations_url":"https://api.github.com/users/andy-armstrong/orgs","repos_url":"https://api.github.com/users/andy-armstrong/repos","events_url":"https://api.github.com/users/andy-armstrong/events{/privacy}","received_events_url":"https://api.github.com/users/andy-armstrong/received_events","type":"User","site_admin":false},"body":"https://openedx.atlassian.net/projects/UITK/issues/UITK-1\r\n\r\nThis is my first attempt at bringing the edx-platform's pagination components into the UI Toolkit.\r\n\r\nFYI @dsjen @AlasdairSwan @talbs","created_at":"2015-09-17T21:33:12Z","updated_at":"2016-01-08T21:13:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f1cfe1bf81ca3ca5d5809002ee2b981ce13c9626","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2/commits","review_comments_url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2/comments","review_comment_url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/2/comments","statuses_url":"https://api.github.com/repos/edx/edx-ui-toolkit/statuses/7a6a31fe52e4ebc739bd537f701380330c00c8eb","head":{"label":"edx:andya/add-pagination-components","ref":"andya/add-pagination-components","sha":"7a6a31fe52e4ebc739bd537f701380330c00c8eb","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":40644985,"name":"edx-ui-toolkit","full_name":"edx/edx-ui-toolkit","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-ui-toolkit","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-ui-toolkit","forks_url":"https://api.github.com/repos/edx/edx-ui-toolkit/forks","keys_url":"https://api.github.com/repos/edx/edx-ui-toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ui-toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ui-toolkit/teams","hooks_url":"https://api.github.com/repos/edx/edx-ui-toolkit/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ui-toolkit/events","assignees_url":"https://api.github.com/repos/edx/edx-ui-toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ui-toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ui-toolkit/tags","blobs_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ui-toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ui-toolkit/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ui-toolkit/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ui-toolkit/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ui-toolkit/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ui-toolkit/subscription","commits_url":"https://api.github.com/repos/edx/edx-ui-toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ui-toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-ui-toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ui-toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ui-toolkit/merges","archive_url":"https://api.github.com/repos/edx/edx-ui-toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ui-toolkit/downloads","issues_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ui-toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ui-toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ui-toolkit/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ui-toolkit/releases{/id}","created_at":"2015-08-13T07:28:13Z","updated_at":"2015-09-17T18:38:49Z","pushed_at":"2016-01-08T20:11:22Z","git_url":"git://github.com/edx/edx-ui-toolkit.git","ssh_url":"git@github.com:edx/edx-ui-toolkit.git","clone_url":"https://github.com/edx/edx-ui-toolkit.git","svn_url":"https://github.com/edx/edx-ui-toolkit","homepage":null,"size":64,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":4,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"4ad4ef8b459da788659be2289c12794794a0030a","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":40644985,"name":"edx-ui-toolkit","full_name":"edx/edx-ui-toolkit","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-ui-toolkit","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-ui-toolkit","forks_url":"https://api.github.com/repos/edx/edx-ui-toolkit/forks","keys_url":"https://api.github.com/repos/edx/edx-ui-toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ui-toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ui-toolkit/teams","hooks_url":"https://api.github.com/repos/edx/edx-ui-toolkit/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ui-toolkit/events","assignees_url":"https://api.github.com/repos/edx/edx-ui-toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ui-toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ui-toolkit/tags","blobs_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ui-toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ui-toolkit/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ui-toolkit/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ui-toolkit/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ui-toolkit/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ui-toolkit/subscription","commits_url":"https://api.github.com/repos/edx/edx-ui-toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ui-toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ui-toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-ui-toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ui-toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ui-toolkit/merges","archive_url":"https://api.github.com/repos/edx/edx-ui-toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ui-toolkit/downloads","issues_url":"https://api.github.com/repos/edx/edx-ui-toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ui-toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ui-toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ui-toolkit/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ui-toolkit/releases{/id}","created_at":"2015-08-13T07:28:13Z","updated_at":"2015-09-17T18:38:49Z","pushed_at":"2016-01-08T20:11:22Z","git_url":"git://github.com/edx/edx-ui-toolkit.git","ssh_url":"git@github.com:edx/edx-ui-toolkit.git","clone_url":"https://github.com/edx/edx-ui-toolkit.git","svn_url":"https://github.com/edx/edx-ui-toolkit","homepage":null,"size":64,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2"},"html":{"href":"https://github.com/edx/edx-ui-toolkit/pull/2"},"issue":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/2"},"comments":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-ui-toolkit/statuses/7a6a31fe52e4ebc739bd537f701380330c00c8eb"}}}}