{"action":"created","comment":{"url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/comments/32843842","id":32843842,"diff_hunk":"@@ -0,0 +1,1175 @@\n+if (typeof(define) !== 'function') {\n+  var define = require('amdefine');\n+}\n+\n+define(['bluebird', 'test/helpers/mocks', 'requirejs'], function(Promise, mocks, requirejs) {\n+  global.Promise = Promise;\n+\n+  var suites = [];\n+\n+  function flatten(array){\n+    var flat = [];\n+    for (var i = 0, l = array.length; i < l; i++){\n+      var type = Object.prototype.toString.call(array[i]).split(' ').pop().split(']').shift().toLowerCase();\n+      if (type) { flat = flat.concat(/^(array|collection|arguments|object)$/.test(type) ? flatten(array[i]) : array[i]); }\n+    }\n+    return flat;\n+  }\n+\n+  suites.push({\n+    name: \"Sync Suite\",\n+    desc: \"testing the sync adapter instance\",\n+\n+    setup: function(env, test){\n+      mocks.defineMocks(env);\n+\n+      global.RemoteStorage = function(){\n+        RemoteStorage.eventHandling(this, 'sync-busy', 'sync-done', 'ready', 'sync-interval-change', 'error');\n+      };\n+      global.RemoteStorage.log = function() {};\n+      global.RemoteStorage.config = {\n+        changeEvents: { local: true, window: false, remote: true, conflict: true }\n+      };\n+      RemoteStorage.Unauthorized = function() { Error.apply(this, arguments); };\n+      RemoteStorage.Unauthorized.prototype = Object.create(Error.prototype);\n+\n+      require('./src/util.js');\n+      if (global.rs_util) {\n+        RemoteStorage.util = global.rs_util;\n+      } else {\n+        global.rs_util = RemoteStorage.util;\n+      }\n+\n+\n+      require('./src/eventhandling.js');\n+      if (global.rs_eventhandling){\n+        RemoteStorage.eventHandling = global.rs_eventhandling;\n+      } else {\n+        global.rs_eventhandling = RemoteStorage.eventHandling;\n+      }\n+\n+      require('./src/cachinglayer.js');\n+      if (global.rs_cachinglayer) {\n+        RemoteStorage.cachingLayer = global.rs_cachinglayer;\n+      } else {\n+        global.rs_cachinglayer = RemoteStorage.cachingLayer;\n+      }\n+\n+      require('./src/inmemorystorage.js');\n+      if (global.rs_ims) {\n+        RemoteStorage.InMemoryStorage = global.rs_ims;\n+      } else {\n+        global.rs_ims = RemoteStorage.InMemoryStorage;\n+      }\n+\n+      require('./src/sync.js');\n+      if (global.rs_sync) {\n+        RemoteStorage.Sync = global.rs_sync;\n+      } else {\n+        global.rs_sync = RemoteStorage.Sync;\n+      }\n+\n+      require('./src/authorize.js');\n+      if (global.rs_authorize) {\n+        RemoteStorage.Authorize = global.rs_authorize;\n+      } else {\n+        global.rs_authorize = RemoteStorage.Authorize;\n+      }\n+\n+      test.done();\n+    },\n+\n+    beforeEach: function(env, test){\n+      env.rs = new RemoteStorage();\n+      env.rs.local = new RemoteStorage.InMemoryStorage(env.rs);\n+      env.rs.remote = new FakeRemote();\n+      env.rs.access = new FakeAccess();\n+      env.rs.caching = new FakeCaching();\n+      env.rs.sync = new RemoteStorage.Sync(env.rs.local, env.rs.remote, env.rs.access, env.rs.caching);\n+      global.remoteStorage = env.rs;\n+\n+      env.rs.sync.numThreads = 5;\n+      env.rs.remote.connected = true;\n+      env.rs.remote.online = true;\n+      env.rs.sync._tasks = {};\n+      env.rs.sync._running = {};\n+\n+      test.done();\n+    },\n+\n+    tests: [\n+      {\n+        desc: \"getParentPath works correctly\",\n+        run: function(env,test){\n+          test.assertAnd(env.rs.sync.getParentPath('/a'), '/');\n+          test.assertAnd(env.rs.sync.getParentPath('/a/'), '/');\n+          test.assertAnd(env.rs.sync.getParentPath('/a/b'), '/a/');\n+          test.assertAnd(env.rs.sync.getParentPath('/a/b/'), '/a/');\n+          test.assertAnd(env.rs.sync.getParentPath('/a/b/c'), '/a/b/');\n+          test.assertAnd(env.rs.sync.getParentPath('/a/b/c/'), '/a/b/');\n+          test.done();\n+        }\n+      },\n+\n+      {\n+        desc: \"RemoteStorage.sync() returns immediately if not connected\",\n+        run: function(env,test){\n+          var failed = false;\n+          env.rs.remote.connected = false;\n+          env.rs.on('sync-busy', function(){\n+            failed = true;\n+          });\n+\n+          env.rs.sync.sync().then(function(){\n+            test.assert(failed, false);\n+          });\n+        }\n+      },\n+\n+      {\n+        desc : \"Sync adapter sets and removes all event listeners\",\n+        run : function(env, test) {\n+          function allHandlers() {\n+            var handlers = env.rs._handlers;\n+            var l = 0;\n+            for (var k in handlers) {\n+              l += handlers[k].length;\n+            }\n+            return l;\n+          }\n+\n+          test.assertAnd(allHandlers(), 0, \"before init found \"+allHandlers()+\" handlers\");\n+\n+          RemoteStorage.Sync._rs_init(env.rs);\n+          test.assertAnd(allHandlers(), 1, \"after init found \"+allHandlers()+\" handlers\");\n+\n+          RemoteStorage.Sync._rs_cleanup(env.rs);\n+          test.assertAnd(allHandlers(), 0, \"after cleanup found \"+allHandlers()+\" handlers\");","path":"test/unit/sync-suite.new.js","position":147,"original_position":147,"commit_id":"14a00f4896d7de926c6faba3afbf4ebeb3792440","original_commit_id":"14a00f4896d7de926c6faba3afbf4ebeb3792440","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Mixed double and single quotes.","created_at":"2015-06-19T16:13:46Z","updated_at":"2015-06-19T16:13:46Z","html_url":"https://github.com/remotestorage/remotestorage.js/pull/868#discussion_r32843842","pull_request_url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868","_links":{"self":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/comments/32843842"},"html":{"href":"https://github.com/remotestorage/remotestorage.js/pull/868#discussion_r32843842"},"pull_request":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868"}}},"pull_request":{"url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868","id":38123218,"html_url":"https://github.com/remotestorage/remotestorage.js/pull/868","diff_url":"https://github.com/remotestorage/remotestorage.js/pull/868.diff","patch_url":"https://github.com/remotestorage/remotestorage.js/pull/868.patch","issue_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/868","number":868,"state":"open","locked":false,"title":"When offline, ignore maxAge (with log) instead of failing","user":{"login":"skddc","id":842,"avatar_url":"https://avatars.githubusercontent.com/u/842?v=3","gravatar_id":"","url":"https://api.github.com/users/skddc","html_url":"https://github.com/skddc","followers_url":"https://api.github.com/users/skddc/followers","following_url":"https://api.github.com/users/skddc/following{/other_user}","gists_url":"https://api.github.com/users/skddc/gists{/gist_id}","starred_url":"https://api.github.com/users/skddc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skddc/subscriptions","organizations_url":"https://api.github.com/users/skddc/orgs","repos_url":"https://api.github.com/users/skddc/repos","events_url":"https://api.github.com/users/skddc/events{/privacy}","received_events_url":"https://api.github.com/users/skddc/received_events","type":"User","site_admin":false},"body":"This is a continuation of #861.\r\n\r\nI reverted my changes to rejecting the promises for internal gets with maxAge and changed it to only set it to false when a default maxAge is added, when disconnected and offline. This is now just a small enhancement, as it was already done when disconnected, and now it's also ignored (with a message) when not explicitly defining a maxAge.\r\n\r\nWhen you explicitly define one, the promise will be rejected, same as before, so you as a developer have the power over how you want it to behave. Either you care about it and set maxAge explicitly, or it just works when offline.\r\n\r\nReady for review/merge.","created_at":"2015-06-19T16:13:29Z","updated_at":"2015-06-19T16:13:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09b09e7aefa5f59cb00a4a2ea7ce46286ea743b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868/commits","review_comments_url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868/comments","review_comment_url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/868/comments","statuses_url":"https://api.github.com/repos/remotestorage/remotestorage.js/statuses/14a00f4896d7de926c6faba3afbf4ebeb3792440","head":{"label":"remotestorage:bugfix/849-offline_mode_max_age_2","ref":"bugfix/849-offline_mode_max_age_2","sha":"14a00f4896d7de926c6faba3afbf4ebeb3792440","user":{"login":"remotestorage","id":2323242,"avatar_url":"https://avatars.githubusercontent.com/u/2323242?v=3","gravatar_id":"","url":"https://api.github.com/users/remotestorage","html_url":"https://github.com/remotestorage","followers_url":"https://api.github.com/users/remotestorage/followers","following_url":"https://api.github.com/users/remotestorage/following{/other_user}","gists_url":"https://api.github.com/users/remotestorage/gists{/gist_id}","starred_url":"https://api.github.com/users/remotestorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remotestorage/subscriptions","organizations_url":"https://api.github.com/users/remotestorage/orgs","repos_url":"https://api.github.com/users/remotestorage/repos","events_url":"https://api.github.com/users/remotestorage/events{/privacy}","received_events_url":"https://api.github.com/users/remotestorage/received_events","type":"Organization","site_admin":false},"repo":{"id":1052694,"name":"remotestorage.js","full_name":"remotestorage/remotestorage.js","owner":{"login":"remotestorage","id":2323242,"avatar_url":"https://avatars.githubusercontent.com/u/2323242?v=3","gravatar_id":"","url":"https://api.github.com/users/remotestorage","html_url":"https://github.com/remotestorage","followers_url":"https://api.github.com/users/remotestorage/followers","following_url":"https://api.github.com/users/remotestorage/following{/other_user}","gists_url":"https://api.github.com/users/remotestorage/gists{/gist_id}","starred_url":"https://api.github.com/users/remotestorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remotestorage/subscriptions","organizations_url":"https://api.github.com/users/remotestorage/orgs","repos_url":"https://api.github.com/users/remotestorage/repos","events_url":"https://api.github.com/users/remotestorage/events{/privacy}","received_events_url":"https://api.github.com/users/remotestorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/remotestorage/remotestorage.js","description":"JavaScript client library for integrating remoteStorage in apps","fork":false,"url":"https://api.github.com/repos/remotestorage/remotestorage.js","forks_url":"https://api.github.com/repos/remotestorage/remotestorage.js/forks","keys_url":"https://api.github.com/repos/remotestorage/remotestorage.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/remotestorage/remotestorage.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/remotestorage/remotestorage.js/teams","hooks_url":"https://api.github.com/repos/remotestorage/remotestorage.js/hooks","issue_events_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/events{/number}","events_url":"https://api.github.com/repos/remotestorage/remotestorage.js/events","assignees_url":"https://api.github.com/repos/remotestorage/remotestorage.js/assignees{/user}","branches_url":"https://api.github.com/repos/remotestorage/remotestorage.js/branches{/branch}","tags_url":"https://api.github.com/repos/remotestorage/remotestorage.js/tags","blobs_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/remotestorage/remotestorage.js/statuses/{sha}","languages_url":"https://api.github.com/repos/remotestorage/remotestorage.js/languages","stargazers_url":"https://api.github.com/repos/remotestorage/remotestorage.js/stargazers","contributors_url":"https://api.github.com/repos/remotestorage/remotestorage.js/contributors","subscribers_url":"https://api.github.com/repos/remotestorage/remotestorage.js/subscribers","subscription_url":"https://api.github.com/repos/remotestorage/remotestorage.js/subscription","commits_url":"https://api.github.com/repos/remotestorage/remotestorage.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/remotestorage/remotestorage.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/remotestorage/remotestorage.js/contents/{+path}","compare_url":"https://api.github.com/repos/remotestorage/remotestorage.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/remotestorage/remotestorage.js/merges","archive_url":"https://api.github.com/repos/remotestorage/remotestorage.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/remotestorage/remotestorage.js/downloads","issues_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues{/number}","pulls_url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls{/number}","milestones_url":"https://api.github.com/repos/remotestorage/remotestorage.js/milestones{/number}","notifications_url":"https://api.github.com/repos/remotestorage/remotestorage.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/remotestorage/remotestorage.js/labels{/name}","releases_url":"https://api.github.com/repos/remotestorage/remotestorage.js/releases{/id}","created_at":"2010-11-04T23:09:23Z","updated_at":"2015-06-17T02:28:07Z","pushed_at":"2015-06-19T16:13:29Z","git_url":"git://github.com/remotestorage/remotestorage.js.git","ssh_url":"git@github.com:remotestorage/remotestorage.js.git","clone_url":"https://github.com/remotestorage/remotestorage.js.git","svn_url":"https://github.com/remotestorage/remotestorage.js","homepage":"http://remotestorage.io","size":120340,"stargazers_count":604,"watchers_count":604,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":69,"mirror_url":null,"open_issues_count":84,"forks":69,"open_issues":84,"watchers":604,"default_branch":"master"}},"base":{"label":"remotestorage:master","ref":"master","sha":"a145f8389b9009baa626a575e885883f357f2b2e","user":{"login":"remotestorage","id":2323242,"avatar_url":"https://avatars.githubusercontent.com/u/2323242?v=3","gravatar_id":"","url":"https://api.github.com/users/remotestorage","html_url":"https://github.com/remotestorage","followers_url":"https://api.github.com/users/remotestorage/followers","following_url":"https://api.github.com/users/remotestorage/following{/other_user}","gists_url":"https://api.github.com/users/remotestorage/gists{/gist_id}","starred_url":"https://api.github.com/users/remotestorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remotestorage/subscriptions","organizations_url":"https://api.github.com/users/remotestorage/orgs","repos_url":"https://api.github.com/users/remotestorage/repos","events_url":"https://api.github.com/users/remotestorage/events{/privacy}","received_events_url":"https://api.github.com/users/remotestorage/received_events","type":"Organization","site_admin":false},"repo":{"id":1052694,"name":"remotestorage.js","full_name":"remotestorage/remotestorage.js","owner":{"login":"remotestorage","id":2323242,"avatar_url":"https://avatars.githubusercontent.com/u/2323242?v=3","gravatar_id":"","url":"https://api.github.com/users/remotestorage","html_url":"https://github.com/remotestorage","followers_url":"https://api.github.com/users/remotestorage/followers","following_url":"https://api.github.com/users/remotestorage/following{/other_user}","gists_url":"https://api.github.com/users/remotestorage/gists{/gist_id}","starred_url":"https://api.github.com/users/remotestorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remotestorage/subscriptions","organizations_url":"https://api.github.com/users/remotestorage/orgs","repos_url":"https://api.github.com/users/remotestorage/repos","events_url":"https://api.github.com/users/remotestorage/events{/privacy}","received_events_url":"https://api.github.com/users/remotestorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/remotestorage/remotestorage.js","description":"JavaScript client library for integrating remoteStorage in apps","fork":false,"url":"https://api.github.com/repos/remotestorage/remotestorage.js","forks_url":"https://api.github.com/repos/remotestorage/remotestorage.js/forks","keys_url":"https://api.github.com/repos/remotestorage/remotestorage.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/remotestorage/remotestorage.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/remotestorage/remotestorage.js/teams","hooks_url":"https://api.github.com/repos/remotestorage/remotestorage.js/hooks","issue_events_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/events{/number}","events_url":"https://api.github.com/repos/remotestorage/remotestorage.js/events","assignees_url":"https://api.github.com/repos/remotestorage/remotestorage.js/assignees{/user}","branches_url":"https://api.github.com/repos/remotestorage/remotestorage.js/branches{/branch}","tags_url":"https://api.github.com/repos/remotestorage/remotestorage.js/tags","blobs_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/remotestorage/remotestorage.js/statuses/{sha}","languages_url":"https://api.github.com/repos/remotestorage/remotestorage.js/languages","stargazers_url":"https://api.github.com/repos/remotestorage/remotestorage.js/stargazers","contributors_url":"https://api.github.com/repos/remotestorage/remotestorage.js/contributors","subscribers_url":"https://api.github.com/repos/remotestorage/remotestorage.js/subscribers","subscription_url":"https://api.github.com/repos/remotestorage/remotestorage.js/subscription","commits_url":"https://api.github.com/repos/remotestorage/remotestorage.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/remotestorage/remotestorage.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/remotestorage/remotestorage.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/remotestorage/remotestorage.js/contents/{+path}","compare_url":"https://api.github.com/repos/remotestorage/remotestorage.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/remotestorage/remotestorage.js/merges","archive_url":"https://api.github.com/repos/remotestorage/remotestorage.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/remotestorage/remotestorage.js/downloads","issues_url":"https://api.github.com/repos/remotestorage/remotestorage.js/issues{/number}","pulls_url":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls{/number}","milestones_url":"https://api.github.com/repos/remotestorage/remotestorage.js/milestones{/number}","notifications_url":"https://api.github.com/repos/remotestorage/remotestorage.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/remotestorage/remotestorage.js/labels{/name}","releases_url":"https://api.github.com/repos/remotestorage/remotestorage.js/releases{/id}","created_at":"2010-11-04T23:09:23Z","updated_at":"2015-06-17T02:28:07Z","pushed_at":"2015-06-19T16:13:29Z","git_url":"git://github.com/remotestorage/remotestorage.js.git","ssh_url":"git@github.com:remotestorage/remotestorage.js.git","clone_url":"https://github.com/remotestorage/remotestorage.js.git","svn_url":"https://github.com/remotestorage/remotestorage.js","homepage":"http://remotestorage.io","size":120340,"stargazers_count":604,"watchers_count":604,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":69,"mirror_url":null,"open_issues_count":84,"forks":69,"open_issues":84,"watchers":604,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868"},"html":{"href":"https://github.com/remotestorage/remotestorage.js/pull/868"},"issue":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/868"},"comments":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/issues/868/comments"},"review_comments":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868/comments"},"review_comment":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/pulls/868/commits"},"statuses":{"href":"https://api.github.com/repos/remotestorage/remotestorage.js/statuses/14a00f4896d7de926c6faba3afbf4ebeb3792440"}}}}