tracco 0.0.11 → 0.0.12

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.0.12
2
+ - Adding a TrackedCard#trello_notifications to fetch all the notifications belonging to the card
3
+ - Introducing FactoryGirl as a factory gem to simplify specs
4
+
1
5
  0.0.11
2
6
  - Adding a TrackedCard.all_tracked_cards method to fetch all cards with a valid tracking. Moreover, sorting_options can be passed to sort using a method e.g. TrackedCard.all_tracked_cards(:method => :name, :order => :desc)
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tracco (0.0.11)
4
+ tracco (0.0.12)
5
5
  bson_ext
6
6
  chronic
7
7
  google_drive
@@ -35,6 +35,8 @@ GEM
35
35
  debugger-ruby_core_source (>= 1.1.1)
36
36
  debugger-ruby_core_source (1.1.8)
37
37
  diff-lcs (1.1.3)
38
+ factory_girl (4.2.0)
39
+ activesupport (>= 3.0.0)
38
40
  faraday (0.8.5)
39
41
  multipart-post (~> 1.1)
40
42
  google_drive (0.3.3)
@@ -102,6 +104,7 @@ PLATFORMS
102
104
  DEPENDENCIES
103
105
  database_cleaner
104
106
  debugger
107
+ factory_girl
105
108
  mongoid-rspec
106
109
  rake
107
110
  rspec
@@ -41,6 +41,12 @@ class TrackedCard
41
41
  sorting_options[:order] == :desc ? cards.reverse : cards
42
42
  end
43
43
 
44
+ def self.build_from(trello_card)
45
+ trello_card_id = trello_card.id
46
+ trello_card.attributes.delete(:id)
47
+ new(trello_card.attributes.merge(trello_id: trello_card_id))
48
+ end
49
+
44
50
  def status
45
51
  if done?
46
52
  :done
@@ -51,12 +57,6 @@ class TrackedCard
51
57
  end
52
58
  end
53
59
 
54
- def self.build_from(trello_card)
55
- trello_card_id = trello_card.id
56
- trello_card.attributes.delete(:id)
57
- new(trello_card.attributes.merge(trello_id: trello_card_id))
58
- end
59
-
60
60
  def add(tracking)
61
61
  tracking.add_to(self)
62
62
  end
@@ -116,6 +116,11 @@ class TrackedCard
116
116
  estimate_errors
117
117
  end
118
118
 
119
+ def trello_notifications
120
+ notification_ids = efforts.map(&:tracking_notification_id) | estimates.map(&:tracking_notification_id)
121
+ notification_ids.map { |each_id| Trello::Notification.find(each_id) }.sort_by(&:date)
122
+ end
123
+
119
124
  def to_s
120
125
  "[#{name}]. Total effort: #{total_effort}h. Estimates #{estimates.map(&:to_s)}. Efforts: #{efforts.map(&:to_s)}"
121
126
  end
@@ -1,3 +1,3 @@
1
1
  class TrelloEffortTracker
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
@@ -0,0 +1,13 @@
1
+ FactoryGirl.define do
2
+ factory :tracked_card do
3
+ sequence(:name) { |n| "any_card_#{n}" }
4
+ description "any description"
5
+ sequence(:short_id, 1000) { |n| n }
6
+ sequence(:trello_id, 100000) { |n| "xyz#{n}" }
7
+ done false
8
+ closed false
9
+
10
+ # embeds_many :estimates
11
+ # embeds_many :efforts
12
+ end
13
+ end
data/spec/spec_helper.rb CHANGED
@@ -18,12 +18,16 @@ Bundler.require(:spec)
18
18
 
19
19
  require 'tracco'
20
20
 
21
+ require 'factory_girl'
22
+ FactoryGirl.find_definitions
23
+
21
24
  # Requires supporting ruby files with custom matchers and macros, etc,
22
25
  # in spec/support/ and its subdirectories.
23
26
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
24
27
 
25
28
  RSpec.configure do |configuration|
26
29
  configuration.include Mongoid::Matchers
30
+ configuration.include FactoryGirl::Syntax::Methods # Repeating "FactoryGirl" is too verbose for me...
27
31
  end
