highrise 3.2.1 → 3.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71cd31f6f19cdaccbfee0fe9d620698930bdb284
4
- data.tar.gz: 17e30e6d078c224e3c4b0d664e3a24fd2dfc1932
3
+ metadata.gz: bb615e43912e24c36c1e3ff4a5b70a5b787aca23
4
+ data.tar.gz: 46d52dfc726248c0811895def78caa5d26b2142b
5
5
  SHA512:
6
- metadata.gz: 8bbd1dfa7c07273b73c00d078f98f405c209f3fa77b6eefa0dbd44afb57ab63bdf2d919b359356f0e13f8327dd6cc5224b51de2277f7fafec1e3f94ccaa14b09
7
- data.tar.gz: 53891509f8ede23d45abe6e9f78de34c2784162c8fffd414a3d068ec5677234e722efbe0f5f5ee55d5344dd169c5b957c579baad21963f04b52b36b026e2c196
6
+ metadata.gz: 35d74823407a77440e4e357a4deba5b52209ac8db186e87c107be959dd5dbf25c5e8c2c477176f20ac056f92dcae1aa9405aecbd0aadebf13481bbc98eb99ad1
7
+ data.tar.gz: 0cbe9933253d038deca5fac73a4310b54aff4b7cc55e5707c53d64cc9c866d0e1c92bfecf73a3a1693991c280d14d269a7835ca4e755a497310e913883ccc391
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- highrise (3.2.1)
4
+ highrise (3.2.2)
5
5
  activeresource (>= 3.2.13)
6
6
 
7
7
  GEM
@@ -37,6 +37,7 @@ GEM
37
37
  diff-lcs (>= 1.1.3, < 2.0)
38
38
  rspec-mocks (2.13.0)
39
39
  thread_safe (0.3.2)
40
+ thread_safe (0.3.2-java)
40
41
  tzinfo (0.3.39)
41
42
 
42
43
  PLATFORMS
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.add_development_dependency "rspec"
13
13
  s.add_development_dependency "rake"
14
14
 
