insightly 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Insightly::Relationship do
4
+ before(:each) do
5
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
+ Insightly::Configuration.logger = Insightly::Configuration._debug_logger
7
+
8
+
9
+ @relationship = Insightly::Relationship.build({"RELATIONSHIP_ID" => 1,
10
+ "FOR_ORGANISATIONS" => false,
11
+ "FOR_CONTACTS" => true,
12
+ "REVERSE" => "Colleague",
13
+ "FORWARD" => "Colleague",
14
+ "REVERSE_TITLE" => "is a colleague of",
15
+ "FORWARD_TITLE" => "is a colleague of"})
16
+ @relationship2 = Insightly::Relationship.build({"RELATIONSHIP_ID" => 2,
17
+ "FOR_ORGANISATIONS" => true,
18
+ "FOR_CONTACTS" => false,
19
+ "REVERSE" => "is a supplier to",
20
+ "FORWARD" => "is a custoemr of",
21
+ "REVERSE_TITLE" => "Supplier",
22
+ "FORWARD_TITLE" => "Customer"})
23
+
24
+ @all_relationships = [@relationship, @relationship2]
25
+ end
26
+ it "should have a url base" do
27
+ Insightly::Relationship.new.url_base.should == "Relationships"
28
+ end
29
+ it "should be able to fetch all" do
30
+
31
+ Insightly::Relationship.any_instance.stub(:get_collection).and_return(@all_relationships.collect { |x| x.remote_data })
32
+ Insightly::Relationship.all.should == @all_relationships
33
+
34
+ end
35
+ it "should have be able to ask the relationship id" do
36
+ @relationship.relationship_id.should == 1
37
+ end
38
+ it "should have a remote id" do
39
+ @relationship.remote_id.should == @relationship.relationship_id
40
+ end
41
+
42
+ end
@@ -0,0 +1,70 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Insightly::Tag do
4
+ before(:each) do
5
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
+ @tag = Insightly::Tag.build({
7
+ "TAG_NAME" => "Happy"
8
+ })
9
+ @tag2 = Insightly::Tag.build({
10
+ "TAG_NAME" => "Happy"
11
+ })
12
+ @all_tags = [@tag, @tag2]
13
+ end
14
+ it "should be able to build an tag from data" do
15
+ data = {
16
+ "TAG_NAME" => "Happy"
17
+
18
+ }
19
+ @tag = Insightly::Tag.build(data)
20
+
21
+ @tag.remote_data.should == data
22
+ end
23
+ it "should be able to fetch all tags" do
24
+ Insightly::Tag.any_instance.stub(:get_collection).and_return(@all_tags.collect { |x| x.remote_data })
25
+ Insightly::Tag.all.should == @all_tags
26
+ end
27
+ it "should allow you to see tags by contact" do
28
+ Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Contacts").and_return([@tag.remote_data])
29
+ Insightly::Tag.contact_tags.should == [@tag]
30
+ end
31
+ it "should allow you to see tags by organisations" do
32
+ Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Organisations").and_return([@tag.remote_data])
33
+ Insightly::Tag.contact_tags.should == [@tag]
34
+ end
35
+ it "should allow you to see tags by opportunites" do
36
+ Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Opportunities").and_return([@tag.remote_data])
37
+ Insightly::Tag.contact_tags.should == [@tag]
38
+ end
39
+ it "should allow you to see tags by projects" do
40
+ Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Projects").and_return([@tag.remote_data])
41
+ Insightly::Tag.contact_tags.should == [@tag]
42
+ end
43
+ it "should allow you to see tags by emails" do
44
+ Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Emails").and_return([@tag.remote_data])
45
+ Insightly::Tag.contact_tags.should == [@tag]
46
+ end
47
+ it "should allow you to build a tag from a string" do
48
+ @tag = Insightly::Tag.build("Happy")
49
+ @tag.tag_name.should == "Happy"
50
+ @tag.remote_data.should == {"TAG_NAME" => "Happy"}
51
+ end
52
+ it "should be able to retrieve the data as an array" do
53
+ @tag.remote_data["TAG_NAME"].should == "Happy"
54
+ end
55
+ it "should be able to convert to json" do
56
+ @tag.to_json.should == @tag.remote_data.to_json
57
+ end
58
+
59
+ it "should know if two tages are equal" do
60
+ @tag2 = Insightly::Tag.build(@tag.remote_data.clone)
61
+ @tag2.should == @tag
62
+ @tag.tag_name = "Bob"
63
+ @tag2.should_not == @tag
64
+ end
65
+
66
+ it "should have accessor for tag_name" do
67
+ @tag.tag_name = "Will"
68
+ @tag.tag_name.should == "Will"
69
+ end
70
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Insightly::TaskCategory do
4
+ before(:each) do
5
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
+ Insightly::Configuration.logger = Insightly::Configuration._debug_logger
7
+
8
+ @all = Insightly::TaskCategory.all
9
+
10
+ @task_category = Insightly::TaskCategory.build({ "CATEGORY_ID" => 1,
11
+ "ACTIVE" => true,
12
+ "BACKGROUND_COLOR" => '019301',
13
+ "CATEGORY_NAME" => "Meeting"})
14
+
15
+ @task_category2 = Insightly::TaskCategory.build({ "CATEGORY_ID" => 2,
16
+ "ACTIVE" => true,
17
+ "BACKGROUND_COLOR" => '019301',
18
+ "CATEGORY_NAME" => "Phone call"})
19
+ @all_task_categories = [@task_category, @task_category2]
20
+ end
21
+ it "should have a url base" do
22
+ Insightly::TaskCategory.new.url_base.should == "TaskCategories"
23
+ end
24
+ it "should be able to fetch all of the task_categories" do
25
+
26
+ Insightly::TaskCategory.any_instance.stub(:get_collection).and_return(@all_task_categories.collect { |x| x.remote_data })
27
+ Insightly::TaskCategory.all.should == @all_task_categories
28
+
29
+ end
30
+ it "should have a remote id" do
31
+ @task_category.remote_id.should == @task_category.category_id
32
+ end
33
+ it "should be able to retrieve the data as an array" do
34
+ @task_category.remote_data["CATEGORY_NAME"].should == "Meeting"
35
+ end
36
+ it "should be able to convert to json" do
37
+ @task_category.to_json.should == @task_category.remote_data.to_json
38
+ end
39
+
40
+ it "should know if two task_categories are equal" do
41
+ @task_category2 = Insightly::TaskCategory.build(@task_category.remote_data.clone)
42
+ @task_category2.should == @task_category
43
+ @task_category.category_name = "Bob"
44
+ @task_category2.should_not == @task_category
45
+ end
46
+
47
+ it "should have accessor for category_name" do
48
+ @task_category.category_name = "Will"
49
+ @task_category.category_name.should == "Will"
50
+ end
51
+
52
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Insightly::TeamMember do
4
+ before(:each) do
5
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
+ Insightly::Configuration.logger = Insightly::Configuration._debug_logger
7
+
8
+
9
+ @team_member = Insightly::TeamMember.build({"MEMBER_TEAM_ID" => nil,
10
+ "TEAM_ID" => 1,
11
+ "MEMBER_USER_ID" => 100,
12
+ "PERMISSION_ID" => 2000})
13
+ @team_member2 = Insightly::TeamMember.build({"MEMBER_TEAM_ID" => nil,
14
+ "TEAM_ID" => 1,
15
+ "MEMBER_USER_ID" => 101,
16
+ "PERMISSION_ID" => 2000})
17
+
18
+ @all_team_members = [@team_member, @team_member2]
19
+ end
20
+ it "should have a url base" do
21
+ Insightly::TeamMember.new.url_base.should == "TeamMembers"
22
+ end
23
+ it "should be able to fetch all" do
24
+
25
+ Insightly::TeamMember.any_instance.stub(:get_collection).and_return(@all_team_members.collect { |x| x.remote_data })
26
+ Insightly::TeamMember.all.should == @all_team_members
27
+
28
+ end
29
+ it "should have be able to ask the team id" do
30
+ @team_member.team_id.should == 1
31
+ end
32
+ it "should have a remote id" do
33
+ @team_member.remote_id.should == @team_member.team_id
34
+ end
35
+
36
+ end
@@ -0,0 +1,165 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Insightly::OpportunityStateReason do
4
+ before(:each) do
5
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
+ Insightly::Configuration.logger = Insightly::Configuration._debug_logger
7
+ @user = Insightly::User.build({
8
+ "DATE_UPDATED_UTC" => "2010-12-27 04:22:00",
9
+ "DATE_CREATED_UTC" => "2010-12-27 04:22:00",
10
+ "ACTIVE" => true,
11
+ "TIMEZONE_ID" => "Central Standard Time",
12
+ "EMAIL_ADDRESS" => "ron@aol.com",
13
+ "ACCOUNT_OWNER" => false,
14
+ "CONTACT_ID" => 123456789,
15
+ "USER_ID" => 1,
16
+ "ADMINISTRATOR" => true,
17
+ "LAST_NAME" => "Campbell",
18
+ "FIRST_NAME" => "Ron"
19
+ })
20
+ @user2 = Insightly::User.build({
21
+ "DATE_UPDATED_UTC" => "2010-12-27 04:22:00",
22
+ "DATE_CREATED_UTC" => "2010-12-27 04:22:00",
23
+ "ACTIVE" => true,
24
+ "TIMEZONE_ID" => "Central Standard Time",
25
+ "EMAIL_ADDRESS" => "allen@aol.com",
26
+ "ACCOUNT_OWNER" => false,
27
+ "CONTACT_ID" => 923456789,
28
+ "USER_ID" => 2,
29
+ "ADMINISTRATOR" => true,
30
+ "LAST_NAME" => "Campbell",
31
+ "FIRST_NAME" => "Allen"
32
+ })
33
+ @all_users = [@user, @user2]
34
+ end
35
+ it "should have a url base" do
36
+ Insightly::User.new.url_base.should == "Users"
37
+
38
+ end
39
+ it "should get the user id" do
40
+ @user.user_id.should == 1
41
+ end
42
+ it "should have a remote id" do
43
+ @user.remote_id.should == @user.user_id
44
+ end
45
+ context "name" do
46
+ before(:each) do
47
+ @user = Insightly::User.build({"FIRST_NAME" => "Ron", "LAST_NAME" => "Campbell"})
48
+ end
49
+
50
+ it "should return the name" do
51
+
52
+ @user.name.should == "Ron Campbell"
53
+ end
54
+ it "should handle nil first name" do
55
+ @user.first_name = nil
56
+ @user.name.should == "Campbell"
57
+ end
58
+ it "should handle nil last name" do
59
+ @user.last_name = nil
60
+ @user.name.should == "Ron"
61
+ end
62
+ it "should handle empty first name" do
63
+ @user.first_name = ""
64
+ @user.name.should == "Campbell"
65
+ end
66
+ it "should handle empty last name" do
67
+ @user.last_name = ""
68
+ @user.name.should == "Ron"
69
+ end
70
+ it "should handle nil first and last name" do
71
+ @user.first_name = nil
72
+ @user.last_name = nil
73
+ @user.name.should == ""
74
+ end
75
+ it "should handle empty first and last name" do
76
+ @user.first_name = ""
77
+ @user.last_name = ""
78
+ @user.name.should == ""
79
+ end
80
+ end
81
+ context "last_name_first" do
82
+ before(:each) do
83
+ @user = Insightly::User.build({"FIRST_NAME" => "Ron", "LAST_NAME" => "Campbell"})
84
+ end
85
+
86
+ it "should return the last name first" do
87
+
88
+ @user.last_name_first.should == "Campbell,Ron"
89
+ end
90
+ it "should handle nil first name" do
91
+ @user.first_name = nil
92
+ @user.last_name_first.should == "Campbell,"
93
+ end
94
+ it "should handle nil last name" do
95
+ @user.last_name = nil
96
+ @user.last_name_first.should == ",Ron"
97
+ end
98
+ it "should handle empty first name" do
99
+ @user.first_name = ""
100
+ @user.last_name_first.should == "Campbell,"
101
+ end
102
+ it "should handle empty last name" do
103
+ @user.last_name = ""
104
+ @user.last_name_first.should == ",Ron"
105
+ end
106
+ it "should handle nil first and last name" do
107
+ @user.first_name = nil
108
+ @user.last_name = nil
109
+ @user.last_name_first.should == ""
110
+ end
111
+ it "should handle empty first and last name" do
112
+ @user.first_name = ""
113
+ @user.last_name = ""
114
+ @user.last_name_first.should == ""
115
+ end
116
+ end
117
+ context "search/find" do
118
+ before(:each) do
119
+ Insightly::User.any_instance.stub(:get_collection).and_return(@all_users.collect { |x| x.remote_data })
120
+ end
121
+ it "should be able to pull all of them" do
122
+ Insightly::User.all.should == @all_users
123
+ end
124
+
125
+ it "should return nil if not found by email" do
126
+ Insightly::User.find_by_email("will").should be_nil
127
+ end
128
+ it "should return nil if not found by email" do
129
+ Insightly::User.find_by_email("will").should be_nil
130
+ end
131
+ it "should return [] if not found all by email" do
132
+ Insightly::User.find_all_by_email("will").should == []
133
+ end
134
+ it "should return [] if not found all by name" do
135
+ Insightly::User.find_all_by_name("will").should == []
136
+ end
137
+
138
+ it " should allow you to find someone by their email " do
139
+ Insightly::User.find_by_email("ron@aol.com").should == @user
140
+ end
141
+ it " should allow you to find a list by their email " do
142
+ Insightly::User.find_all_by_email("ron@aol.com").should == [ @user]
143
+ end
144
+ it " should allow you to find someone by their name " do
145
+
146
+ Insightly::User.find_by_name("Ron Campbell").should == @user
147
+ end
148
+ it " should allow you to find a list by their name " do
149
+ Insightly::User.find_all_by_name("Ron Campbell").should == [@user]
150
+ end
151
+ it " should allow you to find somone by part of an email " do
152
+ Insightly::User.find_by_email("ron").should == @user
153
+ end
154
+ it " should allow you to find a list by part of an email " do
155
+ Insightly::User.find_by_email("aol.com").should == @user
156
+ end
157
+ it " should allow you to find a list by part of a name " do
158
+ Insightly::User.find_by_name("Ron").should == @user
159
+ end
160
+ it " should allow you to find someone by part of a name " do
161
+ Insightly::User.find_all_by_name("Campbell").should == [@user, @user2]
162
+ end
163
+ end
164
+
165
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insightly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Elmendorf
@@ -16,11 +16,10 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-09-13 00:00:00 Z
19
+ date: 2012-09-14 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: builder
23
- prerelease: false
22
+ type: :runtime
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
@@ -32,11 +31,11 @@ dependencies:
32
31
  - 0
