freshtrack 0.4.1 → 0.4.1.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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.4.1.1 2009-07-31
2
+
3
+ * Maybe adding the invoice files to the Manifest is a good idea.
4
+
1
5
  == 0.4.1 2009-07-31
2
6
 
3
7
  * 1 tiny enhancement:
data/Manifest.txt CHANGED
@@ -17,6 +17,7 @@ lib/freshtrack/time_collectors/punch.rb
17
17
  lib/freshtrack/time_collectors/punchy_template.rb
18
18
  lib/freshbooks/extensions.rb
19
19
  lib/freshbooks/extensions/base_object.rb
20
+ lib/freshbooks/extensions/invoice.rb
20
21
  lib/freshbooks/extensions/project.rb
21
22
  lib/freshbooks/extensions/task.rb
22
23
  lib/freshbooks/extensions/time_entry.rb
@@ -30,6 +31,7 @@ spec/core_ext/time_spec.rb
30
31
  spec/time_collectors/one_inch_punch_spec.rb
31
32
  spec/time_collectors/punch_spec.rb
32
33
  spec/freshbooks/base_object_spec.rb
34
+ spec/freshbooks/invoice_spec.rb
33
35
  spec/freshbooks/project_spec.rb
34
36
  spec/freshbooks/task_spec.rb
35
37
  spec/freshbooks/time_entry_spec.rb
@@ -0,0 +1,40 @@
1
+ module FreshBooks
2
+ class Invoice
3
+ TYPE_MAPPINGS['date'] = Date
4
+
5
+ def open?
6
+ !%w[draft paid].include?(status)
7
+ end
8
+
9
+ def client
10
+ Client.get(client_id)
11
+ end
12
+
13
+ attr_accessor :number
14
+
15
+ alias_method :old_brackets, :[]
16
+ def [](m)
17
+ if m.to_s == 'number'
18
+ self.number
19
+ else
20
+ old_brackets(m)
21
+ end
22
+ end
23
+
24
+ alias_method :old_brackets_equal, :[]=
25
+ def []=(m, v)
26
+ if m.to_s == 'number'
27
+ self.number = v
28
+ else
29
+ old_brackets_equal(m, v)
30
+ end
31
+ end
32
+
33
+ class << self
34
+ alias_method :old_members, :members
35
+ def members
36
+ old_members + ['number']
37
+ end
38
+ end
39
+ end
40
+ end
@@ -3,7 +3,8 @@ module Freshtrack #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
5
  TINY = 1
6
+ FUCKUP = 1
6
7
 
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
+ STRING = [MAJOR, MINOR, TINY, FUCKUP].join('.')
8
9
  end
9
10
  end
