sugarcrm 0.9.11 → 0.9.12

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 (49) hide show
  1. data/README.rdoc +11 -0
  2. data/Rakefile +1 -0
  3. data/VERSION +1 -1
  4. data/lib/rails/generators/sugarcrm/config/config_generator.rb +22 -0
  5. data/lib/rails/generators/sugarcrm/config/templates/initializer.rb +4 -0
  6. data/lib/rails/generators/sugarcrm/config/templates/sugarcrm.yml +19 -0
  7. data/lib/sugarcrm.rb +1 -0
  8. data/lib/sugarcrm/associations/association_collection.rb +7 -0
  9. data/lib/sugarcrm/associations/associations.rb +5 -0
  10. data/lib/sugarcrm/attributes/attribute_methods.rb +17 -0
  11. data/lib/sugarcrm/base.rb +1 -1
  12. data/lib/sugarcrm/connection/api/get_available_modules.rb +1 -1
  13. data/lib/sugarcrm/connection/api/get_document_revision.rb +2 -2
  14. data/lib/sugarcrm/connection/api/get_entries.rb +1 -1
  15. data/lib/sugarcrm/connection/api/get_entries_count.rb +1 -1
  16. data/lib/sugarcrm/connection/api/get_entry.rb +1 -1
  17. data/lib/sugarcrm/connection/api/get_entry_list.rb +1 -1
  18. data/lib/sugarcrm/connection/api/get_module_fields.rb +1 -1
  19. data/lib/sugarcrm/connection/api/get_note_attachment.rb +1 -1
  20. data/lib/sugarcrm/connection/api/get_relationships.rb +2 -2
  21. data/lib/sugarcrm/connection/api/get_report_entries.rb +1 -1
  22. data/lib/sugarcrm/connection/api/get_user_id.rb +1 -1
  23. data/lib/sugarcrm/connection/api/get_user_team_id.rb +1 -1
  24. data/lib/sugarcrm/connection/api/logout.rb +1 -1
  25. data/lib/sugarcrm/connection/api/seamless_login.rb +1 -1
  26. data/lib/sugarcrm/connection/api/search_by_module.rb +1 -1
  27. data/lib/sugarcrm/connection/api/set_campaign_merge.rb +1 -1
  28. data/lib/sugarcrm/connection/api/set_document_revision.rb +18 -4
  29. data/lib/sugarcrm/connection/api/set_entries.rb +1 -1
  30. data/lib/sugarcrm/connection/api/set_entry.rb +1 -1
  31. data/lib/sugarcrm/connection/api/set_note_attachment.rb +1 -1
  32. data/lib/sugarcrm/connection/api/set_relationship.rb +1 -1
  33. data/lib/sugarcrm/connection/api/set_relationships.rb +1 -1
  34. data/lib/sugarcrm/connection/connection.rb +9 -5
  35. data/lib/sugarcrm/connection_pool.rb +162 -0
  36. data/lib/sugarcrm/exceptions.rb +1 -0
  37. data/lib/sugarcrm/module_methods.rb +3 -3
  38. data/lib/sugarcrm/session.rb +63 -28
  39. data/sugarcrm.gemspec +143 -0
  40. data/sugarcrm.tmproj +952 -0
  41. data/test/connection/test_login.rb +1 -2
  42. data/test/connection/test_set_document_revision.rb +28 -0
  43. data/test/helper.rb +1 -1
  44. data/test/test_connection_pool.rb +33 -0
  45. data/test/test_session.rb +33 -16
  46. data/test/test_sugarcrm.rb +2 -5
  47. metadata +71 -61
  48. data/.document +0 -5
  49. data/test/config_test.yaml +0 -15
@@ -3,8 +3,7 @@ require 'helper'
3
3
  class TestLogin < ActiveSupport::TestCase
4
4
  context "A SugarCRM.connection" do
5
5
  should "login and set session id" do
6
- assert (SugarCRM.connection.session_id.class == String)
7
- assert_equal SugarCRM.connection.session.id, SugarCRM.connection.session_id
6
+ assert SugarCRM.connection.sugar_session_id.class == String
8
7
  end