33
32
  - 0
34
33
  version: 2.0.0
35
- type: :runtime
36
34
  version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: json
39
35
  prerelease: false
36
+ name: builder
37
+ - !ruby/object:Gem::Dependency
38
+ type: :runtime
40
39
  requirement: &id002 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
@@ -48,11 +47,11 @@ dependencies:
48
47
  - 7
49
48
  - 5
50
49
  version: 1.7.5
51
- type: :runtime
52
50
  version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: rest-client
55
51
  prerelease: false
52
+ name: json
53
+ - !ruby/object:Gem::Dependency
54
+ type: :runtime
56
55
  requirement: &id003 !ruby/object:Gem::Requirement
57
56
  none: false
58
57
  requirements:
@@ -64,11 +63,11 @@ dependencies:
64
63
  - 6
65
64
  - 7
66
65
  version: 1.6.7
67
- type: :runtime
68
66
  version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: logger
71
67
  prerelease: false
68
+ name: rest-client
69
+ - !ruby/object:Gem::Dependency
70
+ type: :runtime
72
71
  requirement: &id004 !ruby/object:Gem::Requirement
73
72
  none: false
74
73
  requirements:
@@ -80,11 +79,11 @@ dependencies:
80
79
  - 2
81
80
  - 8
82
81
  version: 1.2.8
