rogerio-augusto-highrise 2.0.2

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.
Files changed (54) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG +136 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.mkdn +84 -0
  5. data/Rakefile +40 -0
  6. data/VERSION.yml +5 -0
  7. data/autotest/discover.rb +3 -0
  8. data/examples/config_initializers_highrise.rb +12 -0
  9. data/examples/extending.rb +31 -0
  10. data/examples/sample.rb +10 -0
  11. data/highrise.gemspec +129 -0
  12. data/install.rb +1 -0
  13. data/lib/cachable.rb +83 -0
  14. data/lib/highrise/account.rb +8 -0
  15. data/lib/highrise/base.rb +7 -0
  16. data/lib/highrise/comment.rb +4 -0
  17. data/lib/highrise/company.rb +18 -0
  18. data/lib/highrise/deal.rb +5 -0
  19. data/lib/highrise/deal_category.rb +4 -0
  20. data/lib/highrise/email.rb +9 -0
  21. data/lib/highrise/group.rb +4 -0
  22. data/lib/highrise/kase.rb +8 -0
  23. data/lib/highrise/membership.rb +4 -0
  24. data/lib/highrise/note.rb +9 -0
  25. data/lib/highrise/pagination.rb +29 -0
  26. data/lib/highrise/person.rb +30 -0
  27. data/lib/highrise/subject.rb +25 -0
  28. data/lib/highrise/tag.rb +12 -0
  29. data/lib/highrise/taggable.rb +17 -0
  30. data/lib/highrise/task.rb +11 -0
  31. data/lib/highrise/user.rb +17 -0
  32. data/lib/highrise.rb +22 -0
  33. data/spec/cachable_spec.rb +84 -0
  34. data/spec/highrise/account_spec.rb +16 -0
  35. data/spec/highrise/base_spec.rb +13 -0
  36. data/spec/highrise/comment_spec.rb +14 -0
  37. data/spec/highrise/company_spec.rb +79 -0
  38. data/spec/highrise/deal_category_spec.rb +12 -0
  39. data/spec/highrise/deal_spec.rb +20 -0
  40. data/spec/highrise/email_spec.rb +25 -0
  41. data/spec/highrise/group_spec.rb +14 -0
  42. data/spec/highrise/kase_spec.rb +25 -0
  43. data/spec/highrise/membership_spec.rb +14 -0
  44. data/spec/highrise/note_spec.rb +23 -0
  45. data/spec/highrise/pagination_spec.rb +10 -0
  46. data/spec/highrise/person_spec.rb +96 -0
  47. data/spec/highrise/subject_spec.rb +49 -0
  48. data/spec/highrise/tag_spec.rb +23 -0
  49. data/spec/highrise/task_spec.rb +23 -0
  50. data/spec/highrise/user_spec.rb +35 -0
  51. data/spec/spec.opts +7 -0
  52. data/spec/spec_helper.rb +20 -0
  53. data/uninstall.rb +1 -0
  54. metadata +179 -0