9
8
  end
10
9
  end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ class TestSetDocumentRevision < ActiveSupport::TestCase
4
+ context "A SugarCRM.connection" do
5
+ should "Update a document revision" do
6
+ file = File.read("test/config_test.yaml")
7
+ # Create a new document, no file is attached or uploaded at this stage.
8
+ d = SugarCRM::Document.create(
9
+ :revision => 1,
10
+ :active_date => Date.today,
11
+ :filename => "config_test.yaml",
12
+ :document_name=> "config_test.yaml",
13
+ :uploadfile => "config_test.yaml"
14
+ )
15
+ # Did we succeed?
16
+ assert !d.new?
17
+ # Create a new document revision, attaching the file to the document_revision, and associating the document
18
+ # revision with parent document
19
+ assert SugarCRM.connection.set_document_revision(d.id, d.revision + 1, {:file => file, :file_name => "config_test.yaml"})
20
+ # Delete the document
21
+ assert d.delete
22
+ # Remove any document revisions associated with that document
23
+ SugarCRM::DocumentRevision.find_all_by_document_id(d.id).each do |dr|
24
+ assert dr.delete
25
+ end
26
+ end
27
+ end
28
+ end
data/test/helper.rb CHANGED
@@ -12,5 +12,5 @@ class ActiveSupport::TestCase
12
12
  # put your credentials into a YAML file in the test directory
13
13
  # the format should be identical to the config_test.yaml found in the same directory
14
14
  raise "test/config.yaml file not found. See README for instructions on setting up a testing environment" unless File.exists? CONFIG_PATH
15
- SugarCRM::Session.new_from_file(CONFIG_PATH)
15
+ SugarCRM::Session.from_file(CONFIG_PATH)
16
16
  end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ class TestConnectionPool < ActiveSupport::TestCase
4
+ context "A SugarCRM::ConnectionPool instance" do
5
+ should "have a default pool size of 1 if Rails isn't defined" do
6
+ assert_equal 1, SugarCRM.session.connection_pool.size
7
+ end
8
+
9
+ should "be able to specify its pool size" do
10
+ config = SugarCRM.session.config
11
+ sess = SugarCRM::Session.new(config[:base_url], config[:username], config[:password], {:connection_pool => {:size => 3}})
12
+
13
+ begin
14
+ assert_equal 3, sess.connection_pool.size
15
+ ensure
16
+ sess.disconnect!
17
+ end
18
+ end
19
+
20
+ should "be able to specify its timeout" do
21
+ assert_equal 5, SugarCRM.session.connection_pool.timeout # test default
22
+
23
+ config = SugarCRM.session.config
24
+ sess = SugarCRM::Session.new(config[:base_url], config[:username], config[:password], {:connection_pool => {:wait_timeout => 3}})
25
+
26
+ begin
27
+ assert_equal 3, sess.connection_pool.timeout
28
+ ensure
29
+ sess.disconnect!
30
+ end
31
+ end
32
+ end
33
+ end
data/test/test_session.rb CHANGED
@@ -1,5 +1,17 @@
1
1
  require 'helper'
2
2
 
3
+ CONFIG_TEST_PATH = File.join(File.dirname(__FILE__), 'config_test.yaml')
4
+
5
+ # contents of config_test.yaml
6
+ CONFIG_CONTENTS = {
7
+ :config => {
8
+ :base_url => 'http://127.0.0.1/sugarcrm',
9
+ :username => 'admin',
10
+ :password => 'letmein'
11
+ }
12
+ }
13
+ CONFIG_CONTENTS.freeze
14
+
3
15
  class TestSession < ActiveSupport::TestCase
4
16
  context "The SugarCRM::Session class" do
5
17
  should "raise SugarCRM::MissingCredentials if at least one of url/username/password is missing" do
@@ -8,14 +20,26 @@ class TestSession < ActiveSupport::TestCase
8
20
 
9
21
  should "assign namespaces in a way that prevents collisions" do
10
22
  # Namespae0 already assigned (linked to the current connection)