@@ -0,0 +1,136 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
2
+
3
+ describe FreshBooks::Invoice do
4
+ before :each do
5
+ @invoice = FreshBooks::Invoice.new
6
+ end
7
+
8
+ describe 'attributes' do
9
+ it 'should have an invoice_id' do
10
+ @invoice.should respond_to(:invoice_id)
11
+ end
12
+
13
+ it 'should have a client_id' do
14
+ @invoice.should respond_to(:client_id)
15
+ end
16
+
17
+ it 'should have a date' do
18
+ @invoice.should respond_to(:date)
19
+ end
20
+
21
+ it 'should have a status' do
22
+ @invoice.should respond_to(:status)
23
+ end
24
+ end
25
+
26
+ describe 'type mappings' do
27
+ before :each do
28
+ @mapping = FreshBooks::Invoice::TYPE_MAPPINGS
29
+ end
30
+
31
+ it 'should map client_id to Fixnum' do
32
+ @mapping['client_id'].should == Fixnum
33
+ end
34
+
35
+ it 'should map date to Date' do
36
+ @mapping['date'].should == Date
37
+ end
38
+ end
39
+
40
+ it 'should indicate open status' do
41
+ @invoice.should respond_to(:open?)
42
+ end
43
+
44
+ describe 'indicating open status' do
45
+ it "should be false if the status is 'draft'" do
46
+ @invoice.status = 'draft'
47
+ @invoice.should_not be_open
48
+ end
49
+
50
+ it "should be true if the status is 'sent'" do
51
+ @invoice.status = 'sent'
52
+ @invoice.should be_open
53
+ end
54
+
55
+ it "should be true if the status is 'viewed'" do
56
+ @invoice.status = 'viewed'
57
+ @invoice.should be_open
58
+ end
59
+
60
+ it "should be false if the status is 'paid'" do
61
+ @invoice.status = 'paid'
62
+ @invoice.should_not be_open
63
+ end
64
+
65
+ it "should be true if the status is 'partial'" do
66
+ @invoice.status = 'partial'
67
+ @invoice.should be_open
68
+ end
69
+ end
70
+
71
+ it 'should have a client' do
72
+ @invoice.should respond_to(:client)
73
+ end
74
+
75
+ describe 'client' do
76
+ it 'should find client based on client_id' do
77
+ client_id = stub('client ID')
78
+ @invoice.stubs(:client_id).returns(client_id)
79
+ FreshBooks::Client.expects(:get).with(client_id)
80
+ @invoice.client
81
+ end
82
+
83
+ it 'should return found project' do
84
+ client = stub('client')
85
+ client_id = stub('client ID')
86
+ @invoice.stubs(:client_id).returns(client_id)
87
+ FreshBooks::Client.expects(:get).with(client_id).returns(client)
88
+ @invoice.client.should == client
89
+ end
90
+ end
91
+
92
+ describe 'number' do
93
+ it 'should be settable and gettable as an accessor' do
94
+ @invoice.number = '1234'
95
+ @invoice.number.should == '1234'
96
+ end
97
+
98
+ it 'should be settable using []' do
99
+ @invoice['number'] = '1234'
100
+ @invoice.number.should == '1234'
101
+ end
102
+
103
+ it 'should be gettable using []' do
104
+ @invoice.number = '1234'
105
+ @invoice['number'].should == '1234'
106
+ end
107
+
108
+ it 'should show up in the members list' do
109
+ FreshBooks::Invoice.members.should include('number')
110
+ end
111
+ end
112
+
113
+ it 'should still have important core behavior' do
114
+ FreshBooks::Invoice.should respond_to(:list)
115
+ end
116
+
117
+ it 'should still be a type of BaseObject' do
118
+ FreshBooks::Invoice.should < FreshBooks::BaseObject
119
+ end
120
+
121
+ it 'should still have other fields in the members list' do
122
+ members = FreshBooks::Invoice.members
123
+ members.should include('invoice_id')
124
+ members.should include('client_id')
125
+ members.should include('status')
126
+ members.should include('date')
127
+ end
128
+
129
+ it 'should still allow other fields to be set and get using []' do
130
+ @invoice['status'] = 'paid'
131
+ @invoice.status.should == 'paid'
132
+
133
+ @invoice.client_id = 3
134
+ @invoice['client_id'].should == 3
135
+ end
136
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freshtrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yossef Mendelssohn
@@ -83,6 +83,7 @@ files:
83
83
  - lib/freshtrack/time_collectors/punchy_template.rb
84
84
  - lib/freshbooks/extensions.rb
85
85
  - lib/freshbooks/extensions/base_object.rb
86
+ - lib/freshbooks/extensions/invoice.rb
86
87
  - lib/freshbooks/extensions/project.rb
87
88
  - lib/freshbooks/extensions/task.rb
88
89
  - lib/freshbooks/extensions/time_entry.rb
@@ -96,6 +97,7 @@ files:
96
97
  - spec/time_collectors/one_inch_punch_spec.rb
97
98
  - spec/time_collectors/punch_spec.rb
98
99
  - spec/freshbooks/base_object_spec.rb
100
+ - spec/freshbooks/invoice_spec.rb
99
101
  - spec/freshbooks/project_spec.rb
100
102
  - spec/freshbooks/task_spec.rb
101
103
  - spec/freshbooks/time_entry_spec.rb