15
- s.files = [".gitignore", ".ruby-version", ".travis.yml", "Gemfile", "Gemfile.lock", "MIT-LICENSE", "README.md", "Rakefile", "autotest/discover.rb", "certs/gem-public_cert.pem", "examples/config_initializers_highrise.rb", "examples/extending.rb", "examples/sample.rb", "highrise.gemspec", "highrise.gemspec.erb", "lib/highrise.rb", "lib/highrise/account.rb", "lib/highrise/base.rb", "lib/highrise/comment.rb", "lib/highrise/company.rb", "lib/highrise/deal.rb", "lib/highrise/deal_category.rb", "lib/highrise/email.rb", "lib/highrise/group.rb", "lib/highrise/kase.rb", "lib/highrise/membership.rb", "lib/highrise/note.rb", "lib/highrise/pagination.rb", "lib/highrise/party.rb", "lib/highrise/person.rb", "lib/highrise/recording.rb", "lib/highrise/searchable.rb", "lib/highrise/subject.rb", "lib/highrise/subject_data.rb", "lib/highrise/subject_field.rb", "lib/highrise/tag.rb", "lib/highrise/taggable.rb", "lib/highrise/task.rb", "lib/highrise/task_category.rb", "lib/highrise/user.rb", "lib/highrise/version.rb", "spec/highrise/account_spec.rb", "spec/highrise/base_spec.rb", "spec/highrise/comment_spec.rb", "spec/highrise/company_spec.rb", "spec/highrise/deal_category_spec.rb", "spec/highrise/deal_spec.rb", "spec/highrise/email_spec.rb", "spec/highrise/group_spec.rb", "spec/highrise/kase_spec.rb", "spec/highrise/membership_spec.rb", "spec/highrise/note_spec.rb", "spec/highrise/pagination_behavior.rb", "spec/highrise/pagination_spec.rb", "spec/highrise/party_spec.rb", "spec/highrise/person_spec.rb", "spec/highrise/recording_spec.rb", "spec/highrise/searchable_behavior.rb", "spec/highrise/searchable_spec.rb", "spec/highrise/subject_data_spec.rb", "spec/highrise/subject_field_spec.rb", "spec/highrise/subject_spec.rb", "spec/highrise/tag_spec.rb", "spec/highrise/taggable_behavior.rb", "spec/highrise/taggable_spec.rb", "spec/highrise/task_category_spec.rb", "spec/highrise/task_spec.rb", "spec/highrise/user_spec.rb", "spec/spec_helper.rb"]
15
+ s.files = [".gitignore", ".ruby-version", ".travis.yml", "Gemfile", "Gemfile.lock", "MIT-LICENSE", "README.md", "Rakefile", "autotest/discover.rb", "certs/gem-public_cert.pem", "examples/config_initializers_highrise.rb", "examples/extending.rb", "examples/sample.rb", "highrise.gemspec", "highrise.gemspec.erb", "lib/highrise.rb", "lib/highrise/account.rb", "lib/highrise/base.rb", "lib/highrise/comment.rb", "lib/highrise/company.rb", "lib/highrise/custom_fields.rb", "lib/highrise/deal.rb", "lib/highrise/deal_category.rb", "lib/highrise/email.rb", "lib/highrise/group.rb", "lib/highrise/kase.rb", "lib/highrise/membership.rb", "lib/highrise/note.rb", "lib/highrise/pagination.rb", "lib/highrise/party.rb", "lib/highrise/person.rb", "lib/highrise/recording.rb", "lib/highrise/searchable.rb", "lib/highrise/subject.rb", "lib/highrise/subject_data.rb", "lib/highrise/subject_field.rb", "lib/highrise/tag.rb", "lib/highrise/taggable.rb", "lib/highrise/task.rb", "lib/highrise/task_category.rb", "lib/highrise/user.rb", "lib/highrise/version.rb", "spec/highrise/account_spec.rb", "spec/highrise/base_spec.rb", "spec/highrise/comment_spec.rb", "spec/highrise/company_spec.rb", "spec/highrise/deal_category_spec.rb", "spec/highrise/deal_spec.rb", "spec/highrise/email_spec.rb", "spec/highrise/group_spec.rb", "spec/highrise/kase_spec.rb", "spec/highrise/membership_spec.rb", "spec/highrise/note_spec.rb", "spec/highrise/pagination_behavior.rb", "spec/highrise/pagination_spec.rb", "spec/highrise/party_spec.rb", "spec/highrise/person_spec.rb", "spec/highrise/recording_spec.rb", "spec/highrise/searchable_behavior.rb", "spec/highrise/searchable_spec.rb", "spec/highrise/subject_data_spec.rb", "spec/highrise/subject_field_spec.rb", "spec/highrise/subject_spec.rb", "spec/highrise/tag_spec.rb", "spec/highrise/taggable_behavior.rb", "spec/highrise/taggable_spec.rb", "spec/highrise/task_category_spec.rb", "spec/highrise/task_spec.rb", "spec/highrise/user_spec.rb", "spec/spec_helper.rb"]
16
16
  s.test_files = ["examples/config_initializers_highrise.rb", "examples/extending.rb", "examples/sample.rb", "spec/highrise/account_spec.rb", "spec/highrise/base_spec.rb", "spec/highrise/comment_spec.rb", "spec/highrise/company_spec.rb", "spec/highrise/deal_category_spec.rb", "spec/highrise/deal_spec.rb", "spec/highrise/email_spec.rb", "spec/highrise/group_spec.rb", "spec/highrise/kase_spec.rb", "spec/highrise/membership_spec.rb", "spec/highrise/note_spec.rb", "spec/highrise/pagination_behavior.rb", "spec/highrise/pagination_spec.rb", "spec/highrise/party_spec.rb", "spec/highrise/person_spec.rb", "spec/highrise/recording_spec.rb", "spec/highrise/searchable_behavior.rb", "spec/highrise/searchable_spec.rb", "spec/highrise/subject_data_spec.rb", "spec/highrise/subject_field_spec.rb", "spec/highrise/subject_spec.rb", "spec/highrise/tag_spec.rb", "spec/highrise/taggable_behavior.rb", "spec/highrise/taggable_spec.rb", "spec/highrise/task_category_spec.rb", "spec/highrise/task_spec.rb", "spec/highrise/user_spec.rb", "spec/spec_helper.rb"]
