artisan-core 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,61 +0,0 @@
1
- require 'artisan/stories/story_collection'
2
-
3
- describe Artisan::Stories::StoryCollection do
4
- context "on init" do
5
- it "has empty list of stories" do
6
- Artisan::Stories::StoryCollection.new.stories.should == []
7
- end
8
-
9
- it "#new saves list of stories" do
10
- story1, story2 = stub, stub
11
- Artisan::Stories::StoryCollection.new([story1, story2]).all.should == [story1, story2]
12
- end
13
- end
14
-
15
- context "#estimated_points" do
16
- it "sums the estimates of all stories" do
17
- stories = [ stub(:estimate => 1.5), stub(:estimate => 2) ]
18
- Artisan::Stories::StoryCollection.new(stories).estimated_points.should == 3.5
19
- end
20
- end
21
-
22
- context "#completed_points" do
23
- it "sums the estimates of all completed stories" do
24
- complete = stub(:estimate => 1.5, :complete? => true)
25
- incomplete = stub(:estimate => 3, :complete? => false)
26
- Artisan::Stories::StoryCollection.new([complete, incomplete]).completed_points.should == 1.5
27
- end
28
- end
29
-
30
- context "#billed points" do
31
- it "sums the estimates of all billable, completed stories" do
32
- billable = stub(:estimate => 1.5, :complete? => true, :nonbillable? => false)
33
- nonbillable = stub(:estimate => 1.5, :complete? => true, :nonbillable? => true)
34
- incomplete = stub(:estimate => 3, :complete? => false, :nonbillable? => false)
35
- Artisan::Stories::StoryCollection.new([billable, nonbillable, incomplete]).billed_points.should == 1.5
36
- end
37
- end
38
-
39
- context "#billable points" do
40
- it "sums the estimates of all billable stories" do
41
- billable = stub(:estimate => 1.5, :complete? => true, :nonbillable? => false)
42
- nonbillable = stub(:estimate => 1.5, :complete? => true, :nonbillable? => true)
43
- incomplete = stub(:estimate => 3, :complete? => false, :nonbillable? => false)
44
- Artisan::Stories::StoryCollection.new([billable, nonbillable, incomplete]).billable_points.should == 4.5
45
- end
46
- end
47
-
48
- context "#all_complete?" do
49
- it "is true if all stories are complete" do
50
- complete1 = stub(:complete? => true)
51
- complete2 = stub(:complete? => true)
52
- Artisan::Stories::StoryCollection.new([complete1, complete2]).all_complete?.should be_true
53
- end
54
-
55
- it "is false if not all stories are complete" do
56
- complete = stub(:complete? => true)
57
- incomplete = stub(:complete? => false)
58
- Artisan::Stories::StoryCollection.new([complete, incomplete]).all_complete?.should be_false
59
- end
60
- end
61
- end
@@ -1,222 +0,0 @@
1
- require "artisan/story_column_changer"
2
- require "spec_helper"
3
- require "artisan-memory-repository/models/project"
4
- require "artisan-memory-repository/models/iteration"
5
- require "artisan-memory-repository/models/user"
6
- require "artisan-memory-repository/models/story"
7
-
8
- class Artisan::Activity::StoryAuditor;end;
9
-
10
- describe Artisan::StoryColumnChanger do
11
- let(:story_repository) { Artisan::Repository.story }
12
-
13
- context "status changes" do
14
- before(:each) do
15
- @user = Artisan::Repository.user.new(:login => "mike", :password => "password", :email => "mike@example.com", :full_name => "mike jansen")
16
- @user2 = Artisan::Repository.user.new(:login => "brimans", :password => "password", :email => "briman@thegmails.com", :full_name => "briman pratt")
17
-
18
- @project = Artisan::Repository.project.new(:name => "Artisan")
19
- @iteration = Artisan::Repository.iteration.new(:project_id => @project.id, :committed_points => 10, :start_date => "11/05/2010", :finish_date => "11/06/2010")
20
- end
21
-
22
- describe "move to backlog" do
23
-
24
- before(:each) do
25
- Artisan::Activity::StoryAuditor.stub!(:backlogged)
26
- @story = Artisan::Repository.story.new(:name => 'abc', :assigned_user => @user, :complete => true, :completed_at => Date.today, :iteration => @iteration,
27
- :accepted_at => Date.today, :accepted_by_user => @user2, :project => @project)
28
- @project.stories = [@story]
29
-
30
- @changer = Artisan::StoryColumnChanger.new(@story, @user)
31
- end
32
-
33
- it "moves a story to the backlog" do
34
- @changer.move_to_backlog
35
- @story.iteration.should be_nil
36
- end
37
-
38
- it "marks story as incomplete" do
39
- @changer.move_to_backlog
40
- @story.should_not be_complete
41
- end
42
-
43
- it "clears completed at" do
44
- @changer.move_to_backlog
45
- @story.completed_at.should be_nil
46
- end
47
-
48
- it "drops assigned user" do
49
- @changer.move_to_backlog
50
- @story.assigned_user_id.should be_nil
51
- end
52
-
53
- it "saves" do
54
- @changer.move_to_backlog
55
- @story.id.should_not be_nil
56
- end
57
-
58
- it "creates a story auditor" do
59
- Artisan::Activity::StoryAuditor.should_receive(:backlogged).with(@story.id, @project.id, @user.id)
60
- @changer.move_to_backlog
61
- end
62
-
63
- end
64
-
65
- describe "move to ready" do
66
- before :each do
67
- @story = Artisan::Repository.story.new(:name => 'abc', :assigned_user => @user, :complete => true, :completed_at => Time.now,
68
- :accepted_at => Time.now, :accepted_by_user => @user2, :project => @project)
69
-
70
- @changer = Artisan::StoryColumnChanger.new(@story, @user)
71
- Artisan::Activity::StoryAuditor.stub!(:readied)
72
- end
73
-
74
- it "assigns iteration to story" do
75
- @changer.move_to_ready(@iteration)
76
- story_repository.ready(@iteration).should == [@story]
77
- end
78
-
79
- it "disassociates assigned user from story when state is changed from working" do
80
- @changer.move_to_ready(@iteration)
81
- @story.assigned_user_id.should be_nil
82
- end
83
-
84
- it "disassociates assigned user from story and marks story incomplete when state is changed from completed" do
85
- @changer.move_to_ready(@iteration)
86
- @story.should_not be_complete
87
- end
88
-
89
- it "disassociates assigned user from story and removes completed at time" do
90
- @changer.move_to_ready(@iteration)
91
- @story.completed_at.should be_nil
92
- end
93
-
94
- it "saves" do
95
- @changer.move_to_ready(@iteration)
96
- @story.id.should_not be_nil
97
- end
98
-
99
- it "creates a story auditor" do
100
- Artisan::Activity::StoryAuditor.should_receive(:readied).with(@story.id, @project.id, @user.id)
101
- @changer.move_to_ready(@iteration)
102
- end
103
- end
104
-
105
- describe "move to working" do
106
- before :each do
107
- @story = Artisan::Repository.story.new(:name => 'abc', :assigned_user => @user, :complete => true, :completed_at => Time.now, :accepted_at => Time.now,
108
- :accepted_by_user => @user, :project => @project)
109
- Artisan::Activity::StoryAuditor.stub!(:worked)
110
- end
111
-
112
- it "assigns story to an iteration" do
113
- changer = Artisan::StoryColumnChanger.new(@story, @user)
114
- changer.move_to_working(@user, @iteration)
115
-
116
- story_repository.working(@iteration).should == [@story]
117
- end
118
-
119
- it "assigns current user to story when state is changed from ready" do
120
- changer = Artisan::StoryColumnChanger.new(@story, @user)
121
- changer.move_to_working(@user, @iteration)
122
-
123
- @story.assigned_user.should == @user
124
- end
125
-
126
- it "marks story incomplete when state is changed from complete" do
127
- changer = Artisan::StoryColumnChanger.new(@story, @user)
128
- changer.move_to_working(@user, @iteration)
129
-
130
- @story.should_not be_complete
131
- end
132
-
133
- it "marks story completed at time as nil when state is changed from complete" do
134
- changer = Artisan::StoryColumnChanger.new(@story, @user)
135
- changer.move_to_working(@user, @iteration)
136
-
137
- @story.completed_at.should be_nil
138
- end
139
-
140
- it "marks only if there is no current user" do
141
- @story.update_attributes(:assigned_user => @user2)
142
-
143
- changer = Artisan::StoryColumnChanger.new(@story, @user)
144
- changer.move_to_working(@user, @iteration)
145
-
146
- @story.assigned_user.should == @user2
147
- end
148
-
149
- it "saves" do
150
- changer = Artisan::StoryColumnChanger.new(@story, @user)
151
- changer.move_to_working(@user, @iteration)
152
-
153
- @story.id.should_not be_nil
154
- end
155
-
156
- it "creates a story auditor" do
157
- Artisan::Activity::StoryAuditor.should_receive(:worked).with(@story.id, @project.id, @user.id)
158
- changer = Artisan::StoryColumnChanger.new(@story, @user)
159
- changer.move_to_working(@user, @iteration)
160
- end
161
- end
162
-
163
- describe "move to completed" do
164
- before :each do
165
- Artisan::Activity::StoryAuditor.stub!(:completed)
166
- Artisan::Activity::StoryAuditor.stub!(:worked)
167
- Artisan::Activity::StoryAuditor.stub!(:accepted)
168
- @story = Artisan::Repository.story.new(:name => 'abc', :project => @project)
169
- end
170
-
171
- it "saves" do
172
- changer = Artisan::StoryColumnChanger.new(@story, @user)
173
- changer.move_to_completed(@user, @iteration)
174
-
175
- @story.id.should_not be_nil
176
- end
177
-
178
- it "assigns story to iteration" do
179
- changer = Artisan::StoryColumnChanger.new(@story, @user)
180
- changer.move_to_completed(@user, @iteration)
181
-
182
- story_repository.completed(@iteration).should == [@story]
183
- end
184
-
185
- it "marks story complete" do
186
- changer = Artisan::StoryColumnChanger.new(@story, @user)
187
- changer.move_to_completed(@user, @iteration)
188
-
189
- @story.should be_complete
190
- end
191
-
192
- it "marks story completed at time" do
193
- changer = Artisan::StoryColumnChanger.new(@story, @user)
194
- changer.move_to_completed(@user, @iteration)
195
-
196
- @story.completed_at.should_not be_nil
197
- end
198
-
199
- it "sets assigned user if not set" do
200
- changer = Artisan::StoryColumnChanger.new(@story, @user)
201
- changer.move_to_completed(@user, @iteration)
202
-
203
- @story.assigned_user.should == @user
204
- end
205
-
206
- it "marks only if there is no current user" do
207
- changer = Artisan::StoryColumnChanger.new(@story, @user)
208
- changer.move_to_working(@user2, @iteration)
209
-
210
- changer.move_to_completed(@user, @iteration)
211
-
212
- @story.assigned_user.should == @user2
213
- end
214
-
215
- it "creates a story auditor" do
216
- Artisan::Activity::StoryAuditor.should_receive(:completed).with(@story.id, @project.id, @user.id)
217
- changer = Artisan::StoryColumnChanger.new(@story, @user)
218
- changer.move_to_completed(@user, @iteration)
219
- end
220
- end
221
- end
222
- end
@@ -1,25 +0,0 @@
1
- require 'artisan/story_exporter'
2
-
3
- class Story;end;
4
-
5
- describe StoryExporter do
6
-
7
- context "#to_json" do
8
-
9
- it "exports null to empty" do
10
- StoryExporter.new(nil).to_json.should == "{}"
11
- end
12
-
13
- it "returns empty hash if there is no story" do
14
- StoryExporter.new(nil).to_json.should == "{}"
15
- end
16
-
17
- it "calls to_json on the model" do
18
- story = mock(Story)
19
- story.should_receive(:to_json).with(:except => StoryExporter::UNNECESSARY_FIELDS, :include => {:assigned_user => {:only => :full_name, :methods => [:gravatar_url]}}).and_return("some_json")
20
- StoryExporter.new(story).to_json.should == "some_json"
21
- end
22
-
23
- end
24
-
25
- end
@@ -1,67 +0,0 @@
1
- require "artisan/stories/story_sorter"
2
- require "artisan/stories/stories_interactor"
3
- require "artisan-memory-repository/models/project"
4
- require "artisan-memory-repository/models/user"
5
- require "artisan-memory-repository/models/iteration"
6
- require "artisan-memory-repository/models/story"
7
- require "active_support/all"
8
-
9
- describe Artisan::Stories::StorySorter do
10
-
11
- before(:each) do
12
- @project = Artisan::Repository.project.create(:name => "project")
13
- @project.stories = []
14
- @project.stories.stub!(:where).and_return(@project.stories)
15
-
16
- @iteration = Artisan::Repository.iteration.new(:start_date => "2011-01-01", :finish_date => "2011-01-02")
17
- @iteration.stories = []
18
- @project.iterations = [@iteration]
19
-
20
- @user = Artisan::Repository.user.new(:email => "test@example.com", :login => "login", :full_name => "some name")
21
- end
22
-
23
- #TODO - PWP - intermitten failure
24
- it "should save order in the backlog" do
25
- story1 = Artisan::Repository.story.new(:name => 'story1')
26
- story2 = Artisan::Repository.story.new(:name => 'story2')
27
- story3 = Artisan::Repository.story.new(:name => 'story3')
28
-
29
- @project.stories << story1
30
- @project.stories << story2
31
- @project.stories << story3
32
- @project.stories.stub!(:backlog).and_return(@project.stories)
33
-
34
- Artisan::Stories::StorySorter.new(@project, 'backlog', [story2.id.to_s, story3.id.to_s, story1.id.to_s], @iteration).sort
35
-
36
- Artisan::Stories::StoriesInteractor.new(@project.id, nil).backlog.stories.sort_by{|story| story.position}.map(&:name).should == ["story2", "story3", "story1"]
37
- end
38
-
39
- it "should save order in the ready column" do
40
- story1 = Artisan::Repository.story.new(:name => 'story1')
41
- story2 = Artisan::Repository.story.new(:name => 'story2')
42
- story3 = Artisan::Repository.story.new(:name => 'story3')
43
-
44
- @iteration.stories << story1
45
- @iteration.stories << story2
46
- @iteration.stories << story3
47
-
48
- @iteration.stories.should_receive(:ready).and_return(@iteration.stories)
49
-
50
- Artisan::Stories::StorySorter.new(@project, 'ready', [story2.id.to_s, story3.id.to_s, story1.id.to_s], @iteration).sort
51
-
52
- story2.position.should == 1
53
- story3.position.should == 2
54
- story1.position.should == 3
55
- end
56
-
57
- it "should not blow up if it doesn't have the story" do
58
- story = Artisan::Repository.story.new(:name => 'story1', :assigned_user => @user, :complete => true, :accepted_at => Date.today, :accepted_by_user => @user)
59
- @iteration.stories << story
60
- @iteration.stories.should_receive(:accepted).and_return(@iteration.stories)
61
-
62
- Artisan::Stories::StorySorter.new(@project, 'accepted', [story.id.to_s, 233], @iteration).sort
63
-
64
- story.position.should == 1
65
- end
66
-
67
- end
data/spec/team_spec.rb DELETED
@@ -1,107 +0,0 @@
1
- require "artisan/team"
2
- require "artisan-memory-repository/user_repository"
3
- require "artisan-memory-repository/project_repository"
4
- require "artisan/member"
5
-
6
- require 'spec_helper'
7
-
8
- class Member;end;
9
-
10
-
11
- describe Team, "add team member" do
12
- let(:project_repo) { Artisan::Repository.project }
13
- let(:user_repo) { Artisan::Repository.user }
14
- let(:project) { project_repo.create }
15
-
16
- let(:current_user) do
17
- user_repo.create(:full_name => "paul", :login => "anothertest")
18
- end
19
-
20
- let(:new_user) do
21
- user_repo.create(:full_name => "a name", :login => "a-testtest")
22
- end
23
-
24
- before(:each) { user_repo.destroy_all }
25
-
26
- it "only lets an admin add a project" do
27
- user_management = Team.new(project, nil)
28
- user_management.add_team_member(new_user)
29
- user_management.user?(new_user).should be_true
30
- end
31
-
32
- it "adds new owners" do
33
- user_management = Team.new(project, nil)
34
- user_management.add_team_owner(new_user)
35
- user_management.owner?(new_user).should be_true
36
- end
37
-
38
- it "doesn't add another record if the user is already on the project" do
39
- project_repo.add_member(project, current_user, true)
40
- user_management = Team.new(project, nil)
41
- project.users.size.should == 1
42
- end
43
-
44
- it "is an owner of the project" do
45
- project_repo.add_member(project, current_user, true)
46
-
47
- Team.new(project, nil).owner?(current_user).should be_true
48
- end
49
-
50
- it "is not an owner if there is no project" do
51
- Team.new(nil, nil).owner?(current_user).should be_false
52
- end
53
-
54
- it "user doesn't have the project" do
55
- Team.new(project, nil).owner?(current_user).should be_false
56
- end
57
-
58
- it "user isn't the owner" do
59
- Team.new(project, nil).owner?(current_user).should be_false
60
- end
61
-
62
- it "is a user of the project" do
63
- project_repo.add_member(project, current_user, false)
64
-
65
- Team.new(project, nil).owner?(current_user).should be_false
66
- Team.new(project, nil).user?(current_user).should be_true
67
- end
68
-
69
-
70
- describe Team, "#owners" do
71
- it "lists owners" do
72
- project_repo.add_member(project, current_user, true)
73
- project_repo.add_member(project, new_user, true)
74
-
75
- owners = Team.new(project, nil).owners
76
- owners.should be_include(new_user)
77
- owners.should be_include(current_user)
78
- end
79
- end
80
-
81
-
82
- describe "user_management#remove_user" do
83
-
84
- it "doesn't blow up if you can't find the user" do
85
- Team.new(project, current_user).remove_user(new_user)
86
- lambda{Team.new(project, current_user).remove_user(new_user)}.should_not raise_error
87
- end
88
-
89
- it "removes the user" do
90
- project_repo.add_member(project, new_user, false)
91
-
92
- Team.new(project, nil).remove_user(new_user)
93
-
94
- project_repo.is_member?(project, new_user).should be_false
95
- end
96
-
97
- it "takes the user off the email lists when removed" do
98
- @members = double(:remove_from_email_lists => nil)
99
- Artisan::Member.stub!(:new).and_return(@members)
100
- @members.should_receive(:remove_from_email_lists)
101
-
102
- project_repo.add_member(project, new_user, false)
103
-
104
- Team.new(project, nil).remove_user(new_user)
105
- end
106
- end
107
- end