gravatar-ultimate 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +13 -0
- data/.travis.yml +16 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/README.rdoc +19 -25
- data/Rakefile +9 -38
- data/environments/rails-2.3/README +243 -0
- data/environments/rails-2.3/Rakefile +10 -0
- data/environments/rails-2.3/app/controllers/application_controller.rb +10 -0
- data/environments/rails-2.3/app/helpers/application_helper.rb +3 -0
- data/environments/rails-2.3/config/boot.rb +114 -0
- data/environments/rails-2.3/config/database.yml +22 -0
- data/environments/rails-2.3/config/environment.rb +43 -0
- data/environments/rails-2.3/config/environments/development.rb +17 -0
- data/environments/rails-2.3/config/environments/production.rb +28 -0
- data/environments/rails-2.3/config/environments/test.rb +28 -0
- data/environments/rails-2.3/config/initializers/backtrace_silencers.rb +7 -0
- data/environments/rails-2.3/config/initializers/cookie_verification_secret.rb +7 -0
- data/environments/rails-2.3/config/initializers/inflections.rb +10 -0
- data/environments/rails-2.3/config/initializers/mime_types.rb +5 -0
- data/environments/rails-2.3/config/initializers/new_rails_defaults.rb +21 -0
- data/environments/rails-2.3/config/initializers/session_store.rb +15 -0
- data/environments/rails-2.3/config/locales/en.yml +5 -0
- data/environments/rails-2.3/config/routes.rb +43 -0
- data/environments/rails-2.3/db/seeds.rb +7 -0
- data/environments/rails-2.3/doc/README_FOR_APP +2 -0
- data/environments/rails-2.3/public/404.html +30 -0
- data/environments/rails-2.3/public/422.html +30 -0
- data/environments/rails-2.3/public/500.html +30 -0
- data/environments/rails-2.3/public/favicon.ico +0 -0
- data/environments/rails-2.3/public/images/rails.png +0 -0
- data/environments/rails-2.3/public/index.html +275 -0
- data/environments/rails-2.3/public/javascripts/application.js +2 -0
- data/environments/rails-2.3/public/javascripts/controls.js +963 -0
- data/environments/rails-2.3/public/javascripts/dragdrop.js +973 -0
- data/environments/rails-2.3/public/javascripts/effects.js +1128 -0
- data/environments/rails-2.3/public/javascripts/prototype.js +4320 -0
- data/environments/rails-2.3/public/robots.txt +5 -0
- data/environments/rails-2.3/script/about +4 -0
- data/environments/rails-2.3/script/console +3 -0
- data/environments/rails-2.3/script/dbconsole +3 -0
- data/environments/rails-2.3/script/destroy +3 -0
- data/environments/rails-2.3/script/generate +3 -0
- data/environments/rails-2.3/script/performance/benchmarker +3 -0
- data/environments/rails-2.3/script/performance/profiler +3 -0
- data/environments/rails-2.3/script/plugin +3 -0
- data/environments/rails-2.3/script/runner +3 -0
- data/environments/rails-2.3/script/server +3 -0
- data/environments/rails-2.3/test/performance/browsing_test.rb +9 -0
- data/environments/rails-2.3/test/test_helper.rb +38 -0
- data/environments/rails-3.1/.gitignore +15 -0
- data/environments/rails-3.1/README +261 -0
- data/environments/rails-3.1/Rakefile +7 -0
- data/environments/rails-3.1/app/assets/images/rails.png +0 -0
- data/environments/rails-3.1/app/assets/javascripts/application.js +9 -0
- data/environments/rails-3.1/app/assets/stylesheets/application.css +7 -0
- data/environments/rails-3.1/app/controllers/application_controller.rb +3 -0
- data/environments/rails-3.1/app/helpers/application_helper.rb +2 -0
- data/environments/rails-3.1/app/mailers/.gitkeep +0 -0
- data/environments/rails-3.1/app/models/.gitkeep +0 -0
- data/environments/rails-3.1/app/views/layouts/application.html.erb +14 -0
- data/environments/rails-3.1/config.ru +4 -0
- data/environments/rails-3.1/config/application.rb +48 -0
- data/environments/rails-3.1/config/boot.rb +6 -0
- data/environments/rails-3.1/config/database.yml +25 -0
- data/environments/rails-3.1/config/environment.rb +5 -0
- data/environments/rails-3.1/config/environments/development.rb +30 -0
- data/environments/rails-3.1/config/environments/production.rb +60 -0
- data/environments/rails-3.1/config/environments/test.rb +39 -0
- data/environments/rails-3.1/config/initializers/backtrace_silencers.rb +7 -0
- data/environments/rails-3.1/config/initializers/inflections.rb +10 -0
- data/environments/rails-3.1/config/initializers/mime_types.rb +5 -0
- data/environments/rails-3.1/config/initializers/secret_token.rb +7 -0
- data/environments/rails-3.1/config/initializers/session_store.rb +8 -0
- data/environments/rails-3.1/config/initializers/wrap_parameters.rb +14 -0
- data/environments/rails-3.1/config/locales/en.yml +5 -0
- data/environments/rails-3.1/config/routes.rb +58 -0
- data/environments/rails-3.1/db/seeds.rb +7 -0
- data/environments/rails-3.1/doc/README_FOR_APP +2 -0
- data/environments/rails-3.1/lib/assets/.gitkeep +0 -0
- data/environments/rails-3.1/lib/tasks/.gitkeep +0 -0
- data/environments/rails-3.1/public/404.html +26 -0
- data/environments/rails-3.1/public/422.html +26 -0
- data/environments/rails-3.1/public/500.html +26 -0
- data/environments/rails-3.1/public/favicon.ico +0 -0
- data/environments/rails-3.1/public/index.html +241 -0
- data/environments/rails-3.1/public/robots.txt +5 -0
- data/environments/rails-3.1/script/rails +6 -0
- data/environments/rails-3.1/test/fixtures/.gitkeep +0 -0
- data/environments/rails-3.1/test/functional/.gitkeep +0 -0
- data/environments/rails-3.1/test/integration/.gitkeep +0 -0
- data/environments/rails-3.1/test/performance/browsing_test.rb +12 -0
- data/environments/rails-3.1/test/test_helper.rb +13 -0
- data/environments/rails-3.1/test/unit/.gitkeep +0 -0
- data/environments/rails-3.1/vendor/assets/stylesheets/.gitkeep +0 -0
- data/environments/rails-3.1/vendor/plugins/.gitkeep +0 -0
- data/environments/rails.rb +26 -0
- data/gemfiles/rails-2.3.14 +5 -0
- data/gemfiles/rails-2.3.14.lock +55 -0
- data/gemfiles/rails-3.1.3 +5 -0
- data/gemfiles/rails-3.1.3.lock +110 -0
- data/gravatar-ultimate.gemspec +13 -53
- data/lib/gravatar.rb +68 -30
- data/lib/gravatar/cache.rb +27 -21
- data/lib/gravatar/dependencies.rb +1 -18
- data/lib/gravatar/test_case.rb +105 -0
- data/lib/gravatar/version.rb +8 -0
- data/spec/fixtures/image.jpg +0 -0
- data/spec/fixtures/responses/grav.addresses +24 -0
- data/spec/fixtures/responses/grav.deleteUserimage +18 -0
- data/spec/fixtures/responses/grav.exists +20 -0
- data/spec/fixtures/responses/grav.exists.invalid +20 -0
- data/spec/fixtures/responses/grav.exists.multiple_invalid +21 -0
- data/spec/fixtures/responses/grav.removeImage +20 -0
- data/spec/fixtures/responses/grav.saveData +18 -0
- data/spec/fixtures/responses/grav.saveUrl +18 -0
- data/spec/fixtures/responses/grav.test +22 -0
- data/spec/fixtures/responses/grav.useUserimage +20 -0
- data/spec/fixtures/responses/grav.userimages +27 -0
- data/spec/lib/gravatar/cache_setup_spec.rb +2 -0
- data/spec/lib/gravatar/{cache_and_logger_spec.rb → cache_spec.rb} +12 -1
- data/spec/lib/gravatar/test_case_spec.rb +40 -0
- data/spec/lib/gravatar_spec.rb +97 -61
- data/spec/spec_helper.rb +37 -9
- metadata +208 -38
- data/VERSION +0 -1
- data/spec/lib/gravatar/dependencies_spec.rb +0 -33
data/spec/fixtures/image.jpg
CHANGED
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 17:03:38 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326992618%7Ce99170b24c4e0980266341fe9624bc8c; expires=Fri, 30-Jan-2054 10:07:16 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 580
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>gravatartest123@gmail.com</name><value><struct>
|
16
|
+
<member><name>rating</name><value><int>0</int></value></member>
|
17
|
+
<member><name>userimage</name><value><string>fed25d74d58274248095ca6b2fe2beff</string></value></member>
|
18
|
+
<member><name>userimage_url</name><value><string>http://en.gravatar.com/userimage/30721149/fed25d74d58274248095ca6b2fe2beff.jpg</string></value></member>
|
19
|
+
</struct></value></member>
|
20
|
+
</struct>
|
21
|
+
</value>
|
22
|
+
</param>
|
23
|
+
</params>
|
24
|
+
</methodResponse>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 18:24:30 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326997469%7C42587efbd6b763ee850c6df8d4773dce; expires=Fri, 30-Jan-2054 12:48:59 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 163
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<boolean>1</boolean>
|
15
|
+
</value>
|
16
|
+
</param>
|
17
|
+
</params>
|
18
|
+
</methodResponse>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 18:37:10 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326998230%7Cb89ab5cf21fa3ffa20f17df81a3b12f5; expires=Fri, 30-Jan-2054 13:14:20 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 253
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>ef23bdc1f1fb9e3f46843a00e5832d98</name><value><int>1</int></value></member>
|
16
|
+
</struct>
|
17
|
+
</value>
|
18
|
+
</param>
|
19
|
+
</params>
|
20
|
+
</methodResponse>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 17:22:37 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326993757%7C72540173b0631c51e85fc01dca61e168; expires=Fri, 30-Jan-2054 10:45:14 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 253
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>719bc43b2d4ded25e0164af83484f8f9</name><value><int>0</int></value></member>
|
16
|
+
</struct>
|
17
|
+
</value>
|
18
|
+
</param>
|
19
|
+
</params>
|
20
|
+
</methodResponse>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 17:33:37 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326994417%7C848cddd19297979345219d34a7a6a018; expires=Fri, 30-Jan-2054 11:07:14 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 345
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>bdc68bf1ad91e719bf9e9527158b1aa6</name><value><int>0</int></value></member>
|
16
|
+
<member><name>09abeab96651fd6be4ae2d3a6f3140ee</name><value><int>0</int></value></member>
|
17
|
+
</struct>
|
18
|
+
</value>
|
19
|
+
</param>
|
20
|
+
</params>
|
21
|
+
</methodResponse>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 18:01:15 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326996075%7C14852bd9e471836f3694c45941fe4786; expires=Fri, 30-Jan-2054 12:02:30 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 254
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>gravatartest123@gmail.com</name><value><boolean>1</boolean></value></member>
|
16
|
+
</struct>
|
17
|
+
</value>
|
18
|
+
</param>
|
19
|
+
</params>
|
20
|
+
</methodResponse>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 17:36:21 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326994581%7C6c6de4cd3ca0d618837a95c62d3040c1; expires=Fri, 30-Jan-2054 11:12:42 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 192
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<string>3fe9302284aa75e9916f364a3f7989e4</string>
|
15
|
+
</value>
|
16
|
+
</param>
|
17
|
+
</params>
|
18
|
+
</methodResponse>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 17:00:43 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326992442%7C26b54ee039346e757eddd969dfa13bc1; expires=Fri, 30-Jan-2054 10:01:24 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 192
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<string>fed25d74d58274248095ca6b2fe2beff</string>
|
15
|
+
</value>
|
16
|
+
</param>
|
17
|
+
</params>
|
18
|
+
</methodResponse>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 15:40:29 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326987629%7Cc15a3b35dc03e97ba2b8a22f523579c8; expires=Fri, 30-Jan-2054 07:20:58 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 397
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>password</name><value><string>censored</string></value></member>
|
16
|
+
<member><name>greeting</name><value><string>hello</string></value></member>
|
17
|
+
<member><name>response</name><value><int>1326382829</int></value></member>
|
18
|
+
</struct>
|
19
|
+
</value>
|
20
|
+
</param>
|
21
|
+
</params>
|
22
|
+
</methodResponse>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 17:59:53 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326995990%7C75ab09270934a8e66a014c71b48ff416; expires=Fri, 30-Jan-2054 11:59:40 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 254
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>gravatartest123@gmail.com</name><value><boolean>1</boolean></value></member>
|
16
|
+
</struct>
|
17
|
+
</value>
|
18
|
+
</param>
|
19
|
+
</params>
|
20
|
+
</methodResponse>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 12 Jan 2012 18:35:10 GMT
|
4
|
+
Content-Type: text/xml;charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: gravatar=gravatartest1234%7C1326998110%7C19cb75eb75a09f90a26167c872508d90; expires=Fri, 30-Jan-2054 13:10:20 GMT; path=/; domain=.gravatar.com
|
7
|
+
Content-Length: 677
|
8
|
+
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<methodResponse>
|
11
|
+
<params>
|
12
|
+
<param>
|
13
|
+
<value>
|
14
|
+
<struct>
|
15
|
+
<member><name>fed25d74d58274248095ca6b2fe2beff</name><value><array><data>
|
16
|
+
<value><string>0</string></value>
|
17
|
+
<value><string>http://en.gravatar.com/userimage/30721149/fed25d74d58274248095ca6b2fe2beff.jpg</string></value>
|
18
|
+
</data></array></value></member>
|
19
|
+
<member><name>3fe9302284aa75e9916f364a3f7989e4</name><value><array><data>
|
20
|
+
<value><string>0</string></value>
|
21
|
+
<value><string>http://en.gravatar.com/userimage/30721149/3fe9302284aa75e9916f364a3f7989e4.jpg</string></value>
|
22
|
+
</data></array></value></member>
|
23
|
+
</struct>
|
24
|
+
</value>
|
25
|
+
</param>
|
26
|
+
</params>
|
27
|
+
</methodResponse>
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Gravatar::Cache do
|
4
4
|
subject { Gravatar::Cache.new(new_cache, 30.minutes, "gravatar-specs") }
|
5
|
-
|
5
|
+
|
6
6
|
context "with a nonexistent cache item" do
|
7
7
|
it "should be expired" do
|
8
8
|
subject.expired?(:nothing).should be_true
|
@@ -28,6 +28,13 @@ describe Gravatar::Cache do
|
|
28
28
|
it "should not be expired" do
|
29
29
|
subject.expired?(:nothing).should be_false
|
30
30
|
end
|
31
|
+
|
32
|
+
context "after clearing the cache" do
|
33
|
+
before { subject.clear! }
|
34
|
+
it "should be nil" do
|
35
|
+
subject.call(:nothing) { 2 }.should == 2
|
36
|
+
end
|
37
|
+
end
|
31
38
|
|
32
39
|
it "should not fire the block" do
|
33
40
|
subject.call(:nothing) { @fired = 1 }
|
@@ -80,6 +87,10 @@ describe Gravatar::Cache do
|
|
80
87
|
proc { subject.call(:nothing) { raise "something bad happened" } }.should raise_error(RuntimeError)
|
81
88
|
end
|
82
89
|
end
|
90
|
+
|
91
|
+
it "should provide access to the cached copy" do
|
92
|
+
subject.cached(:nothing).should == 1
|
93
|
+
end
|
83
94
|
end
|
84
95
|
|
85
96
|
it "should return the block value" do
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gravatar::TestCase do
|
4
|
+
before { auth_with :password => '123' }
|
5
|
+
|
6
|
+
it "should have default email address" do
|
7
|
+
self.class.default_email.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise errors instead of logging them" do
|
11
|
+
grav.rescue_errors.should be_false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should use mock responses" do
|
15
|
+
mock_response 'grav.test'
|
16
|
+
test(:greeting => 'hello').should have_key(:response)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should nil out mock responses after use" do
|
20
|
+
mock_response 'grav.test'
|
21
|
+
test(:greeting => 'hello').should have_key(:response)
|
22
|
+
mock_response.should be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should remove mock responses from FakeWeb after use" do
|
26
|
+
mock_response 'grav.test'
|
27
|
+
test(:greeting => 'hello').should have_key(:response)
|
28
|
+
FakeWeb.should_not be_registered_uri(:post, grav.url)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not generate grav more than once" do
|
32
|
+
grav.should be grav
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should replace old mock responses with nil" do
|
36
|
+
mock_response 'grav.test'
|
37
|
+
mock_response nil
|
38
|
+
mock_response.should be_nil
|
39
|
+
end
|
40
|
+
end
|
data/spec/lib/gravatar_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Gravatar do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
default_email $credentials[:primary_email]
|
5
|
+
before { grav.auth_with(:password => $credentials[:password]) }
|
6
|
+
before { mock_response nil }
|
7
|
+
|
8
8
|
it "should allow setting cache duration by instance" do
|
9
|
-
grav = Gravatar.new($credentials[:primary_email])
|
10
9
|
grav.cache_duration = 10.minutes
|
11
10
|
grav.cache_duration.should == 10.minutes
|
12
11
|
end
|
@@ -18,124 +17,161 @@ describe Gravatar do
|
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should require :email" do
|
21
|
-
proc {
|
20
|
+
proc { Gravatar.new(nil, :rescue_errors => false) }.should raise_error(ArgumentError)
|
22
21
|
end
|
23
22
|
|
24
23
|
context "given :email and :key" do
|
25
|
-
|
24
|
+
before { grav $credentials[:primary_email], $credentials }
|
26
25
|
|
27
26
|
context "varying image ratings" do
|
28
27
|
[:g, :pg, :r, :x].each do |rating|
|
29
28
|
it "should save #{rating}-rated URLs and delete them" do
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
mock_response "grav.saveUrl"
|
30
|
+
save_url!(rating, "https://github.com/sinisterchipmunk/gravatar/raw/master/spec/fixtures/image.jpg").should ==
|
31
|
+
"fed25d74d58274248095ca6b2fe2beff"
|
32
|
+
|
33
|
+
mock_response "grav.deleteUserimage"
|
34
|
+
delete_user_image!("fed25d74d58274248095ca6b2fe2beff").should == true
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should raise an ArgumentError given an invalid rating" do
|
37
|
-
proc {
|
39
|
+
proc { save_url!(:invalid_rating, "https://github.com/sinisterchipmunk/gravatar/raw/master/spec/fixtures/image.jpg") }.should \
|
38
40
|
raise_error(ArgumentError)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
44
|
it "should return addresses" do
|
43
|
-
|
45
|
+
mock_response 'grav.addresses'
|
46
|
+
addresses.should_not be_empty
|
44
47
|
end
|
45
48
|
|
46
49
|
it "should test successfully" do
|
47
|
-
|
50
|
+
mock_response 'grav.test'
|
51
|
+
test(:greeting => 'hello').should have_key(:response)
|
48
52
|
end
|
49
53
|
|
50
54
|
it "should save URLs and delete them" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
subject.delete_user_image!("23f086a793459fa25aab280054fec1b2")
|
68
|
-
rescue XMLRPC::FaultException
|
69
|
-
end
|
55
|
+
mock_response 'grav.saveUrl'
|
56
|
+
save_url!(:g, "https://github.com/sinisterchipmunk/gravatar/raw/master/spec/fixtures/image.jpg").should == "fed25d74d58274248095ca6b2fe2beff"
|
57
|
+
|
58
|
+
mock_response 'grav.deleteUserimage'
|
59
|
+
delete_user_image!("fed25d74d58274248095ca6b2fe2beff").should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with a user image attached" do
|
63
|
+
before do
|
64
|
+
mock_response 'grav.saveData'
|
65
|
+
@image_hash = save_data!(:g, mock_image_data)
|
66
|
+
|
67
|
+
mock_response 'grav.useUserimage'
|
68
|
+
use_user_image!(@image_hash, $credentials[:email])
|
69
|
+
|
70
|
+
@image_hash = 'fed25d74d58274248095ca6b2fe2beff'
|
70
71
|
end
|
71
|
-
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
it "should save and delete images and associate/unassociate them with accounts" do
|
74
|
+
mock_response 'grav.removeImage'
|
75
|
+
remove_image!($credentials[:email]).should == { $credentials[:email] => true }
|
76
|
+
|
77
|
+
mock_response 'grav.deleteUserimage'
|
78
|
+
delete_user_image!('image_hash').should == true
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return user images" do
|
82
|
+
mock_response 'grav.userimages'
|
83
|
+
user_images.should include({@image_hash=>
|
84
|
+
[:g, "http://en.gravatar.com/userimage/30721149/#{@image_hash}.jpg"]})
|
85
|
+
end
|
77
86
|
|
78
|
-
|
79
|
-
|
87
|
+
it "should determine that the email has an avatar" do
|
88
|
+
mock_response 'grav.exists'
|
89
|
+
exists?.should be_true
|
90
|
+
end
|
80
91
|
end
|
81
92
|
|
82
|
-
it "should determine that a fake
|
83
|
-
|
93
|
+
it "should determine that a fake email does not have an avatar" do
|
94
|
+
mock_response 'grav.exists.invalid'
|
95
|
+
exists?("not-even-a-valid-email").should be_false
|
84
96
|
end
|
85
97
|
|
86
|
-
it "should determine that multiple fake
|
87
|
-
|
98
|
+
it "should determine that multiple fake emails do not have avatars" do
|
99
|
+
mock_response 'grav.exists.multiple_invalid'
|
100
|
+
exists?("invalid-1", "invalid-2").should == { "invalid-1" => false, "invalid-2" => false }
|
88
101
|
end
|
89
102
|
end
|
90
103
|
|
91
104
|
context "given :email" do
|
92
|
-
|
93
|
-
|
105
|
+
before { grav $credentials[:email] }
|
106
|
+
|
94
107
|
it "should not raise an error" do
|
95
|
-
proc {
|
108
|
+
proc { grav }.should_not raise_error(ArgumentError)
|
96
109
|
end
|
97
110
|
|
98
111
|
it "should return email_hash" do
|
99
|
-
|
112
|
+
email_hash.should == "ef23bdc1f1fb9e3f46843a00e5832d98"
|
100
113
|
end
|
101
114
|
|
102
115
|
it "should return gravatar image_url" do
|
103
|
-
|
116
|
+
image_url.should == "http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98"
|
104
117
|
end
|
105
118
|
|
106
|
-
|
107
|
-
|
119
|
+
context "with a user image attached" do
|
120
|
+
before do
|
121
|
+
grav $credentials[:email], $credentials
|
122
|
+
|
123
|
+
mock_response 'grav.saveData'
|
124
|
+
@image_hash = save_data!(:g, mock_image_data)
|
125
|
+
|
126
|
+
mock_response 'grav.useUserimage'
|
127
|
+
use_user_image!(@image_hash, $credentials[:email])
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should return gravitar image data" do
|
131
|
+
Digest::MD5.hexdigest(grav.image_data).should == Digest::MD5.hexdigest(mock_image_data)
|
132
|
+
end
|
108
133
|
end
|
109
134
|
|
110
135
|
it "should return gravatar image_url with SSL" do
|
111
|
-
|
136
|
+
image_url(:ssl => true).should == "https://secure.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98"
|
112
137
|
end
|
113
138
|
|
114
139
|
it "should return gravatar image_url with size" do
|
115
|
-
|
140
|
+
image_url(:s => 512).should == "http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?s=512"
|
141
|
+
image_url(:size => 512).should == "http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?size=512"
|
116
142
|
end
|
117
143
|
|
118
144
|
it "should return gravatar image_url with rating" do
|
119
|
-
|
145
|
+
image_url(:r => 'pg').should == "http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?r=pg"
|
146
|
+
image_url(:rating => 'pg').should == "http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?rating=pg"
|
120
147
|
end
|
121
148
|
|
122
149
|
it "should return gravatar image_url with file type" do
|
123
|
-
|
150
|
+
image_url(:filetype => 'png').should == "http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98.png"
|
124
151
|
end
|
125
152
|
|
126
153
|
it "should return gravatar image_url with default image" do
|
127
|
-
|
128
|
-
"http://www.gravatar.com/avatar/
|
154
|
+
image_url(:d => "http://example.com/images/example.jpg").should ==
|
155
|
+
"http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?d=http%3A%2F%2Fexample.com%2Fimages%2Fexample.jpg"
|
156
|
+
image_url(:default => "http://example.com/images/example.jpg").should ==
|
157
|
+
"http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?default=http%3A%2F%2Fexample.com%2Fimages%2Fexample.jpg"
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should return gravatar image_url with forcedefault" do
|
161
|
+
image_url(:f => :identicon).should ==
|
162
|
+
"http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?f=identicon"
|
163
|
+
image_url(:forcedefault => :identicon).should ==
|
164
|
+
"http://www.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?forcedefault=identicon"
|
129
165
|
end
|
130
166
|
|
131
167
|
it "should return gravatar image_url with SSL and default and size and rating" do
|
132
168
|
combinations = %w(
|
133
|
-
https://secure.gravatar.com/avatar/
|
134
|
-
https://secure.gravatar.com/avatar/
|
135
|
-
https://secure.gravatar.com/avatar/
|
136
|
-
https://secure.gravatar.com/avatar/
|
169
|
+
https://secure.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?default=identicon&size=80&rating=g
|
170
|
+
https://secure.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?size=80&rating=g&default=identicon
|
171
|
+
https://secure.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?size=80&default=identicon&rating=g
|
172
|
+
https://secure.gravatar.com/avatar/ef23bdc1f1fb9e3f46843a00e5832d98?rating=g&size=80&default=identicon
|
137
173
|
)
|
138
|
-
combinations.should include(
|
174
|
+
combinations.should include(image_url(:ssl => true, :default => "identicon", :size => 80, :rating => :g))
|
139
175
|
end
|
140
176
|
end
|
141
177
|
end
|