wlog 1.1.1 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -48
- data/Rakefile +1 -0
- data/lib/wlog/commands/archive_finished_issues.rb +2 -2
- data/lib/wlog/commands/archive_issues.rb +1 -1
- data/lib/wlog/commands/bootstrap_templates.rb +37 -0
- data/lib/wlog/commands/concat_description.rb +7 -11
- data/lib/wlog/commands/delete_issue.rb +6 -5
- data/lib/wlog/commands/innit_db.rb +62 -6
- data/lib/wlog/commands/make_csv.rb +2 -6
- data/lib/wlog/commands/new_entry.rb +10 -7
- data/lib/wlog/commands/replace_pattern.rb +7 -5
- data/lib/wlog/domain/attachment.rb +50 -75
- data/lib/wlog/domain/invoice.rb +8 -2
- data/lib/wlog/domain/issue.rb +32 -132
- data/lib/wlog/domain/key_value.rb +10 -35
- data/lib/wlog/domain/log_entry.rb +18 -95
- data/lib/wlog/domain/static_configurations.rb +6 -0
- data/lib/wlog/domain/sys_config.rb +2 -5
- data/lib/wlog/migrations/make_standard_tables.rb +59 -0
- data/lib/wlog/ui/cli_interface.rb +55 -44
- data/lib/wlog/ui/commands/create_issue.rb +4 -8
- data/lib/wlog/ui/edit_handler.rb +74 -0
- data/lib/wlog/ui/invoice_ui.rb +133 -0
- data/lib/wlog/ui/issue_ui.rb +21 -77
- data/lib/wlog/ui/template_ui.rb +66 -0
- data/lib/wlog/version.rb +1 -1
- data/spec/domain/attachment_spec.rb +58 -59
- data/spec/domain/commands/concat_desc_spec.rb +10 -13
- data/spec/domain/commands/new_entry_spec.rb +10 -13
- data/spec/domain/commands/replace_pattern_spec.rb +11 -12
- data/spec/domain/issue_spec.rb +35 -38
- data/spec/domain/key_value_spec.rb +5 -8
- data/spec/domain/log_entry_spec.rb +20 -31
- data/spec/domain/sys_config_spec.rb +4 -7
- data/spec/make_db.rb +30 -4
- data/spec/tech/wlog_string_spec.rb +14 -14
- data/wlog.gemspec +2 -1
- metadata +26 -13
- data/lib/wlog/db_registry.rb +0 -38
- data/lib/wlog/domain/sql_modules/attachment_sql.rb +0 -21
- data/lib/wlog/domain/sql_modules/issue_sql.rb +0 -37
- data/lib/wlog/domain/sql_modules/key_value_sql.rb +0 -20
- data/lib/wlog/domain/sql_modules/log_entry_sql.rb +0 -35
- data/lib/wlog/ui/commands/attach_to_issue.rb +0 -0
@@ -1,59 +1,58 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'wlog/domain/
|
5
|
-
require 'wlog/domain/
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
1
|
+
# We'll be ignoring this for now...
|
2
|
+
#
|
3
|
+
# require_relative '../make_db'
|
4
|
+
# require 'wlog/domain/attachment'
|
5
|
+
# require 'wlog/domain/log_entry'
|
6
|
+
# require 'wlog/domain/issue'
|
7
|
+
#
|
8
|
+
# include Wlog
|
9
|
+
#
|
10
|
+
# describe Attachment do
|
11
|
+
#
|
12
|
+
# db_name = './default'
|
13
|
+
#
|
14
|
+
# class FileMock
|
15
|
+
# attr_accessor :filename, :data, :path
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def create_mock_file
|
19
|
+
# fm = FileMock.new
|
20
|
+
# fm.filename = "thefile.txt"
|
21
|
+
# fm.data = "This is my text data."
|
22
|
+
# fm.path = "/home/user/"
|
23
|
+
# fm end
|
24
|
+
#
|
25
|
+
# before(:all) do
|
26
|
+
# make_testing_db(db_name)
|
27
|
+
# @db = DbRegistry.new(db_name)
|
28
|
+
# @issue = Issue.new(@db)
|
29
|
+
# @log_entry = LogEntry.new(@db)
|
30
|
+
#
|
31
|
+
# @issue.description = "This is my issue"
|
32
|
+
# @issue.insert
|
33
|
+
# @log_entry.issue_id = @issue.id
|
34
|
+
# @log_entry.description = "This is my log_entry"
|
35
|
+
# @log_entry.insert
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# after(:all) do
|
39
|
+
# FileUtils.rm db_name
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# # Note: this example uses issue, but this will be valid for whatever other
|
43
|
+
# # type we want to associate to this class.
|
44
|
+
# it "should insert given polymorphic type" do
|
45
|
+
# file = create_mock_file
|
46
|
+
# attach = Attachment.new(@db, Issue.name, @issue.id)
|
47
|
+
# attach.filename = file.filename
|
48
|
+
# attach.data = file.data
|
49
|
+
# attach.insert
|
50
|
+
# check = Attachment.find(@db, Issue.name, @issue.id)
|
51
|
+
# expect(check).to_not eq(nil)
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# it "should return nil if something is not found" do
|
55
|
+
# expect(Attachment.find(@db, Issue.name, 123123123)).to eq(nil)
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
#
|
@@ -1,11 +1,8 @@
|
|
1
1
|
require_relative '../../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/attachment'
|
4
3
|
require 'wlog/domain/log_entry'
|
5
4
|
require 'wlog/domain/issue'
|
6
5
|
|
7
|
-
require 'turntables/turntable'
|
8
|
-
|
9
6
|
|
10
7
|
require 'wlog/commands/concat_description'
|
11
8
|
|
@@ -13,38 +10,38 @@ include Wlog
|
|
13
10
|
|
14
11
|
describe ConcatDescription do
|
15
12
|
|
16
|
-
db_name = '
|
13
|
+
db_name = 'default'
|
14
|
+
db_path = standard_db_path(db_name)
|
17
15
|
|
18
16
|
before(:all) do
|
19
17
|
make_testing_db(db_name)
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@log_entry = LogEntry.new(@db)
|
18
|
+
@issue = Issue.new
|
19
|
+
@log_entry = LogEntry.new
|
23
20
|
@previous_description = "This is my log_entry"
|
24
21
|
|
25
22
|
@issue.description = "This is my issue"
|
26
|
-
@issue.
|
23
|
+
@issue.save
|
27
24
|
@log_entry.issue_id = @issue.id
|
28
25
|
@log_entry.description = @previous_description
|
29
|
-
@log_entry.
|
26
|
+
@log_entry.save
|
30
27
|
end
|
31
28
|
|
32
29
|
after(:all) do
|
33
|
-
FileUtils.rm
|
30
|
+
FileUtils.rm db_path
|
34
31
|
end
|
35
32
|
|
36
33
|
# I know, tests should not really look for implementation details, but things
|
37
34
|
# in our case *should* really inherit the command interface.
|
38
35
|
it "should inherit from commandable" do
|
39
|
-
command = ConcatDescription.new(@
|
36
|
+
command = ConcatDescription.new(@log_entry.id, "asd")
|
40
37
|
expect(command.is_a? Commandable).to eq(true)
|
41
38
|
end
|
42
39
|
|
43
40
|
it "should concatenate a string on command execution" do
|
44
41
|
addition = " my addition"
|
45
|
-
command = ConcatDescription.new(@
|
42
|
+
command = ConcatDescription.new(@log_entry.id, addition)
|
46
43
|
command.execute
|
47
|
-
new_le = LogEntry.find(@
|
44
|
+
new_le = LogEntry.find(@log_entry.id)
|
48
45
|
expect(new_le.description).to eq(@previous_description + addition)
|
49
46
|
end
|
50
47
|
|
@@ -1,41 +1,38 @@
|
|
1
1
|
require_relative '../../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/attachment'
|
4
3
|
require 'wlog/domain/log_entry'
|
5
4
|
require 'wlog/domain/issue'
|
6
5
|
require 'wlog/commands/new_entry'
|
7
6
|
|
8
|
-
require 'turntables/turntable'
|
9
|
-
|
10
7
|
include Wlog
|
11
8
|
|
12
9
|
describe NewEntry do
|
13
10
|
|
14
|
-
db_name = '
|
11
|
+
db_name = 'default'
|
12
|
+
db_path = standard_db_path(db_name)
|
15
13
|
|
16
14
|
before(:all) do
|
17
15
|
make_testing_db(db_name)
|
18
|
-
@
|
19
|
-
@issue = Issue.new(@db)
|
16
|
+
@issue = Issue.new
|
20
17
|
@issue.description = 'my issue'
|
21
|
-
@issue.
|
18
|
+
@issue.save
|
22
19
|
end
|
23
20
|
|
24
21
|
after(:all) do
|
25
|
-
FileUtils.rm
|
22
|
+
FileUtils.rm db_path
|
26
23
|
end
|
27
24
|
|
28
25
|
it "should insert a new entry on execution" do
|
29
|
-
command = NewEntry.new(
|
26
|
+
command = NewEntry.new("my desc", @issue)
|
30
27
|
command.execute
|
31
|
-
expect(LogEntry.
|
28
|
+
expect(LogEntry.count).to eq(1)
|
32
29
|
end
|
33
30
|
|
34
31
|
it "should create 5 more inserts on 5 more executions" do
|
35
|
-
previous = LogEntry.
|
36
|
-
command = NewEntry.new(
|
32
|
+
previous = LogEntry.count
|
33
|
+
command = NewEntry.new("my desc", @issue)
|
37
34
|
5.times{ command.execute }
|
38
|
-
expect(LogEntry.
|
35
|
+
expect(LogEntry.count).to eq(5 + previous)
|
39
36
|
end
|
40
37
|
|
41
38
|
end
|
@@ -1,45 +1,44 @@
|
|
1
1
|
require_relative '../../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/log_entry'
|
4
3
|
require 'wlog/domain/issue'
|
5
4
|
|
6
|
-
require 'turntables/turntable'
|
7
5
|
require 'wlog/commands/replace_pattern'
|
8
6
|
|
9
7
|
include Wlog
|
10
8
|
|
11
9
|
describe ReplacePattern do
|
12
|
-
db_name = '
|
10
|
+
db_name = 'default'
|
11
|
+
db_path = standard_db_path(db_name)
|
12
|
+
|
13
13
|
before(:all) do
|
14
14
|
make_testing_db(db_name)
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@log_entry = LogEntry.new(@db)
|
15
|
+
@issue = Issue.new
|
16
|
+
@log_entry = LogEntry.new
|
18
17
|
@previous_description = "This is my log_entry"
|
19
18
|
|
20
19
|
@issue.description = "This is my issue"
|
21
|
-
@issue.
|
20
|
+
@issue.save
|
22
21
|
@log_entry.issue_id = @issue.id
|
23
22
|
@log_entry.description = @previous_description
|
24
|
-
@log_entry.
|
23
|
+
@log_entry.save
|
25
24
|
end
|
26
25
|
|
27
26
|
after(:all) do
|
28
|
-
FileUtils.rm
|
27
|
+
FileUtils.rm db_path
|
29
28
|
end
|
30
29
|
|
31
30
|
# I know, tests should not really look for implementation details, but things
|
32
31
|
# in our case *should* really inherit the command interface.
|
33
32
|
it "should inherit from commandable" do
|
34
|
-
command = ReplacePattern.new(@
|
33
|
+
command = ReplacePattern.new(@log_entry, "asd", "ASD")
|
35
34
|
expect(command.is_a? Commandable).to eq(true)
|
36
35
|
end
|
37
36
|
|
38
37
|
it "should replace a string in LogEntry on command execution" do
|
39
38
|
addition = " my addition"
|
40
|
-
command = ReplacePattern.new(@
|
39
|
+
command = ReplacePattern.new(@log_entry, 'log_entry', 'wlog_entry')
|
41
40
|
command.execute
|
42
|
-
new_le = LogEntry.find(@
|
41
|
+
new_le = LogEntry.find(@log_entry.id)
|
43
42
|
expect(new_le.description).to eq('This is my wlog_entry')
|
44
43
|
end
|
45
44
|
end
|
data/spec/domain/issue_spec.rb
CHANGED
@@ -1,72 +1,69 @@
|
|
1
1
|
require_relative '../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/issue'
|
4
3
|
|
5
|
-
require 'turntables/turntable'
|
6
|
-
|
7
4
|
include Wlog
|
8
5
|
|
9
6
|
describe Issue do
|
10
7
|
|
11
|
-
db_name = '
|
8
|
+
db_name = 'default'
|
12
9
|
|
13
10
|
before(:all) do
|
14
11
|
make_testing_db(db_name)
|
15
|
-
@db = DbRegistry.new(db_name)
|
16
12
|
end
|
17
13
|
|
18
14
|
after(:all) do
|
19
|
-
|
15
|
+
close_testing_db
|
16
|
+
FileUtils.rm standard_db_path(db_name)
|
20
17
|
end
|
21
18
|
|
22
19
|
it "should insert an issue" do
|
23
|
-
issue = Issue.new
|
20
|
+
issue = Issue.new
|
24
21
|
issue.description = "Some issue"
|
25
22
|
issue.mark_started!
|
26
|
-
issue.
|
23
|
+
issue.save
|
27
24
|
|
28
|
-
ret =
|
25
|
+
ret = Issue.all
|
29
26
|
expect(ret.size).to eq(1)
|
30
27
|
end
|
31
28
|
|
32
29
|
it "should delete an issue" do
|
33
|
-
issue = Issue.new
|
30
|
+
issue = Issue.new
|
34
31
|
issue.description = "Delete issue"
|
35
32
|
issue.mark_started!
|
36
|
-
issue.
|
37
|
-
|
33
|
+
issue.save
|
38
34
|
issue.delete
|
39
|
-
|
35
|
+
|
36
|
+
ret = Issue.find_by_id(issue.id)
|
40
37
|
expect(ret).to eq(nil)
|
41
38
|
end
|
42
39
|
|
43
40
|
it "should mark itself as new" do
|
44
|
-
issue = Issue.new
|
41
|
+
issue = Issue.new
|
45
42
|
issue.mark_started!
|
46
43
|
expect(issue.status).to eq(0)
|
47
44
|
end
|
48
45
|
|
49
46
|
it "should mark itself as working" do
|
50
|
-
issue = Issue.new
|
47
|
+
issue = Issue.new
|
51
48
|
issue.mark_working!
|
52
49
|
expect(issue.status).to eq(1)
|
53
50
|
end
|
54
51
|
|
55
52
|
it "should mark itself as finished" do
|
56
|
-
issue = Issue.new
|
53
|
+
issue = Issue.new
|
57
54
|
issue.mark_finished!
|
58
55
|
expect(issue.status).to eq(2)
|
59
56
|
end
|
60
57
|
|
61
58
|
it "should return nil on issue that is not found" do
|
62
|
-
issue = Issue.
|
59
|
+
issue = Issue.find_by_id(123123123)
|
63
60
|
expect(issue).to eq(nil)
|
64
61
|
end
|
65
62
|
|
66
63
|
it "should find all the inserted values" do
|
67
|
-
issue1 = Issue.new
|
68
|
-
issue2 = Issue.new
|
69
|
-
issue3 = Issue.new
|
64
|
+
issue1 = Issue.new
|
65
|
+
issue2 = Issue.new
|
66
|
+
issue3 = Issue.new
|
70
67
|
|
71
68
|
issue1.description = "find me 1"
|
72
69
|
issue2.description = "find me 2"
|
@@ -76,11 +73,11 @@ describe Issue do
|
|
76
73
|
issue2.long_description = "long desc 2"
|
77
74
|
issue3.long_description = "long desc 3"
|
78
75
|
|
79
|
-
issue1.
|
80
|
-
issue2.
|
81
|
-
issue3.
|
76
|
+
issue1.save
|
77
|
+
issue2.save
|
78
|
+
issue3.save
|
82
79
|
|
83
|
-
arr = Issue.
|
80
|
+
arr = Issue.all
|
84
81
|
descs = arr.collect{|issue| issue.description}
|
85
82
|
ldescs = arr.collect{|issue| issue.long_description}
|
86
83
|
existing = descs & ["find me 1", "find me 2", "find me 3"]
|
@@ -90,38 +87,38 @@ describe Issue do
|
|
90
87
|
end
|
91
88
|
|
92
89
|
it "should not insert an existing value twice" do
|
93
|
-
issue = Issue.new
|
90
|
+
issue = Issue.new
|
94
91
|
issue.description = "Add me once"
|
95
|
-
previous = Issue.
|
96
|
-
issue.
|
97
|
-
issue.
|
98
|
-
issue.
|
99
|
-
issue.
|
100
|
-
newcount = Issue.
|
92
|
+
previous = Issue.all.count
|
93
|
+
issue.save
|
94
|
+
issue.save
|
95
|
+
issue.save
|
96
|
+
issue.save
|
97
|
+
newcount = Issue.all.count
|
101
98
|
expect(newcount).to eq(previous + 1)
|
102
99
|
end
|
103
100
|
|
104
101
|
it "should update with valid information" do
|
105
|
-
issue = Issue.new
|
102
|
+
issue = Issue.new
|
106
103
|
previous = "Update me"
|
107
104
|
after = "UPDATED"
|
108
105
|
issue.description = previous
|
109
|
-
issue.
|
106
|
+
issue.save
|
110
107
|
issue.description = after
|
111
|
-
issue.
|
108
|
+
issue.save
|
112
109
|
|
113
|
-
uissue = Issue.find(
|
110
|
+
uissue = Issue.find(issue.id)
|
114
111
|
expect(uissue.description).to eq(after)
|
115
112
|
end
|
116
113
|
|
117
114
|
it "should find all finished issues" do
|
118
115
|
4.times do
|
119
|
-
iss = Issue.new
|
116
|
+
iss = Issue.new
|
120
117
|
iss.description = "hello"
|
121
118
|
iss.mark_finished!
|
122
|
-
iss.
|
119
|
+
iss.save
|
123
120
|
end
|
124
|
-
issues = Issue.
|
121
|
+
issues = Issue.where(:status => 2)
|
125
122
|
|
126
123
|
issues.each do |iss|
|
127
124
|
expect(iss.status).to eq(2)
|
@@ -1,22 +1,20 @@
|
|
1
1
|
require_relative '../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/key_value'
|
4
3
|
|
5
|
-
require 'turntables/turntable'
|
6
|
-
|
7
4
|
include Wlog
|
8
5
|
|
9
6
|
describe KeyValue do
|
10
7
|
|
11
|
-
db_name = "
|
8
|
+
db_name = "default"
|
9
|
+
db_path = standard_db_path(db_name)
|
12
10
|
|
13
11
|
before(:all) do
|
14
12
|
make_testing_db(db_name)
|
15
|
-
@kv = KeyValue
|
13
|
+
@kv = KeyValue
|
16
14
|
end
|
17
15
|
|
18
16
|
after(:all) do
|
19
|
-
FileUtils.rm db_name
|
17
|
+
FileUtils.rm standard_db_path(db_name)
|
20
18
|
end
|
21
19
|
|
22
20
|
it "Should insert a value" do
|
@@ -27,8 +25,7 @@ describe KeyValue do
|
|
27
25
|
it "Should insert a value only once" do
|
28
26
|
@kv.put!('new_check', '2012')
|
29
27
|
@kv.put!('new_check', '2013')
|
30
|
-
|
31
|
-
ret = db.execute('select * from key_values where key = ?', 'new_check')
|
28
|
+
ret = KeyValue.where(:key => 'new_check')
|
32
29
|
expect(ret.size).to eq(1)
|
33
30
|
end
|
34
31
|
|
@@ -1,63 +1,59 @@
|
|
1
1
|
require_relative '../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/log_entry'
|
4
3
|
require 'wlog/domain/issue'
|
5
4
|
|
6
|
-
require 'turntables/turntable'
|
7
|
-
|
8
5
|
include Wlog
|
9
6
|
|
10
7
|
describe LogEntry do
|
11
8
|
|
12
|
-
db_name = '
|
9
|
+
db_name = 'default'
|
10
|
+
db_path = standard_db_path(db_name)
|
13
11
|
|
14
12
|
before(:all) do
|
15
13
|
make_testing_db(db_name)
|
16
|
-
@
|
17
|
-
@issue = Issue.new(@db)
|
14
|
+
@issue = Issue.new
|
18
15
|
@issue.description = "Attach logs to me!"
|
19
|
-
@issue.
|
16
|
+
@issue.save
|
20
17
|
end
|
21
18
|
|
22
19
|
after(:all) do
|
23
|
-
FileUtils.rm
|
20
|
+
FileUtils.rm db_path
|
24
21
|
end
|
25
22
|
|
26
23
|
it "should be inserted" do
|
27
|
-
le = LogEntry.new
|
24
|
+
le = LogEntry.new
|
28
25
|
desc = "This is a log description"
|
29
26
|
le.description = desc
|
30
|
-
|
31
|
-
le.insert
|
27
|
+
@issue.log_entries << le
|
32
28
|
|
33
|
-
other =
|
29
|
+
other = @issue.log_entries.first
|
34
30
|
expect(other.description).to eq(desc)
|
35
31
|
expect(other.issue_id).to eq(@issue.id)
|
36
32
|
end
|
37
33
|
|
38
34
|
it "should handle something that is not found properly" do
|
39
|
-
le = LogEntry.
|
35
|
+
le = LogEntry.find_by_id(12123123123)
|
40
36
|
expect(le).to eq(nil)
|
41
37
|
end
|
42
38
|
|
43
39
|
it "should not be inserted more than once" do
|
44
|
-
previous = LogEntry.
|
45
|
-
le = LogEntry.new
|
40
|
+
previous = LogEntry.count
|
41
|
+
le = LogEntry.new
|
46
42
|
le.description = "derp"
|
47
43
|
le.issue_id = @issue.id
|
48
|
-
4.times{ le.
|
49
|
-
after = LogEntry.
|
44
|
+
4.times{ le.save }
|
45
|
+
after = LogEntry.count
|
50
46
|
expect(after).to eq(previous + 1)
|
51
47
|
end
|
52
48
|
|
53
49
|
it "should be deleted from the issue" do
|
54
|
-
le = LogEntry.new
|
50
|
+
le = LogEntry.new
|
55
51
|
le.description = "derp derp derp"
|
56
52
|
le.issue_id = @issue.id
|
57
|
-
le.
|
53
|
+
le.save
|
58
54
|
id = le.id
|
59
|
-
|
60
|
-
check = LogEntry.
|
55
|
+
LogEntry.delete(id)
|
56
|
+
check = LogEntry.find_by_id(id)
|
61
57
|
expect(check).to eq(nil)
|
62
58
|
end
|
63
59
|
|
@@ -67,19 +63,12 @@ describe LogEntry do
|
|
67
63
|
after = "herp"
|
68
64
|
le.description = before
|
69
65
|
le.issue_id = @issue.id
|
70
|
-
le.
|
66
|
+
le.save
|
71
67
|
le.description = after
|
72
|
-
le.
|
73
|
-
check = LogEntry.find(
|
68
|
+
le.save
|
69
|
+
check = LogEntry.find(le.id)
|
74
70
|
|
75
71
|
expect(check.description).to eq(after)
|
76
72
|
end
|
77
|
-
|
78
|
-
it "should not be created if no issue id bound" do
|
79
|
-
le = LogEntry.new(@db)
|
80
|
-
le.description = "DERP"
|
81
|
-
expect{le.insert}.to raise_error('Need issue_id')
|
82
|
-
end
|
83
|
-
|
84
73
|
end
|
85
74
|
|
@@ -1,23 +1,20 @@
|
|
1
1
|
require_relative '../make_db'
|
2
|
-
require 'wlog/db_registry'
|
3
2
|
require 'wlog/domain/sys_config'
|
4
3
|
|
5
|
-
require 'turntables/turntable'
|
6
|
-
|
7
4
|
include Wlog
|
8
5
|
|
9
6
|
describe SysConfig do
|
10
7
|
|
11
|
-
db_name = "
|
8
|
+
db_name = "default"
|
9
|
+
db_path = standard_db_path(db_name)
|
12
10
|
|
13
11
|
before(:all) do
|
14
12
|
make_testing_db(db_name)
|
15
|
-
@
|
16
|
-
@sys = SysConfig.new(@db)
|
13
|
+
@sys = SysConfig.new
|
17
14
|
end
|
18
15
|
|
19
16
|
after(:all) do
|
20
|
-
FileUtils.rm
|
17
|
+
FileUtils.rm db_path
|
21
18
|
end
|
22
19
|
|
23
20
|
it "should store last focus" do
|
data/spec/make_db.rb
CHANGED
@@ -1,8 +1,34 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'wlog/commands/innit_db'
|
3
|
+
|
1
4
|
# make the testing database in the relative path
|
2
5
|
def make_testing_db(dbname)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
current = standard_db_path(dbname)
|
7
|
+
ActiveRecord::Base.configurations = {
|
8
|
+
'testing' => {
|
9
|
+
:adapter => 'sqlite3',
|
10
|
+
:database => current,
|
11
|
+
:pool => 5,
|
12
|
+
:timeout => 5000
|
13
|
+
}
|
14
|
+
}
|
15
|
+
ActiveRecord::Base.establish_connection(:testing)
|
16
|
+
setup_db
|
17
|
+
end
|
18
|
+
|
19
|
+
def close_testing_db
|
20
|
+
ActiveRecord::Base.connection.close
|
21
|
+
end
|
22
|
+
|
23
|
+
# make the tables, and perform possible migrations
|
24
|
+
def setup_db
|
25
|
+
ActiveRecord::Migration.verbose = false
|
26
|
+
ActiveRecord::Migration.run(MakeSchemaMigration)
|
27
|
+
|
28
|
+
InnitDb.new.execute_migrations!
|
29
|
+
end
|
30
|
+
|
31
|
+
def standard_db_path(dbname)
|
32
|
+
"#{File.expand_path File.dirname(__FILE__)}/#{dbname}"
|
7
33
|
end
|
8
34
|
|