amiando 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/Gemfile +1 -0
- data/README.md +11 -7
- data/lib/amiando.rb +4 -0
- data/lib/amiando/autorun.rb +24 -0
- data/lib/amiando/boolean.rb +4 -0
- data/lib/amiando/request.rb +13 -1
- data/lib/amiando/resource.rb +10 -5
- data/lib/amiando/result.rb +4 -8
- data/lib/amiando/version.rb +1 -1
- data/test/amiando/amiando_test.rb +11 -0
- data/test/amiando/event_test.rb +12 -11
- data/test/amiando/resource_test.rb +39 -11
- data/test/fixtures/ApiKey/{ded8694c21d2e1c0cec845f72ba452b5.yml → 1d8e3d55d45a77d6eb7796e5abb70281.yml} +18 -18
- data/test/fixtures/ApiKey/1f62195e173114773b3ec2613582ece9.yml +17 -17
- data/test/fixtures/ApiKey/{a948a98b153ab66978e37160f352bfbc.yml → 2bd8734a62569871c33d9b4d85b6a77e.yml} +18 -18
- data/test/fixtures/ApiKey/97d82801a10696aaf385bf5873034b60.yml +17 -17
- data/test/fixtures/Event/{67e55d2f91fa702eb8dc612cbfa661f9.yml → 0d29a0d4fe4acb5754dbbf35fea93978.yml} +19 -19
- data/test/fixtures/Event/{5d6016557d86e7b7ff83d07d1ef4bf44.yml → 0f81fe01f6d9137dabe648694e51108b.yml} +19 -19
- data/test/fixtures/Event/{50cb3d76b40032b0fa5731ce7d2ae2f6.yml → 293b18554ac33089826dcc199d55f66d.yml} +20 -20
- data/test/fixtures/Event/{ebab641e40ca57f8e0883d8ea003bd78.yml → 2d3625bced7e64be6a1f77391e53c92c.yml} +20 -20
- data/test/fixtures/Event/{813535fc6ee153c1a6d8e826f1fe04dc.yml → 3429e430b90972313131c5ec7b140bc5.yml} +20 -20
- data/test/fixtures/Event/548edbff1f623236bf25b782b4d54f00.yml +60 -0
- data/test/fixtures/Event/5839cf01abdb31ee25b467010b843a7e.yml +60 -0
- data/test/fixtures/Event/{eb341dbccefaad75aad439f10cc7d82d.yml → 782ed18e0254a0921f2bdc4ee531be15.yml} +20 -20
- data/test/fixtures/Event/{3b8ae154ad13c7152366b79c0d34b053.yml → 79874f1be286c23c9073abadd30bfb54.yml} +18 -18
- data/test/fixtures/Event/7cc1b7624fd157ace68f1228ac3dcdf0.yml +60 -0
- data/test/fixtures/Event/819153d5998556cd0e0a69843b82e180.yml +60 -0
- data/test/fixtures/Event/8aa7c9a23f8cfb78429186ed32506a85.yml +60 -0
- data/test/fixtures/Event/9c91cd6e67ca4c487277a231642c7348.yml +60 -0
- data/test/fixtures/Event/a43ca700b01ed360f3fd49053a372409.yml +60 -0
- data/test/fixtures/Event/b366ae5348b0369ae9ebe311d27d6e7a.yml +60 -0
- data/test/fixtures/{User/1e3ab0fb92b5b1992f35256b4be7497b.yml → Event/c0215f6e5cc7ce3f38bc8160073ff6e5.yml} +19 -19
- data/test/fixtures/Event/{3a90bf0a17eb1d647f1496d04640797a.yml → c56ad4fb06c53108a17395024b0c6591.yml} +20 -20
- data/test/fixtures/Event/{29a95cd545b2fba8121dce97a3c859e3.yml → cacbf55bdb4305ffc7bde245b549c802.yml} +17 -17
- data/test/fixtures/{ApiKey/76860dbafe66279f25f56cd66b3f6ba1.yml → Event/cd000efc19547014919f0e4beddef16d.yml} +18 -19
- data/test/fixtures/Event/{c88c85889575508f75deee325e16e49d.yml → e8c793aaa218772c909bca09ce1b15a3.yml} +19 -19
- data/test/fixtures/Event/e967b0a7dc4c142076ff86e244b3d7ec.yml +60 -0
- data/test/fixtures/Event/ea326235c2dfbc3fb0a58d40e63dec8a.yml +60 -0
- data/test/fixtures/Event/{ef17351e4bbc84eb776fe16dda31e1e4.yml → f23b74a91d5c997e3db3087a9ac5083c.yml} +20 -20
- data/test/fixtures/Event/f6749539762876faa27fe9d9d9138a75.yml +60 -0
- data/test/fixtures/Event/{a816e5664ff66b8e3d27b74435a0c123.yml → fbfab75b95d5c3df19152e70fbd9689c.yml} +20 -20
- data/test/fixtures/Global/505952258352958b3b59a3812372ed02.yml +17 -17
- data/test/fixtures/Global/{d41a6ca323b5db99b4e3c06e108c52cc.yml → 8d5740635c53798549a973a4f245613e.yml} +20 -20
- data/test/fixtures/PaymentType/{46a58274e28425eeab73c573ea2a3236.yml → 0096aebaa9c29a7bcb381d20697704c3.yml} +20 -20
- data/test/fixtures/PaymentType/{0e4e3995f9ecd10f11b50270c326f23b.yml → 3f67b8ff5994e0239fa2ed6e7dbfcec1.yml} +19 -19
- data/test/fixtures/PaymentType/{0ad10cb8031c0c8b2c2787ca5c390667.yml → 7c37125c353d970dbbbaaef54eaf3d90.yml} +20 -20
- data/test/fixtures/PaymentType/{cd61062dafdb2b4f2a08364482901e49.yml → 99cb9326dac40ba3263f9564d0c38fef.yml} +18 -18
- data/test/fixtures/PaymentType/fbfab75b95d5c3df19152e70fbd9689c.yml +60 -0
- data/test/fixtures/TicketCategory/{bee3d6eb4247fec0849d91fb2f768524.yml → 10f73790dceb968d141b099cd8890fc7.yml} +20 -20
- data/test/fixtures/TicketCategory/{a9b19dc83437d00ffc4603c04f78159f.yml → 1267a63177d0cdbdc9ce0698c746801a.yml} +19 -19
- data/test/fixtures/TicketCategory/{655e7a8089d67b8eeea1176398e4b289.yml → 1292d83aaf8b860c9674dc3deab14f76.yml} +20 -20
- data/test/fixtures/TicketCategory/68afc49b238888d5f21e2bda4112d3ec.yml +60 -0
- data/test/fixtures/TicketCategory/{e6076c26b1b75eec091c5b91c9f75ad9.yml → 9e4aeb649cc0d8ceeadd95ddf3691db5.yml} +18 -18
- data/test/fixtures/TicketCategory/{fe63648cf867613ec93b380e06257349.yml → af30e74612a9be4e082524a58f9fa12f.yml} +18 -18
- data/test/fixtures/TicketCategory/d93efc92d5d6638151f7b098b5f786e2.yml +60 -0
- data/test/fixtures/TicketCategory/fbfab75b95d5c3df19152e70fbd9689c.yml +60 -0
- data/test/fixtures/TicketShop/{03d35073550910e61201cf425b4ff73e.yml → 00f98e3db33c4179bfb87a14c662ae1a.yml} +18 -18
- data/test/fixtures/{Event/c5ad7e1d1c160d7d1132297892a9ec94.yml → TicketShop/95137c716c285b96acef0a0d9f4b55c2.yml} +20 -20
- data/test/fixtures/{Event/49877df5f8c251e3364a3560ab1ab46c.yml → TicketShop/98af95fbe3b6921d446c8ad57f476683.yml} +19 -19
- data/test/fixtures/TicketShop/{15c36c73e9f1d3255a61a559e3b98562.yml → dc18e2818f5b86f9e6609703d4165c80.yml} +20 -20
- data/test/fixtures/TicketShop/{ece5150c24e5000bf4eff8dcdb6311bb.yml → f8b2b6ca29914576989fa3c2fc21d516.yml} +20 -20
- data/test/fixtures/User/01fec3bc2a1e516b338622c402243255.yml +60 -0
- data/test/fixtures/User/{e51278f9f771be0c6c3ac0e4ee1b6459.yml → 05317b0072cb1096bfb6967b6ed8d3f6.yml} +18 -18
- data/test/fixtures/User/{0f635f4bb82fdc84af205efe76f43ae0.yml → 0d0a11e4a50e0c07c5a9ea57d82b0f73.yml} +20 -20
- data/test/fixtures/User/20151bd612c24a781cfda884ddea4648.yml +60 -0
- data/test/fixtures/User/{eb30a195ac7829d506954f472e9e6dea.yml → 2b96ad3dbac7864d8567eee7aef596f8.yml} +18 -18
- data/test/fixtures/User/5083f674a088c59d7f57e167d7a68846.yml +60 -0
- data/test/fixtures/User/60ce8f1f2c00efb20e63cac38a2c3733.yml +60 -0
- data/test/fixtures/User/{7d493f7758d9795ad522bc827cb51b77.yml → 6336fa05acc193628f86cced59cfb181.yml} +19 -19
- data/test/fixtures/User/6b47fa7d9877e42cf0efc331760a4297.yml +60 -0
- data/test/fixtures/User/72a03fe8088b0e860de88f5017ddad1a.yml +60 -0
- data/test/fixtures/User/939e0f42cf958e9be75705d71f9c5d46.yml +60 -0
- data/test/fixtures/User/b9227cff5e90a733e50df2a9110a3061.yml +60 -0
- data/test/fixtures/User/{6501a4db53a97afe6f7b9afeeb996888.yml → cf8a518069a9b3ad71e45ca607a3eb31.yml} +18 -18
- data/test/fixtures/User/d0d7823d8c1402e1959481c4a5fe7acf.yml +60 -0
- data/test/fixtures/User/{3bac6d29256056f2b9a1ea6fad26966d.yml → e0f7ab1b2afa0f1ea2be473bc3dd3838.yml} +19 -19
- data/test/fixtures/User/{6ad0dd77081f413e3df25d6a625d38cd.yml → ea31627d93c898465d0dbe44c86ca6ed.yml} +20 -20
- data/test/fixtures/User/{baa28f50439b903e423dbdf918fff20b.yml → efb3543620c2a1753972b79b1a747b00.yml} +18 -18
- data/test/support/factory.rb +1 -1
- data/test/test_helper.rb +10 -3
- metadata +134 -162
- data/test/fixtures/ApiKey/018fa0a2281ec9026bc122bc346366f6.yml +0 -60
- data/test/fixtures/ApiKey/a703d1fcec1576fa8cb4ca1c5f53f545.yml +0 -62
- data/test/fixtures/ApiKey/b7ecc9e79dd856dec661554cd00490ed.yml +0 -62
- data/test/fixtures/ApiKey/fa883db60c0390aa8948098d32497015.yml +0 -60
- data/test/fixtures/Event/361940ebc5f074b1d6d96c2dbeb573ab.yml +0 -60
- data/test/fixtures/Event/8eabb0f839e03cde5818397c7121e6b4.yml +0 -61
- data/test/fixtures/Event/96a5ccd0281a67a4bdb276516b77e756.yml +0 -62
- data/test/fixtures/Event/9e689bd5495dc898a710cba8e6d1d779.yml +0 -62
- data/test/fixtures/Event/d6a585196f1a2a94d22f22a2140d4c07.yml +0 -60
- data/test/fixtures/Event/e00eebd4faf194fe592fa6e7615909b8.yml +0 -60
- data/test/fixtures/Event/e753b6f404795c6635856ea43b0c7d35.yml +0 -60
- data/test/fixtures/PaymentType/49877df5f8c251e3364a3560ab1ab46c.yml +0 -60
- data/test/fixtures/PaymentType/c1ea7b9755738d0bdc9336955cd4fa52.yml +0 -62
- data/test/fixtures/PaymentType/fb24238618b16cb664a5277279e14ff0.yml +0 -62
- data/test/fixtures/TicketCategory/0412c9d453efd804e171c6ba57fd980a.yml +0 -66
- data/test/fixtures/TicketCategory/49877df5f8c251e3364a3560ab1ab46c.yml +0 -60
- data/test/fixtures/TicketCategory/4d3f8d9ff3fb728fc37aaa6e40355a00.yml +0 -62
- data/test/fixtures/TicketCategory/5d4fdfda01ed8193c6bbc5e089db5a4b.yml +0 -60
- data/test/fixtures/TicketCategory/c6f8563714904f006b28ac06312b107d.yml +0 -60
- data/test/fixtures/TicketCategory/ebfcf07be91b8cb6d05156713592abc9.yml +0 -60
- data/test/fixtures/TicketShop/0524d80dc6e3fad88d49adf71ffa2ab9.yml +0 -60
- data/test/fixtures/TicketShop/09729fb0d9f1490bec3acfa0e6742190.yml +0 -60
- data/test/fixtures/TicketShop/4605dd240202cd7510bfecaf474ac615.yml +0 -62
- data/test/fixtures/TicketShop/5c1f5488a196f44f2c18cc186816fd42.yml +0 -60
- data/test/fixtures/TicketShop/71f80402a72be32fdd34074d4426b765.yml +0 -62
- data/test/fixtures/TicketShop/bc24338e918c6edb07a55f4d580c5af3.yml +0 -60
- data/test/fixtures/TicketShop/d095062bf22d235f277c979b025e5cac.yml +0 -60
- data/test/fixtures/User/0b4a60c6c962b4b3af9ab21832cd76b2.yml +0 -60
- data/test/fixtures/User/1c2f2c8a5372e998f38b9d387107cee2.yml +0 -60
- data/test/fixtures/User/3ffaba64188557400a8678dbefd75990.yml +0 -60
- data/test/fixtures/User/5a26c7f9edf6d6027b19b57feda4a96f.yml +0 -60
- data/test/fixtures/User/5c17b4b5287f5d0ba390e25e99cf2270.yml +0 -49
- data/test/fixtures/User/89e6cb6ae39e29a154c99e0e33bb1b91.yml +0 -60
- data/test/fixtures/User/90a3bfe214f17305e356ad3f1a9c9ce7.yml +0 -60
- data/test/fixtures/User/92ad6537c8be5aab7cbd778d424f4944.yml +0 -60
- data/test/fixtures/User/9485b68940997e23e3721a413d4fbdd5.yml +0 -49
- data/test/fixtures/User/98348fe6fbecb7916faadd835916d94d.yml +0 -60
- data/test/fixtures/User/b63d7aa4703a3140b4d9884e9f302362.yml +0 -60
- data/test/fixtures/User/b8c3fd04d7bd0925c3ccd3a3978ab8e6.yml +0 -49
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# amiando
|
1
|
+
# amiando [![Build Status](https://secure.travis-ci.org/xing/amiando.png)](http://travis-ci.org/xing/amiando)
|
2
2
|
|
3
3
|
This is a gem to access the amiando REST API. You can check the original
|
4
4
|
documentation here:
|
@@ -12,15 +12,19 @@ parallel using [Typhoeus](https://github.com/dbalatero/typhoeus).
|
|
12
12
|
|
13
13
|
You can query multiple requests and run then like this:
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
jorge = Amiando::User.find(5678)
|
15
|
+
albert = Amiando::User.find(1234)
|
16
|
+
jorge = Amiando::User.find(5678)
|
18
17
|
|
19
|
-
Amiando.run
|
20
|
-
```
|
18
|
+
Amiando.run
|
21
19
|
|
22
20
|
Both requests will happen in parallel.
|
23
21
|
|
22
|
+
You can also do synchronous requests by prepending 'sync_' to the method name:
|
23
|
+
|
24
|
+
albert = Amiando::User.sync_find(1234)
|
25
|
+
|
26
|
+
### Note
|
27
|
+
|
24
28
|
All attributes should be used in snake_case format instead of the CamelCase
|
25
29
|
used in the official documentation. For example, for a user, you should call
|
26
|
-
first_name instead of firstName.
|
30
|
+
first_name instead of firstName.
|
data/lib/amiando.rb
CHANGED
@@ -13,6 +13,7 @@ module Amiando
|
|
13
13
|
autoload :TicketCategory, 'amiando/ticket_category'
|
14
14
|
autoload :TicketShop, 'amiando/ticket_shop'
|
15
15
|
autoload :PaymentType, 'amiando/payment_type'
|
16
|
+
autoload :Autorun, 'amiando/autorun'
|
16
17
|
|
17
18
|
module Error
|
18
19
|
class ServiceDown < Exception; end
|
@@ -26,6 +27,9 @@ module Amiando
|
|
26
27
|
|
27
28
|
class << self
|
28
29
|
attr_accessor :api_key
|
30
|
+
attr_accessor :logger
|
31
|
+
attr_accessor :verbose
|
32
|
+
attr_accessor :autorun
|
29
33
|
|
30
34
|
URL = 'https://amiando.com'
|
31
35
|
TEST_URL = 'https://test.amiando.com'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Amiando
|
2
|
+
module Autorun
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def autorun(*fields)
|
9
|
+
fields.each do |field|
|
10
|
+
class_eval <<-EOS, __FILE__, __LINE__
|
11
|
+
def #{field}
|
12
|
+
Amiando.run if Amiando.autorun && !defined?(@#{field})
|
13
|
+
if defined?(@#{field})
|
14
|
+
@#{field}
|
15
|
+
else
|
16
|
+
raise Error::NotInitialized.new('Called result before the query was run')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
EOS
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/amiando/boolean.rb
CHANGED
@@ -8,8 +8,12 @@ module Amiando
|
|
8
8
|
# After the object is populated, you can ask the result with the result
|
9
9
|
# method.
|
10
10
|
class Boolean
|
11
|
+
include Amiando::Autorun
|
12
|
+
|
11
13
|
attr_accessor :request, :response
|
12
14
|
|
15
|
+
autorun :request, :response, :result
|
16
|
+
|
13
17
|
def initialize(response_attribute)
|
14
18
|
@response_attribute = response_attribute.to_s
|
15
19
|
end
|
data/lib/amiando/request.rb
CHANGED
@@ -12,7 +12,19 @@ module Amiando
|
|
12
12
|
params = default_params.merge(params || {})
|
13
13
|
end
|
14
14
|
|
15
|
-
super(path, :method => verb, :params => params, :verbose =>
|
15
|
+
super(path, :method => verb, :params => params, :verbose => Amiando.verbose)
|
16
|
+
end
|
17
|
+
|
18
|
+
def log_response
|
19
|
+
if Amiando.logger
|
20
|
+
filtered_url = url.gsub(/password=([^&]+)/, "password=[FILTERED]")
|
21
|
+
Amiando.logger.info "REST request #{filtered_url} returned #{response.code} and took #{response.time} seconds"
|
22
|
+
|
23
|
+
if Amiando.logger.debug? && response.body
|
24
|
+
filtered_body = response.body.inspect.gsub(/password: .*/,'password: [FILTERED]')
|
25
|
+
Amiando.logger.debug "REST request body: #{filtered_body}"
|
26
|
+
end
|
27
|
+
end
|
16
28
|
end
|
17
29
|
|
18
30
|
private
|
data/lib/amiando/resource.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
module Amiando
|
2
2
|
class Resource
|
3
|
+
include Amiando::Autorun
|
4
|
+
|
3
5
|
attr_accessor :request, :response
|
4
6
|
attr_reader :success, :attributes
|
5
7
|
|
8
|
+
autorun :request, :response, :success, :attributes
|
9
|
+
|
6
10
|
class << self
|
7
11
|
def map(local, remote, options = {})
|
8
12
|
mapping[local] = remote
|
@@ -57,6 +61,7 @@ module Amiando
|
|
57
61
|
object.request = req
|
58
62
|
|
59
63
|
req.on_complete do |response|
|
64
|
+
req.log_response
|
60
65
|
|
61
66
|
# Raise different errors depending on the return codes
|
62
67
|
case response.code
|
@@ -115,15 +120,15 @@ module Amiando
|
|
115
120
|
end
|
116
121
|
|
117
122
|
def method_missing(method_name, *args, &block)
|
118
|
-
if
|
119
|
-
|
123
|
+
if attributes.key?(method_name) && args.empty?
|
124
|
+
attributes[method_name]
|
120
125
|
else
|
121
126
|
super
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
130
|
def id
|
126
|
-
|
131
|
+
attributes[:id]
|
127
132
|
end
|
128
133
|
|
129
134
|
def populate(reponse_body)
|
@@ -150,9 +155,9 @@ module Amiando
|
|
150
155
|
protected
|
151
156
|
|
152
157
|
def set_attributes(attributes)
|
153
|
-
@attributes = {}
|
154
|
-
|
155
158
|
if attributes
|
159
|
+
@attributes = {}
|
160
|
+
|
156
161
|
self.class.reverse_map_params(attributes).each do |k,v|
|
157
162
|
@attributes[k.to_sym] = v
|
158
163
|
end
|
data/lib/amiando/result.rb
CHANGED
@@ -8,8 +8,12 @@ module Amiando
|
|
8
8
|
# After the object is populated, you can ask the result with the result
|
9
9
|
# method.
|
10
10
|
class Result
|
11
|
+
include Amiando::Autorun
|
12
|
+
|
11
13
|
attr_accessor :request, :response, :errors
|
12
14
|
|
15
|
+
autorun :request, :response, :result, :errors
|
16
|
+
|
13
17
|
def initialize(&block)
|
14
18
|
@populator = block
|
15
19
|
end
|
@@ -21,13 +25,5 @@ module Amiando
|
|
21
25
|
@result = @populator.call(response_body, self)
|
22
26
|
end
|
23
27
|
end
|
24
|
-
|
25
|
-
def result
|
26
|
-
if defined?(@result)
|
27
|
-
@result
|
28
|
-
else
|
29
|
-
raise Error::NotInitialized.new('Called result before the query was run')
|
30
|
-
end
|
31
|
-
end
|
32
28
|
end
|
33
29
|
end
|
data/lib/amiando/version.rb
CHANGED
@@ -10,4 +10,15 @@ describe Amiando do
|
|
10
10
|
Amiando.base_url.must_equal 'https://amiando.com'
|
11
11
|
Amiando.development!
|
12
12
|
end
|
13
|
+
|
14
|
+
describe 'logger' do
|
15
|
+
it 'should define a logger' do
|
16
|
+
log = StringIO.new
|
17
|
+
Amiando.logger = Logger.new(log)
|
18
|
+
Amiando.logger.debug 'hi'
|
19
|
+
|
20
|
+
log.string.must_match(/hi/)
|
21
|
+
Amiando.logger = nil
|
22
|
+
end
|
23
|
+
end
|
13
24
|
end
|
data/test/amiando/event_test.rb
CHANGED
@@ -11,23 +11,23 @@ describe Amiando::Event do
|
|
11
11
|
|
12
12
|
describe 'find' do
|
13
13
|
it 'finds an already existing event' do
|
14
|
-
|
15
|
-
Amiando.
|
14
|
+
identifier = "event-find-#{HydraCache.revision}"
|
15
|
+
original = Amiando::Factory.create(:event, :identifier => identifier)
|
16
16
|
|
17
17
|
event = Amiando::Event.find(original.id)
|
18
18
|
Amiando.run
|
19
19
|
|
20
20
|
event.id.must_equal original.id
|
21
|
-
event.identifier.must_equal
|
21
|
+
event.identifier.must_equal identifier
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'exists' do
|
26
|
-
it 'checks if an event
|
27
|
-
|
28
|
-
Amiando.
|
26
|
+
it 'checks if an event already exists' do
|
27
|
+
identifier = "event-exists-#{HydraCache.revision}"
|
28
|
+
original = Amiando::Factory.create(:event, :identifier => identifier)
|
29
29
|
|
30
|
-
exists = Amiando::Event.exists?(
|
30
|
+
exists = Amiando::Event.exists?(identifier)
|
31
31
|
Amiando.run
|
32
32
|
|
33
33
|
exists.result.must_equal true
|
@@ -35,12 +35,12 @@ describe Amiando::Event do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'create' do
|
38
|
-
it 'creates an event
|
38
|
+
it 'creates an event with valid parameters passed' do
|
39
39
|
event = Amiando::Event.create(
|
40
40
|
:host_id => Amiando::TEST_USER.id,
|
41
41
|
:title => 'Secret title',
|
42
42
|
:country => 'es',
|
43
|
-
:selected_date => Time.at(0)
|
43
|
+
:selected_date => Time.at(0).utc
|
44
44
|
)
|
45
45
|
|
46
46
|
Amiando.run
|
@@ -112,10 +112,11 @@ describe Amiando::Event do
|
|
112
112
|
|
113
113
|
describe 'search' do
|
114
114
|
it 'finds events by identifier' do
|
115
|
-
|
115
|
+
identifier = "event-search-#{HydraCache.revision}"
|
116
|
+
event = Amiando::Factory(:event, :identifier => identifier)
|
116
117
|
Amiando.run
|
117
118
|
|
118
|
-
search = Amiando::Event.search(:identifier =>
|
119
|
+
search = Amiando::Event.search(:identifier => identifier)
|
119
120
|
Amiando.run
|
120
121
|
|
121
122
|
search.result.must_include event.id
|
@@ -11,11 +11,6 @@ describe Amiando::Resource do
|
|
11
11
|
post object, 'somewhere', :populate_method => :populate_create
|
12
12
|
object
|
13
13
|
end
|
14
|
-
|
15
|
-
def populate_create(response_body)
|
16
|
-
@success = response_body['success']
|
17
|
-
end
|
18
|
-
|
19
14
|
end
|
20
15
|
|
21
16
|
it 'raises error when amiando is down' do
|
@@ -56,21 +51,21 @@ describe Amiando::Resource do
|
|
56
51
|
end
|
57
52
|
|
58
53
|
it 'maps attributes with typecasting' do
|
59
|
-
time = Time.at(0)
|
60
|
-
expected = { :creation => '1970-01-
|
54
|
+
time = Time.at(0).utc
|
55
|
+
expected = { :creation => '1970-01-01T00:00:00Z' }
|
61
56
|
Wadus.map_params(:creation => time).must_equal expected
|
62
57
|
end
|
63
58
|
|
64
59
|
it 'automatically typecasts if the object is a Time' do
|
65
|
-
time = Time.at(0)
|
66
|
-
expected = { :firstName => '1970-01-
|
60
|
+
time = Time.at(0).utc
|
61
|
+
expected = { :firstName => '1970-01-01T00:00:00Z' }
|
67
62
|
Wadus.map_params(:first_name => time).must_equal expected
|
68
63
|
end
|
69
64
|
|
70
65
|
it 'reverse maps attributes with typecasting' do
|
71
|
-
time = Time.at(0)
|
66
|
+
time = Time.at(0).utc
|
72
67
|
expected = { :creation => time }
|
73
|
-
Wadus.reverse_map_params(:creation => '1970-01-
|
68
|
+
Wadus.reverse_map_params(:creation => '1970-01-01T00:00:00Z').must_equal expected
|
74
69
|
end
|
75
70
|
|
76
71
|
describe 'synchronous calls' do
|
@@ -79,4 +74,37 @@ describe Amiando::Resource do
|
|
79
74
|
Wadus.sync_create.success.must_equal true
|
80
75
|
end
|
81
76
|
end
|
77
|
+
|
78
|
+
describe 'autorun' do
|
79
|
+
before do
|
80
|
+
Amiando.autorun = true
|
81
|
+
stub_request(:post, /somewhere/).to_return(:status => 200, :body => '{"success":true, "id": 1}')
|
82
|
+
end
|
83
|
+
|
84
|
+
after do
|
85
|
+
Amiando.autorun = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
let(:wadus) { Wadus.create }
|
89
|
+
|
90
|
+
it 'should return the result when calling autorun' do
|
91
|
+
wadus.id.must_equal 1
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should return the success' do
|
95
|
+
wadus.success.must_equal true
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should return no errors' do
|
99
|
+
wadus.errors.must_be_nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should return the request' do
|
103
|
+
wadus.request.wont_be_nil
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should return the response' do
|
107
|
+
wadus.response.wont_be_nil
|
108
|
+
end
|
109
|
+
end
|
82
110
|
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
--- !ruby/object:Typhoeus::Response
|
2
|
-
app_connect_time:
|
2
|
+
app_connect_time: 4.7e-05
|
3
3
|
body: "{\"success\":true}"
|
4
4
|
code: 200
|
5
|
-
connect_time:
|
5
|
+
connect_time: 4.7e-05
|
6
6
|
curl_error_message: No error
|
7
7
|
curl_return_code: 0
|
8
|
-
effective_url: https://test.amiando.com/api/apiKey/
|
8
|
+
effective_url: https://test.amiando.com/api/apiKey/179133?version=1&apikey=0wDGphOP9KiqovK8mrCFQB6vn8a6DKzxQ0Zo9nev1OTSGebnOK&format=json
|
9
9
|
first_header_line: HTTP/1.1 200 OK
|
10
10
|
headers: |
|
11
11
|
HTTP/1.1 200 OK
|
12
|
-
Date:
|
12
|
+
Date: Tue, 25 Oct 2011 14:52:32 GMT
|
13
13
|
Server: Apache/2.0.55 (Red Hat)
|
14
|
-
Set-Cookie: JSESSIONID=
|
15
|
-
Set-Cookie: JSESSIONID=
|
14
|
+
Set-Cookie: JSESSIONID=C4B1E16C88A6EDEE31C26E104A1D4454.web01; Path=/; Secure
|
15
|
+
Set-Cookie: JSESSIONID=C4B1E16C88A6EDEE31C26E104A1D4454.web01; Path=/
|
16
16
|
accept-charset: utf-8
|
17
17
|
P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD CON OUR IND UNI PUR COM CNT"
|
18
18
|
Access-Control-Allow-Origin: *
|
19
19
|
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT
|
20
|
-
Set-Cookie: ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=
|
20
|
+
Set-Cookie: ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=NjNzbWVlN25mUmJ4ZHd6NToxMzIwNzY0MTQxNjI4OjJkZmUwMTYwMDUwOGZlYjc4ZGRhM2Q5NThmZWZlNTA3; Expires=Sun, 23-Oct-2016 14:55:41 GMT; Path=/
|
21
21
|
Accept-Ranges: bytes
|
22
22
|
Cache-Control: max-age=7200
|
23
|
-
Expires:
|
23
|
+
Expires: Tue, 25 Oct 2011 16:52:32 GMT
|
24
24
|
Vary: User-Agent
|
25
25
|
Transfer-Encoding: chunked
|
26
26
|
Content-Type: application/json;charset=UTF-8
|
@@ -33,28 +33,28 @@ headers_hash: !map:Typhoeus::NormalizedHeaderHash
|
|
33
33
|
Transfer-Encoding: chunked
|
34
34
|
Access-Control-Allow-Origin: "*"
|
35
35
|
Content-Type: application/json;charset=UTF-8
|
36
|
-
Date:
|
36
|
+
Date: Tue, 25 Oct 2011 14:52:32 GMT
|
37
37
|
Accept-Ranges: bytes
|
38
38
|
Server: Apache/2.0.55 (Red Hat)
|
39
39
|
Set-Cookie:
|
40
|
-
- JSESSIONID=
|
41
|
-
- JSESSIONID=
|
42
|
-
- ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=
|
43
|
-
Expires:
|
40
|
+
- JSESSIONID=C4B1E16C88A6EDEE31C26E104A1D4454.web01; Path=/; Secure
|
41
|
+
- JSESSIONID=C4B1E16C88A6EDEE31C26E104A1D4454.web01; Path=/
|
42
|
+
- ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=NjNzbWVlN25mUmJ4ZHd6NToxMzIwNzY0MTQxNjI4OjJkZmUwMTYwMDUwOGZlYjc4ZGRhM2Q5NThmZWZlNTA3; Expires=Sun, 23-Oct-2016 14:55:41 GMT; Path=/
|
43
|
+
Expires: Tue, 25 Oct 2011 16:52:32 GMT
|
44
44
|
Cache-Control: max-age=7200
|
45
45
|
Accept-Charset: utf-8
|
46
46
|
http_version:
|
47
47
|
mock: false
|
48
|
-
name_lookup_time:
|
49
|
-
pretransfer_time:
|
48
|
+
name_lookup_time: 4.7e-05
|
49
|
+
pretransfer_time: 5.6e-05
|
50
50
|
request: |-
|
51
51
|
:method => :post,
|
52
|
-
:url => https://test.amiando.com/api/apiKey/
|
52
|
+
:url => https://test.amiando.com/api/apiKey/179133?version=1&apikey=0wDGphOP9KiqovK8mrCFQB6vn8a6DKzxQ0Zo9nev1OTSGebnOK&format=json,
|
53
53
|
:params => {:enabled=>false},
|
54
54
|
:headers => {"User-Agent"=>"Typhoeus - http://github.com/dbalatero/typhoeus/tree/master"}
|
55
55
|
requested_http_method:
|
56
56
|
requested_url:
|
57
57
|
start_time:
|
58
|
-
start_transfer_time: 0.
|
58
|
+
start_transfer_time: 0.140784
|
59
59
|
status_message: OK
|
60
|
-
time: 0.
|
60
|
+
time: 0.140835
|
@@ -1,26 +1,26 @@
|
|
1
1
|
--- !ruby/object:Typhoeus::Response
|
2
|
-
app_connect_time:
|
3
|
-
body: "{\"id\":
|
2
|
+
app_connect_time: 5.4e-05
|
3
|
+
body: "{\"id\":179134,\"success\":true,\"apiKey\":{\"id\":179134,\"enabled\":true,\"name\":\"wadus1\",\"identifier\":\"goePEGEozdjz4S1L\",\"key\":\"vAkR1Y5tN5s1p1GV566TriYq6dmhh7AuW7uxMwAEUvpNA4Apyz\"}}"
|
4
4
|
code: 201
|
5
|
-
connect_time:
|
5
|
+
connect_time: 5.4e-05
|
6
6
|
curl_error_message: No error
|
7
7
|
curl_return_code: 0
|
8
8
|
effective_url: https://test.amiando.com/api/apiKey/create?version=1&format=json
|
9
9
|
first_header_line: HTTP/1.1 201 Created
|
10
10
|
headers: |
|
11
11
|
HTTP/1.1 201 Created
|
12
|
-
Date:
|
12
|
+
Date: Tue, 25 Oct 2011 14:52:32 GMT
|
13
13
|
Server: Apache/2.0.55 (Red Hat)
|
14
|
-
Set-Cookie: JSESSIONID=
|
15
|
-
Set-Cookie: JSESSIONID=
|
14
|
+
Set-Cookie: JSESSIONID=8D97AA2BF2114EF413FE0C307C03F6C0.web01; Path=/; Secure
|
15
|
+
Set-Cookie: JSESSIONID=8D97AA2BF2114EF413FE0C307C03F6C0.web01; Path=/
|
16
16
|
accept-charset: utf-8
|
17
17
|
P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD CON OUR IND UNI PUR COM CNT"
|
18
18
|
Access-Control-Allow-Origin: *
|
19
19
|
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT
|
20
|
-
Set-Cookie: ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=
|
20
|
+
Set-Cookie: ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=MDBtWmI1Vk5BeXZiNWhHaDoxMzIwNzY0MTQxNzgyOjM5YWMxMmZiMDhiZTllMDNjNWYzYzBjNWEzOTBmYjY3; Expires=Sun, 23-Oct-2016 14:55:41 GMT; Path=/
|
21
21
|
Accept-Ranges: bytes
|
22
22
|
Cache-Control: max-age=7200
|
23
|
-
Expires:
|
23
|
+
Expires: Tue, 25 Oct 2011 16:52:32 GMT
|
24
24
|
Vary: User-Agent
|
25
25
|
Transfer-Encoding: chunked
|
26
26
|
Content-Type: application/json;charset=UTF-8
|
@@ -33,20 +33,20 @@ headers_hash: !map:Typhoeus::NormalizedHeaderHash
|
|
33
33
|
Transfer-Encoding: chunked
|
34
34
|
Access-Control-Allow-Origin: "*"
|
35
35
|
Content-Type: application/json;charset=UTF-8
|
36
|
-
Date:
|
36
|
+
Date: Tue, 25 Oct 2011 14:52:32 GMT
|
37
37
|
Accept-Ranges: bytes
|
38
38
|
Server: Apache/2.0.55 (Red Hat)
|
39
39
|
Set-Cookie:
|
40
|
-
- JSESSIONID=
|
41
|
-
- JSESSIONID=
|
42
|
-
- ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=
|
43
|
-
Expires:
|
40
|
+
- JSESSIONID=8D97AA2BF2114EF413FE0C307C03F6C0.web01; Path=/; Secure
|
41
|
+
- JSESSIONID=8D97AA2BF2114EF413FE0C307C03F6C0.web01; Path=/
|
42
|
+
- ANONYMOUS_HASHED_REMEMBER_ME_COOKIE_KEY=MDBtWmI1Vk5BeXZiNWhHaDoxMzIwNzY0MTQxNzgyOjM5YWMxMmZiMDhiZTllMDNjNWYzYzBjNWEzOTBmYjY3; Expires=Sun, 23-Oct-2016 14:55:41 GMT; Path=/
|
43
|
+
Expires: Tue, 25 Oct 2011 16:52:32 GMT
|
44
44
|
Cache-Control: max-age=7200
|
45
45
|
Accept-Charset: utf-8
|
46
46
|
http_version:
|
47
47
|
mock: false
|
48
|
-
name_lookup_time:
|
49
|
-
pretransfer_time:
|
48
|
+
name_lookup_time: 5.4e-05
|
49
|
+
pretransfer_time: 6.2e-05
|
50
50
|
request: |-
|
51
51
|
:method => :post,
|
52
52
|
:url => https://test.amiando.com/api/apiKey/create?version=1&format=json,
|
@@ -55,6 +55,6 @@ request: |-
|
|
55
55
|
requested_http_method:
|
56
56
|
requested_url:
|
57
57
|
start_time:
|
58
|
-
start_transfer_time: 0.
|
58
|
+
start_transfer_time: 0.101058
|
59
59
|
status_message: Created
|
60
|
-
time: 0.
|
60
|
+
time: 0.101107
|