tracker-application 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/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/tracker/application/create_story.rb +17 -0
- data/lib/tracker/application/create_story_story.rb +33 -0
- data/lib/tracker/application/load_blocked_stories.rb +21 -0
- data/lib/tracker/application/load_closed_stories.rb +15 -0
- data/lib/tracker/application/load_epic_stories.rb +24 -0
- data/lib/tracker/application/load_finished_stories.rb +21 -0
- data/lib/tracker/application/load_started_stories.rb +21 -0
- data/lib/tracker/application/load_story.rb +17 -0
- data/lib/tracker/application/load_story_child_story_stories.rb +25 -0
- data/lib/tracker/application/load_story_parent_story_stories.rb +25 -0
- data/lib/tracker/application/load_story_story.rb +21 -0
- data/lib/tracker/application/load_unblocked_stories.rb +21 -0
- data/lib/tracker/application/version.rb +5 -0
- data/lib/tracker/application.rb +19 -0
- data/spec/create_story_spec.rb +14 -0
- data/spec/create_story_story_spec.rb +87 -0
- data/spec/load_blocked_stories_spec.rb +35 -0
- data/spec/load_closed_stories_spec.rb +41 -0
- data/spec/load_epic_stories_spec.rb +41 -0
- data/spec/load_finished_stories_spec.rb +42 -0
- data/spec/load_started_stories_spec.rb +43 -0
- data/spec/load_story_child_story_stories_spec.rb +34 -0
- data/spec/load_story_parent_story_stories_spec.rb +34 -0
- data/spec/load_story_spec.rb +14 -0
- data/spec/load_story_story_spec.rb +40 -0
- data/spec/load_unblocked_stories_spec.rb +35 -0
- data/spec/spec_helper.rb +15 -0
- data/tracker-application.gemspec +29 -0
- metadata +188 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0ae01d21e9f6848e4dda0d3940fc00bb0f1df3a0
|
4
|
+
data.tar.gz: ec2a9ae3d1feee84a36c060dd9b824bcca723133
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6677cbad68c60cd7777a13ddf1d1119ca090e60bd476a1723caf3cde4bef86d4bfd6b61f7bae8a7bd75f89594f79dadcd9f94bebb70bac4fdfc6e2222a6a0b09
|
7
|
+
data.tar.gz: 06d0791d7c85f11ce19550285d7711026a1ffed015b3165a8843b25f5c84770284ee5b2f8b03c09b786a5505977d1c5231c9bebb825fc411d984e2f46c946f3b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ben Bergstein
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Tracker::Application
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'tracker-application'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install tracker-application
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class CreateStory
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
title = context[:title]
|
10
|
+
|
11
|
+
story_id = Tracker.pg[:stories].insert(title: title)
|
12
|
+
|
13
|
+
context[:story_id] = story_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class CreateStoryStory
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
child_story_id = context[:child_story_id]
|
10
|
+
parent_story_id = context[:parent_story_id]
|
11
|
+
|
12
|
+
story_story_attributes = {
|
13
|
+
parent_story_id: parent_story_id,
|
14
|
+
child_story_id: child_story_id
|
15
|
+
}
|
16
|
+
|
17
|
+
recursive_sql = Tracker::PG.recursive_parent_story_stories_sql(parent_story_id)
|
18
|
+
|
19
|
+
invalid_story_stories = Tracker.pg[:story_stories].where("id in (#{recursive_sql})").where(
|
20
|
+
parent_story_id: child_story_id
|
21
|
+
)
|
22
|
+
|
23
|
+
if Tracker.pg[:story_stories].where(story_story_attributes).any?
|
24
|
+
fail!(message: :already_exists)
|
25
|
+
else
|
26
|
+
invalid_story_stories.delete
|
27
|
+
story_story_id = Tracker.pg[:story_stories].insert(story_story_attributes)
|
28
|
+
context[:story_story_id] = story_story_id
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadBlockedStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
blocked_stories = Tracker.pg[:stories].where(where_sql_statement)
|
10
|
+
|
11
|
+
context[:blocked_stories] = blocked_stories
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def where_sql_statement
|
17
|
+
'(select count(id) from story_stories where story_stories.parent_story_id = stories.id) > 0'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadClosedStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
closed_stories = Tracker.pg[:stories].where('closed_at IS NOT NULL')
|
10
|
+
|
11
|
+
context[:closed_stories] = closed_stories
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadEpicStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
epic_stories = Tracker.pg[:stories].where(where_sql_statement)
|
10
|
+
|
11
|
+
context[:epic_stories] = epic_stories
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def where_sql_statement
|
17
|
+
'%s AND %s' % [
|
18
|
+
'(SELECT COUNT(id) FROM story_stories WHERE story_stories.parent_story_id = stories.id) > 0',
|
19
|
+
'(SELECT COUNT(id) FROM story_stories WHERE story_stories.child_story_id = stories.id) = 0'
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadFinishedStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
finished_stories = Tracker.pg[:stories].where(where_sql_statement)
|
10
|
+
|
11
|
+
context[:finished_stories] = finished_stories
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def where_sql_statement
|
17
|
+
'finished_at IS NOT NULL AND closed_at IS NULL'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadStartedStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
started_stories = Tracker.pg[:stories].where(where_sql_statement)
|
10
|
+
|
11
|
+
context[:started_stories] = started_stories
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def where_sql_statement
|
17
|
+
'started_at IS NOT NULL AND finished_at IS NULL AND closed_at IS NULL'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadStory
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
story_id = context[:story_id]
|
10
|
+
|
11
|
+
story = Tracker.pg[:stories][id: story_id]
|
12
|
+
|
13
|
+
context[:story] = story
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadStoryChildStoryStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
story_id = context[:story_id]
|
10
|
+
|
11
|
+
child_story_stories = Tracker.pg[:story_stories]
|
12
|
+
.where(parent_story_id: story_id)
|
13
|
+
.join(:stories, id: :child_story_id)
|
14
|
+
.select(
|
15
|
+
:story_stories__id,
|
16
|
+
:story_stories__parent_story_id,
|
17
|
+
:story_stories__child_story_id,
|
18
|
+
:stories__title___child_story_title
|
19
|
+
)
|
20
|
+
|
21
|
+
context[:child_story_stories] = child_story_stories
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadStoryParentStoryStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
story_id = context[:story_id]
|
10
|
+
|
11
|
+
parent_story_stories = Tracker.pg[:story_stories]
|
12
|
+
.where(child_story_id: story_id)
|
13
|
+
.join(:stories, id: :parent_story_id)
|
14
|
+
.select(
|
15
|
+
:story_stories__id,
|
16
|
+
:story_stories__parent_story_id,
|
17
|
+
:story_stories__child_story_id,
|
18
|
+
:stories__title___parent_story_title
|
19
|
+
)
|
20
|
+
|
21
|
+
context[:parent_story_stories] = parent_story_stories
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadStoryStory
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
parent_story_id = context[:parent_story_id]
|
10
|
+
child_story_id = context[:child_story_id]
|
11
|
+
|
12
|
+
story_story = Tracker.pg[:story_stories][
|
13
|
+
parent_story_id: parent_story_id,
|
14
|
+
child_story_id: child_story_id
|
15
|
+
]
|
16
|
+
|
17
|
+
context[:story_story] = story_story
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'interactor'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
class LoadUnblockedStories
|
6
|
+
include Interactor
|
7
|
+
|
8
|
+
def perform
|
9
|
+
unblocked_stories = Tracker.pg[:stories].where(where_sql_statement)
|
10
|
+
|
11
|
+
context[:unblocked_stories] = unblocked_stories
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def where_sql_statement
|
17
|
+
'(select count(id) from story_stories where story_stories.parent_story_id = stories.id) = 0'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "tracker/application/version"
|
2
|
+
require "tracker/application/create_story"
|
3
|
+
require "tracker/application/create_story_story"
|
4
|
+
require "tracker/application/load_story"
|
5
|
+
require "tracker/application/load_story_story"
|
6
|
+
require "tracker/application/load_unblocked_stories"
|
7
|
+
require "tracker/application/load_blocked_stories"
|
8
|
+
require "tracker/application/load_story_parent_story_stories"
|
9
|
+
require "tracker/application/load_story_child_story_stories"
|
10
|
+
require "tracker/application/load_epic_stories"
|
11
|
+
require "tracker/application/load_started_stories"
|
12
|
+
require "tracker/application/load_finished_stories"
|
13
|
+
require "tracker/application/load_closed_stories"
|
14
|
+
require "tracker/application/recursively_load_story_parent_stories"
|
15
|
+
|
16
|
+
module Tracker
|
17
|
+
module Application
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe CreateStory do
|
6
|
+
subject(:result) { CreateStory.perform(title: 'My title') }
|
7
|
+
|
8
|
+
it 'creates a story' do
|
9
|
+
expect(->{subject}).to change{Tracker.pg[:stories].count}.by(1)
|
10
|
+
expect(result.story_id).to eq Tracker.pg[:stories].where(title: 'My title').first[:id]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe CreateStoryStory do
|
6
|
+
let(:parent_story_id) { Tracker.pg[:stories].insert(title: 'Parent story') }
|
7
|
+
let(:child_story_id) { Tracker.pg[:stories].insert(title: 'Child story') }
|
8
|
+
|
9
|
+
subject(:result) do
|
10
|
+
CreateStoryStory.perform(
|
11
|
+
parent_story_id: parent_story_id,
|
12
|
+
child_story_id: child_story_id
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:new_story_story) do
|
17
|
+
Tracker.pg[:story_stories].first(
|
18
|
+
parent_story_id: parent_story_id,
|
19
|
+
child_story_id: child_story_id
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'creates a story story' do
|
24
|
+
expect(->{subject}).to change{Tracker.pg[:story_stories].count}.by(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'is successful' do
|
28
|
+
expect(result).to be_success
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'includes the id of the new story story in the result' do
|
32
|
+
expect(result.story_story_id).to eq new_story_story[:id]
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when the story story already exists' do
|
36
|
+
before do
|
37
|
+
attributes = {
|
38
|
+
parent_story_id: parent_story_id,
|
39
|
+
child_story_id: child_story_id
|
40
|
+
}
|
41
|
+
|
42
|
+
Tracker.pg[:story_stories].insert(attributes)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'does not create a story story' do
|
46
|
+
expect(->{subject}).not_to change{Tracker.pg[:story_stories].count}.by(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'includes a message in the result' do
|
50
|
+
expect(result.message).to eq :already_exists
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'is not successful' do
|
54
|
+
expect(result).not_to be_success
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the child story is the parent story of a story that is the parent to the parent story' do
|
59
|
+
let!(:parent_parent_story_id) do
|
60
|
+
Tracker.pg[:stories].insert(title: 'Parent story story')
|
61
|
+
end
|
62
|
+
|
63
|
+
let!(:parent_parent_story_story_id) do
|
64
|
+
Tracker.pg[:story_stories].insert(
|
65
|
+
child_story_id: parent_story_id,
|
66
|
+
parent_story_id: parent_parent_story_id
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
let!(:parent_parent_parent_story_id) do
|
71
|
+
Tracker.pg[:story_stories].insert(
|
72
|
+
child_story_id: parent_parent_story_id,
|
73
|
+
parent_story_id: child_story_id
|
74
|
+
)
|
75
|
+
endx
|
76
|
+
|
77
|
+
it 'deletes parent_parent_parent_story_id' do
|
78
|
+
expect(->{subject}).to change{Tracker.pg[:story_stories][id: parent_parent_parent_story_id]}.from(
|
79
|
+
id: parent_parent_parent_story_id,
|
80
|
+
child_story_id: parent_parent_story_id,
|
81
|
+
parent_story_id: child_story_id
|
82
|
+
).to(nil)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadBlockedStories do
|
6
|
+
let(:unblocked_story_id){Tracker.pg[:stories].insert(title: 'Unblocked story')}
|
7
|
+
let(:blocked_story_id){Tracker.pg[:stories].insert(title: 'Blocked story')}
|
8
|
+
|
9
|
+
before do
|
10
|
+
CreateStoryStory.perform(
|
11
|
+
parent_story_id: blocked_story_id,
|
12
|
+
child_story_id: unblocked_story_id
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
subject(:result) { LoadBlockedStories.perform }
|
17
|
+
|
18
|
+
it 'is successful' do
|
19
|
+
expect(result).to be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'includes the blocked story and not the unblocked story' do
|
23
|
+
expect(result.blocked_stories.all).to eq [
|
24
|
+
{
|
25
|
+
id: blocked_story_id,
|
26
|
+
title: 'Blocked story',
|
27
|
+
started_at: nil,
|
28
|
+
finished_at: nil,
|
29
|
+
closed_at: nil
|
30
|
+
}
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadClosedStories do
|
6
|
+
let!(:closed_story_id){Tracker.pg[:stories].insert(title: 'Closed story', closed_at: closed_at)}
|
7
|
+
let(:closed_at){Time.new}
|
8
|
+
|
9
|
+
before do
|
10
|
+
Tracker.pg[:stories].insert(
|
11
|
+
title: 'Started story',
|
12
|
+
started_at: Time.new
|
13
|
+
)
|
14
|
+
|
15
|
+
Tracker.pg[:stories].insert(
|
16
|
+
title: 'Finished story',
|
17
|
+
started_at: Time.new,
|
18
|
+
finished_at: Time.new
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
subject(:result){LoadClosedStories.perform}
|
23
|
+
|
24
|
+
it 'is successful' do
|
25
|
+
expect(result).to be_success
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'includes only the closed story' do
|
29
|
+
expect(result.closed_stories.all).to eq [
|
30
|
+
{
|
31
|
+
id: closed_story_id,
|
32
|
+
title: 'Closed story',
|
33
|
+
started_at: nil,
|
34
|
+
finished_at: nil,
|
35
|
+
closed_at: closed_at
|
36
|
+
}
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadEpicStories do
|
6
|
+
let(:unblocked_story_id){Tracker.pg[:stories].insert(title: 'Unblocked story')}
|
7
|
+
let(:blocked_story_id){Tracker.pg[:stories].insert(title: 'Blocked story')}
|
8
|
+
let(:epic_story_id){Tracker.pg[:stories].insert(title: 'Epic story')}
|
9
|
+
|
10
|
+
before do
|
11
|
+
CreateStoryStory.perform(
|
12
|
+
parent_story_id: blocked_story_id,
|
13
|
+
child_story_id: unblocked_story_id
|
14
|
+
)
|
15
|
+
|
16
|
+
CreateStoryStory.perform(
|
17
|
+
parent_story_id: epic_story_id,
|
18
|
+
child_story_id: blocked_story_id
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
subject(:result) { LoadEpicStories.perform }
|
23
|
+
|
24
|
+
it 'is successful' do
|
25
|
+
expect(result).to be_success
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'includes only the epic story' do
|
29
|
+
expect(result.epic_stories.all).to eq [
|
30
|
+
{
|
31
|
+
id: epic_story_id,
|
32
|
+
title: 'Epic story',
|
33
|
+
started_at: nil,
|
34
|
+
finished_at: nil,
|
35
|
+
closed_at: nil
|
36
|
+
}
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadFinishedStories do
|
6
|
+
let!(:finished_story_id){Tracker.pg[:stories].insert(title: 'Finished story', finished_at: finished_at)}
|
7
|
+
let(:finished_at){Time.new}
|
8
|
+
|
9
|
+
before do
|
10
|
+
Tracker.pg[:stories].insert(
|
11
|
+
title: 'Started story',
|
12
|
+
started_at: Time.new
|
13
|
+
)
|
14
|
+
|
15
|
+
Tracker.pg[:stories].insert(
|
16
|
+
title: 'Closed story',
|
17
|
+
started_at: Time.new,
|
18
|
+
finished_at: Time.new,
|
19
|
+
closed_at: Time.new
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
subject(:result){LoadFinishedStories.perform}
|
24
|
+
|
25
|
+
it 'is successful' do
|
26
|
+
expect(result).to be_success
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'includes only the finished story' do
|
30
|
+
expect(result.finished_stories.all).to eq [
|
31
|
+
{
|
32
|
+
id: finished_story_id,
|
33
|
+
title: 'Finished story',
|
34
|
+
started_at: nil,
|
35
|
+
finished_at: finished_at,
|
36
|
+
closed_at: nil
|
37
|
+
}
|
38
|
+
]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadStartedStories do
|
6
|
+
let!(:started_story_id){Tracker.pg[:stories].insert(title: 'Started story', started_at: started_at)}
|
7
|
+
let(:started_at){Time.new}
|
8
|
+
|
9
|
+
before do
|
10
|
+
Tracker.pg[:stories].insert(
|
11
|
+
title: 'Finished story',
|
12
|
+
started_at: started_at,
|
13
|
+
finished_at: Time.new
|
14
|
+
)
|
15
|
+
|
16
|
+
Tracker.pg[:stories].insert(
|
17
|
+
title: 'Closed story',
|
18
|
+
started_at: started_at,
|
19
|
+
finished_at: Time.new,
|
20
|
+
closed_at: Time.new
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject(:result){LoadStartedStories.perform}
|
25
|
+
|
26
|
+
it 'is successful' do
|
27
|
+
expect(result).to be_success
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'includes only the started story' do
|
31
|
+
expect(result.started_stories.all).to eq [
|
32
|
+
{
|
33
|
+
id: started_story_id,
|
34
|
+
title: 'Started story',
|
35
|
+
started_at: started_at,
|
36
|
+
finished_at: nil,
|
37
|
+
closed_at: nil
|
38
|
+
}
|
39
|
+
]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadStoryChildStoryStories do
|
6
|
+
let(:unblocked_story_id){Tracker.pg[:stories].insert(title: 'Unblocked story')}
|
7
|
+
let(:blocked_story_id){Tracker.pg[:stories].insert(title: 'Blocked story')}
|
8
|
+
|
9
|
+
let!(:parent_story_story_id) do
|
10
|
+
result = Tracker.pg[:story_stories].insert(
|
11
|
+
parent_story_id: blocked_story_id,
|
12
|
+
child_story_id: unblocked_story_id
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
subject(:result) { LoadStoryChildStoryStories.perform(story_id: blocked_story_id) }
|
17
|
+
|
18
|
+
it 'is successful' do
|
19
|
+
expect(result).to be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'includes the only the parent story' do
|
23
|
+
expect(result.child_story_stories.all).to eq [
|
24
|
+
{
|
25
|
+
id: parent_story_story_id,
|
26
|
+
parent_story_id: blocked_story_id,
|
27
|
+
child_story_id: unblocked_story_id,
|
28
|
+
child_story_title: 'Unblocked story'
|
29
|
+
}
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadStoryParentStoryStories do
|
6
|
+
let(:unblocked_story_id){Tracker.pg[:stories].insert(title: 'Unblocked story')}
|
7
|
+
let(:blocked_story_id){Tracker.pg[:stories].insert(title: 'Blocked story')}
|
8
|
+
|
9
|
+
let!(:parent_story_story_id) do
|
10
|
+
result = Tracker.pg[:story_stories].insert(
|
11
|
+
parent_story_id: blocked_story_id,
|
12
|
+
child_story_id: unblocked_story_id
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
subject(:result) { LoadStoryParentStoryStories.perform(story_id: unblocked_story_id) }
|
17
|
+
|
18
|
+
it 'is successful' do
|
19
|
+
expect(result).to be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'includes the only the parent story' do
|
23
|
+
expect(result.parent_story_stories.all).to eq [
|
24
|
+
{
|
25
|
+
id: parent_story_story_id,
|
26
|
+
parent_story_id: blocked_story_id,
|
27
|
+
child_story_id: unblocked_story_id,
|
28
|
+
parent_story_title: 'Blocked story'
|
29
|
+
}
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadStory do
|
6
|
+
let(:story_id){CreateStory.perform(title: 'My Story').story_id}
|
7
|
+
subject(:result){LoadStory.perform(story_id: story_id)}
|
8
|
+
|
9
|
+
it 'creates a story' do
|
10
|
+
expect(result.story).to eq(id: story_id, title: 'My Story', started_at: nil, finished_at: nil, closed_at: nil)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadStoryStory do
|
6
|
+
let(:parent_story_id) { Tracker.pg[:stories].insert(title: 'Parent Story') }
|
7
|
+
let(:child_story_id) { Tracker.pg[:stories].insert(title: 'Child Story') }
|
8
|
+
|
9
|
+
subject(:result) do
|
10
|
+
LoadStoryStory.perform(
|
11
|
+
parent_story_id: parent_story_id,
|
12
|
+
child_story_id: child_story_id
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when the story story does not exist' do
|
17
|
+
it 'is empty and does not blow up' do
|
18
|
+
expect(result.story_story).should be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when the story story exists' do
|
23
|
+
let!(:story_story_id) do
|
24
|
+
Tracker.pg[:story_stories].insert(
|
25
|
+
parent_story_id: parent_story_id,
|
26
|
+
child_story_id: child_story_id
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'loads the story story' do
|
31
|
+
expect(result.story_story).to eq(
|
32
|
+
id: story_story_id,
|
33
|
+
parent_story_id: parent_story_id,
|
34
|
+
child_story_id: child_story_id
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tracker
|
4
|
+
module Application
|
5
|
+
describe LoadUnblockedStories do
|
6
|
+
let(:unblocked_story_id){Tracker.pg[:stories].insert(title: 'Unblocked story')}
|
7
|
+
let(:blocked_story_id){Tracker.pg[:stories].insert(title: 'Blocked story')}
|
8
|
+
|
9
|
+
before do
|
10
|
+
CreateStoryStory.perform(
|
11
|
+
parent_story_id: blocked_story_id,
|
12
|
+
child_story_id: unblocked_story_id
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
subject(:result) { LoadUnblockedStories.perform }
|
17
|
+
|
18
|
+
it 'is successful' do
|
19
|
+
expect(result).to be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'includes the unblocked story and not the blocked story' do
|
23
|
+
expect(result.unblocked_stories.all).to eq [
|
24
|
+
{
|
25
|
+
id: unblocked_story_id,
|
26
|
+
title: 'Unblocked story',
|
27
|
+
started_at: nil,
|
28
|
+
finished_at: nil,
|
29
|
+
closed_at: nil
|
30
|
+
}
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
require 'tracker/application'
|
4
|
+
|
5
|
+
ENV['TEST_DATABASE_URL'] ||= 'postgres://postgres@localhost:5432/new_tracker_test'
|
6
|
+
|
7
|
+
Tracker::PG.database_url = ENV['TEST_DATABASE_URL']
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.around(:each) do |example|
|
11
|
+
Tracker.pg.transaction(rollback: :always) do
|
12
|
+
example.run
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tracker/application/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tracker-application"
|
8
|
+
spec.version = Tracker::Application::VERSION
|
9
|
+
spec.authors = ["Ben Bergstein"]
|
10
|
+
spec.email = ["bennyjbergstein@gmail.com"]
|
11
|
+
spec.description = "Application logic for a tracker app"
|
12
|
+
spec.summary = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "interactor"
|
22
|
+
spec.add_dependency "tracker-p_g"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "foreman"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tracker-application
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Bergstein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: interactor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: tracker-p_g
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: foreman
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Application logic for a tracker app
|
112
|
+
email:
|
113
|
+
- bennyjbergstein@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/tracker/application.rb
|
124
|
+
- lib/tracker/application/create_story.rb
|
125
|
+
- lib/tracker/application/create_story_story.rb
|
126
|
+
- lib/tracker/application/load_blocked_stories.rb
|
127
|
+
- lib/tracker/application/load_closed_stories.rb
|
128
|
+
- lib/tracker/application/load_epic_stories.rb
|
129
|
+
- lib/tracker/application/load_finished_stories.rb
|
130
|
+
- lib/tracker/application/load_started_stories.rb
|
131
|
+
- lib/tracker/application/load_story.rb
|
132
|
+
- lib/tracker/application/load_story_child_story_stories.rb
|
133
|
+
- lib/tracker/application/load_story_parent_story_stories.rb
|
134
|
+
- lib/tracker/application/load_story_story.rb
|
135
|
+
- lib/tracker/application/load_unblocked_stories.rb
|
136
|
+
- lib/tracker/application/version.rb
|
137
|
+
- spec/create_story_spec.rb
|
138
|
+
- spec/create_story_story_spec.rb
|
139
|
+
- spec/load_blocked_stories_spec.rb
|
140
|
+
- spec/load_closed_stories_spec.rb
|
141
|
+
- spec/load_epic_stories_spec.rb
|
142
|
+
- spec/load_finished_stories_spec.rb
|
143
|
+
- spec/load_started_stories_spec.rb
|
144
|
+
- spec/load_story_child_story_stories_spec.rb
|
145
|
+
- spec/load_story_parent_story_stories_spec.rb
|
146
|
+
- spec/load_story_spec.rb
|
147
|
+
- spec/load_story_story_spec.rb
|
148
|
+
- spec/load_unblocked_stories_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- tracker-application.gemspec
|
151
|
+
homepage: ''
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.0.3
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: ''
|
175
|
+
test_files:
|
176
|
+
- spec/create_story_spec.rb
|
177
|
+
- spec/create_story_story_spec.rb
|
178
|
+
- spec/load_blocked_stories_spec.rb
|
179
|
+
- spec/load_closed_stories_spec.rb
|
180
|
+
- spec/load_epic_stories_spec.rb
|
181
|
+
- spec/load_finished_stories_spec.rb
|
182
|
+
- spec/load_started_stories_spec.rb
|
183
|
+
- spec/load_story_child_story_stories_spec.rb
|
184
|
+
- spec/load_story_parent_story_stories_spec.rb
|
185
|
+
- spec/load_story_spec.rb
|
186
|
+
- spec/load_story_story_spec.rb
|
187
|
+
- spec/load_unblocked_stories_spec.rb
|
188
|
+
- spec/spec_helper.rb
|