17
17
  s.require_paths = ["lib"]
18
18
 
@@ -2,6 +2,7 @@ require 'highrise/base'
2
2
  require 'highrise/pagination'
3
3
  require 'highrise/taggable'
4
4
  require 'highrise/searchable'
5
+ require 'highrise/custom_fields'
5
6
  require 'highrise/subject'
6
7
  require 'highrise/comment'
7
8
  require 'highrise/company'
@@ -3,6 +3,7 @@ module Highrise
3
3
  include Pagination
4
4
  include Taggable
5
5
  include Searchable
6
+ include CustomFields
6
7
 
7
8
  def people
8
9
  Person.find_all_across_pages(:from => "/companies/#{id}/people.xml")
@@ -0,0 +1,66 @@
1
+ module Highrise
2
+ module CustomFields
3
+ def field(field_label)
4
+ custom_fields = attributes["subject_datas"] ||= []
5
+ field = custom_fields.detect do |field|
6
+ field.subject_field_label == field_label
7
+ end
8
+ field ? field.value : nil
9
+ end
10
+
11
+ def new_subject_data(field, value)
12
+ Highrise::SubjectData.new(:subject_field_id => field.id, :subject_field_label => field.label, :value => value)
13
+ end
14
+
15
+ def set_field_value(field_label, new_value)
16
+ custom_fields = attributes["subject_datas"] ||= []
17
+ custom_fields.each do |field|
18
+ return field.value = new_value if field.subject_field_label == field_label
19
+ end
20
+
21
+ SubjectField.find(:all).each do |custom_field|
22
+ if custom_field.label == field_label
23
+ return attributes["subject_datas"] << new_subject_data(custom_field, new_value)
24
+ end
25
+ end
26
+ end
27
+
28
+ def transform_subject_field_label field_label
29
+ field_label.downcase.tr(' ', '_')
30
+ end
31
+
32
+ def convert_method_to_field_label method
33
+ custom_fields = attributes["subject_datas"] ||= []
34
+ custom_fields.each do |field|
35
+ method_name_from_field = transform_subject_field_label(field.subject_field_label)
36
+ return field if method_name_from_field == method
37
+ end
38
+ nil
39
+ end
40
+
41
+ def method_missing(method_symbol, *args)
42
+ method_name = method_symbol.to_s
43
+
44
+ if method_name[-1,1] == "="
45
+ attribute_name = method_name[0...-1]
46
+ field = convert_method_to_field_label(attribute_name)
47
+ return set_field_value(field.subject_field_label, args[0]) if field
48
+
49
+ return super if attributes[attribute_name]
50
+
51
+ subject_fields = SubjectField.find(:all)
52
+ unless subject_fields.nil?
53
+ subject_fields.each do |custom_field|
54
+ if transform_subject_field_label(custom_field.label) == attribute_name
55
+ return attributes["subject_datas"] << new_subject_data(custom_field, args[0])
56
+ end
57
+ end
58
+ end
59
+ else
60
+ field = convert_method_to_field_label(method_name)
61
+ return field(field.subject_field_label) if field
62
+ end
63
+ super
64
+ end
65
+ end
66
+ end
@@ -1,8 +1,9 @@
1
1
  module Highrise
2
2
  class Deal < Subject
3
+ include Pagination
3
4
  def update_status(status)
4
5
  raise ArgumentError, "status must be one of 'pending', 'won', or 'lost'" unless %w[pending won lost].include?(status)
