rhoconnect-adapters 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG +4 -0
- data/Gemfile +18 -0
- data/README.md +239 -0
- data/Rakefile +31 -0
- data/bin/rhoconnect-adapters +35 -0
- data/generators/crm/templates/application/application.rb +34 -0
- data/generators/crm/templates/source/source_adapter.rb +10 -0
- data/generators/crm/templates/source/source_spec.rb +25 -0
- data/generators/crm/templates/spec/spec_helper.rb +64 -0
- data/generators/crm/vendor/ms_dynamics/adapter.rb +301 -0
- data/generators/crm/vendor/ms_dynamics/application.rb +56 -0
- data/generators/crm/vendor/ms_dynamics/lib/crm_metadata_service.rb +43 -0
- data/generators/crm/vendor/ms_dynamics/lib/crm_service.rb +141 -0
- data/generators/crm/vendor/ms_dynamics/lib/discovery_service.rb +51 -0
- data/generators/crm/vendor/ms_dynamics/lib/wlid_service.rb +159 -0
- data/generators/crm/vendor/ms_dynamics/ms_dynamics.rb +45 -0
- data/generators/crm/vendor/ms_dynamics/settings/Account.yml +46 -0
- data/generators/crm/vendor/ms_dynamics/settings/Contact.yml +40 -0
- data/generators/crm/vendor/ms_dynamics/settings/GenericObject.yml +18 -0
- data/generators/crm/vendor/ms_dynamics/settings/Lead.yml +53 -0
- data/generators/crm/vendor/ms_dynamics/settings/Opportunity.yml +41 -0
- data/generators/crm/vendor/ms_dynamics/settings/settings.yml +9 -0
- data/generators/crm/vendor/ms_dynamics/spec/application_spec.rb +23 -0
- data/generators/crm/vendor/ms_dynamics/spec/sources/account_spec.rb +49 -0
- data/generators/crm/vendor/ms_dynamics/spec/sources/contact_spec.rb +49 -0
- data/generators/crm/vendor/ms_dynamics/spec/sources/lead_spec.rb +49 -0
- data/generators/crm/vendor/ms_dynamics/spec/sources/opportunity_spec.rb +62 -0
- data/generators/crm/vendor/ms_dynamics/spec/spec_helper.rb +78 -0
- data/generators/crm/vendor/ms_dynamics/spec_data/Account.yml +6 -0
- data/generators/crm/vendor/ms_dynamics/spec_data/Contact.yml +7 -0
- data/generators/crm/vendor/ms_dynamics/spec_data/GenericObject.yml +3 -0
- data/generators/crm/vendor/ms_dynamics/spec_data/Lead.yml +12 -0
- data/generators/crm/vendor/ms_dynamics/spec_data/Opportunity.yml +6 -0
- data/generators/crm/vendor/ms_dynamics/templates.rb +57 -0
- data/generators/crm/vendor/oracle_on_demand/adapter.rb +421 -0
- data/generators/crm/vendor/oracle_on_demand/application.rb +64 -0
- data/generators/crm/vendor/oracle_on_demand/settings/Account.yml +91 -0
- data/generators/crm/vendor/oracle_on_demand/settings/Contact.yml +54 -0
- data/generators/crm/vendor/oracle_on_demand/settings/GenericObject.yml +21 -0
- data/generators/crm/vendor/oracle_on_demand/settings/Lead.yml +72 -0
- data/generators/crm/vendor/oracle_on_demand/settings/Opportunity.yml +69 -0
- data/generators/crm/vendor/oracle_on_demand/settings/settings.yml +8 -0
- data/generators/crm/vendor/oracle_on_demand/spec/application_spec.rb +14 -0
- data/generators/crm/vendor/oracle_on_demand/spec/sources/account_spec.rb +50 -0
- data/generators/crm/vendor/oracle_on_demand/spec/sources/contact_spec.rb +50 -0
- data/generators/crm/vendor/oracle_on_demand/spec/sources/lead_spec.rb +51 -0
- data/generators/crm/vendor/oracle_on_demand/spec/sources/opportunity_spec.rb +51 -0
- data/generators/crm/vendor/oracle_on_demand/spec_data/Account.yml +8 -0
- data/generators/crm/vendor/oracle_on_demand/spec_data/Contact.yml +8 -0
- data/generators/crm/vendor/oracle_on_demand/spec_data/GenericObject.yml +4 -0
- data/generators/crm/vendor/oracle_on_demand/spec_data/Lead.yml +14 -0
- data/generators/crm/vendor/oracle_on_demand/spec_data/Opportunity.yml +6 -0
- data/generators/crm/vendor/oracle_on_demand/templates.rb +52 -0
- data/generators/crm/vendor/salesforce/adapter.rb +315 -0
- data/generators/crm/vendor/salesforce/application.rb +80 -0
- data/generators/crm/vendor/salesforce/settings/Account.yml +53 -0
- data/generators/crm/vendor/salesforce/settings/Contact.yml +61 -0
- data/generators/crm/vendor/salesforce/settings/GenericObject.yml +13 -0
- data/generators/crm/vendor/salesforce/settings/Lead.yml +73 -0
- data/generators/crm/vendor/salesforce/settings/Opportunity.yml +48 -0
- data/generators/crm/vendor/salesforce/settings/settings.yml +6 -0
- data/generators/crm/vendor/salesforce/spec/application_spec.rb +14 -0
- data/generators/crm/vendor/salesforce/spec/sources/account_spec.rb +50 -0
- data/generators/crm/vendor/salesforce/spec/sources/contact_spec.rb +50 -0
- data/generators/crm/vendor/salesforce/spec/sources/lead_spec.rb +51 -0
- data/generators/crm/vendor/salesforce/spec/sources/opportunity_spec.rb +51 -0
- data/generators/crm/vendor/salesforce/spec_data/Account.yml +14 -0
- data/generators/crm/vendor/salesforce/spec_data/Contact.yml +8 -0
- data/generators/crm/vendor/salesforce/spec_data/GenericObject.yml +3 -0
- data/generators/crm/vendor/salesforce/spec_data/Lead.yml +10 -0
- data/generators/crm/vendor/salesforce/spec_data/Opportunity.yml +10 -0
- data/generators/crm/vendor/salesforce/templates.rb +45 -0
- data/generators/crm/vendor/sugar/adapter.rb +291 -0
- data/generators/crm/vendor/sugar/application.rb +50 -0
- data/generators/crm/vendor/sugar/settings/Account.yml +49 -0
- data/generators/crm/vendor/sugar/settings/Contact.yml +62 -0
- data/generators/crm/vendor/sugar/settings/GenericObject.yml +12 -0
- data/generators/crm/vendor/sugar/settings/Lead.yml +76 -0
- data/generators/crm/vendor/sugar/settings/Opportunity.yml +49 -0
- data/generators/crm/vendor/sugar/settings/settings.yml +9 -0
- data/generators/crm/vendor/sugar/spec/application_spec.rb +25 -0
- data/generators/crm/vendor/sugar/spec/sources/account_spec.rb +53 -0
- data/generators/crm/vendor/sugar/spec/sources/contact_spec.rb +53 -0
- data/generators/crm/vendor/sugar/spec/sources/lead_spec.rb +54 -0
- data/generators/crm/vendor/sugar/spec/sources/opportunity_spec.rb +54 -0
- data/generators/crm/vendor/sugar/spec_data/Account.yml +13 -0
- data/generators/crm/vendor/sugar/spec_data/Contact.yml +8 -0
- data/generators/crm/vendor/sugar/spec_data/GenericObject.yml +3 -0
- data/generators/crm/vendor/sugar/spec_data/Lead.yml +16 -0
- data/generators/crm/vendor/sugar/spec_data/Opportunity.yml +10 -0
- data/generators/crm/vendor/sugar/sugar.rb +33 -0
- data/generators/crm/vendor/sugar/templates.rb +58 -0
- data/generators/rhoconnect-adapters.rb +217 -0
- data/lib/rhoconnect-adapters/crm/crm.rb +31 -0
- data/lib/rhoconnect-adapters/soap_service.rb +70 -0
- data/lib/rhoconnect-adapters/version.rb +3 -0
- data/lib/rhoconnect-adapters.rb +2 -0
- data/rhoconnect-adapters.gemspec +36 -0
- data/spec/apps/ms_dynamics_spec.rb +19 -0
- data/spec/apps/oracle_on_demand_spec.rb +20 -0
- data/spec/apps/salesforce_spec.rb +18 -0
- data/spec/apps/sugar_spec.rb +18 -0
- data/spec/generator/generator_spec.rb +113 -0
- data/spec/spec_helper.rb +57 -0
- metadata +288 -0
data/.gitignore
ADDED
data/CHANGELOG
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rhoconnect-adapters.gemspec
|
4
|
+
gemspec
|
5
|
+
gem 'rake'
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem 'rspec', '~> 2.6.0'
|
9
|
+
gem 'rcov', '>= 0.9.8'
|
10
|
+
gem 'sugarcrm', '>= 0.9.15'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'rspec', '~> 2.6.0'
|
15
|
+
gem 'rcov', '>= 0.9.8'
|
16
|
+
gem 'sugarcrm', '>= 0.9.15'
|
17
|
+
end
|
18
|
+
|
data/README.md
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
rhoconnect-adapters
|
2
|
+
===
|
3
|
+
|
4
|
+
rhoconnect-adapters is a ruby library containing a collection of the out-of-box [RhoConnect](http://rhomobile.com/products/rhoconnect) applications
|
5
|
+
for various needs.
|
6
|
+
|
7
|
+
With rhoconnect-adapters, you can utilize the pre-built set of [RhoConnect](http://rhomobile.com/products/rhoconnect/) applications
|
8
|
+
for popular CRM backends (SalesForce, Oracle CRM On Demand, Sugar CRM, etc.). Also, this library includes support for writing your own [RhoConnect](http://rhomobile.com/products/rhoconnect/)
|
9
|
+
CRM applications to extend or customize the default functionality.
|
10
|
+
|
11
|
+
## Setup
|
12
|
+
Install the 'rhoconnect-adapters' gem by using the following command:
|
13
|
+
|
14
|
+
$ [sudo] gem install rhoconnect-adapters
|
15
|
+
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
The 'rhoconnect-adapters' command creates pre-built [RhoConnect](http://rhomobile.com/products/rhoconnect/) applications.
|
19
|
+
Visit the [RhoConnect](http://rhomobile.com/products/rhoconnect/) website for more information.
|
20
|
+
|
21
|
+
### Generating Standard CRM Application
|
22
|
+
|
23
|
+
To create a standard out-of-the-box rhoconnect CRM application use the following command:
|
24
|
+
|
25
|
+
$ rhoconnect-adapters crmapp <app_name> <CRM-backend>
|
26
|
+
|
27
|
+
Here, the \<CRM\-backend\> parameter specifies the CRM backend that your application will use.
|
28
|
+
Currently, the following CRM backends are supported:
|
29
|
+
|
30
|
+
- OracleOnDemand (for [Oracle CRM On Demand](http://crmondemand.oracle.com))
|
31
|
+
- MsDynamics (for [Microsoft Dynamics CRM](http://www.microsoft.com/en-us/dynamics/default.aspx))
|
32
|
+
- Salesforce (for [Salesforce CRM](http://www.salesforce.com/))
|
33
|
+
- Sugar (for [Sugar CRM](http://www.sugarcrm.com/crm/))
|
34
|
+
|
35
|
+
The generated Rhoconnect CRM application structure will include typical [RhoConnect](http://rhomobile.com/products/rhoconnect/)
|
36
|
+
files (for example, application.rb and settings.yml). It will also create a special vendor directory `vendor/\<CRM\-backend\>`
|
37
|
+
containing all support files specific for the corresponding CRM backend.
|
38
|
+
|
39
|
+
By default, the Rhoconnect CRM application will be generated with four standard source adapters corresponding
|
40
|
+
to the following CRM objects:
|
41
|
+
|
42
|
+
- Account
|
43
|
+
- Contact
|
44
|
+
- Lead
|
45
|
+
- Opportunity
|
46
|
+
|
47
|
+
|
48
|
+
### Generating CRM Application without pre-built source adapters
|
49
|
+
|
50
|
+
In some cases, it is necessary to generate an application without any standard sources.
|
51
|
+
For this purpose, use the `--bare` option to generate just the application's skeleton.
|
52
|
+
|
53
|
+
rhoconnect-adapters crmapp <app_name> <CRM-backend> --bare
|
54
|
+
|
55
|
+
|
56
|
+
### Generating CRM source adapters for the Rhoconnect CRM application
|
57
|
+
|
58
|
+
Once you create your Rhoconnect CRM application, you can generate the desired source adapters
|
59
|
+
based on the CRM objects by typing the following command in your application's directory:
|
60
|
+
|
61
|
+
rhoconnect-adapters crmsource <CRM-object-name> <CRM-backend>
|
62
|
+
|
63
|
+
Here, \<CRM\-object\-name\> must exactly correspond to the name of the CRM object you're trying to
|
64
|
+
build the source adapter for.
|
65
|
+
|
66
|
+
## Preparing the Rhoconnect CRM Application
|
67
|
+
|
68
|
+
### OracleOnDemand settings
|
69
|
+
All OracleOnDemand-specific settings are located in the `vendor/oracle_on_demand/settings` directory.
|
70
|
+
In the file `settings.yml` you'll find the entries that you must customize before running the app.
|
71
|
+
These are:
|
72
|
+
|
73
|
+
- **:oraclecrm_service_url:** <oracle_web_services_integration_url> - substitute the default URL with your OracleOnDemand account URL.
|
74
|
+
|
75
|
+
For every source adapter based on CRM object there is a corresponding *'vendor/oracle_on_demand/settings/\<CRM\-object\-name\>.yml'*
|
76
|
+
file containing the descriptions for the OracleOnDemand CRM object.
|
77
|
+
Every CRM object file has the following entries:
|
78
|
+
|
79
|
+
Query_Fields: hash of the objects's fields
|
80
|
+
(each field's element has the value
|
81
|
+
in a form of the hash with the field's options ,
|
82
|
+
containing the following data):
|
83
|
+
Label => <val> - display name of the field
|
84
|
+
Type => <val> - type of the field data
|
85
|
+
(textinput, textarea, Picklist, id, etc.)
|
86
|
+
|
87
|
+
NonQuery_MappingWS_Fields: object's fields that can not be used
|
88
|
+
in OracleCRM Queries
|
89
|
+
(however, Oracle returns them in GetMapping API)
|
90
|
+
|
91
|
+
StaticPickList: Normally, all picklist fields are queried
|
92
|
+
for the allowed values using GetPicklistValues API
|
93
|
+
However, for certain fields OracleCRM API
|
94
|
+
returns the error 'not a valid picklist'
|
95
|
+
This entry is a workaround for this error -
|
96
|
+
fields's picklist values are statically hard-coded here.
|
97
|
+
|
98
|
+
ObjectFields: this one specifies a hash of fields
|
99
|
+
that are actually references to other objects.
|
100
|
+
For example, AccountName field for Contact object
|
101
|
+
is really a reference to the corresponding Account object.'
|
102
|
+
|
103
|
+
TitleFields: this setting specifies an array of fields
|
104
|
+
used in constructing the object's title in the 'Show' page
|
105
|
+
using the Metadata method. Typically, you will want to put
|
106
|
+
`name` fields in here.
|
107
|
+
|
108
|
+
For the default generated CRM object adapters, this file is pre-filled with information. However, you can customize it by including or excluding
|
109
|
+
options. For custom adapters, you need to fill this file with relevant information. List of object's fields, for example, can be obtained
|
110
|
+
from the Oracle CRM On Demand documentation and then later used to fill the Query_Fields setting. Alternatively, user can customize the adapter and obtain
|
111
|
+
the list of fields using the GetMapping API.
|
112
|
+
|
113
|
+
|
114
|
+
### MsDynamics settings
|
115
|
+
All MsDynamics-specific settings are located in the **'vendor/ms_dynamics/settings'** directory.
|
116
|
+
In the file *'settings.yml'* you'll find the entries that are necessary to customize before running the app.
|
117
|
+
These are:
|
118
|
+
|
119
|
+
- **:msdynamics_ticket_url:** <msdynamics_web_services_integration_url> - substitute the default URL with your MsDynamics account URL.
|
120
|
+
|
121
|
+
For every source adapter based on CRM object there is a corresponding *'vendor/msdynamics/settings/\<CRM\-object\-name\>.yml'*
|
122
|
+
file containing the descriptions for the Sugar CRM object.
|
123
|
+
Every CRM object file has the following entries:
|
124
|
+
|
125
|
+
Query_Fields: hash of the objects's fields
|
126
|
+
(each field's element has the value
|
127
|
+
in a form of the hash with the field's options ,
|
128
|
+
containing the following data):
|
129
|
+
Label => <val> - display name of the field
|
130
|
+
Type => <val> - type of the field data
|
131
|
+
(textinput, textarea, Picklist, id, etc.)
|
132
|
+
|
133
|
+
AttributeTypePicklists: this is a hash of picklist arrays
|
134
|
+
for artificially constructed fields
|
135
|
+
that are really represent some other field's type
|
136
|
+
for example, `customerid` field can be either
|
137
|
+
`account` or `contact`. In this case
|
138
|
+
field `customertype_attrtype` will represent `customerid` field's type
|
139
|
+
and will take values from the `AttributeTypePicklists`
|
140
|
+
array for the field `customerid_attrtype`
|
141
|
+
|
142
|
+
ObjectFields: this one specifies a hash of fields
|
143
|
+
that are actually references to other objects.
|
144
|
+
For example, `account_name` field for Contact object
|
145
|
+
is really a reference to the corresponding Account object.
|
146
|
+
|
147
|
+
TitleFields: this setting specifies an array of fields
|
148
|
+
used in constructing the object's title in the 'Show' page
|
149
|
+
using the Metadata method. Typically, you will want to put
|
150
|
+
`name` fields in here.
|
151
|
+
|
152
|
+
For the default generated CRM object adapters, this file is pre-filled with information. However, you can customize it by including or excluding
|
153
|
+
options. For custom adapters, you need to fill this file with relevant information. List of object's fields, for example, can be obtained
|
154
|
+
from the MsDynamics documentation and then later used to fill the Query_Fields setting. Alternatively, user can customize the adapter and obtain
|
155
|
+
the desired list of object's fields using the MsDynamics SOAP API.
|
156
|
+
|
157
|
+
### Sugar settings
|
158
|
+
All Sugar-specific settings are located in the **'vendor/sugar/settings'** directory.
|
159
|
+
In the file *'settings.yml'* you'll find the entries that are necessary to customize before running the app.
|
160
|
+
These are:
|
161
|
+
|
162
|
+
- **:sugarcrm_uri:** <oracle_web_services_integration_url> - substitute the default URL with your OracleOnDemand account URL.
|
163
|
+
- **:debug_enabled:** <true/false> - enable debug output of the backend HTTP transactions.
|
164
|
+
|
165
|
+
For every source adapter based on CRM object there is a corresponding *'vendor/sugar/settings/\<CRM\-object\-name\>.yml'*
|
166
|
+
file containing the descriptions for the Sugar CRM object.
|
167
|
+
Every CRM object file has the following entries:
|
168
|
+
|
169
|
+
Query_Fields: hash of the objects's fields
|
170
|
+
(each field's element has the value
|
171
|
+
in a form of the hash with the field's options ,
|
172
|
+
containing the following data):
|
173
|
+
Label => <val> - display name of the field
|
174
|
+
Type => <val> - type of the field data
|
175
|
+
(textinput, textarea, Picklist, id, etc.)
|
176
|
+
|
177
|
+
ObjectFields: this one specifies a hash of fields
|
178
|
+
that are actually references to other objects.
|
179
|
+
For example, `account_name` field for Contact object
|
180
|
+
is really a reference to the corresponding Account object.
|
181
|
+
|
182
|
+
TitleFields: this setting specifies an array of fields
|
183
|
+
used in constructing the object's title in the 'Show' page
|
184
|
+
using the Metadata method. Typically, you will want to put
|
185
|
+
`name` fields in here.
|
186
|
+
|
187
|
+
For the default generated CRM object adapters, this file is pre-filled with information. However, you can customize it by including or excluding
|
188
|
+
options. For custom adapters, you need to fill this file with relevant information. List of object's fields, for example, can be obtained
|
189
|
+
from the SugarCRM documentation and then later used to fill the Query_Fields setting. Alternatively, user can customize the adapter and obtain
|
190
|
+
the desired list of object's fields using the SugarCRM REST API.
|
191
|
+
|
192
|
+
### Salesforce settings
|
193
|
+
All Salesforce-specific settings are located in the `vendor/salesforce/settings` directory.
|
194
|
+
In the file `settings.yml` you'll find the entries that you must customize before running the app.
|
195
|
+
These are:
|
196
|
+
|
197
|
+
- **:salesforce_login_url:** <salesforce_soap_login_url> - Currently, this parameter is pre-defined to
|
198
|
+
`https://login.salesforce.com/services/Soap/c/22.0` for simple SOAP web service authentication.
|
199
|
+
Rhoconnect-adapters is not using `OAuth2` scheme at this point.
|
200
|
+
|
201
|
+
For every source adapter based on CRM object there is a corresponding *'vendor/salesforce/settings/\<CRM\-object\-name\>.yml'*
|
202
|
+
file containing the descriptions for the OracleOnDemand CRM object.
|
203
|
+
Every CRM object file has the following entries:
|
204
|
+
|
205
|
+
Query_Fields: hash of the objects's fields
|
206
|
+
(each field's element has the value
|
207
|
+
in a form of the hash with the field's options ,
|
208
|
+
containing the following data):
|
209
|
+
Label => <val> - display name of the field
|
210
|
+
Type => <val> - type of the field data
|
211
|
+
(textinput, textarea, Picklist, datetime, id, etc.)
|
212
|
+
|
213
|
+
ObjectFields: this one specifies a hash of fields
|
214
|
+
that are actually references to other objects.
|
215
|
+
For example, AccountId field for Contact object
|
216
|
+
is really a reference to the corresponding Account object.'
|
217
|
+
|
218
|
+
TitleFields: this setting specifies an array of fields
|
219
|
+
used in constructing the object's title in the 'Show' page
|
220
|
+
using the Metadata method. Typically, you will want to put
|
221
|
+
`name` fields in here.
|
222
|
+
|
223
|
+
For the default generated CRM object adapters, this file is pre-filled with sample information. However, you can customize it by including or excluding
|
224
|
+
different fields. For custom adapters, you need to fill this file with relevant information. List of object's fields, for example, can be obtained
|
225
|
+
from the Salesforce documentation and then later used to fill the Query_Fields setting. Alternatively, user can customize the adapter and obtain
|
226
|
+
the list of fields using the `/sobjects/\<CRM\-object\-name\>/describe/` API.
|
227
|
+
|
228
|
+
|
229
|
+
## Running the CRM Application
|
230
|
+
Once your Rhoconnect application is customized and ready to run, you can start it like any other Rhoconnect app.
|
231
|
+
Type the following command in the CRM application's root directory:
|
232
|
+
|
233
|
+
rake rhoconnect:start
|
234
|
+
|
235
|
+
|
236
|
+
## Meta
|
237
|
+
Created and maintained by Rhomobile Inc.
|
238
|
+
|
239
|
+
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'rcov/rcovtask'
|
8
|
+
|
9
|
+
TYPES = {
|
10
|
+
:gen => 'spec/generator/*_spec.rb',
|
11
|
+
:oracle => 'spec/apps/oracle_on_demand*_spec.rb',
|
12
|
+
:ms => 'spec/apps/ms_dynamics*_spec.rb',
|
13
|
+
:sugar => 'spec/apps/sugar*_spec.rb',
|
14
|
+
:salesforce => 'spec/apps/salesforce*_spec.rb'
|
15
|
+
}
|
16
|
+
|
17
|
+
TYPES.each do |type,files|
|
18
|
+
desc "Run specs in #{files}"
|
19
|
+
RSpec::Core::RakeTask.new("spec:#{type}") do |t|
|
20
|
+
t.rspec_opts = ["-b", "-c", "-fd"]
|
21
|
+
t.pattern = FileList[TYPES[type]]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Run all specs"
|
26
|
+
RSpec::Core::RakeTask.new("spec:all") do |t|
|
27
|
+
t.rspec_opts = ["-b", "-c", "-fd"]
|
28
|
+
t.pattern = FileList[TYPES.values]
|
29
|
+
end
|
30
|
+
|
31
|
+
task :default => 'spec:all'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'templater'
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), '..','generators','rhoconnect-adapters')
|
7
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
8
|
+
require File.join(File.dirname(__FILE__), '..','lib','rhoconnect-adapters')
|
9
|
+
|
10
|
+
# Stub this method to force 1.8 compatibility (come on templater!)
|
11
|
+
class Encoding
|
12
|
+
def find
|
13
|
+
"utf-8"
|
14
|
+
end
|
15
|
+
|
16
|
+
def dummy?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class String
|
22
|
+
def force_encoding(enc)
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
def encoding
|
26
|
+
if RUBY_VERSION =~ /1\.8/ and Encoding.responds_to?('new')
|
27
|
+
Encoding.new
|
28
|
+
else
|
29
|
+
Encoding.default_external
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RhoconnectAdapters.run_cli(Dir.pwd, 'rhoconnect-adapters', RhoconnectAdapters::VERSION, ARGV)
|
35
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'vendor/<%=underscore_crm%>/application'
|
2
|
+
|
3
|
+
class Application < RhoconnectAdapters::CRM::<%=crm_name%>::Application
|
4
|
+
class << self
|
5
|
+
def backend
|
6
|
+
'<%=underscore_crm%>'
|
7
|
+
end
|
8
|
+
|
9
|
+
def authenticate(username,password,session=nil)
|
10
|
+
super(username, password, session)
|
11
|
+
# override the default behaviour here
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add hooks for application startup here
|
15
|
+
# Don't forget to call super at the end!
|
16
|
+
def initializer(path)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
# Calling super here returns rack tempfile path:
|
21
|
+
# i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
|
22
|
+
# Note: This tempfile is removed when server stops or crashes...
|
23
|
+
# See http://rack.rubyforge.org/doc/Multipart.html for more info
|
24
|
+
#
|
25
|
+
# Override this by creating a copy of the file somewhere
|
26
|
+
# and returning the path to that file (then don't call super!):
|
27
|
+
# i.e. /mnt/myimages/soccer.png
|
28
|
+
def store_blob(object,field_name,blob)
|
29
|
+
super #=> returns blob[:tempfile]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Application.initializer(ROOT_PATH)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
2
|
+
|
3
|
+
describe "<%=class_name%>" do
|
4
|
+
it_should_behave_like "SpecHelper" do
|
5
|
+
before(:each) do
|
6
|
+
setup_test_for <%=class_name%>,'testuser'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should process <%=class_name%> query" do
|
10
|
+
pending
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should process <%=class_name%> create" do
|
14
|
+
pending
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should process <%=class_name%> update" do
|
18
|
+
pending
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should process <%=class_name%> delete" do
|
22
|
+
pending
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set environment to test
|
4
|
+
ENV['RHO_ENV'] = 'test'
|
5
|
+
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__),'..'))
|
6
|
+
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.require(:default, ENV['RHO_ENV'].to_sym)
|
9
|
+
|
10
|
+
# Try to load vendor-ed rhoconnect, otherwise load the gem
|
11
|
+
begin
|
12
|
+
require 'vendor/rhoconnect/lib/rhoconnect'
|
13
|
+
rescue LoadError
|
14
|
+
require 'rhoconnect'
|
15
|
+
end
|
16
|
+
|
17
|
+
$:.unshift File.join(File.dirname(__FILE__), "..") # FIXME:
|
18
|
+
# Load our rhoconnect application
|
19
|
+
require 'application'
|
20
|
+
include Rhoconnect
|
21
|
+
|
22
|
+
require 'rhoconnect/test_methods'
|
23
|
+
|
24
|
+
# Monkey patch to fix the following issue:
|
25
|
+
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/shared_example_group.rb:45:
|
26
|
+
# in `ensure_shared_example_group_name_not_taken': Shared example group '...' already exists (ArgumentError)
|
27
|
+
module RSpec
|
28
|
+
module Core
|
29
|
+
module SharedExampleGroup
|
30
|
+
private
|
31
|
+
def ensure_shared_example_group_name_not_taken(name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module TestHelpers
|
38
|
+
class << self
|
39
|
+
@created_records = {}
|
40
|
+
attr_accessor :created_records
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
shared_examples_for "SpecHelper" do
|
45
|
+
include Rhoconnect::TestMethods
|
46
|
+
|
47
|
+
def load_credentials(backend)
|
48
|
+
file = YAML.load_file(File.join(ROOT_PATH,'..','rhoconnect-adapters-test',"#{Rhoconnect.under_score(backend)}.yml"))
|
49
|
+
return file.nil? ? {} : file
|
50
|
+
end
|
51
|
+
|
52
|
+
before(:all) do
|
53
|
+
credentials = load_credentials(Application.backend)
|
54
|
+
@test_user = "#{credentials[:test_user]}"
|
55
|
+
@test_password = "#{credentials[:test_password]}"
|
56
|
+
puts "Specify test user before running these specs" unless @test_user.length > 0
|
57
|
+
puts "Specify test user password before running these specs" unless @test_password.length > 0
|
58
|
+
end
|
59
|
+
|
60
|
+
before(:each) do
|
61
|
+
Store.db.flushdb
|
62
|
+
Application.initializer(ROOT_PATH)
|
63
|
+
end
|
64
|
+
end
|