potam 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +52 -0
- data/README.rdoc +6 -0
- data/Rakefile +44 -0
- data/bin/potam +89 -0
- data/db/old.db +0 -0
- data/db/old2.db +0 -0
- data/db/potam.db +0 -0
- data/features/addnote.feature +26 -0
- data/features/addtask.feature +26 -0
- data/features/listtasks.feature +66 -0
- data/features/potam.feature +8 -0
- data/features/report.feature +58 -0
- data/features/step_definitions/potam_steps.rb +43 -0
- data/features/subtasks.feature +31 -0
- data/features/support/env.rb +27 -0
- data/features/taskinfo.feature +128 -0
- data/lib/db.rb +56 -0
- data/lib/dialog.rb +91 -0
- data/lib/notes.rb +3 -0
- data/lib/potam/version.rb +3 -0
- data/lib/potam.rb +9 -0
- data/lib/report.rb +48 -0
- data/lib/subtasks.rb +11 -0
- data/lib/tasks.rb +19 -0
- data/lib/timer.rb +12 -0
- data/potam.gemspec +23 -0
- data/potam.rdoc +5 -0
- data/results.html +480 -0
- data/spec/db_spec.rb +87 -0
- data/spec/notes_spec.rb +68 -0
- data/spec/report_spec.rb +89 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/subtasks_spec.rb +74 -0
- data/spec/tasks_spec.rb +86 -0
- data/spec/timer_spec.rb +31 -0
- data/test/clean.db +0 -0
- data/test/default_test.rb +14 -0
- data/test/test.db +0 -0
- data/test/test_helper.rb +9 -0
- metadata +148 -0
data/spec/db_spec.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'db'
|
3
|
+
|
4
|
+
class Test_DB < DB
|
5
|
+
end
|
6
|
+
|
7
|
+
describe DB do
|
8
|
+
|
9
|
+
let(:test_data) { [
|
10
|
+
{ id: 1, param_int1: 1, param_str1: 'value1', param_int2: 1, param_str2: 'value1' },
|
11
|
+
{ id: 2, param_int1: 2, param_str1: 'value2', param_int2: 2, param_str2: 'value2' },
|
12
|
+
{ id: 3, param_int1: 3, param_str1: 'value3', param_int2: 3, param_str2: 'value3' }
|
13
|
+
# { id: 4, param_int1: 4, param_str1: 'value4', param_int2: 4, param_str2: 'value4' },
|
14
|
+
# { id: 5, param_int1: 5, param_str1: 'value5', param_int2: 5, param_str2: 'value5' },
|
15
|
+
# { id: 6, param_int1: 6, param_str1: 'value6', param_int2: 6, param_str2: 'value6' },
|
16
|
+
# { id: 7, param_int1: 7, param_str1: 'value7', param_int2: 7, param_str2: 'value7' },
|
17
|
+
# { id: 8, param_int1: 8, param_str1: 'value8', param_int2: 8, param_str2: 'value8' },
|
18
|
+
# { id: 9, param_int1: 9, param_str1: 'value9', param_int2: 9, param_str2: 'value9' },
|
19
|
+
# { id: 10, param_int1: 10, param_str1: 'value10', param_int2: 10, param_str2: 'value10' },
|
20
|
+
# { id: 11, param_int1: 11, param_str1: 'value11', param_int2: 11, param_str2: 'value11' },
|
21
|
+
# { id: 12, param_int1: 12, param_str1: 'value12', param_int2: 12, param_str2: 'value12' },
|
22
|
+
# { id: 13, param_int1: 13, param_str1: 'value13', param_int2: 13, param_str2: 'value13' },
|
23
|
+
] }
|
24
|
+
|
25
|
+
let(:db) { double }
|
26
|
+
|
27
|
+
let(:db_table) { double(Sequel.sqlite("#{File.expand_path(File.dirname(__FILE__))}/../db/potam.db")) }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
allow(db).to receive(:[]).with(:test_db) { db_table }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#initialize' do
|
34
|
+
it 'should create attr_reader according class name' do
|
35
|
+
test = Test_DB.new
|
36
|
+
expect(test).to respond_to(:new_test_d_id)
|
37
|
+
end
|
38
|
+
it 'should connect to table by class name' do
|
39
|
+
expect(db).to receive(:[]).with(:test_db)
|
40
|
+
test = Test_DB.new(db)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#create' do
|
45
|
+
it 'should save data to table' do
|
46
|
+
test_data.each do |record|
|
47
|
+
expect(db_table).to receive(:insert).with(record) { record[:id] }
|
48
|
+
test = Test_DB.new(db)
|
49
|
+
test.create(record)
|
50
|
+
expect(test.new_test_d_id).to eq(record[:id])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#last' do
|
56
|
+
it 'should return 10 last records ordered by id desc' do
|
57
|
+
ordered = double
|
58
|
+
limited = double
|
59
|
+
allow(db_table).to receive(:order).with(Sequel.desc(:id)) { ordered }
|
60
|
+
allow(ordered).to receive(:limit).with(10) { limited }
|
61
|
+
expect(limited).to receive(:all)
|
62
|
+
test = Test_DB.new(db)
|
63
|
+
test.last
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#list' do
|
68
|
+
it 'should return all records ordered by id desc' do
|
69
|
+
ordered = double
|
70
|
+
allow(db_table).to receive(:order).with(Sequel.desc(:id)) { ordered }
|
71
|
+
expect(ordered).to receive(:all)
|
72
|
+
test = Test_DB.new(db)
|
73
|
+
test.list
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#info' do
|
78
|
+
it 'should return record by id' do
|
79
|
+
selected = double
|
80
|
+
allow(db_table).to receive(:where).with("id = ?", 1) { selected }
|
81
|
+
expect(selected).to receive(:first)
|
82
|
+
test = Test_DB.new(db)
|
83
|
+
test.info(1)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/spec/notes_spec.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'notes'
|
3
|
+
|
4
|
+
describe Notes do
|
5
|
+
# let(:notes) { [
|
6
|
+
# { id: 1, task_id: 1, text: 'Заметка 1', created_at: 1415791040 },
|
7
|
+
# { id: 2, task_id: 1, text: 'Заметка 2', created_at: 1415791041 },
|
8
|
+
# { id: 3, task_id: 1, text: 'Заметка 3', created_at: 1415791042 },
|
9
|
+
# { id: 4, task_id: 1, text: 'Заметка 4', created_at: 1415791043 },
|
10
|
+
# { id: 5, task_id: 1, text: 'Заметка 5', created_at: 1415791044 },
|
11
|
+
# { id: 6, task_id: 1, text: 'Заметка 6', created_at: 1415791045 },
|
12
|
+
# { id: 7, task_id: 1, text: 'Заметка 7', created_at: 1415791046 },
|
13
|
+
# { id: 8, task_id: 1, text: 'Заметка 8', created_at: 1415791047 },
|
14
|
+
# { id: 9, task_id: 1, text: 'Заметка 9', created_at: 1415791048 },
|
15
|
+
# { id: 10, task_id: 1, text: 'Заметка 10', created_at: 1415791049 },
|
16
|
+
# { id: 11, task_id: 1, text: 'Заметка 11', created_at: 1415791050 },
|
17
|
+
# { id: 12, task_id: 1, text: 'Заметка 12', created_at: 1415791051 },
|
18
|
+
# { id: 13, task_id: 1, text: 'Заметка 13', created_at: 141579104052 },
|
19
|
+
# ] }
|
20
|
+
|
21
|
+
let(:db) { double(Sequel.sqlite) }
|
22
|
+
|
23
|
+
let(:db_table) { double(Sequel::Dataset) }
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
allow(db).to receive(:[]).with(:notes) { db_table }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#last' do
|
30
|
+
it 'should list 10 last notes for specific task ordered by id desc' do
|
31
|
+
ordered = double
|
32
|
+
limited = double
|
33
|
+
selected = double
|
34
|
+
expect(db_table).to receive(:where).with("task_id = ?", 1) { selected }
|
35
|
+
expect(selected).to receive(:order).with(Sequel.desc(:id)) { ordered }
|
36
|
+
expect(ordered).to receive(:limit).with(10) { limited }
|
37
|
+
expect(limited).to receive(:all)
|
38
|
+
test = Notes.new(db)
|
39
|
+
test.last(1)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#list' do
|
44
|
+
it 'should list all notes for specific task ordered by id desc' do
|
45
|
+
ordered = double
|
46
|
+
selected = double
|
47
|
+
expect(db_table).to receive(:where).with("task_id = ?", 1) { selected }
|
48
|
+
expect(selected).to receive(:order).with(Sequel.desc(:id)) { ordered }
|
49
|
+
expect(ordered).to receive(:all)
|
50
|
+
test = Notes.new(db)
|
51
|
+
test.list(1)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# describe 'Notes#create' do
|
56
|
+
# it 'should save note to DB' do
|
57
|
+
# db = double(Sequel.sqlite("#{File.expand_path(File.dirname(__FILE__))}/../db/potam.db"))
|
58
|
+
# db_notes = double
|
59
|
+
# notes.each do |note|
|
60
|
+
# allow(db).to receive(:[]).with(:notes) { db_notes }
|
61
|
+
# expect(db_notes).to receive(:insert).with(
|
62
|
+
# task_id: note[:task_id], text: note[:text], created_at: note[:created_at])
|
63
|
+
# test_notes = Notes.new(db)
|
64
|
+
# test_notes.create(task_id: note[:task_id], text: note[:text], created_at: note[:created_at])
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
end
|
data/spec/report_spec.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'report'
|
3
|
+
|
4
|
+
describe Report do
|
5
|
+
# Ср. нояб. 5 10:16:01
|
6
|
+
# Ср. нояб. 5 13:13:01
|
7
|
+
# Ср. нояб. 12 22:16:06
|
8
|
+
let(:tasks) { [
|
9
|
+
{ id: 1, title: 'Тестовая задача 1', description: 'Описание тестовой задачи 1', created_at: 1415164561 },
|
10
|
+
{ id: 2, title: 'Тестовая задача 2', description: 'Описание тестовой задачи 2', created_at: 1415175181 },
|
11
|
+
{ id: 3, title: 'Тестовая задача 3', description: 'Описание тестовой задачи 3', created_at: 1415812566 }
|
12
|
+
] }
|
13
|
+
# Ср. нояб. 5 17:00:25
|
14
|
+
# Чт. нояб. 6 10:13:21, Пн. нояб. 10 09:10:21
|
15
|
+
# Чт. нояб. 13 11:00:01
|
16
|
+
let(:subtasks) { [
|
17
|
+
{ id: 1, task_id: 1, title: 'Подзадача 1', status: 0, created_at: 1415188825, finished_at: 0 },
|
18
|
+
{ id: 2, task_id: 2, title: 'Подзадача 2', status: 1, created_at: 1415250801, finished_at: 1415592621 },
|
19
|
+
{ id: 3, task_id: 3, title: 'Подзадача 3', status: 0, created_at: 1415858401, finished_at: 0 }
|
20
|
+
] }
|
21
|
+
# Пт. нояб. 7 10:10:23
|
22
|
+
# Вт. нояб. 11 14:50:32
|
23
|
+
# Чт. нояб. 13 11:00:00
|
24
|
+
let(:notes) { [
|
25
|
+
{ id: 1, task_id: 1, text: 'Заметка 1', created_at: 1415337023 },
|
26
|
+
{ id: 2, task_id: 2, text: 'Заметка 2', created_at: 1415699432 },
|
27
|
+
{ id: 3, task_id: 3, text: 'Заметка 3', created_at: 1415858400 }
|
28
|
+
] }
|
29
|
+
|
30
|
+
let(:report) { {
|
31
|
+
tasks:
|
32
|
+
[
|
33
|
+
tasks[2], tasks[1]
|
34
|
+
],
|
35
|
+
events:
|
36
|
+
[
|
37
|
+
{object: :task, status: :created, task_id: tasks[2][:id], text: tasks[2][:title], timestamp: tasks[2][:created_at]},
|
38
|
+
{object: :note, status: :created, task_id: tasks[2][:id], text: notes[2][:text], timestamp: notes[2][:created_at]},
|
39
|
+
{object: :subtask, status: :created, task_id: tasks[2][:id], text: subtasks[2][:title], timestamp: subtasks[2][:created_at]},
|
40
|
+
{object: :subtask, status: :finished, task_id: tasks[1][:id], text: subtasks[1][:title], timestamp: subtasks[1][:finished_at]},
|
41
|
+
{object: :note, status: :created, task_id: tasks[1][:id], text: notes[1][:text], timestamp: notes[1][:created_at]}
|
42
|
+
]
|
43
|
+
} }
|
44
|
+
|
45
|
+
before(:each) do
|
46
|
+
FileUtils.cp(CLEANDB, TESTDB)
|
47
|
+
db = Sequel.sqlite(TESTDB)
|
48
|
+
{tasks: tasks, subtasks: subtasks, notes: notes}.each do |table_name, data|
|
49
|
+
table = db[:"#{table_name}"]
|
50
|
+
data.each do |record|
|
51
|
+
table.insert(record)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
ENV['POTAMTIME'] = '1415974561'
|
55
|
+
ENV['POTAM'] = 'test'
|
56
|
+
@report = Report.new(db)
|
57
|
+
end
|
58
|
+
|
59
|
+
after(:each) do
|
60
|
+
FileUtils.cp(CLEANDB, TESTDB)
|
61
|
+
ENV['POTAM'] = 'production'
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#week' do
|
65
|
+
it 'should return weekly report' do
|
66
|
+
expect(@report.week).to eq(report)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#to_event' do
|
71
|
+
it 'should add task to events' do
|
72
|
+
@report.__send__(:to_event, tasks[2])
|
73
|
+
expect(@report.instance_variable_get(:@report)[:events][0]).to eq(report[:events][0])
|
74
|
+
end
|
75
|
+
it 'should add note to events' do
|
76
|
+
@report.__send__(:to_event, notes[2])
|
77
|
+
expect(@report.instance_variable_get(:@report)[:events][0]).to eq(report[:events][1])
|
78
|
+
end
|
79
|
+
it 'should add subtask to events with started_at' do
|
80
|
+
@report.__send__(:to_event, subtasks[2])
|
81
|
+
expect(@report.instance_variable_get(:@report)[:events][0]).to eq(report[:events][2])
|
82
|
+
end
|
83
|
+
it 'should add subtask to events with finished_at' do
|
84
|
+
@report.__send__(:to_event, subtasks[1], :finished)
|
85
|
+
expect(@report.instance_variable_get(:@report)[:events][0]).to eq(report[:events][3])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'subtasks'
|
3
|
+
|
4
|
+
describe Subtasks do
|
5
|
+
|
6
|
+
let(:db) { double(Sequel.sqlite) }
|
7
|
+
let(:db_table) { double(Sequel::Dataset) }
|
8
|
+
let(:selected) { double(Sequel::Dataset) }
|
9
|
+
|
10
|
+
describe '#finish!' do
|
11
|
+
|
12
|
+
around(:example) do |example|
|
13
|
+
ENV['POTAMTIME'] = '1415812666'
|
14
|
+
ENV['POTAM'] = 'test'
|
15
|
+
example.run
|
16
|
+
ENV['POTAM'] = 'production'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should change status to finished' do
|
20
|
+
expect(db).to receive(:[]).with(:subtasks) { db_table }
|
21
|
+
expect(db_table).to receive(:where).with("id = ?", 1) { selected }
|
22
|
+
expect(selected).to receive(:update).with(status: 1, finished_at: 1415812666)
|
23
|
+
test = Subtasks.new(db)
|
24
|
+
test.finish!(1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#active' do
|
29
|
+
it 'should return active subtasks for specified task' do
|
30
|
+
ordered = double
|
31
|
+
selected_by_task_id = double
|
32
|
+
expect(db).to receive(:[]).with(:subtasks) { db_table }
|
33
|
+
expect(db_table).to receive(:where).with("task_id = ?", 1) { selected_by_task_id }
|
34
|
+
expect(selected_by_task_id).to receive(:where).with("status = ?", 0) { selected }
|
35
|
+
expect(selected).to receive(:order).with(Sequel.desc(:id)) { ordered }
|
36
|
+
expect(ordered).to receive(:all)
|
37
|
+
test = Subtasks.new(db)
|
38
|
+
test.active(1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
# describe Subtasks do
|
45
|
+
# let(:subtasks) { [
|
46
|
+
# { id: 1, task_id: 1, title: 'Подзадача 1', status: 0, created_at: 1415791040 },
|
47
|
+
# { id: 2, task_id: 2, title: 'Подзадача 2', status: 0, created_at: 1415791041 },
|
48
|
+
# { id: 3, task_id: 3, title: 'Подзадача 3', status: 0, created_at: 1415791042 },
|
49
|
+
# { id: 4, task_id: 4, title: 'Подзадача 4', status: 0, created_at: 1415791043 },
|
50
|
+
# { id: 5, task_id: 5, title: 'Подзадача 5', status: 0, created_at: 1415791044 },
|
51
|
+
# { id: 6, task_id: 6, title: 'Подзадача 6', status: 0, created_at: 1415791045 },
|
52
|
+
# { id: 7, task_id: 7, title: 'Подзадача 7', status: 0, created_at: 1415791046 },
|
53
|
+
# { id: 8, task_id: 8, title: 'Подзадача 8', status: 0, created_at: 1415791047 },
|
54
|
+
# { id: 9, task_id: 9, title: 'Подзадача 9', status: 0, created_at: 1415791048 },
|
55
|
+
# { id: 10, task_id: 1, title: 'Подзадача 10', status: 0, created_at: 1415791049 },
|
56
|
+
# { id: 11, task_id: 1, title: 'Подзадача 11', status: 0, created_at: 1415791050 },
|
57
|
+
# { id: 12, task_id: 1, title: 'Подзадача 12', status: 0, created_at: 1415791051 },
|
58
|
+
# { id: 13, task_id: 1, title: 'Подзадача 13', status: 0, created_at: 141579104052 },
|
59
|
+
# ] }
|
60
|
+
|
61
|
+
# describe 'Subtasks#create' do
|
62
|
+
# it 'should save subtask to DB' do
|
63
|
+
# db = double(Sequel.sqlite("#{File.expand_path(File.dirname(__FILE__))}/../db/potam.db"))
|
64
|
+
# db_subtasks = double
|
65
|
+
# subtasks.each do |subtask|
|
66
|
+
# allow(db).to receive(:[]).with(:subtasks) { db_subtasks }
|
67
|
+
# expect(db_subtasks).to receive(:insert).with(
|
68
|
+
# task_id: subtask[:task_id], title: subtask[:title], status: 0, created_at: subtask[:created_at])
|
69
|
+
# test_subtasks = Subtasks.new(db)
|
70
|
+
# test_subtasks.create(task_id: subtask[:task_id], title: subtask[:title], status: 0, created_at: subtask[:created_at])
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
# end
|
data/spec/tasks_spec.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tasks'
|
3
|
+
|
4
|
+
describe Tasks do
|
5
|
+
let(:tasks) { [
|
6
|
+
{ id: 1, title: 'Тестовая задача 1', description: 'Описание тестовой задачи 1', created_at: 1415812561 },
|
7
|
+
{ id: 2, title: 'Тестовая задача 2', description: 'Описание тестовой задачи 2', created_at: 1415812566 },
|
8
|
+
{ id: 3, title: 'Тестовая задача 3', description: 'Описание тестовой задачи 3', created_at: 1415812571 },
|
9
|
+
{ id: 4, title: 'Тестовая задача 4', description: 'Описание тестовой задачи 4', created_at: 1415812576 },
|
10
|
+
{ id: 5, title: 'Тестовая задача 5', description: 'Описание тестовой задачи 5', created_at: 1415812581 },
|
11
|
+
{ id: 6, title: 'Тестовая задача 6', description: 'Описание тестовой задачи 6', created_at: 1415812586 },
|
12
|
+
{ id: 7, title: 'Тестовая задача 7', description: 'Описание тестовой задачи 7', created_at: 1415812591 },
|
13
|
+
{ id: 8, title: 'Тестовая задача 8', description: 'Описание тестовой задачи 8', created_at: 1415812596 },
|
14
|
+
{ id: 9, title: 'Тестовая задача 9', description: 'Описание тестовой задачи 9', created_at: 1415812601 },
|
15
|
+
{ id: 10, title: 'Тестовая задача 10', description: 'Описание тестовой задачи 10', created_at: 1415812606 },
|
16
|
+
{ id: 11, title: 'Тестовая задача 11', description: 'Описание тестовой задачи 11', created_at: 1415812611 },
|
17
|
+
{ id: 12, title: 'Тестовая задача 12', description: 'Описание тестовой задачи 12', created_at: 1415812616 },
|
18
|
+
{ id: 13, title: 'Тестовая задача 13', description: 'Описание тестовой задачи 13', created_at: 1415812621 }
|
19
|
+
] }
|
20
|
+
|
21
|
+
let(:subtasks) { [
|
22
|
+
{ id: 1, task_id: 1, title: 'Подзадача 1', status: 0, created_at: 1415812626, finished_at: 0 },
|
23
|
+
{ id: 2, task_id: 2, title: 'Подзадача 2', status: 1, created_at: 1415812566, finished_at: 1415812631 }
|
24
|
+
] }
|
25
|
+
|
26
|
+
let(:notes) { [
|
27
|
+
{ id: 1, task_id: 1, text: 'Заметка 1', created_at: 1415812566 },
|
28
|
+
{ id: 2, task_id: 1, text: 'Заметка 2', created_at: 1415812571 },
|
29
|
+
{ id: 3, task_id: 3, text: 'Заметка 3', created_at: 1415812961 }
|
30
|
+
] }
|
31
|
+
|
32
|
+
let(:order) { [3, 2, 1] + (4..13).to_a.reverse }
|
33
|
+
|
34
|
+
# let(:db) { double(Sequel.sqlite) }
|
35
|
+
|
36
|
+
# let(:db_table) { double(Sequel::Dataset) }
|
37
|
+
|
38
|
+
# describe 'Tasks#create' do
|
39
|
+
# it 'should save task to DB' do
|
40
|
+
# db = double(Sequel.sqlite("#{File.expand_path(File.dirname(__FILE__))}/../db/potam.db"))
|
41
|
+
# db_tasks = double
|
42
|
+
# tasks.each do |task|
|
43
|
+
# allow(db).to receive(:[]).with(:tasks) { db_tasks }
|
44
|
+
# expect(db_tasks).to receive(:insert).with(
|
45
|
+
# title: task[:title], description: task[:description], created_at: task[:created_at])
|
46
|
+
# test_tasks = Tasks.new(db)
|
47
|
+
# test_tasks.create(title: task[:title], description: task[:description], created_at: task[:created_at])
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
|
52
|
+
before(:each) do
|
53
|
+
FileUtils.cp(CLEANDB, TESTDB)
|
54
|
+
db = Sequel.sqlite(TESTDB)
|
55
|
+
# @db_tasks = @db[:tasks]
|
56
|
+
{tasks: tasks, subtasks: subtasks, notes: notes}.each do |table_name, data|
|
57
|
+
table = db[:"#{table_name}"]
|
58
|
+
data.each do |record|
|
59
|
+
table.insert(record)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
@test_tasks = Tasks.new(db)
|
63
|
+
end
|
64
|
+
|
65
|
+
after(:each) do
|
66
|
+
FileUtils.cp(CLEANDB, TESTDB)
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#last' do
|
70
|
+
it 'should list 10 last tasks, ordered by time of changes in subtasks or notes' do
|
71
|
+
expect(@test_tasks.last).to eq(tasks.sort_by{ |task| order.index(task[:id]) }.first(10))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#list' do
|
76
|
+
it 'should list all tasks, ordered by time of changes in subtasks or notes' do
|
77
|
+
expect(@test_tasks.list).to eq(tasks.sort_by{ |task| order.index(task[:id]) })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# describe 'Tasks#info' do
|
82
|
+
# it 'should return info about task' do
|
83
|
+
# expect(@test_tasks.info(1)).to eq(tasks[0])
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
end
|
data/spec/timer_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'timer'
|
2
|
+
|
3
|
+
class Test
|
4
|
+
include Timer
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Timer do
|
8
|
+
let(:test) { Test.new }
|
9
|
+
let(:now) { 1415942161 }
|
10
|
+
let(:last_mon) { 1415559600 }
|
11
|
+
|
12
|
+
around(:example) do |example|
|
13
|
+
ENV['POTAMTIME'] = now.to_s
|
14
|
+
ENV['POTAM'] = 'test'
|
15
|
+
example.run
|
16
|
+
ENV['POTAM'] = 'production'
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#now' do
|
20
|
+
it 'should return test timestamp' do
|
21
|
+
expect(test.now).to eq(now)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#last_mon' do
|
26
|
+
it 'should return last mondau 00:00:00 timestamp' do
|
27
|
+
expect(test.last_mon).to eq(last_mon)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/test/clean.db
ADDED
Binary file
|
data/test/test.db
ADDED
Binary file
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: potam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.12.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.12.2
|
69
|
+
description:
|
70
|
+
email: 0x22aa2@gmail.com
|
71
|
+
executables:
|
72
|
+
- potam
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- README.rdoc
|
76
|
+
- potam.rdoc
|
77
|
+
files:
|
78
|
+
- ".rspec"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- bin/potam
|
84
|
+
- db/old.db
|
85
|
+
- db/old2.db
|
86
|
+
- db/potam.db
|
87
|
+
- features/addnote.feature
|
88
|
+
- features/addtask.feature
|
89
|
+
- features/listtasks.feature
|
90
|
+
- features/potam.feature
|
91
|
+
- features/report.feature
|
92
|
+
- features/step_definitions/potam_steps.rb
|
93
|
+
- features/subtasks.feature
|
94
|
+
- features/support/env.rb
|
95
|
+
- features/taskinfo.feature
|
96
|
+
- lib/db.rb
|
97
|
+
- lib/dialog.rb
|
98
|
+
- lib/notes.rb
|
99
|
+
- lib/potam.rb
|
100
|
+
- lib/potam/version.rb
|
101
|
+
- lib/report.rb
|
102
|
+
- lib/subtasks.rb
|
103
|
+
- lib/tasks.rb
|
104
|
+
- lib/timer.rb
|
105
|
+
- potam.gemspec
|
106
|
+
- potam.rdoc
|
107
|
+
- results.html
|
108
|
+
- spec/db_spec.rb
|
109
|
+
- spec/notes_spec.rb
|
110
|
+
- spec/report_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/subtasks_spec.rb
|
113
|
+
- spec/tasks_spec.rb
|
114
|
+
- spec/timer_spec.rb
|
115
|
+
- test/clean.db
|
116
|
+
- test/default_test.rb
|
117
|
+
- test/test.db
|
118
|
+
- test/test_helper.rb
|
119
|
+
homepage:
|
120
|
+
licenses: []
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options:
|
124
|
+
- "--title"
|
125
|
+
- potam
|
126
|
+
- "--main"
|
127
|
+
- README.rdoc
|
128
|
+
- "-ri"
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.2
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Personal Offline TAsk Manager - POTAM
|
148
|
+
test_files: []
|