History

Add version to doc manifest

Ref #25.

Thibaut Courouble committed 10 years ago

Commit b67a02e1 parent 621ac0a3 files · +5 −4Browse files

Unified · Split

3 files
  1. assets/javascripts/models/doc.coffee +2 −2
  2. lib/docs/core/doc.rb +1 −0
  3. test/lib/docs/core/doc_test.rb +2 −2
assets/javascripts/models/doc.coffee+2−2
@@ -1,10 +1,10 @@
1class app.models.Doc extends app.Model1class app.models.Doc extends app.Model
2 # Attributes: name, slug, type, release, db_size, mtime, links2 # Attributes: name, slug, type, version, release, db_size, mtime, links
3 3
4 constructor: ->4 constructor: ->
5 super5 super
6 @reset @6 @reset @
7 [@slug_without_version, @version] = @slug.split('~v')7 @slug_without_version = @slug.split('~v')[0]
8 @fullName = "#{@name}" + if @version then " #{@version}" else ''8 @fullName = "#{@name}" + if @version then " #{@version}" else ''
9 @icon = @slug_without_version9 @icon = @slug_without_version
10 @text = @toEntry().text10 @text = @toEntry().text
lib/docs/core/doc.rb+1−0
@@ -66,6 +66,7 @@ module Docs · 65 unmodified lines
66 def as_json66 def as_json
67 json = { name: name, slug: slug, type: type }67 json = { name: name, slug: slug, type: type }
68 json[:links] = links if links.present?68 json[:links] = links if links.present?
69 json[:version] = version if version.present?
69 json[:release] = release if release.present?70 json[:release] = release if release.present?
70 json71 json
71 end72 end
test/lib/docs/core/doc_test.rb+2−2
@@ -133,10 +133,10 @@ class DocsDocTest < MiniTest::Spec · 132 unmodified lines
133 assert_instance_of Hash, doc.as_json133 assert_instance_of Hash, doc.as_json
134 end134 end
135 135
136 it "includes the doc's name, slug, type, and release" do136 it "includes the doc's name, slug, type, version, and release" do
137 assert_equal %i(name slug type), doc.as_json.keys137 assert_equal %i(name slug type), doc.as_json.keys
138 138
139 %w(name slug type release links).each do |attribute|139 %w(name slug type version release links).each do |attribute|
140 eval "stub(doc).#{attribute} { attribute }"140 eval "stub(doc).#{attribute} { attribute }"
141 assert_equal attribute, doc.as_json[attribute.to_sym]141 assert_equal attribute, doc.as_json[attribute.to_sym]
142 end142 end