83
- type: :runtime
84
82
  version_requirements: *id004
85
- - !ruby/object:Gem::Dependency
86
- name: activesupport
87
83
  prerelease: false
84
+ name: logger
85
+ - !ruby/object:Gem::Dependency
86
+ type: :runtime
88
87
  requirement: &id005 !ruby/object:Gem::Requirement
89
88
  none: false
90
89
  requirements:
@@ -94,11 +93,11 @@ dependencies:
94
93
  segments:
95
94
  - 3
96
95
  version: "3"
97
- type: :runtime
98
96
  version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: i18n
101
97
  prerelease: false
98
+ name: activesupport
99
+ - !ruby/object:Gem::Dependency
100
+ type: :runtime
102
101
  requirement: &id006 !ruby/object:Gem::Requirement
103
102
  none: false
104
103
  requirements:
@@ -108,8 +107,9 @@ dependencies:
108
107
  segments:
109
108
  - 0
110
109
  version: "0"
111
- type: :runtime
112
110
  version_requirements: *id006
111
+ prerelease: false
112
+ name: i18n
113
113
  description: Ruby library for integrating with http://Insight.ly . This gem makes it easy to talk to their recently released REST API.
114
114
  email: code@r26d.com
115
115
  executables: []
@@ -121,38 +121,57 @@ extra_rdoc_files: []
121
121
  files:
122
122
  - README.md
123
123
  - LICENSE
124
- - lib/insightly/read_write.rb
125
- - lib/insightly/task.rb
126
- - lib/insightly/link_helper.rb
127
- - lib/insightly/opportunity.rb
128
- - lib/insightly/contact_info.rb
129
- - lib/insightly/read_only.rb
124
+ - lib/insightly.rb
125
+ - lib/insightly/base.rb
126
+ - lib/insightly/organisation.rb
130
127
  - lib/insightly/contact_info_helper.rb
131
- - lib/insightly/task_link_helper.rb
128
+ - lib/insightly/contact_info.rb
129
+ - lib/insightly/comment.rb
130
+ - lib/insightly/base_data.rb
131
+ - lib/insightly/task_category.rb
132
132
  - lib/insightly/configuration.rb
133
- - lib/insightly/version.rb
133
+ - lib/insightly/team_member.rb
134
134
  - lib/insightly/link.rb
135
+ - lib/insightly/relationship.rb
136
+ - lib/insightly/tag.rb
135
137
  - lib/insightly/task_link.rb
136
- - lib/insightly/comment.rb
137
- - lib/insightly/organisation.rb
138
+ - lib/insightly/opportunity_category.rb
139
+ - lib/insightly/tag_helper.rb
138
140
  - lib/insightly/contact.rb