11
- One = SugarCRM::Session.new_from_file(CONFIG_PATH)
12
- Two = SugarCRM::Session.new_from_file(CONFIG_PATH)
23
+ One = SugarCRM::Session.from_file(CONFIG_PATH)
24
+ Two = SugarCRM::Session.from_file(CONFIG_PATH)
13
25
  One.disconnect!
14
- Three = SugarCRM::Session.new_from_file(CONFIG_PATH)
26
+ Three = SugarCRM::Session.from_file(CONFIG_PATH)
15
27
  assert_not_equal Two, Three # namespaces must be different
16
28
  Two.disconnect!
17
29
  Three.disconnect!
18
30
  end
31
+
32
+ should "parse config parameters from a file" do
33
+ assert_equal CONFIG_CONTENTS, SugarCRM::Session.parse_config_file(CONFIG_PATH)
34
+ end
35
+
36
+ should "create a session from a config file" do
37
+ assert_difference('SugarCRM.namespaces.size') do
38
+ SugarCRM::Session.from_file(CONFIG_PATH)
39
+ end
40
+
41
+ SugarCRM.const_get(SugarCRM.namespaces.last).disconnect
42
+ end
19
43
  end
20
44
 
21
45
  context "A SugarCRM::Session instance" do
@@ -32,15 +56,8 @@ class TestSession < ActiveSupport::TestCase
32
56
  end
33
57
 
34
58
  should "load config file" do
35
- SugarCRM.load_config File.join(File.dirname(__FILE__), 'config_test.yaml')
36
- config_contents = {
37
- :config => {
38
- :base_url => 'http://127.0.0.1/sugarcrm',
39
- :username => 'admin',
40
- :password => 'letmein'
41
- }
42
- }
43
- config_contents[:config].each{|k,v| assert_equal v, SugarCRM.config[k]}
59
+ SugarCRM.load_config CONFIG_TEST_PATH
60
+ CONFIG_CONTENTS[:config].each{|k,v| assert_equal v, SugarCRM.config[k]}
44
61
  end
45
62
 
46
63
  should "be able to disconnect, and log in to Sugar automatically if credentials are present in config file" do
@@ -52,7 +69,7 @@ class TestSession < ActiveSupport::TestCase
52
69
 
53
70
  assert_raise(SugarCRM::NoActiveSession){ SugarCRM.current_user }
54
71
 
55
- SugarCRM::Session.new_from_file(CONFIG_PATH)
72
+ SugarCRM::Session.from_file(CONFIG_PATH)
56
73
 
57
74
  assert_nothing_raised{ SugarCRM.current_user }
58
75
  assert SugarCRM.sessions.size == 1
@@ -75,7 +92,7 @@ class TestSession < ActiveSupport::TestCase
75
92
  assert_equal 1, SugarCRM.namespaces.size
76
93
 
77
94
  assert_difference('SugarCRM.namespaces.size') do
78
- OneA = SugarCRM::Session.new_from_file(CONFIG_PATH)
95
+ OneA = SugarCRM::Session.from_file(CONFIG_PATH)
79
96
  end
80
97
 
81
98
  assert_difference('SugarCRM.namespaces.size', -1) do
@@ -85,7 +102,7 @@ class TestSession < ActiveSupport::TestCase
85
102
 
86
103
  should "add a used namespace on each new connection" do
87
104
  assert_difference('SugarCRM.used_namespaces.size') do
88
- OneB = SugarCRM::Session.new_from_file(CONFIG_PATH)
105
+ OneB = SugarCRM::Session.from_file(CONFIG_PATH)
89
106
  end
90
107
 
91
108
  # connection (and namespace) is reused => no used namespace should be added
@@ -99,7 +116,7 @@ class TestSession < ActiveSupport::TestCase
99
116
  end
100
117
 
101
118
  should "not allow access to methods on SugarCRM if there are multiple active connections" do
102
- OneC = SugarCRM::Session.new_from_file(CONFIG_PATH)
119
+ OneC = SugarCRM::Session.from_file(CONFIG_PATH)
103
120
 
104
121
  assert_raise(SugarCRM::MultipleSessions){ SugarCRM.current_user }
