{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/comments/154102805","pull_request_review_id":80213786,"id":154102805,"diff_hunk":"@@ -0,0 +1,139 @@\n+require \"spec_helper\"\n+\n+RSpec.describe GovukNavigationHelpers::RelatedNavigationSidebar do\n+  def payload_for(schema, content_item)\n+    generator = GovukSchemas::RandomExample.for_schema(schema, schema_type: \"frontend\")\n+    fully_valid_content_item = generator.merge_and_validate(content_item)\n+    GovukNavigationHelpers::NavigationHelper.new(fully_valid_content_item).related_navigation_sidebar\n+  end\n+\n+  describe \"#related-navigation-sidebar\" do\n+    it \"can handle randomly generated content\" do\n+      generator = GovukSchemas::RandomExample.for_schema(\"placeholder\", schema_type: \"frontend\")\n+\n+      expect { payload_for(\"placeholder\", generator.payload) }.to_not raise_error\n+    end\n+\n+    it \"returns empty arrays if there are no related navigation sidebar links\" do\n+      nothing = payload_for(\"placeholder\",\n+        \"details\" => {\n+          \"external_related_links\" => []\n+        },\n+        \"links\" => {\n+        }\n+      )\n+\n+      expected = {\n+        related_items: [],\n+        collections: [],\n+        topics: [],\n+        policies: [],\n+        publishers: [],\n+        other: [[], []]\n+      }\n+\n+      expect(nothing).to eql(expected)\n+    end\n+\n+    it \"extracts and returns the appropriate related links\" do\n+      payload = payload_for(\"speech\",\n+        \"details\" => {\n+          \"body\" => \"body\",\n+          \"government\" => {\n+            \"title\" => \"government\",\n+            \"slug\" => \"government\",\n+            \"current\" => true\n+            },\n+          \"political\" => true,\n+          \"delivered_on\" => \"2017-09-22T14:30:00+01:00\"\n+        },\n+        \"links\" => {\n+          \"ordered_related_items\" => [\n+            {\n+              \"content_id\" => \"32c1b93d-2553-47c9-bc3c-fc5b513ecc32\",","path":"spec/navigation_sidebar_spec.rb","position":53,"original_position":53,"commit_id":"62fca7f1c2689d5eaa36d2d1f73565ddd7b74e3f","original_commit_id":"62fca7f1c2689d5eaa36d2d1f73565ddd7b74e3f","user":{"login":"steventux","id":93511,"avatar_url":"https://avatars0.githubusercontent.com/u/93511?v=4","gravatar_id":"","url":"https://api.github.com/users/steventux","html_url":"https://github.com/steventux","followers_url":"https://api.github.com/users/steventux/followers","following_url":"https://api.github.com/users/steventux/following{/other_user}","gists_url":"https://api.github.com/users/steventux/gists{/gist_id}","starred_url":"https://api.github.com/users/steventux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steventux/subscriptions","organizations_url":"https://api.github.com/users/steventux/orgs","repos_url":"https://api.github.com/users/steventux/repos","events_url":"https://api.github.com/users/steventux/events{/privacy}","received_events_url":"https://api.github.com/users/steventux/received_events","type":"User","site_admin":false},"body":"I would limit the expected payload to the keys/values you actually assert on, or is it the case that you need the `content_id` and `locale` for validation purposes in `generator.merge_and_validate(content_item)`? ","created_at":"2017-11-30T15:13:05Z","updated_at":"2017-11-30T15:17:23Z","html_url":"https://github.com/alphagov/govuk_navigation_helpers/pull/85#discussion_r154102805","pull_request_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/comments/154102805"},"html":{"href":"https://github.com/alphagov/govuk_navigation_helpers/pull/85#discussion_r154102805"},"pull_request":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85","id":155110651,"html_url":"https://github.com/alphagov/govuk_navigation_helpers/pull/85","diff_url":"https://github.com/alphagov/govuk_navigation_helpers/pull/85.diff","patch_url":"https://github.com/alphagov/govuk_navigation_helpers/pull/85.patch","issue_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/85","number":85,"state":"open","locked":false,"title":"Add logic for navigation sidebar component","user":{"login":"vanitabarrett","id":29889908,"avatar_url":"https://avatars3.githubusercontent.com/u/29889908?v=4","gravatar_id":"","url":"https://api.github.com/users/vanitabarrett","html_url":"https://github.com/vanitabarrett","followers_url":"https://api.github.com/users/vanitabarrett/followers","following_url":"https://api.github.com/users/vanitabarrett/following{/other_user}","gists_url":"https://api.github.com/users/vanitabarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/vanitabarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanitabarrett/subscriptions","organizations_url":"https://api.github.com/users/vanitabarrett/orgs","repos_url":"https://api.github.com/users/vanitabarrett/repos","events_url":"https://api.github.com/users/vanitabarrett/events{/privacy}","received_events_url":"https://api.github.com/users/vanitabarrett/received_events","type":"User","site_admin":false},"body":"Adds logic to provide data for the new [navigation sidebar component](https://government-frontend.herokuapp.com/component-guide/navigation-sidebar).\r\n\r\nWe want the component to display the following information (if available):\r\n- Related items\r\n- Topics\r\n- Organisations\r\n- Collections\r\n- Policies\r\n- External links\r\n- Quick links\r\n- Other contacts\r\n\r\n\r\n### Questions\r\nThere are a couple of things I'm not sure about, please feel free to weigh in:\r\n- The logic currently returns `quick links` over `ordered_related_items`. Is this correct?\r\n- It's been suggested the component name 'navigation sidebar' is too vague. The component is designed to replace the existing [related-items sidebar](https://govuk-static.herokuapp.com/component-guide/related_items) within government-frontend. Maybe we need to come up with a better name - any ideas?","created_at":"2017-11-28T15:57:03Z","updated_at":"2017-11-30T15:17:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29184ab6b11906146b0d47ea5a15ff2feba4f62c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85/commits","review_comments_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85/comments","review_comment_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/85/comments","statuses_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/statuses/62fca7f1c2689d5eaa36d2d1f73565ddd7b74e3f","head":{"label":"alphagov:navigation-sidebar-logic","ref":"navigation-sidebar-logic","sha":"62fca7f1c2689d5eaa36d2d1f73565ddd7b74e3f","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":68029111,"name":"govuk_navigation_helpers","full_name":"alphagov/govuk_navigation_helpers","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/govuk_navigation_helpers","description":"Gem to transform content-store data into payloads for GOV.UK frontend components","fork":false,"url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers","forks_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/forks","keys_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/teams","hooks_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/hooks","issue_events_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/events","assignees_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/tags","blobs_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/languages","stargazers_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/stargazers","contributors_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/contributors","subscribers_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/subscribers","subscription_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/subscription","commits_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/merges","archive_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/downloads","issues_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/deployments","created_at":"2016-09-12T16:57:21Z","updated_at":"2017-04-04T21:51:29Z","pushed_at":"2017-11-30T13:33:12Z","git_url":"git://github.com/alphagov/govuk_navigation_helpers.git","ssh_url":"git@github.com:alphagov/govuk_navigation_helpers.git","clone_url":"https://github.com/alphagov/govuk_navigation_helpers.git","svn_url":"https://github.com/alphagov/govuk_navigation_helpers","homepage":null,"size":131,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"02acca91a280a5e5141bf6e5cfb2b455f955c8a9","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":68029111,"name":"govuk_navigation_helpers","full_name":"alphagov/govuk_navigation_helpers","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/govuk_navigation_helpers","description":"Gem to transform content-store data into payloads for GOV.UK frontend components","fork":false,"url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers","forks_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/forks","keys_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/teams","hooks_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/hooks","issue_events_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/events","assignees_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/tags","blobs_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/languages","stargazers_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/stargazers","contributors_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/contributors","subscribers_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/subscribers","subscription_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/subscription","commits_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/merges","archive_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/downloads","issues_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/deployments","created_at":"2016-09-12T16:57:21Z","updated_at":"2017-04-04T21:51:29Z","pushed_at":"2017-11-30T13:33:12Z","git_url":"git://github.com/alphagov/govuk_navigation_helpers.git","ssh_url":"git@github.com:alphagov/govuk_navigation_helpers.git","clone_url":"https://github.com/alphagov/govuk_navigation_helpers.git","svn_url":"https://github.com/alphagov/govuk_navigation_helpers","homepage":null,"size":131,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85"},"html":{"href":"https://github.com/alphagov/govuk_navigation_helpers/pull/85"},"issue":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/85"},"comments":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/govuk_navigation_helpers/statuses/62fca7f1c2689d5eaa36d2d1f73565ddd7b74e3f"}},"author_association":"NONE"}}
{"actor":{"display_login":"steventux"}}