omnicontacts 0.2.0 → 0.2.1
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.lock
CHANGED
data/README.md
CHANGED
@@ -70,6 +70,33 @@ Yahoo requires you to configure the Permissions your application requires. Make
|
|
70
70
|
Hotmail does not accept requests from localhost. This can be quite annoying during development, but unfortunately this is the way it is.
|
71
71
|
Hotmail presents another "peculiar" feature. Their API returns a Contact object, which does not contain an e-mail field! However, if the contact has either name, family name or both set to null, than there is a field called name which does contain the e-mail address. To summarize, a Hotmail contact will only be returned if the name field contains a valid e-mail address, otherwise it will be skipped. Another consequence is that OmniContacts can provide contacts with only the `:email` key set.
|
72
72
|
|
73
|
+
## Integration Testing
|
74
|
+
|
75
|
+
You can enable test mode like this:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
OmniContacts.integration_test.enabled = true
|
79
|
+
```
|
80
|
+
|
81
|
+
In this way all requests to `/omnicontacts/provider` will be redirected automatically to `/omnicontacts/provider/callback`.
|
82
|
+
|
83
|
+
The `mock` method allows to configure per-provider the result to return:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
OmniContacts.integration_test.mock(:provider_name, :email => "user@example.com")
|
87
|
+
```
|
88
|
+
|
89
|
+
You can either pass a single hash or an array of hashes. If you pass a string, an error will be triggered with subsequent redirect to `/contacts/failure?error_message=internal_error`
|
90
|
+
|
91
|
+
Follows a full example of an integration test:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
OmniContacts.integration_test.enabled = true
|
95
|
+
OmniContacts.integration_test.mock(:gmail, :email => "user@example.com")
|
96
|
+
visit '/contacts/gmail'
|
97
|
+
page.should have_content("user@example.com")
|
98
|
+
```
|
99
|
+
|
73
100
|
## License
|
74
101
|
|
75
102
|
Copyright (c) 2012 Diego81
|
data/lib/omnicontacts.rb
CHANGED
@@ -109,7 +109,7 @@ module OmniContacts
|
|
109
109
|
encoded_method = encode(method.upcase)
|
110
110
|
encoded_url = encode(url)
|
111
111
|
# params must be in alphabetical order
|
112
|
-
encoded_params = encode(to_query_string(params.sort))
|
112
|
+
encoded_params = encode(to_query_string(params.sort { |x, y| x.to_s <=> y.to_s }))
|
113
113
|
base_string = encoded_method + '&' + encoded_url + '&' + encoded_params
|
114
114
|
key = encode(consumer_secret) + '&' + secret
|
115
115
|
hmac_sha1 = OpenSSL::HMAC.digest('sha1', key, base_string)
|
@@ -5,7 +5,12 @@ describe OmniContacts::HTTPUtils do
|
|
5
5
|
|
6
6
|
describe "to_query_string" do
|
7
7
|
it "should create a query string from a map" do
|
8
|
-
OmniContacts::HTTPUtils.to_query_string(:name => "john", :surname => "doe")
|
8
|
+
result = OmniContacts::HTTPUtils.to_query_string(:name => "john", :surname => "doe")
|
9
|
+
if result.match(/^name/)
|
10
|
+
result.should eq("name=john&surname=doe")
|
11
|
+
else
|
12
|
+
result.should eq("surname=doe&name=john")
|
13
|
+
end
|
9
14
|
end
|
10
15
|
end
|
11
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnicontacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|