Skip to content

Commit 4ab0ba2

Browse files
committed
Cleanup of giant merge
1 parent cedb425 commit 4ab0ba2

File tree

8 files changed

+129
-78
lines changed

8 files changed

+129
-78
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gem 'dynamic_form'
1919
gem 'i18n_alchemy'
2020
gem 'virtus'
2121
gem 'github_api', "~> 0.11.1"
22-
gem 'pivotal-tracker', "= 0.5.14", :git => 'https://github.com/hannahhoward/pivotal-tracker'
22+
gem 'lrd-pivotal-tracker', "= 0.5.14"
2323
gem 'newrelic_rpm'
2424
gem 'active_model_serializers'
2525
gem 'bibliotech'

Gemfile.lock

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ GIT
66
activerecord (>= 4.0.0, < 5)
77

88
GIT
9-
remote: https://github.com/hannahhoward/pivotal-tracker
10-
revision: 3c738617558e4734f261bc881688d2d4f83136ca
9+
remote: https://github.com/ncri/nested_form_fields.git
10+
revision: c7edc8645a0f4e5f40bd14740256aebe2998987a
1111
specs:
12-
pivotal-tracker (0.5.14)
13-
builder
14-
crack
15-
happymapper (>= 0.3.2)
16-
nokogiri (>= 1.4.3)
17-
nokogiri (>= 1.5.5)
18-
nokogiri-happymapper (>= 0.5.4)
19-
rest-client (~> 1.6.0)
12+
nested_form_fields (0.7)
13+
coffee-rails (>= 3.2.1)
14+
jquery-rails
15+
rails (>= 3.2.0)
2016

2117
GEM
2218
remote: http://rubygems.org/
@@ -98,6 +94,13 @@ GEM
9894
simplecov (>= 0.7.1, < 1.0.0)
9995
coercible (1.0.0)
10096
descendants_tracker (~> 0.0.1)
97+
coffee-rails (4.1.0)
98+
coffee-script (>= 2.2.0)
99+
railties (>= 4.0.0, < 5.0)
100+
coffee-script (2.4.1)
101+
coffee-script-source
102+
execjs
103+
coffee-script-source (1.9.1.1)
101104
columnize (0.9.0)
102105
compass (0.12.7)
103106
chunky_png (~> 1.2)
@@ -172,6 +175,9 @@ GEM
172175
activesupport (>= 3.2.0, < 4.2)
173176
i18n (~> 0.6)
174177
ice_nine (0.11.1)
178+
jquery-rails (3.1.3)
179+
railties (>= 3.0, < 5.0)
180+
thor (>= 0.14, < 2.0)
175181
json (1.8.2)
176182
json_spec (1.1.4)
177183
multi_json (~> 1.0)
@@ -185,6 +191,13 @@ GEM
185191
sqlite3 (~> 1.3.3)
186192
uuid (~> 2.3.1)
187193
logical_tabs (0.8.0)
194+
lrd-pivotal-tracker (0.5.14)
195+
builder
196+
crack
197+
happymapper (>= 0.3.2)
198+
nokogiri (>= 1.5.5)
199+
nokogiri-happymapper (>= 0.5.4)
200+
rest-client (~> 1.6.0)
188201
lrd_view_tools (0.1.5)
189202
macaddr (1.7.1)
190203
systemu (~> 2.6.2)
@@ -251,13 +264,10 @@ GEM
251264
thor (>= 0.18.1, < 2.0)
252265
raindrops (0.13.0)
253266
rake (10.4.2)
254-
rdoc (4.2.0)
255-
json (~> 1.4)
256267
responders (1.1.2)
257268
railties (>= 3.2, < 4.2)
258-
rest-client (1.6.8)
269+
rest-client (1.6.9)
259270
mime-types (~> 1.16)
260-
rdoc (>= 2.4.2)
261271
rspec (2.13.0)
262272
rspec-core (~> 2.13.0)
263273
rspec-expectations (~> 2.13.0)
@@ -387,12 +397,13 @@ DEPENDENCIES
387397
launchy
388398
logical-insight
389399
logical_tabs
400+
lrd-pivotal-tracker (= 0.5.14)
390401
lrd_view_tools
391402
mizugumo
403+
nested_form_fields!
392404
newrelic_rpm
393405
pg
394406
pivotal-github
395-
pivotal-tracker (= 0.5.14)!
396407
poltergeist
397408
populator
398409
quiet_assets
@@ -415,3 +426,6 @@ DEPENDENCIES
415426
webmock
416427
will_paginate
417428
zurb-foundation (~> 4.0.0)
429+
430+
BUNDLED WITH
431+
1.10.6