105
122
 
@@ -2,11 +2,6 @@ require 'helper'
2
2
 
3
3
  class TestSugarCRM < ActiveSupport::TestCase
4
4
  context "A SugarCRM::Base instance" do
5
-
6
- should "establish a connection when Base#establish_connection" do
7
- # Base#establish_connection was called automatically when loading config file containing connection params
8
- assert SugarCRM.connection.connected?
9
- end
10
5
 
11
6
  should "return the module name" do
12
7
  assert_equal "Users", SugarCRM::User._module.name
@@ -68,6 +63,7 @@ class TestSugarCRM < ActiveSupport::TestCase
68
63
 
69
64
  should "create, modify, and delete a record" do
70
65
  u = SugarCRM::User.new
66
+ assert u.email1?
71
67
  u.email1 = "abc@abc.com"
72
68
  u.first_name = "Test"
73
69
  u.last_name = "User"
@@ -82,6 +78,7 @@ class TestSugarCRM < ActiveSupport::TestCase
82
78
  m.title = "Test User"
83
79
  assert m.save!
84
80
  assert m.delete
81
+ assert m.destroyed?
85
82
  end
86
83
 
87
84
  should "support finding first instance (sorted by attribute)" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 11
9
- version: 0.9.11
8
+ - 12
9
+ version: 0.9.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - Carl Hicks
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-18 00:00:00 -08:00
18
+ date: 2011-03-02 00:00:00 -08:00
19
19
  default_executable: sugarcrm
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -112,65 +112,70 @@ extra_rdoc_files:
112
112
  - LICENSE
113
113
  - README.rdoc
114
114
  files:
115
- - .document
116
- - Gemfile
115
+ - ./Gemfile
116
+ - ./LICENSE
117
+ - ./README.rdoc
118
+ - ./Rakefile
119
+ - ./VERSION
120
+ - ./lib/rails/generators/sugarcrm/config/config_generator.rb
121
+ - ./lib/rails/generators/sugarcrm/config/templates/initializer.rb
122
+ - ./lib/rails/generators/sugarcrm/config/templates/sugarcrm.yml
123
+ - ./lib/sugarcrm.rb
124
+ - ./lib/sugarcrm/associations.rb
125
+ - ./lib/sugarcrm/associations/association.rb
126
+ - ./lib/sugarcrm/associations/association_cache.rb
127
+ - ./lib/sugarcrm/associations/association_collection.rb
128
+ - ./lib/sugarcrm/associations/association_methods.rb
129
+ - ./lib/sugarcrm/associations/associations.rb
130
+ - ./lib/sugarcrm/attributes.rb
131
+ - ./lib/sugarcrm/attributes/attribute_methods.rb
132
+ - ./lib/sugarcrm/attributes/attribute_serializers.rb
133
+ - ./lib/sugarcrm/attributes/attribute_typecast.rb
134
+ - ./lib/sugarcrm/attributes/attribute_validations.rb
135
+ - ./lib/sugarcrm/base.rb
136
+ - ./lib/sugarcrm/config/sugarcrm.yaml
137
+ - ./lib/sugarcrm/connection.rb
138
+ - ./lib/sugarcrm/connection/api/get_available_modules.rb
139
+ - ./lib/sugarcrm/connection/api/get_document_revision.rb
140
+ - ./lib/sugarcrm/connection/api/get_entries.rb
141
+ - ./lib/sugarcrm/connection/api/get_entries_count.rb
142
+ - ./lib/sugarcrm/connection/api/get_entry.rb
143
+ - ./lib/sugarcrm/connection/api/get_entry_list.rb
144
+ - ./lib/sugarcrm/connection/api/get_module_fields.rb
145
+ - ./lib/sugarcrm/connection/api/get_note_attachment.rb
146
+ - ./lib/sugarcrm/connection/api/get_relationships.rb
147
+ - ./lib/sugarcrm/connection/api/get_report_entries.rb
148
+ - ./lib/sugarcrm/connection/api/get_server_info.rb
149
+ - ./lib/sugarcrm/connection/api/get_user_id.rb
150
+ - ./lib/sugarcrm/connection/api/get_user_team_id.rb
151
+ - ./lib/sugarcrm/connection/api/login.rb
152
+ - ./lib/sugarcrm/connection/api/logout.rb
153
+ - ./lib/sugarcrm/connection/api/seamless_login.rb
154
+ - ./lib/sugarcrm/connection/api/search_by_module.rb
155
+ - ./lib/sugarcrm/connection/api/set_campaign_merge.rb
156
+ - ./lib/sugarcrm/connection/api/set_document_revision.rb
157
+ - ./lib/sugarcrm/connection/api/set_entries.rb
158
+ - ./lib/sugarcrm/connection/api/set_entry.rb
159
+ - ./lib/sugarcrm/connection/api/set_note_attachment.rb
160
+ - ./lib/sugarcrm/connection/api/set_relationship.rb
161
+ - ./lib/sugarcrm/connection/api/set_relationships.rb
162
+ - ./lib/sugarcrm/connection/connection.rb
163
+ - ./lib/sugarcrm/connection/helper.rb
164
+ - ./lib/sugarcrm/connection/request.rb
165
+ - ./lib/sugarcrm/connection/response.rb
166
+ - ./lib/sugarcrm/connection_pool.rb
167
+ - ./lib/sugarcrm/exceptions.rb
168
+ - ./lib/sugarcrm/extensions/README.txt
169
+ - ./lib/sugarcrm/finders.rb
170
+ - ./lib/sugarcrm/finders/dynamic_finder_match.rb
171
+ - ./lib/sugarcrm/finders/finder_methods.rb
172
+ - ./lib/sugarcrm/module.rb
173
+ - ./lib/sugarcrm/module_methods.rb
174
+ - ./lib/sugarcrm/session.rb
175
+ - ./sugarcrm.gemspec
176
+ - ./sugarcrm.tmproj
117
177
  - LICENSE
118
178
  - README.rdoc
119
- - Rakefile
120
- - VERSION
121
- - bin/sugarcrm
122
- - lib/sugarcrm.rb
123
- - lib/sugarcrm/associations.rb
124
- - lib/sugarcrm/associations/association.rb
125
- - lib/sugarcrm/associations/association_cache.rb
126
- - lib/sugarcrm/associations/association_collection.rb
127
- - lib/sugarcrm/associations/association_methods.rb
128
- - lib/sugarcrm/associations/associations.rb
129
- - lib/sugarcrm/attributes.rb
130
- - lib/sugarcrm/attributes/attribute_methods.rb
131
- - lib/sugarcrm/attributes/attribute_serializers.rb
132
- - lib/sugarcrm/attributes/attribute_typecast.rb
133
- - lib/sugarcrm/attributes/attribute_validations.rb
134
- - lib/sugarcrm/base.rb
135
- - lib/sugarcrm/config/sugarcrm.yaml
136
- - lib/sugarcrm/connection.rb
137
- - lib/sugarcrm/connection/api/get_available_modules.rb
138
- - lib/sugarcrm/connection/api/get_document_revision.rb
139
- - lib/sugarcrm/connection/api/get_entries.rb
140
- - lib/sugarcrm/connection/api/get_entries_count.rb
141
- - lib/sugarcrm/connection/api/get_entry.rb
142
- - lib/sugarcrm/connection/api/get_entry_list.rb
143
- - lib/sugarcrm/connection/api/get_module_fields.rb
144
- - lib/sugarcrm/connection/api/get_note_attachment.rb
145
- - lib/sugarcrm/connection/api/get_relationships.rb
146
- - lib/sugarcrm/connection/api/get_report_entries.rb
147
- - lib/sugarcrm/connection/api/get_server_info.rb
148
- - lib/sugarcrm/connection/api/get_user_id.rb
149
- - lib/sugarcrm/connection/api/get_user_team_id.rb
150
- - lib/sugarcrm/connection/api/login.rb
151
- - lib/sugarcrm/connection/api/logout.rb
152
- - lib/sugarcrm/connection/api/seamless_login.rb
153
- - lib/sugarcrm/connection/api/search_by_module.rb
154
- - lib/sugarcrm/connection/api/set_campaign_merge.rb
155
- - lib/sugarcrm/connection/api/set_document_revision.rb
156
- - lib/sugarcrm/connection/api/set_entries.rb
157
- - lib/sugarcrm/connection/api/set_entry.rb
158
- - lib/sugarcrm/connection/api/set_note_attachment.rb
159
- - lib/sugarcrm/connection/api/set_relationship.rb
160
- - lib/sugarcrm/connection/api/set_relationships.rb
161
- - lib/sugarcrm/connection/connection.rb
162
- - lib/sugarcrm/connection/helper.rb
163
- - lib/sugarcrm/connection/request.rb
164
- - lib/sugarcrm/connection/response.rb
165
- - lib/sugarcrm/exceptions.rb
166
- - lib/sugarcrm/extensions/README.txt
167
- - lib/sugarcrm/finders.rb
168
- - lib/sugarcrm/finders/dynamic_finder_match.rb
169
- - lib/sugarcrm/finders/finder_methods.rb
170
- - lib/sugarcrm/module.rb
171
- - lib/sugarcrm/module_methods.rb
172
- - lib/sugarcrm/session.rb
173
- - test/config_test.yaml
174
179
  - test/connection/test_get_available_modules.rb
175
180
  - test/connection/test_get_entries.rb
176
181
  - test/connection/test_get_entry.rb
@@ -182,6 +187,7 @@ files:
182
187
  - test/connection/test_get_user_team_id.rb
183
188
  - test/connection/test_login.rb
184
189
  - test/connection/test_logout.rb
190
+ - test/connection/test_set_document_revision.rb
185
191
  - test/connection/test_set_note_attachment.rb
186
192
  - test/connection/test_set_relationship.rb
187
193
  - test/extensions_test/patch.rb
@@ -189,10 +195,12 @@ files:
189
195
  - test/test_association_collection.rb
190
196
  - test/test_associations.rb
191
197
  - test/test_connection.rb
198
+ - test/test_connection_pool.rb
192
199
  - test/test_module.rb
193
200
  - test/test_response.rb
194
201
  - test/test_session.rb
195
202
  - test/test_sugarcrm.rb
203
+ - bin/sugarcrm
196
204
  has_rdoc: true
197
205
  homepage: http://github.com/chicks/sugarcrm
198
206
  licenses: []
@@ -207,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
215
  requirements:
208
216
  - - ">="
209
217
  - !ruby/object:Gem::Version
210
- hash: 2666117297979367978
218
+ hash: 912327613836966464
211
219
  segments:
212
220
  - 0
213
221
  version: "0"
@@ -238,6 +246,7 @@ test_files:
238
246
  - test/connection/test_get_user_team_id.rb
239
247
  - test/connection/test_login.rb
240
248
  - test/connection/test_logout.rb
249
+ - test/connection/test_set_document_revision.rb
241
250
  - test/connection/test_set_note_attachment.rb
242
251
  - test/connection/test_set_relationship.rb
243
252
  - test/extensions_test/patch.rb
@@ -245,6 +254,7 @@ test_files:
245
254
  - test/test_association_collection.rb
246
255
  - test/test_associations.rb
247
256
  - test/test_connection.rb
257
+ - test/test_connection_pool.rb
248
258
  - test/test_module.rb
249
259
  - test/test_response.rb
250
260
  - test/test_session.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
@@ -1,15 +0,0 @@
1
- # below is an example configuration file
2
- #
3
- # to create you own configuration file, simply copy and adapt the text below, removing the '#' in front of the key-value pairs
4
- #
5
- # you'll find an example of a configuration file (used for tests) in test/config_test.yaml
6
- #
7
- # config:
8
- # base_url: http://127.0.0.1/sugarcrm # where your SugarCRM instance is located
9
- # username: admin
10
- # password: letmein
11
-
12
- config:
13
- base_url: http://127.0.0.1/sugarcrm # where your SugarCRM instance is located
14
- username: admin
15
- password: letmein