kmayer-highrise 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.mkdn +69 -0
  3. data/Rakefile +68 -0
  4. data/lib/highrise/base.rb +4 -0
  5. data/lib/highrise/comment.rb +4 -0
  6. data/lib/highrise/company.rb +14 -0
  7. data/lib/highrise/curlhelper.rb +27 -0
  8. data/lib/highrise/curly.rb +96 -0
  9. data/lib/highrise/email.rb +9 -0
  10. data/lib/highrise/group.rb +4 -0
  11. data/lib/highrise/kase.rb +8 -0
  12. data/lib/highrise/membership.rb +4 -0
  13. data/lib/highrise/note.rb +9 -0
  14. data/lib/highrise/pagination.rb +29 -0
  15. data/lib/highrise/person.rb +20 -0
  16. data/lib/highrise/subject.rb +15 -0
  17. data/lib/highrise/tag.rb +7 -0
  18. data/lib/highrise/taggable.rb +29 -0
  19. data/lib/highrise/task.rb +11 -0
  20. data/lib/highrise/user.rb +7 -0
  21. data/lib/highrise/version.rb +9 -0
  22. data/lib/highrise.rb +26 -0
  23. data/spec/highrise/base_spec.rb +13 -0
  24. data/spec/highrise/comment_spec.rb +14 -0
  25. data/spec/highrise/companies/16883216.html +1723 -0
  26. data/spec/highrise/company_spec.rb +70 -0
  27. data/spec/highrise/curlhelper_spec.rb +35 -0
  28. data/spec/highrise/curly_spec.rb +36 -0
  29. data/spec/highrise/email_spec.rb +25 -0
  30. data/spec/highrise/group_spec.rb +14 -0
  31. data/spec/highrise/kase_spec.rb +25 -0
  32. data/spec/highrise/membership_spec.rb +14 -0
  33. data/spec/highrise/note_spec.rb +23 -0
  34. data/spec/highrise/pagination_spec.rb +7 -0
  35. data/spec/highrise/people/16887003.html +1733 -0
  36. data/spec/highrise/person_spec.rb +83 -0
  37. data/spec/highrise/subject_spec.rb +43 -0
  38. data/spec/highrise/tag_spec.rb +21 -0
  39. data/spec/highrise/task_spec.rb +23 -0
  40. data/spec/highrise/user_spec.rb +30 -0
  41. data/spec.opts +7 -0
  42. data/spec_helper.rb +20 -0
  43. metadata +99 -0
@@ -0,0 +1,70 @@
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
8
+ returning @tags = [] do
9
+ @tags << Highrise::Tag.new(:id => "414578", :name => "cliente")
10
+ @tags << Highrise::Tag.new(:id => "414580", :name => "ged")
11
+ @tags << Highrise::Tag.new(: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
+ @company.should_receive(:id).and_return(1)
33
+ Highrise::Person.should_receive(:find).with(:all, {:from=>"/companies/1/people.xml"}).and_return("people")
34
+ @company.people.should == "people"
35
+ end
36
+
37
+ end
38
+
39
+ describe ".tags" do
40
+
41
+ it "should return an array of all tags for that company." do
42
+ file_path = File.dirname(__FILE__) + "/companies/16883216.html"
43
+ @company.stub!(:get_document).and_return(Hpricot(File.open(file_path,"r"){|f| f.read}))
44
+ @company.tags.should == @tags
45
+ end
46
+
47
+ end
48
+
49
+ describe "tag!(tag_name)" do
50
+
51
+ it "should create a tag for this company." do
52
+ @company.should_receive(:post).with(:tags, :name => "client" ).at_least(1).times.and_return(true)
53
+ @company.tag!("client").should be_true
54
+ end
55
+
56
+ end
57
+
58
+ describe "untag!(tag_name)" do
59
+
60
+ it "should delete a tag for this company." do
61
+ file_path = File.dirname(__FILE__) + "/companies/16883216.html"
62
+ @company.stub!(:get_document).and_return(Hpricot(File.open(file_path,"r"){|f| f.read}))
63
+ @company.should_receive(:delete).with("tags/414578").at_least(1).times.and_return(true)
64
+ @company.untag!("cliente").should be_true
65
+ end
66
+
67
+ end
68
+
69
+
70
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::CurlHelper do
4
+ before do
5
+ @curl_helper = Highrise::CurlHelper.new
6
+ end
7
+
8
+ it "should return token and username from Highrise url" do
9
+ highrise_url = "http://00000000000000000aaaaaaabbbbbbbbbbbvvccc:username@planobe.highrisehq.com/"
10
+ @curl_helper.get_userpwd_from_url(highrise_url).should == "00000000000000000aaaaaaabbbbbbbbbbbvvccc:username"
11
+ end
12
+
13
+ it "should return a company html document from Highrise" do
14
+ url = "companies/16883216"
15
+ file_path = File.dirname(__FILE__) + "/#{url}.html"
16
+ @curl_helper.stub!(:get_document).and_return(Hpricot(File.open(file_path,"r"){|f| f.read}))
17
+
18
+ doc = @curl_helper.get_document_from_id(url)
19
+ doc.class.should == Hpricot::Doc
20
+ company_rss_link = doc.search("#stream a").first
21
+ company_rss_link['href'].should == "http://planobe.highrisehq.com/#{url}.atom"
22
+ end
23
+
24
+ it "should return a person html document from Highrise" do
25
+ url = "people/16887003"
26
+ file_path = File.dirname(__FILE__) + "/#{url}.html"
27
+ @curl_helper.stub!(:get_document).and_return(Hpricot(File.open(file_path,"r"){|f| f.read}))
28
+
29
+ doc = @curl_helper.get_document_from_id(url)
30
+ doc.class.should == Hpricot::Doc
31
+ company_rss_link = doc.search("#stream a").first
32
+ company_rss_link['href'].should == "http://planobe.highrisehq.com/#{url}.atom"
33
+ end
34
+
35
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Curly do
4
+ before do
5
+ @curly = Curly.new
6
+ end
7
+
8
+ it "should enable cookies when cookiejar is set" do
9
+ @curly.enable_cookies?.should == false
10
+ @curly.cookiejar = 'foo'
11
+ @curly.enable_cookies?.should == true
12
+ end
13
+
14
+ it "should post params hash" do
15
+ field_arg = an_instance_of(Curl::PostField)
16
+ @curly.should_receive(:http_post).with(field_arg, field_arg)
17
+ @curly.post(:foo => 'bar', :baz => 'foo')
18
+ end
19
+
20
+ it "should get document" do
21
+ @curly.should_receive(:http_get).with().and_return(true)
22
+ @curly.stub!(:response_code).and_return(200)
23
+ @curly.stub!(:body_str).and_return(<<-HTML)
24
+ <html>
25
+ <body>You are being
26
+ <a href=\"http://localhost:3000/login\">redirected</a>.
27
+ </body>
28
+ </html>
29
+ HTML
30
+
31
+ doc = @curly.get('http://example.com').doc
32
+ @curly.url.should == 'http://example.com'
33
+ doc.class.should == Hpricot::Doc
34
+ doc.at('a[@href]').inner_text.should == 'redirected'
35
+ end
36
+ 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 anda 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
+ @note = Highrise::Note.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @note.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
+ @note.should_receive(:id).and_return(1)
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,7 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::Pagination do
4
+
5
+ it "should be tested"
6
+
7
+ end