disqussion 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +80 -0
- data/HISTORY.mkd +5 -0
- data/LICENSE.mkd +20 -0
- data/README.mkd +139 -0
- data/Rakefile +23 -0
- data/disqussion.gemspec +37 -0
- data/lib/disqussion/api.rb +21 -0
- data/lib/disqussion/client/.DS_Store +0 -0
- data/lib/disqussion/client/applications.rb +20 -0
- data/lib/disqussion/client/blacklists.rb +4 -0
- data/lib/disqussion/client/categories.rb +4 -0
- data/lib/disqussion/client/exports.rb +4 -0
- data/lib/disqussion/client/forums.rb +122 -0
- data/lib/disqussion/client/imports.rb +4 -0
- data/lib/disqussion/client/posts.rb +217 -0
- data/lib/disqussion/client/reactions.rb +79 -0
- data/lib/disqussion/client/reports.rb +4 -0
- data/lib/disqussion/client/threads.rb +199 -0
- data/lib/disqussion/client/trends.rb +23 -0
- data/lib/disqussion/client/users.rb +103 -0
- data/lib/disqussion/client/utils.rb +90 -0
- data/lib/disqussion/client/whitelists.rb +4 -0
- data/lib/disqussion/client.rb +46 -0
- data/lib/disqussion/configuration.rb +121 -0
- data/lib/disqussion/connection.rb +36 -0
- data/lib/disqussion/error.rb +51 -0
- data/lib/disqussion/request.rb +38 -0
- data/lib/disqussion/version.rb +3 -0
- data/lib/disqussion/view_helpers.rb +9 -0
- data/lib/disqussion/widget.rb +183 -0
- data/lib/disqussion.rb +25 -0
- data/lib/faraday/response/raise_http_4xx.rb +41 -0
- data/lib/faraday/response/raise_http_5xx.rb +20 -0
- data/spec/disqussion/api_spec.rb +63 -0
- data/spec/disqussion/client/.DS_Store +0 -0
- data/spec/disqussion/client/applications_spec.rb +24 -0
- data/spec/disqussion/client/forums_spec.rb +80 -0
- data/spec/disqussion/client/posts_spec.rb +154 -0
- data/spec/disqussion/client/reactions_spec.rb +63 -0
- data/spec/disqussion/client/threads_spec.rb +128 -0
- data/spec/disqussion/client/trends_spec.rb +24 -0
- data/spec/disqussion/client/users_spec.rb +33 -0
- data/spec/disqussion/client_spec.rb +15 -0
- data/spec/disqussion_spec.rb +101 -0
- data/spec/faraday/response_spec.rb +30 -0
- data/spec/fixtures/applications/listUsage.json +129 -0
- data/spec/fixtures/forums/create.json +12 -0
- data/spec/fixtures/forums/details.json +12 -0
- data/spec/fixtures/forums/listCategories.json +21 -0
- data/spec/fixtures/forums/listPosts.json +859 -0
- data/spec/fixtures/forums/listThreads.json +533 -0
- data/spec/fixtures/posts/approve.json +6 -0
- data/spec/fixtures/posts/create.json +6 -0
- data/spec/fixtures/posts/details.json +35 -0
- data/spec/fixtures/posts/highlight.json +6 -0
- data/spec/fixtures/posts/list.json +247 -0
- data/spec/fixtures/posts/remove.json +6 -0
- data/spec/fixtures/posts/report.json +6 -0
- data/spec/fixtures/posts/restore.json +6 -0
- data/spec/fixtures/posts/spam.json +6 -0
- data/spec/fixtures/posts/unhighlight.json +6 -0
- data/spec/fixtures/posts/vote.json +6 -0
- data/spec/fixtures/reactions/domains.json +4 -0
- data/spec/fixtures/reactions/ips.json +131 -0
- data/spec/fixtures/reactions/threads.json +4 -0
- data/spec/fixtures/reactions/users.json +124 -0
- data/spec/fixtures/threads/close.json +4 -0
- data/spec/fixtures/threads/create.json +22 -0
- data/spec/fixtures/threads/details.json +24 -0
- data/spec/fixtures/threads/list.json +531 -0
- data/spec/fixtures/threads/listMostLiked.json +530 -0
- data/spec/fixtures/threads/listPosts.json +87 -0
- data/spec/fixtures/threads/open.json +8 -0
- data/spec/fixtures/threads/remove.json +4 -0
- data/spec/fixtures/threads/restore.json +4 -0
- data/spec/fixtures/threads/vote.json +4 -0
- data/spec/fixtures/trends/listTreads.json +283 -0
- data/spec/fixtures/users/details.json +19 -0
- data/spec/fixtures/users/follow.json +4 -0
- data/spec/helper.rb +47 -0
- metadata +348 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion do
|
4
|
+
after do
|
5
|
+
Disqussion.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
context "when delegating to a client" do
|
9
|
+
# before do
|
10
|
+
# stub_get("users/details.json").
|
11
|
+
# with(:query => {:"user:username" => "the88"}).
|
12
|
+
# to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# it "should get the correct resource" do
|
16
|
+
# Disqussion.user_timeline('the88')
|
17
|
+
# a_get("users/details.json").
|
18
|
+
# with(:query => {:"user:username" => "the88"}).
|
19
|
+
# should have_been_made
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# it "should return the same results as a client" do
|
23
|
+
# Disqussion.user_timeline('the88').should == Disqussion::Client.new.user_timeline('the88')
|
24
|
+
# end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.respond_to?' do
|
28
|
+
it 'takes an optional include private argument' do
|
29
|
+
Disqussion.respond_to?(:client, true).should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".client" do
|
34
|
+
it "should be a Disqussion::Client" do
|
35
|
+
Disqussion.client.should be_a Disqussion::Client
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".adapter" do
|
40
|
+
it "should return the default adapter" do
|
41
|
+
Disqussion.adapter.should == Disqussion::Configuration::DEFAULT_ADAPTER
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".adapter=" do
|
46
|
+
it "should set the adapter" do
|
47
|
+
Disqussion.adapter = :typhoeus
|
48
|
+
Disqussion.adapter.should == :typhoeus
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe ".endpoint" do
|
53
|
+
it "should return the default endpoint" do
|
54
|
+
Disqussion.endpoint.should == Disqussion::Configuration::DEFAULT_ENDPOINT
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".endpoint=" do
|
59
|
+
it "should set the endpoint" do
|
60
|
+
Disqussion.endpoint = 'http://tumblr.com/'
|
61
|
+
Disqussion.endpoint.should == 'http://tumblr.com/'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".format" do
|
66
|
+
it "should return the default format" do
|
67
|
+
Disqussion.format.should == Disqussion::Configuration::DEFAULT_FORMAT
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe ".format=" do
|
72
|
+
it "should set the format" do
|
73
|
+
Disqussion.format = 'xml'
|
74
|
+
Disqussion.format.should == 'xml'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".user_agent" do
|
79
|
+
it "should return the default user agent" do
|
80
|
+
Disqussion.user_agent.should == Disqussion::Configuration::DEFAULT_USER_AGENT
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ".user_agent=" do
|
85
|
+
it "should set the user_agent" do
|
86
|
+
Disqussion.user_agent = 'Custom User Agent'
|
87
|
+
Disqussion.user_agent.should == 'Custom User Agent'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe ".configure" do
|
92
|
+
Disqussion::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
93
|
+
it "should set the #{key}" do
|
94
|
+
Disqussion.configure do |config|
|
95
|
+
config.send("#{key}=", key)
|
96
|
+
Disqussion.send(key).should == key
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Faraday::Response do
|
4
|
+
before do
|
5
|
+
@client = Disqussion::Client.users
|
6
|
+
end
|
7
|
+
|
8
|
+
{
|
9
|
+
400 => Disqussion::BadRequest,
|
10
|
+
401 => Disqussion::Unauthorized,
|
11
|
+
403 => Disqussion::Forbidden,
|
12
|
+
404 => Disqussion::NotFound,
|
13
|
+
500 => Disqussion::InternalServerError,
|
14
|
+
}.each do |status, exception|
|
15
|
+
context "when HTTP status is #{status}" do
|
16
|
+
|
17
|
+
before do
|
18
|
+
stub_get('users/details.json').
|
19
|
+
with(:query => {:"user:username" => 'the88'}).
|
20
|
+
to_return(:status => status)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise #{exception.name} error" do
|
24
|
+
lambda do
|
25
|
+
@client.details('the88')
|
26
|
+
end.should raise_error(exception)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
{
|
2
|
+
"code": 0,
|
3
|
+
"response": [
|
4
|
+
[
|
5
|
+
"2011-04-05T00:00:00",
|
6
|
+
0
|
7
|
+
],
|
8
|
+
[
|
9
|
+
"2011-04-06T00:00:00",
|
10
|
+
0
|
11
|
+
],
|
12
|
+
[
|
13
|
+
"2011-04-07T00:00:00",
|
14
|
+
0
|
15
|
+
],
|
16
|
+
[
|
17
|
+
"2011-04-08T00:00:00",
|
18
|
+
0
|
19
|
+
],
|
20
|
+
[
|
21
|
+
"2011-04-09T00:00:00",
|
22
|
+
0
|
23
|
+
],
|
24
|
+
[
|
25
|
+
"2011-04-10T00:00:00",
|
26
|
+
0
|
27
|
+
],
|
28
|
+
[
|
29
|
+
"2011-04-11T00:00:00",
|
30
|
+
0
|
31
|
+
],
|
32
|
+
[
|
33
|
+
"2011-04-12T00:00:00",
|
34
|
+
0
|
35
|
+
],
|
36
|
+
[
|
37
|
+
"2011-04-13T00:00:00",
|
38
|
+
0
|
39
|
+
],
|
40
|
+
[
|
41
|
+
"2011-04-14T00:00:00",
|
42
|
+
0
|
43
|
+
],
|
44
|
+
[
|
45
|
+
"2011-04-15T00:00:00",
|
46
|
+
0
|
47
|
+
],
|
48
|
+
[
|
49
|
+
"2011-04-16T00:00:00",
|
50
|
+
0
|
51
|
+
],
|
52
|
+
[
|
53
|
+
"2011-04-17T00:00:00",
|
54
|
+
0
|
55
|
+
],
|
56
|
+
[
|
57
|
+
"2011-04-18T00:00:00",
|
58
|
+
0
|
59
|
+
],
|
60
|
+
[
|
61
|
+
"2011-04-19T00:00:00",
|
62
|
+
0
|
63
|
+
],
|
64
|
+
[
|
65
|
+
"2011-04-20T00:00:00",
|
66
|
+
0
|
67
|
+
],
|
68
|
+
[
|
69
|
+
"2011-04-21T00:00:00",
|
70
|
+
0
|
71
|
+
],
|
72
|
+
[
|
73
|
+
"2011-04-22T00:00:00",
|
74
|
+
0
|
75
|
+
],
|
76
|
+
[
|
77
|
+
"2011-04-23T00:00:00",
|
78
|
+
0
|
79
|
+
],
|
80
|
+
[
|
81
|
+
"2011-04-24T00:00:00",
|
82
|
+
0
|
83
|
+
],
|
84
|
+
[
|
85
|
+
"2011-04-25T00:00:00",
|
86
|
+
0
|
87
|
+
],
|
88
|
+
[
|
89
|
+
"2011-04-26T00:00:00",
|
90
|
+
0
|
91
|
+
],
|
92
|
+
[
|
93
|
+
"2011-04-27T00:00:00",
|
94
|
+
0
|
95
|
+
],
|
96
|
+
[
|
97
|
+
"2011-04-28T00:00:00",
|
98
|
+
0
|
99
|
+
],
|
100
|
+
[
|
101
|
+
"2011-04-29T00:00:00",
|
102
|
+
0
|
103
|
+
],
|
104
|
+
[
|
105
|
+
"2011-04-30T00:00:00",
|
106
|
+
0
|
107
|
+
],
|
108
|
+
[
|
109
|
+
"2011-05-01T00:00:00",
|
110
|
+
0
|
111
|
+
],
|
112
|
+
[
|
113
|
+
"2011-05-02T00:00:00",
|
114
|
+
0
|
115
|
+
],
|
116
|
+
[
|
117
|
+
"2011-05-03T00:00:00",
|
118
|
+
0
|
119
|
+
],
|
120
|
+
[
|
121
|
+
"2011-05-04T00:00:00",
|
122
|
+
3
|
123
|
+
],
|
124
|
+
[
|
125
|
+
"2011-05-05T00:00:00",
|
126
|
+
9
|
127
|
+
]
|
128
|
+
]
|
129
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"code": 0,
|
3
|
+
"response": {
|
4
|
+
"id": "myforum",
|
5
|
+
"name": "the88",
|
6
|
+
"founder": "6138058",
|
7
|
+
"favicon": {
|
8
|
+
"permalink": "http://disqus.com/api/forums/favicons/atestforum.jpg",
|
9
|
+
"cache": "http://mediacdn.disqus.com/1304703476/images/favicon-default.png"
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"code": 0,
|
3
|
+
"response": {
|
4
|
+
"id": "test",
|
5
|
+
"name": "test forum",
|
6
|
+
"founder": "6138058",
|
7
|
+
"favicon": {
|
8
|
+
"permalink": "http://disqus.com/api/forums/favicons/test.jpg",
|
9
|
+
"cache": "http://mediacdn.disqus.com/1304545408/images/favicon-default.png"
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"cursor": {
|
3
|
+
"prev": null,
|
4
|
+
"hasNext": false,
|
5
|
+
"next": "595772:1:0",
|
6
|
+
"hasPrev": false,
|
7
|
+
"total": null,
|
8
|
+
"id": "595772:1:0",
|
9
|
+
"more": false
|
10
|
+
},
|
11
|
+
"code": 0,
|
12
|
+
"response": [
|
13
|
+
{
|
14
|
+
"id": "595772",
|
15
|
+
"forum": "the88",
|
16
|
+
"order": 0,
|
17
|
+
"isDefault": true,
|
18
|
+
"title": "General"
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|