app/models/activity_builder.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ def build
3232
find_user
3333
find_work_unit
3434
@activity = Activity.new(activity_params)
35-
@activity.user_id = @user ? @user.id : nil
36-
@activity.project_id = @project ? @project.id : nil
37-
@activity.work_unit_id = @work_unit ? @work_unit.id : nil
35+
@activity.user_id = user ? user.id : nil
36+
@activity.project_id = project ? project.id : nil
37+
@activity.work_unit_id = work_unit ? work_unit.id : nil
3838
end
39+
3940
if activity.valid?
4041
true
4142
else

app/presenters/bill_report.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def projects_and_hours
4646
clockable_projects.map do |proj|
4747
Project.new(
4848
project_name_with_client(proj),
49-
ProjectWorkQuery.new(bill.work_units.billable).find_for_project(proj).sum(:hours)
49+
ProjectWorkQuery.new(bill.work_units.billable).find_for_project(proj, :exclusive => true).sum(:hours)
5050
)
5151
end
5252
end

db/migrate/20150724191322_add_work_unit_ref_to_activities.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

spec/controllers/pivotal_pull_controller_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
require 'pivotal-tracker'
23

34
describe PivotalPullController, :vcr => {} do
45
before do
@@ -43,7 +44,7 @@
4344
end
4445
end
4546

46-
let :number_of_activities_for_project do 3 end
47+
let(:number_of_activities_for_project){ 3 }
4748

4849
before do
4950
unless defined?(::API_KEYS)
Lines changed: 88 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,113 @@
11
require 'spec_helper'
22

33
describe BillReport, :type => :presenter do
4-
let :billable_projects do
5-
FactoryGirl.create_list(:project, 3, :billable => true)
6-
end
4+
describe "with a mix of project types" do
5+
let :billable_projects do
6+
FactoryGirl.create_list(:project, 3, :billable => true)
7+
end
78

8-
let :unbillable_projects do
9-
FactoryGirl.create_list(:project, 3, :billable => false)
10-
end
9+
let :unbillable_projects do
10+
FactoryGirl.create_list(:project, 3, :billable => false)
11+
end
1112

12-
let :unclockable_projects do
13-
FactoryGirl.create_list(:project, 2, :billable => false, :clockable => false)
14-
end
13+
let :unclockable_projects do
14+
FactoryGirl.create_list(:project, 2, :billable => false, :clockable => false)
15+
end
1516

16-
let :clockable_projects do
17-
billable_projects + unbillable_projects
18-
end
17+
let :clockable_projects do
18+
billable_projects + unbillable_projects
19+
end
1920

20-
let :projects do
21-
(clockable_projects + unclockable_projects).shuffle
22-
end
21+
let :projects do
22+
(clockable_projects + unclockable_projects).shuffle
23+
end
2324

24-
let :bill do
25-
FactoryGirl.create(:bill)
26-
end
25+
let :bill do
26+
FactoryGirl.create(:bill)
27+
end
2728

28-
let :unbillable_wus do
29-
(1..17).zip(projects.cycle).map do |num, project|
30-
FactoryGirl.create(:work_unit, :billable => false, :hours => 1, :project => project, :bill => bill)
29+
let :unbillable_wus do
30+
(1..17).zip(projects.cycle).map do |num, project|
31+
FactoryGirl.create(:work_unit, :billable => false, :hours => 1, :project => project, :bill => bill)
32+
end
3133
end
32-
end
3334

34-
let :billable_wus do
35-
(1..17).zip(projects.cycle).map do |num, project|
36-
FactoryGirl.create(:work_unit, :billable => true, :hours => 1, :project => project, :bill => bill)
35+
let :billable_wus do
36+
(1..17).zip(projects.cycle).map do |num, project|
37+
FactoryGirl.create(:work_unit, :billable => true, :hours => 1, :project => project, :bill => bill)
38+
end
3739
end
38-
end
3940

40-
let :billable_clockable do
41-
billable_wus.find_all do |wu|
42-
wu.project.clockable?
41+
let :billable_clockable do
42+
billable_wus.find_all do |wu|
43+
wu.project.clockable?
44+
end
4345
end
44-
end
4546

46-
let! :work_units do
47-
unbillable_wus + billable_wus
48-
end
47+
let! :work_units do
48+
unbillable_wus + billable_wus
49+
end
4950

