sugarcrm 0.9.14 → 0.9.15

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.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "activesupport", ">= 3.0.0", :require => "active_support"
3
+ gem "activesupport", ">= 2.3.10", :require => "active_support"
4
4
  gem "i18n"
5
5
  gem "json"
6
6
 
@@ -11,12 +11,13 @@ A less clunky way to interact with SugarCRM via REST.
11
11
  == FEATURES/PROBLEMS:
12
12
 
13
13
  * Works with all v2 API calls
14
- * Supports creation, saving, and deletion of SugarCRM specific objects.
14
+ * Supports Rails 2 and 3
15
+ * ActiveRecord style finders and objects
16
+ * Supports creation, saving, and deletion of SugarCRM specific objects
17
+ * Flexible extension framework
15
18
  * Validations, typecasting, and serialization of boolean, date, and integer fields
16
- * Query, update and delete records from collections!
17
- * ActiveRecord style finders!
18
- * Auto-generation of SugarCRM specific objects. When a connection is established, get_available_modules is called and the resultant modules are turned into SugarCRM::Module classes.
19
- * If you want to use the vanilla API, you can access the methods directly on the SugarCRM.connection object.
19
+ * Query, update and delete records from collections
20
+ * Access API methods directly on the SugarCRM.connection object
20
21
 
21
22
  == SYNOPSIS:
22
23
 
@@ -164,7 +165,7 @@ A less clunky way to interact with SugarCRM via REST.
164
165
 
165
166
  == USING THE GEM WITH RAILS 3
166
167
 
167
- Note: this gem requires Rails 3 as it depends on Active Support >= 3.
168
+ Note: this gem works with Active Support >= 2.3.10, but is optimized for Rails 3.
168
169
 
169
170
  1. Add the sugarcrm gem to your Gemfile (sugarcrm gem version >= 0.9.12)
170
171
  2. Run `bundle install`
@@ -245,7 +246,7 @@ To disconnect an active session:
245
246
 
246
247
  == REQUIREMENTS:
247
248
 
248
- * activesupport >= 3.0.0
249
+ * activesupport >= 2.3.10
249
250
  * i18n
250
251
  * json
251
252
 
@@ -271,4 +272,4 @@ Put your credentials in a file called `test/config.yaml` (which you will have to
271
272
 
272
273
  == Copyright
273
274
 
274
- Copyright (c) 2010 Carl Hicks. See LICENSE for details.
275
+ Copyright (c) 2011 Carl Hicks. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.14
1
+ 0.9.15
@@ -124,6 +124,17 @@ module SugarCRM; module AttributeMethods
124
124
  end
125
125
  ?
126
126
  end
127
+
128
+ # return the (polymorphic) parent record corresponding to the parent_id and parent_type attributes
129
+ # (an example of parent polymorphism can be found in the Note module)
130
+ if (@attributes.keys.include? 'parent_id') && (@attributes.keys.include? 'parent_type')
131
+ self.class.module_eval %Q?
132
+ def parent
133
+ (self.class.session.namespace_const.const_get @attributes['parent_type'].singularize).find(@attributes['parent_id'])
134
+ end
135
+ ?
136
+ end
137
+
127
138
  self.class.attribute_methods_generated = true
128
139
  end
129
140
 
@@ -1,7 +1,7 @@
1
1
  module SugarCRM; module AttributeValidations
2
2
  # Checks to see if we have all the neccessary attributes
3
3
  def valid?
4
- @errors = ActiveSupport::HashWithIndifferentAccess.new
4
+ @errors = (defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess).new
5
5
 
6
6
  self.class._module.required_fields.each do |attribute|
7
7
  valid_attribute?(attribute)
@@ -59,4 +59,4 @@ module SugarCRM; module AttributeValidations
59
59
  @errors[attribute] = @errors[attribute] << message unless @errors[attribute].include? message
60
60
  @errors
61
61
  end
62
- end; end
62
+ end; end
@@ -102,10 +102,11 @@ module SugarCRM; class Session
102
102
  end
103
103
 
104
104
  # load credentials from file, and (re)connect to SugarCRM
105
- def load_config(path)
105
+ def load_config(path, opts = {})
106
+ opts.reverse_merge! :reconnect => true
106
107
  new_config = self.class.parse_config_file(path)
107
- @config[:config] = new_config[:config] if new_config
108
- reconnect(@config[:base_url], @config[:username], @config[:password]) if connection_info_loaded?
108
+ update_config(new_config[:config]) if new_config and new_config[:config]
109
+ reconnect(@config[:base_url], @config[:username], @config[:password]) if opts[:reconnect] and connection_info_loaded?
109
110
  @config
110
111
  end
111
112
 
@@ -207,4 +208,4 @@ module SugarCRM; class Session
207
208
  result[:wait_timeout] = wait_timeout if wait_timeout
208
209
  result
209
210
  end
210
- end; end
211
+ end; end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sugarcrm}
8
- s.version = "0.9.14"
8
+ s.version = "0.9.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Carl Hicks", "David Sulc"]
12
- s.date = %q{2011-05-03}
12
+ s.date = %q{2011-05-18}
13
13
  s.default_executable = %q{sugarcrm}
14
14
  s.email = %q{carl.hicks@gmail.com}
15
15
  s.executables = ["sugarcrm"]
@@ -117,14 +117,14 @@ Gem::Specification.new do |s|
117
117
  s.specification_version = 3
118
118
 
119
119
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
120
- s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
120
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.10"])
121
121
  s.add_runtime_dependency(%q<i18n>, [">= 0"])
122
122
  s.add_runtime_dependency(%q<json>, [">= 0"])
123
123
  s.add_development_dependency(%q<shoulda>, [">= 0"])
124
124
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
125
125
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
126
126
  else
127
- s.add_dependency(%q<activesupport>, [">= 3.0.0"])
127
+ s.add_dependency(%q<activesupport>, [">= 2.3.10"])
128
128
  s.add_dependency(%q<i18n>, [">= 0"])
129
129
  s.add_dependency(%q<json>, [">= 0"])
130
130
  s.add_dependency(%q<shoulda>, [">= 0"])
@@ -132,7 +132,7 @@ Gem::Specification.new do |s|
132
132
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
133
133
  end
134
134
  else
135
- s.add_dependency(%q<activesupport>, [">= 3.0.0"])
135
+ s.add_dependency(%q<activesupport>, [">= 2.3.10"])
136
136
  s.add_dependency(%q<i18n>, [">= 0"])
137
137
  s.add_dependency(%q<json>, [">= 0"])
138
138
  s.add_dependency(%q<shoulda>, [">= 0"])
@@ -2,12 +2,13 @@ require 'helper'
2
2
 
3
3
  class TestGetEntryList < ActiveSupport::TestCase
4
4
  context "A SugarCRM.connection" do
5
- should "return a list of entries when sent #get_entry_list and no fields." do
5
+ should "return a list of entries when sent #get_entry_list" do
6
6
  users = SugarCRM.connection.get_entry_list(
7
7
  "Users",
8
8
  "users.deleted = 0"
9
9
  )
10
- assert_equal "admin", users.first.user_name
10
+ assert_kind_of Array, users
11
+ assert_equal SugarCRM.config[:username], users.first.user_name
11
12
  end
12
13
  should "return an object when #get_entry_list" do
13
14
  @response = SugarCRM.connection.get_entry_list(
@@ -19,4 +20,4 @@ class TestGetEntryList < ActiveSupport::TestCase
19
20
  assert_instance_of SugarCRM::User, @response[0]
20
21
  end
21
22
  end
22
- end
23
+ end
@@ -4,8 +4,8 @@ class TestModuleFields < ActiveSupport::TestCase
4
4
  context "A SugarCRM.connection" do
5
5
  should "return a hash of module fields when #get_module_fields" do
6
6
  fields = SugarCRM.connection.get_module_fields("Users")
7
- assert_instance_of ActiveSupport::HashWithIndifferentAccess, fields
7
+ assert_kind_of Hash, fields
8
8
  assert "address_city", fields.keys[0]
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
+ require 'active_support/test_case'
4
5
 
5
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -5,9 +5,9 @@ class TestFinders < ActiveSupport::TestCase
5
5
  should "always return an Array when :all" do
6
6
  users = SugarCRM::User.all(:limit => 10)
7
7
  assert_instance_of Array, users
8
- users = SugarCRM::User.find(:all, :conditions => {:user_name => '= admin'})
8
+ users = SugarCRM::User.find(:all, :conditions => {:user_name => "= #{users.first.user_name}"})
9
9
  assert_instance_of Array, users
10
- assert users.length == 1
10
+ assert_equal 1, users.length
11
11
  users = SugarCRM::User.find(:all, :conditions => {:user_name => '= invalid_user_123'})
12
12
  assert_instance_of Array, users
13
13
  assert users.length == 0
@@ -101,12 +101,12 @@ class TestFinders < ActiveSupport::TestCase
101
101
 
102
102
  should "receive a response containing all fields when sent #get_entry" do
103
103
  u = SugarCRM::User.find(1)
104
- assert_equal u.user_name, "admin"
104
+ assert_not_nil u.user_name
105
105
  end
106
106
 
107
107
  should "return an array of records when sent #find([id1, id2, id3])" do
108
108
  users = SugarCRM::User.find(["seed_sarah_id", 1])
109
- assert_equal "admin", users.last.user_name
109
+ assert_not_nil users.last.user_name
110
110
  end
111
111
 
112
112
  # test Base#find_by_sql edge case
@@ -198,4 +198,4 @@ class TestFinders < ActiveSupport::TestCase
198
198
  assert a.delete
199
199
  end
200
200
  end
201
- end
201
+ end
@@ -15,6 +15,7 @@ CONFIG_CONTENTS.freeze
15
15
  class TestSession < ActiveSupport::TestCase
16
16
  context "The SugarCRM::Session class" do
17
17
  should "raise SugarCRM::MissingCredentials if at least one of url/username/password is missing" do
18
+
18
19
  assert_raise(SugarCRM::MissingCredentials){ SugarCRM.connect('http://127.0.0.1/sugarcrm', nil, nil) }
19
20
  end
20
21
 
@@ -33,7 +34,7 @@ class TestSession < ActiveSupport::TestCase
33
34
  end
34
35
 
35
36
  should "parse config parameters from a file" do
36
- assert_equal CONFIG_CONTENTS, SugarCRM::Session.parse_config_file(CONFIG_PATH)
37
+ assert_equal CONFIG_CONTENTS, SugarCRM::Session.parse_config_file(CONFIG_TEST_PATH)
37
38
  end
38
39
 
39
40
  should "create a session from a config file" do
@@ -59,8 +60,9 @@ class TestSession < ActiveSupport::TestCase
59
60
  end
60
61
 
61
62
  should "load config file" do
62
- SugarCRM.load_config CONFIG_TEST_PATH
63
+ SugarCRM.load_config CONFIG_TEST_PATH, :reconnect => false
63
64
  CONFIG_CONTENTS[:config].each{|k,v| assert_equal v, SugarCRM.config[k]}
65
+ SugarCRM.load_config CONFIG_PATH
64
66
  end
65
67
 
66
68
  should "be able to disconnect, and log in to Sugar automatically if credentials are present in config file" do
@@ -13,7 +13,7 @@ class TestSugarCRM < ActiveSupport::TestCase
13
13
 
14
14
  should "implement self.count" do
15
15
  nb_accounts = SugarCRM::Account.count
16
- assert nb_accounts > 0
16
+ assert nb_accounts > 0, "There should be some Accounts"
17
17
  nb_inc_accounts = nil
18
18
  assert_nothing_raised do
19
19
  nb_inc_accounts = SugarCRM::Account.count(:conditions => {:name => "LIKE '%Inc'"})
@@ -38,7 +38,7 @@ class TestSugarCRM < ActiveSupport::TestCase
38
38
  end
39
39
 
40
40
  should "return the module fields" do
41
- assert_instance_of ActiveSupport::HashWithIndifferentAccess, SugarCRM::Account._module.fields
41
+ assert_kind_of Hash, SugarCRM::Account._module.fields
42
42
  end
43
43
 
44
44
  should "respond to self#methods" do
@@ -59,7 +59,7 @@ class TestSugarCRM < ActiveSupport::TestCase
59
59
  end
60
60
 
61
61
  should "respond to self.attributes_from_modules_fields" do
62
- assert_instance_of ActiveSupport::HashWithIndifferentAccess, SugarCRM::User.attributes_from_module
62
+ assert_kind_of Hash, SugarCRM::User.attributes_from_module
63
63
  end
64
64
 
65
65
  should "return an instance of itself when #new" do
@@ -189,4 +189,12 @@ class TestSugarCRM < ActiveSupport::TestCase
189
189
  end
190
190
  end
191
191
 
192
+ context "A SugarCRM::Note instance" do
193
+ should "return the correct parent record with the `parent` method" do
194
+ note = SugarCRM::Note.first
195
+ parent = note.parent
196
+ assert_equal note.parent_id, parent.id
197
+ assert_equal note.parent_type.singularize, parent.class.to_s.split('::').last
198
+ end
199
+ end
192
200
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sugarcrm
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.14
5
+ version: 0.9.15
6
6
  platform: ruby
7
7
  authors:
8
8
  - Carl Hicks
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-03 00:00:00 -07:00
14
+ date: 2011-05-18 00:00:00 -07:00
15
15
  default_executable: sugarcrm
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 3.0.0
24
+ version: 2.3.10
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: *id001
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - ">="
196
196
  - !ruby/object:Gem::Version
197
- hash: -4256578188939241626
197
+ hash: -1738284526985119473
198
198
  segments:
199
199
  - 0
200
200
  version: "0"