Skip to content

Commit ca61a2b

Browse files
committed
Add Doc#db_path
1 parent 5c46eab commit ca61a2b

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎assets/javascripts/models/doc.coffee‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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
33

44
constructor: ->
55
super

‎lib/docs/core/doc.rb‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ def index_path
2626
File.join path, INDEX_FILENAME
2727
end
2828

29+
def db_path
30+
File.join path, DB_FILENAME
31+
end
32+
2933
def as_json
3034
{ name: name,
3135
slug: slug,
3236
type: type,
3337
version: version,
34-
index_path: index_path }
38+
index_path: index_path,
39+
db_path: db_path }
3540
end
3641

3742
def store_page(store, id)

‎test/lib/docs/core/doc_test.rb‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class DocsDocTest < MiniTest::Spec
8787
end
8888
end
8989

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+
9097
describe ".new" do
9198
it "raises an error when .abstract is true" do
9299
doc.abstract = true
@@ -101,8 +108,8 @@ class DocsDocTest < MiniTest::Spec
101108
assert_instance_of Hash, doc.as_json
102109
end
103110

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|
106113
eval "stub(doc).#{attribute} { attribute }"
107114
assert_equal attribute, doc.as_json[attribute.to_sym]
108115
end

‎test/lib/docs/core/manifest_test.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ class ManifestTest < MiniTest::Spec
4343
'index_path'
4444
end
4545

46+
let :db_path do
47+
'db_path'
48+
end
49+
4650
before do
4751
stub(doc).index_path { index_path }
52+
stub(doc).db_path { db_path }
4853
end
4954

5055
it "returns an array" do

0 commit comments

Comments
 (0)