GitHub PullRequestReviewCommentEvent at 2014-12-12 00:48:24
Repository: js-routes
Actor: andrewhavens
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/railsware/js-routes/pulls/comments/21722343","id":21722343,"diff_hunk":"@@ -238,56 +238,184 @@\n       end\n     end\n \n-    context \"with host\" do\n-      let(:_options) { { :url_links => \"http://localhost\" } }\n-      it \"should generate path and url links\" do\n-        expect(evaljs(\"Routes.inbox_path\")).not_to be_nil\n-        expect(evaljs(\"Routes.inbox_url\")).not_to be_nil\n-        expect(evaljs(\"Routes.inbox_path(1)\")).to eq(routes.inbox_path(1))\n-        expect(evaljs(\"Routes.inbox_url(1)\")).to eq(\"http://localhost#{routes.inbox_path(1)}\")\n-        expect(evaljs(\"Routes.inbox_url(1, { test_key: \\\"test_val\\\" })\")).to eq(\"http://localhost#{routes.inbox_path(1, :test_key => \"test_val\")}\")\n+    context 'with deprecated, non-boolean config value' do\n+      context \"with host\" do\n+        let(:_options) { { :url_links => \"http://localhost\" } }\n+        it \"should generate path and url links\" do\n+          expect(evaljs(\"Routes.inbox_path\")).not_to be_nil\n+          expect(evaljs(\"Routes.inbox_url\")).not_to be_nil\n+          expect(evaljs(\"Routes.inbox_path(1)\")).to eq(routes.inbox_path(1))\n+          expect(evaljs(\"Routes.inbox_url(1)\")).to eq(\"http://localhost#{routes.inbox_path(1)}\")\n+          expect(evaljs(\"Routes.inbox_url(1, { test_key: \\\"test_val\\\" })\")).to eq(\"http://localhost#{routes.inbox_path(1, :test_key => \"test_val\")}\")\n+        end\n       end\n-    end\n \n-    context \"with invalid host\" do\n-      it \"should raise error\" do\n-        expect { JsRoutes.generate({ :url_links => \"localhost\" }) }.to raise_error RuntimeError\n+      context \"with invalid host\" do\n+        it \"should raise error\" do\n+          expect { JsRoutes.generate({ :url_links => \"localhost\" }) }.to raise_error RuntimeError\n+        end\n       end\n-    end\n \n-    context \"with host and camel_case\" do\n-      let(:_options) { { :camel_case => true, :url_links => \"http://localhost\" } }\n-      it \"should generate path and url links\" do\n-        expect(evaljs(\"Routes.inboxPath\")).not_to be_nil\n-        expect(evaljs(\"Routes.inboxUrl\")).not_to be_nil\n-        expect(evaljs(\"Routes.inboxPath(1)\")).to eq(routes.inbox_path(1))\n-        expect(evaljs(\"Routes.inboxUrl(1)\")).to eq(\"http://localhost#{routes.inbox_path(1)}\")\n+      context \"with host and camel_case\" do\n+        let(:_options) { { :camel_case => true, :url_links => \"http://localhost\" } }\n+        it \"should generate path and url links\" do\n+          expect(evaljs(\"Routes.inboxPath\")).not_to be_nil\n+          expect(evaljs(\"Routes.inboxUrl\")).not_to be_nil\n+          expect(evaljs(\"Routes.inboxPath(1)\")).to eq(routes.inbox_path(1))\n+          expect(evaljs(\"Routes.inboxUrl(1)\")).to eq(\"http://localhost#{routes.inbox_path(1)}\")\n+        end\n+      end\n+\n+      context \"with host and prefix\" do\n+        let(:_options) { { :prefix => \"/api\", :url_links => \"https://example.com\" } }\n+        it \"should generate path and url links\" do\n+          expect(evaljs(\"Routes.inbox_path\")).not_to be_nil\n+          expect(evaljs(\"Routes.inbox_url\")).not_to be_nil\n+          expect(evaljs(\"Routes.inbox_path(1)\")).to eq(\"/api#{routes.inbox_path(1)}\")\n+          expect(evaljs(\"Routes.inbox_url(1)\")).to eq(\"https://example.com/api#{routes.inbox_path(1)}\")\n+        end\n       end\n     end\n \n-    context \"with host and prefix\" do\n-      let(:_options) { { :prefix => \"/api\", :url_links => \"https://example.com\" } }\n-      it \"should generate path and url links\" do\n-        expect(evaljs(\"Routes.inbox_path\")).not_to be_nil\n-        expect(evaljs(\"Routes.inbox_url\")).not_to be_nil\n-        expect(evaljs(\"Routes.inbox_path(1)\")).to eq(\"/api#{routes.inbox_path(1)}\")\n-        expect(evaljs(\"Routes.inbox_url(1)\")).to eq(\"https://example.com/api#{routes.inbox_path(1)}\")\n+    context \"when configuring with default_url_options\" do\n+      context \"when default host is not specified\" do\n+        it \"raises an error\" do\n+          expect { JsRoutes.generate({ :url_links => true }) }.to raise_error RuntimeError\n+        end\n+      end\n+\n+      context \"when default host is specified\" do\n+        let(:_options) { { :url_links => true, :default_url_options => {:host => \"example.com\"} } }\n+        \n+        it \"is used as the host\" do\n+          expect(evaljs(\"Routes.inbox_url\")).not_to be_nil\n+          expect(evaljs(\"Routes.inbox_url(1)\")).to eq(\"http://example.com#{routes.inbox_path(1)}\")\n+        end\n+        \n+        it \"does not override host when specified in route\" do\n+          expect(evaljs(\"Routes.sso_url()\")).to eq(routes.sso_url)\n+        end\n+\n+        it \"does not affect path helpers\" do\n+          expect(evaljs(\"Routes.inbox_path\")).not_to be_nil\n+          expect(evaljs(\"Routes.inbox_path(1)\")).to eq(routes.inbox_path(1))\n+        end\n+      end\n+\n+      context \"when default protocol is not specified\" do","path":"spec/js_routes/options_spec.rb","position":null,"original_position":95,"commit_id":"57f20a6dceafc04edea5f2662bc81d296e1dfefc","original_commit_id":"e148d59598f6e5fa7ffa9357bdbc343a94754ff3","user":{"login":"andrewhavens","id":446392,"avatar_url":"https://avatars.githubusercontent.com/u/446392?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewhavens","html_url":"https://github.com/andrewhavens","followers_url":"https://api.github.com/users/andrewhavens/followers","following_url":"https://api.github.com/users/andrewhavens/following{/other_user}","gists_url":"https://api.github.com/users/andrewhavens/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewhavens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewhavens/subscriptions","organizations_url":"https://api.github.com/users/andrewhavens/orgs","repos_url":"https://api.github.com/users/andrewhavens/repos","events_url":"https://api.github.com/users/andrewhavens/events{/privacy}","received_events_url":"https://api.github.com/users/andrewhavens/received_events","type":"User","site_admin":false},"body":"@bogdan I have updated the tests. Please review.","created_at":"2014-12-12T00:48:24Z","updated_at":"2014-12-12T00:48:24Z","html_url":"https://github.com/railsware/js-routes/pull/137#discussion_r21722343","pull_request_url":"https://api.github.com/repos/railsware/js-routes/pulls/137","_links":{"self":{"href":"https://api.github.com/repos/railsware/js-routes/pulls/comments/21722343"},"html":{"href":"https://github.com/railsware/js-routes/pull/137#discussion_r21722343"},"pull_request":{"href":"https://api.github.com/repos/railsware/js-routes/pulls/137"}}},"pull_request":{"url":"https://api.github.com/repos/railsware/js-routes/pulls/137","id":25861437,"html_url":"https://github.com/railsware/js-routes/pull/137","diff_url":"https://github.com/railsware/js-routes/pull/137.diff","patch_url":"https://github.com/railsware/js-routes/pull/137.patch","issue_url":"https://api.github.com/repos/railsware/js-routes/issues/137","number":137,"state":"open","locked":false,"title":"Add support for host, protocol, and port configuration.","user":{"login":"andrewhavens","id":446392,"avatar_url":"https://avatars.githubusercontent.com/u/446392?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewhavens","html_url":"https://github.com/andrewhavens","followers_url":"https://api.github.com/users/andrewhavens/followers","following_url":"https://api.github.com/users/andrewhavens/following{/other_user}","gists_url":"https://api.github.com/users/andrewhavens/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewhavens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewhavens/subscriptions","organizations_url":"https://api.github.com/users/andrewhavens/orgs","repos_url":"https://api.github.com/users/andrewhavens/repos","events_url":"https://api.github.com/users/andrewhavens/events{/privacy}","received_events_url":"https://api.github.com/users/andrewhavens/received_events","type":"User","site_admin":false},"body":"This PR is an alternative to #131, #132, and fixes #127.\r\n\r\n### New Features:\r\n* Adds support for specifying a default protocol, host, and port in `default_url_options`.\r\n* Adds support for routes which specify a specific protocol, host, or port.\r\n\r\n### Changes:\r\n* Changes expectation of `url_links` to a boolean value and deprecates the previous usage. Default protocol, host, and port are now configured with `default_url_options`.","created_at":"2014-12-10T22:35:42Z","updated_at":"2014-12-12T00:48:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a3f31865d10ee7ed3a821c03fbf03332896cb75","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/railsware/js-routes/pulls/137/commits","review_comments_url":"https://api.github.com/repos/railsware/js-routes/pulls/137/comments","review_comment_url":"https://api.github.com/repos/railsware/js-routes/pulls/comments/{number}","comments_url":"https://api.github.com/repos/railsware/js-routes/issues/137/comments","statuses_url":"https://api.github.com/repos/railsware/js-routes/statuses/57f20a6dceafc04edea5f2662bc81d296e1dfefc","head":{"label":"andrewhavens:feature/default-protocol-host-port","ref":"feature/default-protocol-host-port","sha":"57f20a6dceafc04edea5f2662bc81d296e1dfefc","user":{"login":"andrewhavens","id":446392,"avatar_url":"https://avatars.githubusercontent.com/u/446392?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewhavens","html_url":"https://github.com/andrewhavens","followers_url":"https://api.github.com/users/andrewhavens/followers","following_url":"https://api.github.com/users/andrewhavens/following{/other_user}","gists_url":"https://api.github.com/users/andrewhavens/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewhavens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewhavens/subscriptions","organizations_url":"https://api.github.com/users/andrewhavens/orgs","repos_url":"https://api.github.com/users/andrewhavens/repos","events_url":"https://api.github.com/users/andrewhavens/events{/privacy}","received_events_url":"https://api.github.com/users/andrewhavens/received_events","type":"User","site_admin":false},"repo":{"id":27198103,"name":"js-routes","full_name":"andrewhavens/js-routes","owner":{"login":"andrewhavens","id":446392,"avatar_url":"https://avatars.githubusercontent.com/u/446392?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewhavens","html_url":"https://github.com/andrewhavens","followers_url":"https://api.github.com/users/andrewhavens/followers","following_url":"https://api.github.com/users/andrewhavens/following{/other_user}","gists_url":"https://api.github.com/users/andrewhavens/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewhavens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewhavens/subscriptions","organizations_url":"https://api.github.com/users/andrewhavens/orgs","repos_url":"https://api.github.com/users/andrewhavens/repos","events_url":"https://api.github.com/users/andrewhavens/events{/privacy}","received_events_url":"https://api.github.com/users/andrewhavens/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewhavens/js-routes","description":"Brings Rails named routes to javascript","fork":true,"url":"https://api.github.com/repos/andrewhavens/js-routes","forks_url":"https://api.github.com/repos/andrewhavens/js-routes/forks","keys_url":"https://api.github.com/repos/andrewhavens/js-routes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewhavens/js-routes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewhavens/js-routes/teams","hooks_url":"https://api.github.com/repos/andrewhavens/js-routes/hooks","issue_events_url":"https://api.github.com/repos/andrewhavens/js-routes/issues/events{/number}","events_url":"https://api.github.com/repos/andrewhavens/js-routes/events","assignees_url":"https://api.github.com/repos/andrewhavens/js-routes/assignees{/user}","branches_url":"https://api.github.com/repos/andrewhavens/js-routes/branches{/branch}","tags_url":"https://api.github.com/repos/andrewhavens/js-routes/tags","blobs_url":"https://api.github.com/repos/andrewhavens/js-routes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewhavens/js-routes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewhavens/js-routes/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewhavens/js-routes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewhavens/js-routes/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewhavens/js-routes/languages","stargazers_url":"https://api.github.com/repos/andrewhavens/js-routes/stargazers","contributors_url":"https://api.github.com/repos/andrewhavens/js-routes/contributors","subscribers_url":"https://api.github.com/repos/andrewhavens/js-routes/subscribers","subscription_url":"https://api.github.com/repos/andrewhavens/js-routes/subscription","commits_url":"https://api.github.com/repos/andrewhavens/js-routes/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewhavens/js-routes/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewhavens/js-routes/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewhavens/js-routes/issues/comments/{number}","contents_url":"https://api.github.com/repos/andrewhavens/js-routes/contents/{+path}","compare_url":"https://api.github.com/repos/andrewhavens/js-routes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewhavens/js-routes/merges","archive_url":"https://api.github.com/repos/andrewhavens/js-routes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewhavens/js-routes/downloads","issues_url":"https://api.github.com/repos/andrewhavens/js-routes/issues{/number}","pulls_url":"https://api.github.com/repos/andrewhavens/js-routes/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewhavens/js-routes/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewhavens/js-routes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewhavens/js-routes/labels{/name}","releases_url":"https://api.github.com/repos/andrewhavens/js-routes/releases{/id}","created_at":"2014-11-26T22:01:56Z","updated_at":"2014-12-10T04:42:12Z","pushed_at":"2014-12-12T00:47:57Z","git_url":"git://github.com/andrewhavens/js-routes.git","ssh_url":"git@github.com:andrewhavens/js-routes.git","clone_url":"https://github.com/andrewhavens/js-routes.git","svn_url":"https://github.com/andrewhavens/js-routes","homepage":"http://railsware.github.io/js-routes/","size":580,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"railsware:master","ref":"master","sha":"ebf4bbc79f23146e21b9bdabfda6c5a44e25fd69","user":{"login":"railsware","id":9354,"avatar_url":"https://avatars.githubusercontent.com/u/9354?v=3","gravatar_id":"","url":"https://api.github.com/users/railsware","html_url":"https://github.com/railsware","followers_url":"https://api.github.com/users/railsware/followers","following_url":"https://api.github.com/users/railsware/following{/other_user}","gists_url":"https://api.github.com/users/railsware/gists{/gist_id}","starred_url":"https://api.github.com/users/railsware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/railsware/subscriptions","organizations_url":"https://api.github.com/users/railsware/orgs","repos_url":"https://api.github.com/users/railsware/repos","events_url":"https://api.github.com/users/railsware/events{/privacy}","received_events_url":"https://api.github.com/users/railsware/received_events","type":"Organization","site_admin":false},"repo":{"id":2149005,"name":"js-routes","full_name":"railsware/js-routes","owner":{"login":"railsware","id":9354,"avatar_url":"https://avatars.githubusercontent.com/u/9354?v=3","gravatar_id":"","url":"https://api.github.com/users/railsware","html_url":"https://github.com/railsware","followers_url":"https://api.github.com/users/railsware/followers","following_url":"https://api.github.com/users/railsware/following{/other_user}","gists_url":"https://api.github.com/users/railsware/gists{/gist_id}","starred_url":"https://api.github.com/users/railsware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/railsware/subscriptions","organizations_url":"https://api.github.com/users/railsware/orgs","repos_url":"https://api.github.com/users/railsware/repos","events_url":"https://api.github.com/users/railsware/events{/privacy}","received_events_url":"https://api.github.com/users/railsware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/railsware/js-routes","description":"Brings Rails named routes to javascript","fork":false,"url":"https://api.github.com/repos/railsware/js-routes","forks_url":"https://api.github.com/repos/railsware/js-routes/forks","keys_url":"https://api.github.com/repos/railsware/js-routes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/railsware/js-routes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/railsware/js-routes/teams","hooks_url":"https://api.github.com/repos/railsware/js-routes/hooks","issue_events_url":"https://api.github.com/repos/railsware/js-routes/issues/events{/number}","events_url":"https://api.github.com/repos/railsware/js-routes/events","assignees_url":"https://api.github.com/repos/railsware/js-routes/assignees{/user}","branches_url":"https://api.github.com/repos/railsware/js-routes/branches{/branch}","tags_url":"https://api.github.com/repos/railsware/js-routes/tags","blobs_url":"https://api.github.com/repos/railsware/js-routes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/railsware/js-routes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/railsware/js-routes/git/refs{/sha}","trees_url":"https://api.github.com/repos/railsware/js-routes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/railsware/js-routes/statuses/{sha}","languages_url":"https://api.github.com/repos/railsware/js-routes/languages","stargazers_url":"https://api.github.com/repos/railsware/js-routes/stargazers","contributors_url":"https://api.github.com/repos/railsware/js-routes/contributors","subscribers_url":"https://api.github.com/repos/railsware/js-routes/subscribers","subscription_url":"https://api.github.com/repos/railsware/js-routes/subscription","commits_url":"https://api.github.com/repos/railsware/js-routes/commits{/sha}","git_commits_url":"https://api.github.com/repos/railsware/js-routes/git/commits{/sha}","comments_url":"https://api.github.com/repos/railsware/js-routes/comments{/number}","issue_comment_url":"https://api.github.com/repos/railsware/js-routes/issues/comments/{number}","contents_url":"https://api.github.com/repos/railsware/js-routes/contents/{+path}","compare_url":"https://api.github.com/repos/railsware/js-routes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/railsware/js-routes/merges","archive_url":"https://api.github.com/repos/railsware/js-routes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/railsware/js-routes/downloads","issues_url":"https://api.github.com/repos/railsware/js-routes/issues{/number}","pulls_url":"https://api.github.com/repos/railsware/js-routes/pulls{/number}","milestones_url":"https://api.github.com/repos/railsware/js-routes/milestones{/number}","notifications_url":"https://api.github.com/repos/railsware/js-routes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/railsware/js-routes/labels{/name}","releases_url":"https://api.github.com/repos/railsware/js-routes/releases{/id}","created_at":"2011-08-03T14:53:48Z","updated_at":"2014-12-10T14:54:15Z","pushed_at":"2014-12-08T20:04:15Z","git_url":"git://github.com/railsware/js-routes.git","ssh_url":"git@github.com:railsware/js-routes.git","clone_url":"https://github.com/railsware/js-routes.git","svn_url":"https://github.com/railsware/js-routes","homepage":"http://railsware.github.io/js-routes/","size":1134,"stargazers_count":744,"watchers_count":744,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":70,"mirror_url":null,"open_issues_count":10,"forks":70,"open_issues":10,"watchers":744,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/railsware/js-routes/pulls/137"},"html":{"href":"https://github.com/railsware/js-routes/pull/137"},"issue":{"href":"https://api.github.com/repos/railsware/js-routes/issues/137"},"comments":{"href":"https://api.github.com/repos/railsware/js-routes/issues/137/comments"},"review_comments":{"href":"https://api.github.com/repos/railsware/js-routes/pulls/137/comments"},"review_comment":{"href":"https://api.github.com/repos/railsware/js-routes/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/railsware/js-routes/pulls/137/commits"},"statuses":{"href":"https://api.github.com/repos/railsware/js-routes/statuses/57f20a6dceafc04edea5f2662bc81d296e1dfefc"}}}}