Add version to doc manifest

Ref #25.
pull/308/merge
Thibaut Courouble 9 years ago
parent 621ac0a350
commit b67a02ed35

@ -1,10 +1,10 @@
class app.models.Doc extends app.Model
# Attributes: name, slug, type, release, db_size, mtime, links
# Attributes: name, slug, type, version, release, db_size, mtime, links
constructor: ->
super
@reset @
[@slug_without_version, @version] = @slug.split('~v')
@slug_without_version = @slug.split('~v')[0]
@fullName = "#{@name}" + if @version then " #{@version}" else ''
@icon = @slug_without_version
@text = @toEntry().text

@ -66,6 +66,7 @@ module Docs
def as_json
json = { name: name, slug: slug, type: type }
json[:links] = links if links.present?
json[:version] = version if version.present?
json[:release] = release if release.present?
json
end

@ -133,10 +133,10 @@ class DocsDocTest < MiniTest::Spec
assert_instance_of Hash, doc.as_json
end
it "includes the doc's name, slug, type, and release" do
it "includes the doc's name, slug, type, version, and release" do
assert_equal %i(name slug type), doc.as_json.keys
%w(name slug type release links).each do |attribute|
%w(name slug type version release links).each do |attribute|
eval "stub(doc).#{attribute} { attribute }"
assert_equal attribute, doc.as_json[attribute.to_sym]
end

Loading…
Cancel
Save