5
6
  self.put(:status, :status => {:name => status})
6
7
  end
7
8
  end
8
- end
9
+ end
@@ -3,6 +3,7 @@ module Highrise
3
3
  include Pagination
4
4
  include Taggable
5
5
  include Searchable
6
+ include CustomFields
6
7
 
7
8
  def company
8
9
  Company.find(company_id) if company_id
@@ -20,71 +21,16 @@ module Highrise
20
21
  contact_data.web_addresses.first
21
22
  end
22
23
 
23
- def label
24
- 'Party'
25
- end
26
-
27
- def field(field_label)
28
- custom_fields = attributes["subject_datas"] ||= []
29
- field = custom_fields.detect do |field|
30
- field.subject_field_label == field_label
31
- end
32
- field ? field.value : nil
33
- end
34
-
35
- def new_subject_data(field, value)
36
- Highrise::SubjectData.new(:subject_field_id => field.id, :subject_field_label => field.label, :value => value)
37
- end
38
-
39
- def set_field_value(field_label, new_value)
40
- custom_fields = attributes["subject_datas"] ||= []
41
- custom_fields.each do |field|
42
- return field.value = new_value if field.subject_field_label== field_label
43
- end
44
-
45
- SubjectField.find(:all).each do |custom_field|
46
- if custom_field.label == field_label
47
- return attributes["subject_datas"] << new_subject_data(custom_field, new_value)
48
- end
49
- end
24
+ def email_addresses
25
+ contact_data.email_addresses.collect { |address| address.address } rescue []
50
26
  end
51
27
 
52
- def transform_subject_field_label field_label
53
- field_label.downcase.tr(' ', '_')
28
+ def phone_numbers
29
+ contact_data.phone_numbers.collect { |phone_number| phone_number.number } rescue []
54
30
  end
55
-
56
- def convert_method_to_field_label method
57
- custom_fields = attributes["subject_datas"] ||= []
58
- custom_fields.each do |field|
59
- method_name_from_field = transform_subject_field_label(field.subject_field_label)
60
- return field if method_name_from_field == method
61
- end
62
- nil
31
+
32
+ def label
33
+ 'Party'
63
34
  end
64
-
65
- def method_missing(method_symbol, *args)
66
- method_name = method_symbol.to_s
67
-
68
- if method_name[-1,1] == "="
69
- attribute_name = method_name[0...-1]
70
- field = convert_method_to_field_label(attribute_name)
71
- return set_field_value(field.subject_field_label, args[0]) if field
72
-
73
- return super if attributes[attribute_name]
74
-
75
- subject_fields = SubjectField.find(:all)
76
- unless subject_fields.nil?
77
- subject_fields.each do |custom_field|
78
- if transform_subject_field_label(custom_field.label) == attribute_name
79
- return attributes["subject_datas"] << new_subject_data(custom_field, args[0])
80
- end
81
- end
82
- end
83
- else
84
- field = convert_method_to_field_label(method_name)
85
- return field(field.subject_field_label) if field
86
- end
87
- super
88
- end
89
35
  end
90
36
  end
@@ -1,7 +1,8 @@
1
1
  module Highrise
2
2
  class Subject < Base
3
- def notes
4
- Note.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/notes.xml")
3
+ def notes(options={})
4
+ options.merge!(:from => "/#{self.class.collection_name}/#{id}/notes.xml")
5
+ Note.find_all_across_pages(options)
5
6
  end
6
7
 
7
8
  def add_note(attrs={})
@@ -16,12 +17,14 @@ module Highrise
16
17
  Task.create attrs
17
18
  end
18
19
 
19
- def emails
20
- Email.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/emails.xml")
20
+ def emails(options={})
21
+ options.merge!(:from => "/#{self.class.collection_name}/#{id}/emails.xml")
22
+ Email.find_all_across_pages(options)
21
23
  end
22
24
 