50-
let :total_billable_hours do
51-
billable_wus.inject(0) do |total, wu|
52-
total + wu.hours
51+
let :total_billable_hours do
52+
billable_wus.inject(0) do |total, wu|
53+
total + wu.hours
54+
end
5355
end
54-
end
5556

56-
subject :bill_report do
57-
BillReport.new(bill)
58-
end
57+
subject :bill_report do
58+
BillReport.new(bill)
59+
end
5960

60-
it "should total hours consistently" do
61-
expect(bill_report.total_hours).to eql(billable_clockable.length * 1.0)
62-
end
61+
it "should total hours consistently" do
62+
expect(bill_report.total_hours).to eql(billable_clockable.length * 1.0)
63+
end
64+
65+
it "should have all the projects in #projects_and_hours" do
66+
expect(bill_report.projects_and_hours.length).to eql(clockable_projects.length)
67+
end
68+
69+
it "should have all the billable WUs in #work_units_and_hours" do
70+
expect(bill_report.work_units_and_hours.length).to eql(billable_clockable.length)
71+
expect(bill_report.work_units_and_hours.map(&:notes).sort).to eql(billable_clockable.map(&:notes).sort)
72+
end
6373

64-
it "should have all the projects in #projects_and_hours" do
65-
expect(bill_report.projects_and_hours.length).to eql(clockable_projects.length)
6674
end
75+
describe "with child projects" do
76+
77+
let! :project do FactoryGirl.create(:project, :name => "Topmost") end
78+
let! :child_project do FactoryGirl.create(:project, :name => "Middle", :parent_id => project.id) end
79+
let! :grandchild_project do FactoryGirl.create(:project, :name => "Bottom", :parent_id => child_project.id) end
80+
let! :bill do FactoryGirl.create(:bill) end
81+
82+
2.times do |idx|
83+
let! "project_work_unit_#{idx}" do
84+
FactoryGirl.create(:work_unit, :project => project, :hours => 2, :bill => bill)
85+
end
86+
let! "child_project_work_unit_#{idx}" do
87+
FactoryGirl.create(:work_unit, :project => child_project, :hours => 4, :bill => bill)
88+
end
89+
let! "grandchild_project_work_unit_#{idx}" do
90+
FactoryGirl.create(:work_unit, :project => grandchild_project, :hours => 6, :bill => bill)
91+
end
92+
end
93+
94+
subject :bill_report do
95+
BillReport.new(bill)
96+
end
97+
98+
it "should total hours consistently" do
99+
expect(bill_report.total_hours.to_f).to eql((2 * 2 + 2 * 4 + 2 * 6) * 1.0)
100+
end
101+
102+
it "should not accumulate hours to parent projects" do
103+
expect(bill_report.projects_and_hours.length).to eql(3)
104+
expect(bill_report.projects_and_hours.map(&:hours).map(&:to_f)).to include(4.0, 8.0, 12.0)
105+
end
106+
107+
it "should have all the billable WUs in #work_units_and_hours" do
108+
expect(bill_report.work_units_and_hours.length).to eql(6)
109+
end
67110

68-
it "should have all the billable WUs in #work_units_and_hours" do
69-
expect(bill_report.work_units_and_hours.length).to eql(billable_clockable.length)
70-
expect(bill_report.work_units_and_hours.map(&:notes).sort).to eql(billable_clockable.map(&:notes).sort)
71111
end
72112

73113
end

spec/stories/admin_views_a_bill_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
let! :admin do FactoryGirl.create(:admin) end
1010
let! :user do FactoryGirl.create(:user) end
11-
let! :project do FactoryGirl.create(:project) end
12-
let! :child_project do FactoryGirl.create(:project, :parent_id => project.id) end
13-
let! :grandchild_project do FactoryGirl.create(:project, :parent_id => child_project.id) end
11+
let! :project do FactoryGirl.create(:project, :name => "Topmost") end
12+
let! :child_project do FactoryGirl.create(:project, :name => "Middle", :parent_id => project.id) end
13+
let! :grandchild_project do FactoryGirl.create(:project, :name => "Bottom", :parent_id => child_project.id) end
1414
let! :bill do FactoryGirl.create(:bill) end
1515

1616
2.times do |idx|
@@ -46,4 +46,4 @@
4646
expect(page).to_not have_content('56.0') # this would be the total if the hours accumulated through the children
4747
end
4848

49-
end
49+
end

0 commit comments

Comments
 (0)