141
+ - lib/insightly/user.rb
142
+ - lib/insightly/currency.rb
143
+ - lib/insightly/custom_field.rb
144
+ - lib/insightly/read_only.rb
145
+ - lib/insightly/read_write.rb
139
146
  - lib/insightly/address_helper.rb
140
- - lib/insightly/base_data.rb
141
- - lib/insightly/opportunity_state_reason.rb
142
- - lib/insightly/base.rb
147
+ - lib/insightly/version.rb
148
+ - lib/insightly/opportunity.rb
149
+ - lib/insightly/link_helper.rb
150
+ - lib/insightly/task.rb
151
+ - lib/insightly/task_link_helper.rb
152
+ - lib/insightly/country.rb
143
153
  - lib/insightly/address.rb
144
- - lib/insightly.rb
154
+ - lib/insightly/opportunity_state_reason.rb
155
+ - spec/unit/user_spec.rb
145
156
  - spec/unit/task_link_spec.rb
146
- - spec/unit/organisation_spec.rb
147
- - spec/unit/base_spec.rb
157
+ - spec/unit/country_spec.rb
158
+ - spec/unit/configuration_spec.rb
159
+ - spec/unit/task_spec.rb
160
+ - spec/unit/currency_spec.rb
148
161
  - spec/unit/comment_spec.rb
162
+ - spec/unit/base_spec.rb
163
+ - spec/unit/tag_spec.rb
164
+ - spec/unit/organisation_spec.rb
165
+ - spec/unit/custom_field_spec.rb
149
166
  - spec/unit/opportunity_spec.rb
167
+ - spec/unit/task_category_spec.rb
168
+ - spec/unit/opportunity_category_spec.rb
169
+ - spec/unit/team_member_spec.rb
150
170
  - spec/unit/opportunity_state_reason_spec.rb
151
- - spec/unit/contact_spec.rb
152
- - spec/unit/link_spec.rb
153
- - spec/unit/configuration_spec.rb
154
- - spec/unit/task_spec.rb
155
171
  - spec/unit/address_spec.rb
172
+ - spec/unit/relationship_spec.rb
173
+ - spec/unit/link_spec.rb
174
+ - spec/unit/contact_spec.rb
156
175
  - spec/spec_helper.rb
157
176
  - insightly.gemspec
158
177
  homepage: https://github.com/r26D/insightly
@@ -184,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
203
  requirements: []
185
204
 
186
205
  rubyforge_project:
187
- rubygems_version: 1.8.17
206
+ rubygems_version: 1.8.24
188
207
  signing_key:
189
208
  specification_version: 3
190
209
  summary: Insight.ly Ruby Client Library