23
- def upcoming_tasks
24
- Task.find(:all, :from => "/#{self.class.collection_name}/#{id}/tasks.xml")
25
+ def upcoming_tasks(options={})
26
+ options.merge!(:from => "/#{self.class.collection_name}/#{id}/tasks.xml")
27
+ Task.find(:all, options)
25
28
  end
26
29
 
27
30
  def label
@@ -1,12 +1,17 @@
1
1
  module Highrise
2
- module Taggable
2
+ module Taggable
3
+
3
4
  def tags
4
- self.attributes.has_key?("tags") ? self.attributes["tags"] : self.get(:tags)
5
+ unless self.attributes.has_key?("tags")
6
+ person_or_company = self.class.find(id)
7
+ self.attributes["tags"] = person_or_company.attributes.has_key?("tags") ? person_or_company.tags : []
8
+ end
9
+ self.attributes["tags"]
5
10
  end
6
11
 
7
12
  def tag!(tag_name)
8
13
  self.post(:tags, :name => tag_name) unless tag_name.blank?
9
- end
14
+ end
10
15
 
11
16
  def untag!(tag_name)
12
17
  to_delete = self.tags.find{|tag| tag.attributes['name'] == tag_name} unless tag_name.blank?
@@ -1,3 +1,3 @@
1
1
  module Highrise
2
- VERSION = "3.2.1"
2
+ VERSION = "3.2.3"
3
3
  end
@@ -12,6 +12,72 @@ describe Highrise::Company do
12
12
  Highrise::Person.should_receive(:find_all_across_pages).with(:from=>"/companies/1/people.xml").and_return("people")
13
13
  subject.people.should == "people"
14
14
  end
15
-
15
+
16
+ describe "Custom fields" do
17
+
18
+ before (:each) do
19
+ @fruit_company = Highrise::Company.new({ :company => {
20
+ :id => 1,
21
+ :name => "John Doe & Co.",
22
+ :subject_datas => [{
23
+ :subject_field_label => "Fruit Banana",
24
+ :value => "Yellow"
25
+ }, {
26
+ :subject_field_label => "Fruit Grape",
27
+ :value => "Green"
28
+ }]
29
+ }
30
+ })
31
+ @subject_field_blueberry = Highrise::SubjectField.new ({:id => 1, :label => "Fruit Blueberry"})
32
+ @subject_field_papaya = Highrise::SubjectField.new ({:id => 2, :label => "Fruit Papaya"})
33
+ end
34
+
35
+ it "Can get the value of a custom field via the field method" do
36
+ @fruit_company.field("Fruit Banana").should== "Yellow"
37
+ end
38
+
39
+ it "Can get the value of a custom field using a custom method call" do
40
+ @fruit_company.fruit_grape.should== "Green"
41
+ end
42
+
43
+ it "Will raise an exception on an unknown field" do
44
+ expect {@fruit_company.unknown_fruit}.to raise_exception(NoMethodError)
45
+ end
46
+
47
+ it "Can set the value of a custom field via the field method" do
48
+ @fruit_company.set_field_value("Fruit Grape", "Red")
49
+ @fruit_company.field("Fruit Grape").should== "Red"
50
+ end
51
+
52
+ it "Can set the value of a custom field" do
53
+ @fruit_company.fruit_grape= "Red"
54
+ @fruit_company.field("Fruit Grape").should== "Red"
55
+ end
56
+
57
+ it "Assignment just returns the arguments (like ActiveResource base does)" do
58
+ Highrise::SubjectField.should_receive(:find).with(:all).and_return []
59
+ (@fruit_company.unknown_fruit = 10).should== 10
60
+ end
61
+
62
+ it "Can deal with the find returning nil (which is a bit ugly in the ActiveResource API)" do
63
+ Highrise::SubjectField.should_receive(:find).with(:all).and_return nil
64
+ (@fruit_company.unknown_fruit = 10).should== 10
65
+ end
66
+
67
+ it "Can set the value of a custom field that wasn't there via the field method, but that was defined (happens on new Person)" do
68
+ Highrise::SubjectField.should_receive(:find).with(:all).and_return([@subject_field_papaya, @subject_field_blueberry])
69
+ @fruit_company.set_field_value("Fruit Blueberry", "Purple")
70
+ @fruit_company.field("Fruit Blueberry").should== "Purple"
71
+ @fruit_company.attributes["subject_datas"][2].subject_field_id.should == 1
72
+ end
73
+
74
+ it "Can still set and read the usual way of reading attrivutes" do
75
+ @fruit_company.name = "Jacob"
76
+ @fruit_company.name.should== "Jacob"
77
+
78
+ end
79
+
80
+ end
81
+
16
82
  it { subject.label.should == 'Party' }