28
32
 
29
33
  # force test env for the mongodb configuration
@@ -6,7 +6,7 @@ describe TrackedCard do
6
6
  Date.stub(:today).and_return(Date.parse("2012-11-05"))
7
7
  end
8
8
 
9
- subject(:card) { TrackedCard.new(name: "any", short_id: 1234, trello_id: "123123") }
9
+ subject(:card) { build(:tracked_card) }
10
10
 
11
11
  %w{piero tommaso michele}.each do |username|
12
12
  let(username.to_sym) { Member.new(username: username) }
@@ -32,8 +32,8 @@ describe TrackedCard do
32
32
 
33
33
  describe ".find_by_trello_id" do
34
34
  it "finds a card given its Trello id" do
35
- card = TrackedCard.create(name: "any card", short_id: 1234, trello_id: "1")
36
- another_card = TrackedCard.create(name: "another card", short_id: 3456, trello_id: "2")
35
+ card = create(:tracked_card, trello_id: "1")
36
+ another_card = create(:tracked_card, trello_id: "2")
37
37
 
38
38
  TrackedCard.find_by_trello_id("1").should == card
39
39
  TrackedCard.find_by_trello_id("3").should == nil
@@ -42,57 +42,53 @@ describe TrackedCard do
42
42
 
43
43
  describe ".all_tracked_cards" do
44
44
  it "finds all tracked cards with a valid tracking" do
45
- card = TrackedCard.create(name: "any card", short_id: 1234, trello_id: "1")
46
- card.estimates << Estimate.new(amount: 5, date: Date.today)
47
- card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
48
-
49
- card_without_tracking = TrackedCard.create(name: "another card", short_id: 3456, trello_id: "2")
45
+ # TODO introduce a factory on estimate and effort
46
+ card = create(:tracked_card, :estimates => [Estimate.new(amount: 5, date: Date.today)],
47
+ :efforts => [Effort.new(amount: 3, date: Date.today, members: [piero])])
48
+ card_without_tracking = create(:tracked_card)
50
49
 
51
50
 
52
51
  TrackedCard.all_tracked_cards.should == [card]
53
52
  end
54
53
 
55
54
  it "optionally sorts the cards using a given sorting method" do
56
- # TODO introduce a factory (fabricator?)
57
- card = TrackedCard.create(name: "AAA", short_id: 1234, trello_id: "1")
55
+ card = create(:tracked_card, name: "AAA")
58
56
  card.estimates << Estimate.new(amount: 5, date: Date.today)
59
57
  card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
60
58
 
61
- another_card = TrackedCard.create(name: "ZZZ", short_id: 1235, trello_id: "2")
59
+ another_card = create(:tracked_card, name: "ZZZ")
62
60
  another_card.estimates << Estimate.new(amount: 5, date: Date.today)
63
61
  another_card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
64
62
 
65
- card_without_tracking = TrackedCard.create(name: "another card", short_id: 3456, trello_id: "2")
63
+ card_without_tracking = create(:tracked_card)
66
64
 
67
65
  TrackedCard.all_tracked_cards(:method => :name).should == [card, another_card]
68
66
  end
69
67
 
70
68
  it "applies an optional sorting order" do
71
- # TODO introduce a factory (fabricator?)
72
- card = TrackedCard.create(name: "AAA", short_id: 1234, trello_id: "1")
69
+ card = create(:tracked_card, name: "AAA")
73
70
  card.estimates << Estimate.new(amount: 5, date: Date.today)
74
71
  card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
75
72
 
76
- another_card = TrackedCard.create(name: "ZZZ", short_id: 1235, trello_id: "2")
73
+ another_card = create(:tracked_card, name: "ZZZ")
77
74
  another_card.estimates << Estimate.new(amount: 5, date: Date.today)
78
75
  another_card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
79
76
 
80
- card_without_tracking = TrackedCard.create(name: "another card", short_id: 3456, trello_id: "2")
77
+ card_without_tracking = create(:tracked_card)
81
78
 
82
79
  TrackedCard.all_tracked_cards(:method => :name, :order => :desc).should == [another_card, card]
83
80
  end
84
81
 