@@ -0,0 +1,29 @@
1
+ module Highrise
2
+ module Pagination
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def find_all_across_pages(options = {})
9
+ records = []
10
+ each(options) { |record| records << record }
11
+ records
12
+ end
13
+
14
+ def each(options = {})
15
+ options[:params] ||= {}
16
+ options[:params][:n] = 0
17
+
18
+ loop do
19
+ if (records = self.find(:all, options)).any?
20
+ records.each { |record| yield record }
21
+ options[:params][:n] += records.size
22
+ else
23
+ break # no people included on that page, thus no more people total
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ module Highrise
2
+ class Person < Subject
3
+ include Pagination
4
+ include Taggable
5
+
6
+ def self.find_all_across_pages_since(time)
7
+ find_all_across_pages(:params => { :since => time.utc.to_s(:db).gsub(/[^\d]/, '') })
8
+ end
9
+
10
+ def company
11
+ Company.find(company_id) if company_id
12
+ end
13
+
14
+ def name
15
+ "#{first_name rescue ''} #{last_name rescue ''}".strip
16
+ end
17
+
18
+ def address
19
+ contact_data.addresses.first
20
+ end
21
+
22
+ def web_address
23
+ contact_data.web_addresses.first
24
+ end
25
+
26
+ def label
27
+ 'Party'
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ module Highrise
2
+ class Subject < Base
3
+ def notes
4
+ Note.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/notes.xml")
5
+ end
6
+
7
+ def add_note(attrs={})
8
+ attrs[:subject_id] = self.id
9
+ attrs[:subject_type] = self.label
10
+ Note.create attrs
11
+ end
12
+
13
+ def emails
14
+ Email.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/emails.xml")
15
+ end
16
+
17
+ def upcoming_tasks
18
+ Task.find(:all, :from => "/#{self.class.collection_name}/#{id}/tasks.xml")
19
+ end
20
+
21
+ def label
22
+ self.class.name.split('::').last
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ module Highrise
2
+ class Tag < Base
3
+ def ==(object)
4
+ (object.instance_of?(self.class) && object.id == self.id && object.name == self.name)
5
+ end
6
+
7
+ # You can't find :one because that finds all *objects* with that tag
8
+ def self.find_by_name(arg)
9
+ tags = self.find(:all).detect{|tag| tag.name == arg}
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module Highrise
2
+ module Taggable
3
+ def tags
4
+ self.get(:tags)
5
+ end
6
+ def tag!(tag_name)
7
+ self.post(:tags, :name => tag_name) unless tag_name.blank?
8
+ end
9
+ def untag!(tag_name)
10
+ to_delete = self.tags.find{|tag| tag['name'] == tag_name} unless tag_name.blank?
11
+ self.untag_id!(to_delete['id']) unless to_delete.nil?
12
+ end
13
+ def untag_id!(tag_id)
14
+ self.delete("tags/#{tag_id}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Highrise
2
+ class Task < Base
3
+ # find(:all, :from => :upcoming)
4
+ # find(:all, :from => :assigned)
5
+ # find(:all, :from => :completed)
6
+
7
+ def complete!
8
+ load_attributes_from_response(post(:complete))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Highrise
2
+ class User < Base
3
+ def join(group)
4
+ Membership.create(:user_id => id, :group_id => group.id)
5
+ end
6
+
7
+ # Permits API-key retrieval using name and password.
8
+ # Highrise::User.site = "https://yourcompany.highrise.com"
9
+ # Highrise::User.user = "your_user_name"
10
+ # Highrise::User.password = "s3kr3t"
11
+ # Highrise::User.me.token # contains the API token for "your_user_name"
12
+ def self.me
13
+ user = User.new()
14
+ find(:one, :from => "/me.xml")
15
+ end
16
+ end
17
+ end
data/lib/highrise.rb ADDED
@@ -0,0 +1,22 @@
1
+ gem 'activeresource', " >= 2.3.8"
2
+ require 'active_resource'
3
+ $:.unshift(File.dirname(__FILE__))
4
+
5
+ require 'highrise/base'
6
+ require 'highrise/pagination'
7
+ require 'highrise/taggable'
8
+ require 'highrise/subject'
9
+ require 'highrise/comment'
10
+ require 'highrise/company'
11
+ require 'highrise/email'
12
+ require 'highrise/group'
13
+ require 'highrise/kase'
14
+ require 'highrise/membership'
15
+ require 'highrise/note'
16
+ require 'highrise/person'
17
+ require 'highrise/task'
18
+ require 'highrise/user'
19
+ require 'highrise/tag'
20
+ require 'highrise/deal'
21
+ require 'highrise/account'
22
+ require 'highrise/deal_category'
@@ -0,0 +1,84 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ class CachedResource < ActiveResource::Base
4
+ include ::Cachable
5
+ end
6
+
7
+ describe CachedResource, "class configuration" do
8
+ before(:each) do
9
+ CachedResource.site = 'http://example.com.i:3000'
10
+ end
11
+
12
+ it "should tell us if caching is active" do
13
+ CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
14
+ CachedResource.connection.is_caching?.should == true
15
+ end
16
+
17
+ it "should tell us if caching is not active" do
18
+ CachedResource.connection.cache_store = nil
19
+ CachedResource.connection.is_caching?.should == false
20
+ end
21
+ end
22
+
23
+ describe CachedResource do
24
+ before(:all) do
25
+ CachedResource.site = 'http://example.com.i:3000'
26
+ CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
27
+ end
28
+
29
+ after(:all) do
30
+ CachedResource.connection.cache_store = :none
31
+ end
32
+
33
+ before(:each) do
34
+ @thing = CachedResource.new(:id => 1)
35
+ @key = :key
36
+ CachedResource.connection.stub!(:cache_key).and_return(@key)
37
+ end
38
+
39
+ context "when a cached response is available" do
40
+ before(:each) do
41
+ CachedResource.connection.cache_store.write(@key, @thing.attributes)
42
+ end
43
+
44
+ it "should NOT make a request to the RESTful server" do
45
+ CachedResource.connection.should_not_receive(:get_without_cache)
46
+ CachedResource.find(1)
47
+ end
48
+
49
+ it "should read from the cache" do
50
+ CachedResource.find(1).should == @thing
51
+ end
52
+
53
+ it "should delete from the cache when an object is DELETEd" do
54
+ CachedResource.connection.should_receive(:delete_without_cache)
55
+ CachedResource.delete(1)
56
+ CachedResource.connection.cache_store.read(@key).should == nil
57
+ end
58
+
59
+ it "should delete from the cache when an object is modified" do
60
+ thing = CachedResource.find(1)
61
+ thing.stub(:load_attributes_from_response).and_return(@thing.attributes)
62
+ CachedResource.connection.should_receive(:put_without_cache)
63
+ thing.save
64
+ CachedResource.connection.cache_store.read(@key).should == nil
65
+ end
66
+ end
67
+
68
+ context "when a cached response is NOT available" do
69
+ before(:each) do
70
+ CachedResource.connection.cache_store.delete(@key)
71
+ end
72
+
73
+ it "SHOULD perform an ActiveResource request" do
74
+ CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
75
+ CachedResource.find(1)
76
+ end
77
+
78
+ it "should cache the response using the caching key" do
79
+ CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
80
+ CachedResource.find(1)
81
+ CachedResource.connection.cache_store.read(@key).should == @thing.attributes
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Account do
4
+ before(:each) do
5
+ @account = Highrise::Account.new
6
+ end
7
+
8
+ it "should be instance of Highrise::Base" do
9
+ @account.kind_of?(Highrise::Base).should be_true
10
+ end
11
+
12
+ it "should delegate to find(:one, :from => '/account.xml') when account is called" do
13
+ Highrise::Account.should_receive(:find).with(:one, {:from => "/account.xml"}).and_return(@account)
14
+ Highrise::Account.me.should == @account
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Base do
4
+
5
+ before(:each) do
6
+ @base = Highrise::Base.new
7
+ end
8
+
9
+ it "should be instance of ActiveResource::Base" do
10
+ @base.kind_of?(ActiveResource::Base).should be_true
11
+ end
12
+
13
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Comment do
4
+
5
+ before(:each) do
6
+ @comment = Highrise::Comment.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @comment.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+
14
+ end
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Company do
4
+
5
+ before(:each) do
6
+ Highrise::Base.site = 'http://example.com.i:3000'
7
+ @company = Highrise::Company.new(:id => 1)
8
+ returning @tags = [] do
9
+ @tags << {'id' => "414578", 'name' => "cliente"}
10
+ @tags << {'id' => "414580", 'name' => "ged"}
11
+ @tags << {'id' => "414579", 'name' => "iepc"}
12
+ end
13
+ end
14
+
15
+ it "should be instance of Highrise::Base" do
16
+ @company.kind_of?(Highrise::Base).should be_true
17
+ end
18
+
19
+ describe ".find_all_across_pages_since" do
20
+
21
+ it "should delegate to find_all_across_pages with correct params" do
22
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
23
+ Highrise::Company.should_receive(:find_all_across_pages).with({:params=>{:since=>"20090114174311"}}).and_return("result")
24
+ Highrise::Company.find_all_across_pages_since(time).should == "result"
25
+ end
26
+
27
+ end
28
+
29
+ describe "people" do
30
+
31
+ it "should delegate to Highrise::Person.find with correct params" do
32
+ Highrise::Person.should_receive(:find).with(:all, {:from=>"/companies/1/people.xml"}).and_return("people")
33
+ @company.people.should == "people"
34
+ end
35
+
36
+ end
37
+
38
+ describe ".tags" do
39
+
40
+ it "should return an array of all tags for that company." do
41
+ @company.should_receive(:get).with(:tags).and_return(@tags)
42
+ @company.tags.should == @tags
43
+ end
44
+
45
+ end
46
+
47
+ describe "tag!(tag_name)" do
48
+
49
+ it "should create a tag for this company." do
50
+ @company.should_receive(:post).with(:tags, :name => "client" ).and_return(true)
51
+ @company.tag!("client").should be_true
52
+ end
53
+
54
+ end
55
+
56
+ describe "untag!(tag_name)" do
57
+
58
+ it "should delete a tag for this company." do
59
+ @company.should_receive(:get).with(:tags).and_return(@tags)
60
+ @company.should_receive(:delete).with("tags/414578").and_return(true)
61
+ @company.untag!("cliente").should be_true
62
+ end
63
+
64
+ end
65
+
66
+ describe ".label" do
67
+ it "should return 'Party' for label" do
68
+ @company.label.should == 'Party'
69
+ end
70
+ end
71
+
72
+ describe ".add_note" do
73
+ it "should delegate to Highrise::Note.create with correct params" do
74
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Party'}).and_return(mock('note'))
75
+ @company.add_note :body=>'body'
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::DealCategory do
4
+
5
+ before(:each) do
6
+ @deal_category = Highrise::DealCategory.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @deal_category.kind_of?(Highrise::Base).should be_true
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Deal do
4
+
5
+ before(:each) do
6
+ @deal = Highrise::Deal.new(:id => 1)
7
+ end
8
+
9
+ it "should be instance of Highrise::Subject" do
10
+ @deal.kind_of?(Highrise::Subject).should be_true
11
+ end
12
+
13
+ describe ".add_note" do
14
+ it "should delegate to Highrise::Note.create with correct params" do
15
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Deal'}).and_return(mock('note'))
16
+ @deal.add_note :body=>'body'
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Email do
4
+
5
+ before(:each) do
6
+ @mail = Highrise::Email.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @mail.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+ describe "comments" do
14
+
15
+ it "should delegate to Highrise::Comment.find with correct params" do
16
+ @mail.should_receive(:email_id).and_return(1)
17
+ Highrise::Comment.should_receive(:find).with(:all, {:from=>"/emails/1/comments.xml"}).and_return("comments")
18
+ @mail.comments.should == "comments"
19
+ end
20
+
21
+ end
22
+
23
+
24
+
25
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Group do
4
+
5
+ before(:each) do
6
+ @group = Highrise::Group.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @group.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+
14
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Kase do
4
+
5
+ before(:each) do
6
+ @kase = Highrise::Kase.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Subject" do
10
+ @kase.kind_of?(Highrise::Subject).should be_true
11
+ end
12
+
13
+ describe ".close!" do
14
+
15
+ it "should set close date and save" do
16
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
17
+ Time.should_receive(:now).and_return(time)
18
+ @kase.should_receive(:closed_at=).with(time.utc)
19
+ @kase.should_receive(:save)
20
+ @kase.close!
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Membership do
4
+
5
+ before(:each) do
6
+ @member = Highrise::Membership.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @member.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+
14
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Note do
4
+
5
+ before(:each) do
6
+ Highrise::Base.site = 'http://example.com.i:3000'
7
+ @note = Highrise::Note.new(:id => 1)
8
+ end
9
+
10
+ it "should be instance of Highrise::Base" do
11
+ @note.kind_of?(Highrise::Base).should be_true
12
+ end
13
+
14
+ describe "comments" do
15
+
16
+ it "should delegate to Highrise::Comment.find with correct params" do
17
+ Highrise::Comment.should_receive(:find).with(:all, {:from=>"/notes/1/comments.xml"}).and_return("comments")
18
+ @note.comments.should == "comments"
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Pagination do
4
+
5
+ it "should be tested" do
6
+ Highrise::Person.should_receive(:find).with(:all,{:params=>{:n=>0}}).and_return(["people"])
7
+ Highrise::Person.should_receive(:find).with(:all,{:params=>{:n=>1}}).and_return([])
8
+ Highrise::Person.find_all_across_pages.should == ["people"]
9
+ end
10
+ end
@@ -0,0 +1,96 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Highrise::Person do
6
+
7
+ before(:each) do
8
+ Highrise::Base.site = 'http://example.com.i:3000'
9
+ @person = Highrise::Person.new(:id => 1)
10
+ returning @tags = [] do
11
+ @tags << {'id' => "414578", 'name' => "cliente"}
12
+ @tags << {'id' => "414587", 'name' => "walk"}
13
+ end
14
+ end
15
+
16
+ it "should be instance of Highrise::Subject" do
17
+ @person.kind_of?(Highrise::Subject).should be_true
18
+ end
19
+
20
+ describe ".find_all_across_pages_since" do
21
+
22
+ it "should delegate to find_all_across_pages with correct params" do
23
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
24
+ Highrise::Person.should_receive(:find_all_across_pages).with({:params=>{:since=>"20090114174311"}}).and_return("result")
25
+ Highrise::Person.find_all_across_pages_since(time).should == "result"
26
+ end
27
+
28
+ end
29
+
30
+ describe ".company" do
31
+
32
+ it "should return nil when doesn't have company_id" do
33
+ @person.should_receive(:company_id).and_return(nil)
34
+ @person.company.should be_nil
35
+ end
36
+
37
+ it "should delegate to Highrise::Company when have company_id" do
38
+ @person.should_receive(:company_id).at_least(2).times.and_return(1)
39
+ Highrise::Company.should_receive(:find).with(1).and_return("company")
40
+ @person.company.should == "company"
41
+ end
42
+
43
+ end
44
+
45
+ describe ".name" do
46
+
47
+ it "should concat fist_name with last_name and strip" do
48
+ @person.should_receive(:first_name).and_return("Marcos")
49
+ @person.should_receive(:last_name).and_return("Tapajós ")
50
+ @person.name.should == "Marcos Tapajós"
51
+ end
52
+
53
+ end
54
+
55
+ describe ".tags" do
56
+
57
+ it "should return an array of all tags for that user." do
58
+ @person.should_receive(:get).with(:tags).and_return(@tags)
59
+ @person.tags.should == @tags
60
+ end
61
+
62
+ end
63
+
64
+ describe "tag!(tag_name)" do
65
+
66
+ it "should create a tag for this user." do
67
+ @person.should_receive(:post).with(:tags, :name => "Forum_User" ).and_return(true)
68
+ @person.tag!("Forum_User").should be_true
69
+ end
70
+
71
+ end
72
+
73
+ describe "untag!(tag_name)" do
74
+
75
+ it "should delete a tag for this user." do
76
+ @person.should_receive(:get).with(:tags).and_return(@tags)
77
+ @person.should_receive(:delete).with("tags/414578").and_return(true)
78
+ @person.untag!("cliente").should be_true
79
+ end
80
+
81
+ end
82
+
83
+ describe ".label" do
84
+ it "should return 'Party' for label" do
85
+ @person.label.should == 'Party'
86
+ end
87
+ end
88
+
89
+ describe ".add_note" do
90
+ it "should delegate to Highrise::Note.create with correct params" do
91
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Party'}).and_return(mock('note'))
92
+ @person.add_note :body=>'body'
93
+ end
94
+ end
95
+
96
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Subject do
4
+
5
+ before(:each) do
6
+ @subject = Highrise::Subject.new(:id => 1)
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @subject.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+ describe ".notes" do
14
+ it "should delegate to Highrise::Note with correct params" do Highrise::Note.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/notes.xml"}).and_return("notes")
15
+ @subject.notes.should == "notes"
16
+ end
17
+ end
18
+
19
+ describe ".add_note" do
20
+ it "should delegate to Highrise::Note.create with correct params" do
21
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Subject'}).and_return(mock('note'))
22
+ @subject.add_note :body=>'body'
23
+ end
24
+ end
25
+
26
+ describe ".emails" do
27
+ it "should delegate to Highrise::Email with correct params" do
28
+ Highrise::Email.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/emails.xml"}).and_return("emails")
29
+ @subject.emails.should == "emails"
30
+ end
31
+ end
32
+
33
+
34
+ describe ".upcoming_tasks" do
35
+
36
+ it "should delegate to Highrise::Task with correct params" do
37
+ Highrise::Task.should_receive(:find).with(:all, {:from=>"/subjects/1/tasks.xml"}).and_return("tasks")
38
+ @subject.upcoming_tasks.should == "tasks"
39
+ end
40
+
41
+ end
42
+
43
+ describe ".label" do
44
+ it "should return the class name as a string" do
45
+ @subject.label.should == "Subject"
46
+ end
47
+ end
48
+
49
+ end