17
83
  end
@@ -29,6 +29,68 @@ describe Highrise::Person do
29
29
  subject.name.should == "Marcos Tapajós"
30
30
  end
31
31
 
32
+ describe "#email_addresses" do
33
+ it "returns an empty array when there are none set" do
34
+ subject.email_addresses.should == []
35
+ end
36
+
37
+ it "returns all email_addresses as string in an array" do
38
+ subject = Highrise::Person.new(:id => 1,
39
+ :contact_data => {
40
+ :email_addresses => [{
41
+ :email_address => {
42
+ :address => "important@person.com"
43
+ }
44
+ }]
45
+ })
46
+ subject.email_addresses.should == ["important@person.com"]
47
+ end
48
+ end
49
+
50
+ describe "#phone_numbers" do
51
+ it "returns an empty array when there is none set" do
52
+ subject.phone_numbers.should== []
53
+ end
54
+
55
+ it "returns all phone numbers as a string aray" do
56
+ subject = Highrise::Person.new(:id => 1,
57
+ :contact_data => {
58
+ :phone_numbers => [{
59
+ :phone_number => {
60
+ :number => "123456789"
61
+ }
62
+ }]
63
+ })
64
+ subject.phone_numbers.should== [ "123456789" ]
65
+ end
66
+ end
67
+
68
+ describe "#tags" do
69
+
70
+ let(:person_tags) { [
71
+ {'id' => "414578", 'name' => "cliente"},
72
+ {'id' => "414580", 'name' => "ged"},
73
+ {'id' => "414579", 'name' => "iepc"} ]
74
+ }
75
+
76
+ let(:person_john_doe) { { :id => 1, :first_name => "John", :last_name => "Doe" } }
77
+ let(:person_john_doe_request){ ActiveResource::Request.new(:get, '/people/1.xml', nil, {"Authorization"=>"Bearer OAUTH_TOKEN", "Accept"=>"application/xml"}) }
78
+ let(:person_john_doe_request_pair){ {person_john_doe_request => ActiveResource::Response.new(person_john_doe.to_xml, 200, {})} }
79
+
80
+ it "should return the tags as a Highrise::Tag" do
81
+ person_john_doe[:tags] = person_tags
82
+ ActiveResource::HttpMock.respond_to(person_john_doe_request_pair)
83
+ tags = person_tags.collect {|tag| Highrise::Tag.new(tag)}
84
+ subject.tags.should == tags
85
+ end
86
+
87
+ it "should return an empty collection when there are no tags" do
88
+ ActiveResource::HttpMock.respond_to(person_john_doe_request_pair)
89
+ subject.tags.should == []
90
+ end
91
+ end
92
+
93
+
32
94
  describe "#tags" do
33
95
  before(:each) do
34
96
  (@tags = []).tap do
@@ -42,13 +104,13 @@ describe Highrise::Person do
42
104
  subject.tags.should == @tags
43
105
  }
44
106
  end
45
-
107
+
46
108
  describe "Custom fields" do
47
-
109
+
48
110
  before (:each) do