85
82
  it "uses the ascending order as default sorting order option" do
86
- # TODO introduce a factory (fabricator?)
87
- card = TrackedCard.create(name: "AAA", short_id: 44, trello_id: "100")
83
+ card = create(:tracked_card, name: "AAA", short_id: 44)
88
84
  card.estimates << Estimate.new(amount: 5, date: Date.today)
89
85
  card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
90
86
 
91
- another_card = TrackedCard.create(name: "ZZZ", short_id: 12, trello_id: "200")
87
+ another_card = create(:tracked_card, name: "ZZZ", short_id: 12)
92
88
  another_card.estimates << Estimate.new(amount: 5, date: Date.today)
93
89
  another_card.efforts << Effort.new(amount: 3, date: Date.today, members: [piero])
94
90
 
95
- card_without_tracking = TrackedCard.create(name: "another card", short_id: 3456, trello_id: "2")
91
+ card_without_tracking = create(:tracked_card, short_id: 3456)
96
92
 
97
93
  TrackedCard.all_tracked_cards(:method => :short_id).should == [another_card, card]
98
94
  end
@@ -116,7 +112,7 @@ describe TrackedCard do
116
112
  end
117
113
 
118
114
  it "updates an existing tracked card on a given trello card" do
119
- existing_card = TrackedCard.create(name: "an old name", short_id: 1234, trello_id: trello_card.id)
115
+ existing_card = create(:tracked_card, name: "an old name", trello_id: trello_card.id)
120
116
 
121
117
  updated_card = TrackedCard.update_or_create_with(trello_card)
122
118
 
@@ -185,6 +181,20 @@ describe TrackedCard do
185
181
  card.efforts.should have(2).efforts
186
182
  end
187
183
 
184
+ describe "#trello_notifications" do
185
+ let(:first_notification) { stub("notification1", date: Date.yesterday) }
186
+ let(:second_notification) { stub("notification1", date: Date.today) }
187
+
188
+ it "fetch all the card notifications from trello" do
189
+ card.estimates << Estimate.new(tracking_notification_id: "xyz987", amount: 5, date: Date.yesterday)
190
+ card.efforts << Effort.new(tracking_notification_id: "abc123", amount: 3, date: Date.today, members: [piero])
191
+
192
+ Trello::Notification.should_receive(:find).with("xyz987").and_return(second_notification)
193
+ Trello::Notification.should_receive(:find).with("abc123").and_return(first_notification)
194
+ card.trello_notifications.should == [first_notification, second_notification]
195
+ end
196
+ end
197
+
188
198
  describe "equality" do
189
199
  it "is equal to another TrelloCard when the trello id is the same" do
190
200
  card = TrackedCard.new(name: "a name", trello_id: "123456789")
data/tracco.gemspec CHANGED
@@ -37,5 +37,6 @@ Gem::Specification.new do |gem|
37
37
  gem.add_development_dependency 'rspec-mocks'
38
38
  gem.add_development_dependency 'mongoid-rspec'
39
39
  gem.add_development_dependency 'database_cleaner'
40
+ gem.add_development_dependency 'factory_girl'
40
41
  gem.add_development_dependency 'debugger'
41
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-19 00:00:00.000000000 Z
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-trello
@@ -203,6 +203,22 @@ dependencies:
203
203
  - - ! '>='
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: factory_girl
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
206
222
  - !ruby/object:Gem::Dependency
207
223
  name: debugger
208
224
  requirement: !ruby/object:Gem::Requirement
@@ -268,6 +284,7 @@ files:
268
284
  - script/mate.sh
269
285
  - spec/effort_spec.rb
270
286
  - spec/estimate_spec.rb
287
+ - spec/factories/tracked_card_factory.rb
271
288
  - spec/integration/trello_authorization_spec.rb
272
289
  - spec/integration/trello_tracker_spec.rb
273
290
  - spec/member_spec.rb
@@ -298,7 +315,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
315
  version: '0'
299
316
  segments:
300
317
  - 0
301
- hash: 961343114344696159
318
+ hash: 2200448488814002736
302
319
  required_rubygems_version: !ruby/object:Gem::Requirement
303
320
  none: false
304
321
  requirements: