highrise 2.0.1 → 3.0.0

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 (63) hide show
  1. data/Gemfile +3 -0
  2. data/Gemfile.lock +38 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.mkdn +21 -29
  5. data/Rakefile +6 -31
  6. data/autotest/discover.rb +1 -3
  7. data/examples/config_initializers_highrise.rb +1 -9
  8. data/examples/sample.rb +0 -1
  9. data/highrise.gemspec +24 -117
  10. data/lib/highrise.rb +6 -5
  11. data/lib/highrise/account.rb +0 -1
  12. data/lib/highrise/base.rb +15 -3
  13. data/lib/highrise/comment.rb +1 -2
  14. data/lib/highrise/company.rb +3 -2
  15. data/lib/highrise/deal.rb +4 -1
  16. data/lib/highrise/deal_category.rb +3 -0
  17. data/lib/highrise/group.rb +1 -2
  18. data/lib/highrise/kase.rb +13 -2
  19. data/lib/highrise/membership.rb +1 -2
  20. data/lib/highrise/pagination.rb +8 -1
  21. data/lib/highrise/party.rb +11 -0
  22. data/lib/highrise/person.rb +1 -4
  23. data/lib/highrise/recording.rb +5 -0
  24. data/lib/highrise/searchable.rb +22 -0
  25. data/lib/highrise/subject.rb +6 -0
  26. data/lib/highrise/tag.rb +0 -5
  27. data/lib/highrise/taggable.rb +4 -1
  28. data/lib/highrise/task_category.rb +3 -0
  29. data/lib/highrise/version.rb +3 -0
  30. data/spec/highrise/account_spec.rb +5 -11
  31. data/spec/highrise/base_spec.rb +45 -10
  32. data/spec/highrise/comment_spec.rb +2 -11
  33. data/spec/highrise/company_spec.rb +10 -72
  34. data/spec/highrise/deal_category_spec.rb +13 -0
  35. data/spec/highrise/deal_spec.rb +16 -13
  36. data/spec/highrise/email_spec.rb +7 -19
  37. data/spec/highrise/group_spec.rb +2 -11
  38. data/spec/highrise/kase_spec.rb +10 -18
  39. data/spec/highrise/membership_spec.rb +2 -11
  40. data/spec/highrise/note_spec.rb +8 -17
  41. data/spec/highrise/pagination_behavior.rb +20 -0
  42. data/spec/highrise/pagination_spec.rb +4 -6
  43. data/spec/highrise/party_spec.rb +16 -0
  44. data/spec/highrise/person_spec.rb +23 -80
  45. data/spec/highrise/recording_spec.rb +13 -0
  46. data/spec/highrise/searchable_behavior.rb +13 -0
  47. data/spec/highrise/searchable_spec.rb +8 -0
  48. data/spec/highrise/subject_spec.rb +20 -35
  49. data/spec/highrise/tag_spec.rb +8 -13
  50. data/spec/highrise/taggable_behavior.rb +27 -0
  51. data/spec/highrise/taggable_spec.rb +9 -0
  52. data/spec/highrise/task_category_spec.rb +13 -0
  53. data/spec/highrise/task_spec.rb +6 -18
  54. data/spec/highrise/user_spec.rb +11 -28
  55. data/spec/spec_helper.rb +9 -18
  56. metadata +55 -42
  57. data/CHANGELOG +0 -131
  58. data/VERSION.yml +0 -5
  59. data/install.rb +0 -1
  60. data/lib/cachable.rb +0 -83
  61. data/spec/cachable_spec.rb +0 -84
  62. data/spec/spec.opts +0 -7
  63. data/uninstall.rb +0 -1
@@ -1,14 +1,5 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
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
-
4
+ it { should be_a_kind_of Highrise::Base }
14
5
  end
@@ -1,25 +1,17 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Highrise::Kase do
4
-
5
- before(:each) do
6
- @kase = Highrise::Kase.new
7
- end
4
+ it { should be_a_kind_of Highrise::Subject }
8
5
 
9
- it "should be instance of Highrise::Subject" do
10
- @kase.kind_of?(Highrise::Subject).should be_true
6
+ it "#close!" do
7
+ mocked_now = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
8
+ Time.should_receive(:now).and_return(mocked_now)
9
+ subject.should_receive(:update_attribute).with(:closed_at, mocked_now.utc)
10
+ subject.close!
11
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
12
 
13
+ it "#open!" do
14
+ subject.should_receive(:update_attribute).with(:closed_at, nil)
15
+ subject.open!
23
16
  end
24
-
25
17
  end
@@ -1,14 +1,5 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
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
-
4
+ it { should be_a_kind_of Highrise::Base }
14
5
  end
@@ -1,23 +1,14 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
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
4
+ subject { Highrise::Note.new(:id => 1) }
13
5
 
14
- describe "comments" do
6
+ it { should be_a_kind_of Highrise::Base }
15
7
 
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
8
+ it_should_behave_like "a paginated class"
22
9
 
10
+ it "#comments" do
11
+ Highrise::Comment.should_receive(:find).with(:all, {:from=>"/notes/1/comments.xml"}).and_return("comments")
12
+ subject.comments.should == "comments"
13
+ end
23
14
  end
@@ -0,0 +1,20 @@
1
+ shared_examples_for "a paginated class" do
2
+ it { subject.class.included_modules.should include(Highrise::Pagination) }
3
+
4
+ it ".find_all_across_pages" do
5
+ subject.class.should_receive(:find).with(:all,{:params=>{:n=>0}}).and_return(["things"])
6
+ subject.class.should_receive(:find).with(:all,{:params=>{:n=>1}}).and_return([])
7
+ subject.class.find_all_across_pages.should == ["things"]
8
+ end
9
+
10
+ it ".find_all_across_pages with zero results" do
11
+ subject.class.should_receive(:find).with(:all,{:params=>{:n=>0}}).and_return(nil)
12
+ subject.class.find_all_across_pages.should == []
13
+ end
14
+
15
+ it ".find_all_across_pages_since" do
16
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
17
+ subject.class.should_receive(:find_all_across_pages).with({:params=>{:since=>"20090114174311"}}).and_return("result")
18
+ subject.class.find_all_across_pages_since(time).should == "result"
19
+ end
20
+ end
@@ -1,10 +1,8 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Highrise::Pagination do
4
+ class TestClass < Highrise::Base; include Highrise::Pagination; end
5
+ subject { TestClass.new }
4
6
 
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
7
+ it_should_behave_like "a paginated class"
10
8
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Highrise::Party do
4
+ it { should be_a_kind_of Highrise::Base }
5
+
6
+ it ".recently_viewed" do
7
+ Highrise::Party.should_receive(:find).with(:all, {:from => '/parties/recently_viewed.xml'})
8
+ Highrise::Party.recently_viewed
9
+ end
10
+
11
+ it ".deletions_since" do
12
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
13
+ Highrise::Party.should_receive(:find).with(:all, {:from => '/parties/deletions.xml', :params=>{:since=>"20090114174311"}}).and_return("result")
14
+ Highrise::Party.deletions_since(time).should == "result"
15
+ end
16
+ end
@@ -1,96 +1,39 @@
1
1
  # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
4
3
 
5
4
  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
5
+ subject { Highrise::Person.new(:id => 1) }
15
6
 
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
7
+ it { should be_a_kind_of Highrise::Subject }
27
8
 
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
9
+ it_should_behave_like "a paginated class"
10
+ it_should_behave_like "a taggable class"
11
+ it_should_behave_like "a searchable class"
42
12
 
13
+ it ".find_all_across_pages_since" do
14
+ mocked_now = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
15
+ Highrise::Person.should_receive(:find_all_across_pages).with({:params=>{:since=>"20090114174311"}}).and_return("result")
16
+ Highrise::Person.find_all_across_pages_since(mocked_now).should == "result"
43
17
  end
44
18
 
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"
19
+ describe "#company" do
20
+ it "returns nil when it doesn't have a company" do
21
+ subject.should_receive(:company_id).and_return(nil)
22
+ subject.company.should be_nil
51
23
  end
52
24
 
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'
25
+ it "delegate to Highrise::Company when have company_id" do
26
+ subject.should_receive(:company_id).at_least(2).times.and_return(1)
27
+ Highrise::Company.should_receive(:find).with(1).and_return("company")
28
+ subject.company.should == "company"
86
29
  end
87
30
  end
88
31
 
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
32
+ it "#name" do
33
+ subject.should_receive(:first_name).and_return("Marcos")
34
+ subject.should_receive(:last_name).and_return("Tapajós ")
35
+ subject.name.should == "Marcos Tapajós"
94
36
  end
95
37
 
38
+ it { subject.label.should == 'Party' }
96
39
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Highrise::Recording do
4
+ it { should be_a_kind_of Highrise::Base }
5
+
6
+ it_should_behave_like "a paginated class"
7
+
8
+ it ".find_all_across_pages_since" do
9
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
10
+ Highrise::Recording.should_receive(:find_all_across_pages).with({:params=>{:since=>"20090114174311"}}).and_return("result")
11
+ Highrise::Recording.find_all_across_pages_since(time).should == "result"
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ shared_examples_for "a searchable class" do
2
+ it { subject.class.included_modules.should include(Highrise::Searchable) }
3
+
4
+ it ".search" do
5
+ find_args = {:from => "/#{subject.class.collection_name}/search.xml", :params => {"criteria[email]" => "john.doe@example.com", "criteria[zip]" => "90210"}}
6
+ if subject.class.respond_to?(:find_all_across_pages)
7
+ subject.class.should_receive(:find_all_across_pages).with(find_args)
8
+ else
9
+ subject.class.should_receive(:find).with(:all, find_args)
10
+ end
11
+ subject.class.search(:email => "john.doe@example.com", :zip => "90210")
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Highrise::Searchable do
4
+ class TestClass < Highrise::Base; include Highrise::Searchable; end
5
+ subject { TestClass.new }
6
+
7
+ it_should_behave_like "a searchable class"
8
+ end
@@ -1,49 +1,34 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Highrise::Subject do
4
+ subject { Highrise::Subject.new(:id => 1) }
4
5
 
5
- before(:each) do
6
- @subject = Highrise::Subject.new(:id => 1)
7
- end
6
+ it { should be_a_kind_of Highrise::Base }
8
7
 
9
- it "should be instance of Highrise::Base" do
10
- @subject.kind_of?(Highrise::Base).should be_true
8
+ it "#notes" do
9
+ Highrise::Note.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/notes.xml"}).and_return("notes")
10
+ subject.notes.should == "notes"
11
11
  end
12
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
13
+ it "#add_note" do
14
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Subject'}).and_return(mock('note'))
15
+ subject.add_note :body=>'body'
17
16
  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
17
+
18
+ it "#add_task" do
19
+ Highrise::Task.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Subject'}).and_return(mock('task'))
20
+ subject.add_task :body=>'body'
24
21
  end
25
22
 
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
23
+ it "#emails" do
24
+ Highrise::Email.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/emails.xml"}).and_return("emails")
25
+ subject.emails.should == "emails"
31
26
  end
32
27
 
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
-
28
+ it "#upcoming_tasks" do
29
+ Highrise::Task.should_receive(:find).with(:all, {:from=>"/subjects/1/tasks.xml"}).and_return("tasks")
30
+ subject.upcoming_tasks.should == "tasks"
41
31
  end
42
32
 
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
-
33
+ it { subject.label.should == "Subject" }
49
34
  end
@@ -1,23 +1,18 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Highrise::Tag do
4
- before(:each) do
5
- Highrise::Base.site = 'http://example.com.i/'
6
- @tag = Highrise::Tag.new(:id => 1, :name => "Name")
7
- end
4
+ subject { Highrise::Tag.new(:id => 1, :name => "Name") }
8
5
 
9
- it "should be instance of Highrise::Base" do
10
- @tag.kind_of?(Highrise::Base).should be_true
11
- end
6
+ it { should be_a_kind_of Highrise::Base }
12
7
 
13
- it "should support equality" do
8
+ it "supports equality" do
14
9
  tag = Highrise::Tag.new(:id => 1, :name => "Name")
15
- @tag.should == tag
10
+ subject.should == tag
16
11
  end
17
12
 
18
- it "it should find_by_name" do
13
+ it ".find_by_name" do
19
14
  tag = Highrise::Tag.new(:id => 2, :name => "Next")
20
- Highrise::Tag.should_receive(:find).with(:all).and_return([tag, @tag])
21
- Highrise::Tag.find_by_name("Name").should == @tag
15
+ Highrise::Tag.should_receive(:find).with(:all).and_return([tag, subject])
16
+ Highrise::Tag.find_by_name("Name").should == subject
22
17
  end
23
18
  end
@@ -0,0 +1,27 @@
1
+ shared_examples_for "a taggable class" do
2
+ before(:each) do
3
+ (@tags = []).tap do
4
+ @tags << {'id' => "414578", 'name' => "cliente"}
5
+ @tags << {'id' => "414580", 'name' => "ged"}
6
+ @tags << {'id' => "414579", 'name' => "iepc"}
7
+ end
8
+ end
9
+
10
+ it { subject.class.included_modules.should include(Highrise::Taggable) }
11
+
12
+ it "#tags" do
13
+ subject.should_receive(:get).with(:tags).and_return(@tags)
14
+ subject.tags.should == @tags
15
+ end
16
+
17
+ it "#tag!(tag_name)" do
18
+ subject.should_receive(:post).with(:tags, :name => "client" ).and_return(true)
19
+ subject.tag!("client").should be_true
20
+ end
21
+
22
+ it "#untag!(tag_name)" do
23
+ subject.should_receive(:get).with(:tags).and_return(@tags)
24
+ subject.should_receive(:delete).with("tags/414578").and_return(true)
25
+ subject.untag!("cliente").should be_true
26
+ end
27
+ end