49
- @fruit_person = Highrise::Person.new({ :person => {
50
- :id => 1,
51
- :first_name => "John",
111
+ @fruit_person = Highrise::Person.new({ :person => {
112
+ :id => 1,
113
+ :first_name => "John",
52
114
  :last_name => "Doe",
53
115
  :subject_datas => [{
54
116
  :subject_field_label => "Fruit Banana",
@@ -61,53 +123,53 @@ describe Highrise::Person do
61
123
  })
62
124
  @subject_field_blueberry = Highrise::SubjectField.new ({:id => 1, :label => "Fruit Blueberry"})
63
125
  @subject_field_papaya = Highrise::SubjectField.new ({:id => 2, :label => "Fruit Papaya"})
64
- end
65
-
126
+ end
127
+
66
128
  it "Can get the value of a custom field via the field method" do
67
129
  @fruit_person.field("Fruit Banana").should== "Yellow"
68
130
  end
69
-
131
+
70
132
  it "Can get the value of a custom field using a custom method call" do
71
133
  @fruit_person.fruit_grape.should== "Green"
72
134
  end
73
-
135
+
74
136
  it "Will raise an exception on an unknown field" do
75
137
  expect {@fruit_person.unknown_fruit}.to raise_exception(NoMethodError)
76
138
  end
77
-
139
+
78
140
  it "Can set the value of a custom field via the field method" do
79
141
  @fruit_person.set_field_value("Fruit Grape", "Red")
80
142
  @fruit_person.field("Fruit Grape").should== "Red"
81
143
  end
82
-
144
+
83
145
  it "Can set the value of a custom field" do
84
146
  @fruit_person.fruit_grape= "Red"
85
147
  @fruit_person.fruit_grape.should== "Red"
86
148
  end
87
-
149
+
88
150
  it "Assignment just returns the arguments (like ActiveResource base does)" do
89
151
  Highrise::SubjectField.should_receive(:find).with(:all).and_return []
90
152
  (@fruit_person.unknown_fruit = 10).should== 10
91
153
  end
92
-
154
+
93
155
  it "Can deal with the find returning nil (which is a bit ugly in the ActiveResource API)" do
94
156
  Highrise::SubjectField.should_receive(:find).with(:all).and_return nil
95
- (@fruit_person.unknown_fruit = 10).should== 10
157
+ (@fruit_person.unknown_fruit = 10).should== 10
96
158
  end
97
-
159
+
98
160
  it "Can set the value of a custom field that wasn't there via the field method, but that was defined (happens on new Person)" do
99
161
  Highrise::SubjectField.should_receive(:find).with(:all).and_return([@subject_field_papaya, @subject_field_blueberry])
100
162
  @fruit_person.set_field_value("Fruit Blueberry", "Purple")
101
163
  @fruit_person.field("Fruit Blueberry").should== "Purple"
102
164
  @fruit_person.attributes["subject_datas"][2].subject_field_id.should == 1
103
165
  end
104
-
166
+
105
167
  it "Can still set and read the usual way of reading attrivutes" do
106
168
  @fruit_person.first_name = "Jacob"
107
169
  @fruit_person.first_name.should== "Jacob"
108
-
170
+
109
171
  end
110
-
172
+
111
173
  end
112
174
 
113
175
  it { subject.label.should == 'Party' }
@@ -29,6 +29,28 @@ describe Highrise::Subject do
29
29
  Highrise::Task.should_receive(:find).with(:all, {:from=>"/subjects/1/tasks.xml"}).and_return("tasks")
30
30
  subject.upcoming_tasks.should == "tasks"
31
31
  end
32
+
33
+ context 'finding with since param' do
34
+ before(:each) do
35
+ @utc_time_str = "20090114174311"
36
+ end
37
+
38
+ it "#notes" do
39
+ Highrise::Note.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/notes.xml", :params=>{:since=>@utc_time_str}}).and_return("notes")
40
+ subject.notes(:params=>{:since=>@utc_time_str}).should == "notes"
41
+ end
42
+
43
+ it "#emails" do
44
+ Highrise::Email.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/emails.xml", :params=>{:since=>@utc_time_str}}).and_return("emails")
45
+ subject.emails(:params=>{:since=>@utc_time_str}).should == "emails"
46
+ end
47
+
48
+
49
+ it "#tasks" do
50
+ Highrise::Task.should_receive(:find).with(:all, {:from=>"/subjects/1/tasks.xml", :params=>{:since=>@utc_time_str}}).and_return("tasks")
51
+ subject.upcoming_tasks(:params=>{:since=>@utc_time_str}).should == "tasks"
52
+ end
53
+ end
32
54
 
33
55
  it { subject.label.should == "Subject" }
34
56
  end
@@ -1,6 +1,6 @@
1
1
  shared_examples_for "a taggable class" do
2
2
  before(:each) do
3
- (@tags = []).tap do
3
+ (@tags = []).tap do
4
4
  @tags << Highrise::Tag.new(:name => "cliente", :id => 414578)
5
5
  @tags << Highrise::Tag.new(:name => "ged", :id => 414580)
6
6
  @tags << Highrise::Tag.new(:name => "iepc", :id => 414579)
@@ -9,19 +9,14 @@ shared_examples_for "a taggable class" do
9
9
 
10
10
  it { subject.class.included_modules.should include(Highrise::Taggable) }
11
11
 
12
- it "#tags" do
13
- subject.should_receive(:get).with(:tags).and_return(@tags)
14
- subject.tags.should == @tags
15
- end
16
-
17
12
  it "#tag!(tag_name)" do
18
13
  subject.should_receive(:post).with(:tags, :name => "client" ).and_return(true)
19
14
  subject.tag!("client").should be_true
20
15
  end
21
-
16
+
22
17
  it "#untag!(tag_name)" do
23
- subject.should_receive(:get).with(:tags).and_return(@tags)
18
+ subject.should_receive(:tags).and_return(@tags)
24
19
  subject.should_receive(:delete).with("tags/414578").and_return(true)
25
20
  subject.untag!("cliente").should be_true
26
21
  end
27
- end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highrise
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Tapajós
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-11 00:00:00.000000000 Z
12
+ date: 2016-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 3.2.13
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 3.2.13
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  description: " Based on the original API module from DHH, http://developer.37signals.com/highrise/,
@@ -64,9 +64,9 @@ executables: []
64
64
  extensions: []
65
65
  extra_rdoc_files: []
66
66
  files:
67
- - .gitignore
68
- - .ruby-version
69
- - .travis.yml
67
+ - ".gitignore"
68
+ - ".ruby-version"
69
+ - ".travis.yml"
70
70
  - Gemfile
71
71
  - Gemfile.lock
72
72
  - MIT-LICENSE
@@ -84,6 +84,7 @@ files:
84
84
  - lib/highrise/base.rb
85
85
  - lib/highrise/comment.rb
86
86
  - lib/highrise/company.rb
87
+ - lib/highrise/custom_fields.rb
87
88
  - lib/highrise/deal.rb
88
89
  - lib/highrise/deal_category.rb
89
90
  - lib/highrise/email.rb
@@ -142,17 +143,17 @@ require_paths:
142
143
  - lib
143
144
  required_ruby_version: !ruby/object:Gem::Requirement
144
145
  requirements:
145
- - - '>='
146
+ - - ">="
146
147
  - !ruby/object:Gem::Version
147
148
  version: '0'
148
149
  required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  requirements:
150
- - - '>='
151
+ - - ">="
151
152
  - !ruby/object:Gem::Version
152
153
  version: 1.3.6
153
154
  requirements: []
154
155
  rubyforge_project:
155
- rubygems_version: 2.0.3
156
+ rubygems_version: 2.2.2
156
157
  signing_key:
157
158
  specification_version: 4
158
159
  summary: Ruby wrapper around Highrise API
@@ -188,3 +189,4 @@ test_files:
188
189
  - spec/highrise/task_spec.rb
189
190
  - spec/highrise/user_spec.rb
190
191
  - spec/spec_helper.rb
192
+ has_rdoc: