From bd6e27eca274c35de60c6775480da4992cf9858c Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 17 Jan 2016 11:52:53 -0500 Subject: [PATCH] Optionally include 'release' and 'links' in docs manifest --- lib/docs/core/doc.rb | 9 ++++----- test/lib/docs/core/doc_test.rb | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index 2e7871bb..23203756 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -33,11 +33,10 @@ module Docs end def as_json - { name: name, - slug: slug, - type: type, - release: release, - links: links } + json = { name: name, slug: slug, type: type } + json[:links] = links if links.present? + json[:release] = release if release.present? + json end def store_page(store, id) diff --git a/test/lib/docs/core/doc_test.rb b/test/lib/docs/core/doc_test.rb index 7eeed6de..3e595486 100644 --- a/test/lib/docs/core/doc_test.rb +++ b/test/lib/docs/core/doc_test.rb @@ -116,6 +116,8 @@ class DocsDocTest < MiniTest::Spec end it "includes the doc's name, slug, type, and release" do + assert_equal %i(name slug type), doc.as_json.keys + %w(name slug type release links).each do |attribute| eval "stub(doc).#{attribute} { attribute }" assert_equal attribute, doc.as_json[attribute.to_sym]