{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/comments/185498284","pull_request_review_id":116898391,"id":185498284,"diff_hunk":"@@ -372,6 +377,69 @@\n     end\n   end\n \n+  context \"homepage content item with a level_one_taxon and a child\" do","path":"spec/publishing_api_response_spec.rb","position":83,"original_position":83,"commit_id":"cf810df4f13e992275da9bffbf91a695be3d296f","original_commit_id":"cf810df4f13e992275da9bffbf91a695be3d296f","user":{"login":"leenagupte","id":5793815,"avatar_url":"https://avatars2.githubusercontent.com/u/5793815?v=4","gravatar_id":"","url":"https://api.github.com/users/leenagupte","html_url":"https://github.com/leenagupte","followers_url":"https://api.github.com/users/leenagupte/followers","following_url":"https://api.github.com/users/leenagupte/following{/other_user}","gists_url":"https://api.github.com/users/leenagupte/gists{/gist_id}","starred_url":"https://api.github.com/users/leenagupte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leenagupte/subscriptions","organizations_url":"https://api.github.com/users/leenagupte/orgs","repos_url":"https://api.github.com/users/leenagupte/repos","events_url":"https://api.github.com/users/leenagupte/events{/privacy}","received_events_url":"https://api.github.com/users/leenagupte/received_events","type":"User","site_admin":false},"body":"@1pretz1 You're only using homepage_taxon in one test, so it doesn't need to be in a `let` block. Generally variables are created in `let` and `before` blocks when they needed in multiple tests.\r\n\r\nIt will make the test easier to follow if everything from the `let` is moved into the test, and `homepage_taxon` is set to just the result of calling `from_content_id`.\r\n\r\ne.g.\r\n\r\n```\r\n  context \"homepage content item with a level_one_taxon and a child\" do\r\n    it \"parses each level of taxons from home page\" do\r\n      child_for_level_one_taxon = {\r\n        \"content_id\" => \"84aadc14-9bca-40d9-abb4-4f21f9792a05\",\r\n        \"base_path\" => \"/transport_child\",\r\n        \"title\" => \"Transport child\",\r\n        \"details\" => {\r\n          \"internal_name\" => \"TC 1\",\r\n        },\r\n        \"links\" => {}\r\n      }\r\n\r\n      level_one_taxon = {\r\n        \"content_id\" => \"a4038b29-b332-4f13-98b1-1c9709e216bc\",\r\n        \"base_path\" => \"/transport/all\",\r\n        \"title\" => \"Transport\",\r\n        \"details\" => {\r\n          \"internal_name\" => \"Transport\",\r\n        },\r\n        \"links\" => {\r\n          \"child_taxons\" => [child_for_level_one_taxon],\r\n          \"root_taxon\" => [content_item]\r\n        }\r\n      }\r\n\r\n      expanded_links = {\r\n        \"expanded_links\" => {\r\n          \"level_one_taxons\" => [level_one_taxon],\r\n        }\r\n      }\r\n\r\n      expanded_links_2 = {\r\n        \"expanded_links\" => {\r\n          \"child_taxons\" => [child_for_level_one_taxon]\r\n        }\r\n      }\r\n\r\n      content_item = {\r\n        \"content_id\" => \"f3bbdec2-0e62-4520-a7fd-6ffd5d36e03a\",\r\n        \"base_path\" => \"/\",\r\n        \"title\" => \"GOV.UK homepage\",\r\n        \"details\" => {}\r\n      }\r\n\r\n      allow(publishing_api).to receive(:get_content).with('f3bbdec2-0e62-4520-a7fd-6ffd5d36e03a').and_return(content_item)\r\n      allow(publishing_api).to receive(:get_expanded_links).with('f3bbdec2-0e62-4520-a7fd-6ffd5d36e03a').and_return(expanded_links)\r\n      allow(publishing_api).to receive(:get_expanded_links).with('a4038b29-b332-4f13-98b1-1c9709e216bc').and_return(expanded_links_2)\r\n\r\n      homepage_taxon = GovukTaxonomyHelpers::LinkedContentItem.from_content_id(\r\n        content_id: content_item['content_id'],\r\n        publishing_api: publishing_api\r\n      )\r\n\r\n      expect(homepage_taxon.title).to eq(\"GOV.UK homepage\")\r\n      expect(homepage_taxon.parent).to eq(nil)\r\n      expect(homepage_taxon.children.map(&:title)).to eq([\"Transport\"])\r\n      expect(homepage_taxon.descendants.map(&:title)).to eq([\"Transport\", \"Transport child\"])\r\n      expect(homepage_taxon.children.first.children.first.title).to eq(\"Transport child\")\r\n    end\r\n  end\r\n```\r\n\r\nI'd also consider renaming `content_item` to `root_taxon` so it's a bit easier to picture what the homepage_taxon content_item looks like.\r\n\r\nThe same approach will work from the \"minimal responses with missing links and details hashes\"  test below as well.\r\n\r\nIf you're interested, there is a bit of discussion [here](https://stackoverflow.com/questions/5974360/rspec-what-is-the-difference-between-let-and-a-before-block) about when to use a `let` or a `before` block.","created_at":"2018-05-02T13:39:07Z","updated_at":"2018-05-02T13:39:07Z","html_url":"https://github.com/alphagov/govuk_taxonomy_helpers/pull/16#discussion_r185498284","pull_request_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/comments/185498284"},"html":{"href":"https://github.com/alphagov/govuk_taxonomy_helpers/pull/16#discussion_r185498284"},"pull_request":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16","id":182819662,"html_url":"https://github.com/alphagov/govuk_taxonomy_helpers/pull/16","diff_url":"https://github.com/alphagov/govuk_taxonomy_helpers/pull/16.diff","patch_url":"https://github.com/alphagov/govuk_taxonomy_helpers/pull/16.patch","issue_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/16","number":16,"state":"open","locked":false,"title":"Add function to expand links for level one taxons","user":{"login":"1pretz1","id":24479188,"avatar_url":"https://avatars1.githubusercontent.com/u/24479188?v=4","gravatar_id":"","url":"https://api.github.com/users/1pretz1","html_url":"https://github.com/1pretz1","followers_url":"https://api.github.com/users/1pretz1/followers","following_url":"https://api.github.com/users/1pretz1/following{/other_user}","gists_url":"https://api.github.com/users/1pretz1/gists{/gist_id}","starred_url":"https://api.github.com/users/1pretz1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1pretz1/subscriptions","organizations_url":"https://api.github.com/users/1pretz1/orgs","repos_url":"https://api.github.com/users/1pretz1/repos","events_url":"https://api.github.com/users/1pretz1/events{/privacy}","received_events_url":"https://api.github.com/users/1pretz1/received_events","type":"User","site_admin":false},"body":"LinkedContentItem can now expand the links of 'level_one_taxons' adding the\r\nresults to 'linked_content_item' which holds a nested tree from the\r\nroot taxon(homepage).","created_at":"2018-04-19T15:45:44Z","updated_at":"2018-05-02T13:39:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dea6bec12655632e17dc3fbe0ea319617052ae7a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16/commits","review_comments_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16/comments","review_comment_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/16/comments","statuses_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/statuses/cf810df4f13e992275da9bffbf91a695be3d296f","head":{"label":"alphagov:allow-link-expansion-on-level-one-taxons","ref":"allow-link-expansion-on-level-one-taxons","sha":"cf810df4f13e992275da9bffbf91a695be3d296f","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":81591451,"name":"govuk_taxonomy_helpers","full_name":"alphagov/govuk_taxonomy_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_taxonomy_helpers","description":"Parse the taxonomy of GOV.UK into a browsable tree structure","fork":false,"url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers","forks_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/forks","keys_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/teams","hooks_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/hooks","issue_events_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/events","assignees_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/tags","blobs_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/languages","stargazers_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/stargazers","contributors_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/contributors","subscribers_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/subscribers","subscription_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/subscription","commits_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/merges","archive_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/downloads","issues_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/deployments","created_at":"2017-02-10T17:56:40Z","updated_at":"2017-08-21T08:57:34Z","pushed_at":"2018-04-24T17:56:16Z","git_url":"git://github.com/alphagov/govuk_taxonomy_helpers.git","ssh_url":"git@github.com:alphagov/govuk_taxonomy_helpers.git","clone_url":"https://github.com/alphagov/govuk_taxonomy_helpers.git","svn_url":"https://github.com/alphagov/govuk_taxonomy_helpers","homepage":"","size":40,"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":0,"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":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"14cfef9923aad15077f3cea2541c8e3cdf05697b","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":81591451,"name":"govuk_taxonomy_helpers","full_name":"alphagov/govuk_taxonomy_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_taxonomy_helpers","description":"Parse the taxonomy of GOV.UK into a browsable tree structure","fork":false,"url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers","forks_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/forks","keys_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/teams","hooks_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/hooks","issue_events_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/events","assignees_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/tags","blobs_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/languages","stargazers_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/stargazers","contributors_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/contributors","subscribers_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/subscribers","subscription_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/subscription","commits_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/merges","archive_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/downloads","issues_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/deployments","created_at":"2017-02-10T17:56:40Z","updated_at":"2017-08-21T08:57:34Z","pushed_at":"2018-04-24T17:56:16Z","git_url":"git://github.com/alphagov/govuk_taxonomy_helpers.git","ssh_url":"git@github.com:alphagov/govuk_taxonomy_helpers.git","clone_url":"https://github.com/alphagov/govuk_taxonomy_helpers.git","svn_url":"https://github.com/alphagov/govuk_taxonomy_helpers","homepage":"","size":40,"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":0,"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":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16"},"html":{"href":"https://github.com/alphagov/govuk_taxonomy_helpers/pull/16"},"issue":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/16"},"comments":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/govuk_taxonomy_helpers/statuses/cf810df4f13e992275da9bffbf91a695be3d296f"}},"author_association":"NONE"}}
{"actor":{"display_login":"leenagupte"}}