Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | class app.models.Doc extends app.Model |
| 2 | − # Attributes: name, slug, type, version, index_path, mtime | |
| 2 | + # Attributes: name, slug, type, version, index_path, db_path, mtime | |
| 3 | 3 | |
| 4 | 4 | constructor: -> |
| 5 | 5 | super |
| @@ -26,12 +26,17 @@ module Docs · 25 unmodified lines | ||
| 26 | 26 | File.join path, INDEX_FILENAME |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | + def db_path | |
| 30 | + File.join path, DB_FILENAME | |
| 31 | + end | |
| 32 | + | |
| 29 | 33 | def as_json |
| 30 | 34 | { name: name, |
| 31 | 35 | slug: slug, |
| 32 | 36 | type: type, |
| 33 | 37 | version: version, |
| 34 | − index_path: index_path } | |
| 38 | + index_path: index_path, | |
| 39 | + db_path: db_path } | |
| 35 | 40 | end |
| 36 | 41 | |
| 37 | 42 | def store_page(store, id) |
| @@ -87,6 +87,13 @@ class DocsDocTest < MiniTest::Spec · 86 unmodified lines | ||
| 87 | 87 | end |
| 88 | 88 | end |
| 89 | 89 | |
| 90 | + describe ".db_path" do | |
| 91 | + it "returns .path + ::DB_FILENAME" do | |
| 92 | + stub(doc).path { 'path' } | |
| 93 | + assert_equal File.join('path', Docs::Doc::DB_FILENAME), doc.db_path | |
| 94 | + end | |
| 95 | + end | |
| 96 | + | |
| 90 | 97 | describe ".new" do |
| 91 | 98 | it "raises an error when .abstract is true" do |
| 92 | 99 | doc.abstract = true |
| @@ -101,8 +108,8 @@ class DocsDocTest < MiniTest::Spec · 8 unmodified lines | ||
| 101 | 108 | assert_instance_of Hash, doc.as_json |
| 102 | 109 | end |
| 103 | 110 | |
| 104 | − it "includes the doc's name, slug, type, version and index_path" do | |
| 105 | − %w(name slug type version index_path).each do |attribute| | |
| 111 | + it "includes the doc's name, slug, type, version, index_path and db_path" do | |
| 112 | + %w(name slug type version index_path db_path).each do |attribute| | |
| 106 | 113 | eval "stub(doc).#{attribute} { attribute }" |
| 107 | 114 | assert_equal attribute, doc.as_json[attribute.to_sym] |
| 108 | 115 | end |
| @@ -43,8 +43,13 @@ class ManifestTest < MiniTest::Spec · 42 unmodified lines | ||
| 43 | 43 | 'index_path' |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | + let :db_path do | |
| 47 | + 'db_path' | |
| 48 | + end | |
| 49 | + | |
| 46 | 50 | before do |
| 47 | 51 | stub(doc).index_path { index_path } |
| 52 | + stub(doc).db_path { db_path } | |
| 48 | 53 | end |
| 49 | 54 | |
| 50 | 55 | it "returns an array" do |