disqussion 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +13 -13
- data/HISTORY.mkd +4 -0
- data/README.mkd +5 -5
- data/lib/disqussion/client/categories.rb +112 -1
- data/lib/disqussion/client/exports.rb +22 -0
- data/lib/disqussion/client/forums.rb +3 -3
- data/lib/disqussion/client/imports.rb +36 -1
- data/lib/disqussion/client/reports.rb +75 -0
- data/lib/disqussion/version.rb +1 -1
- data/lib/disqussion/widget.rb +168 -168
- data/lib/faraday/response/raise_http_4xx.rb +4 -11
- data/spec/disqussion/client/categories_spec.rb +76 -0
- data/spec/disqussion/client/export_spec.rb +24 -0
- data/spec/disqussion/client/imports_spec.rb +37 -0
- data/spec/disqussion/client/reports_spec.rb +63 -0
- data/spec/faraday/response_spec.rb +2 -3
- data/spec/fixtures/categories/create.json +10 -0
- data/spec/fixtures/categories/details.json +10 -0
- data/spec/fixtures/categories/list.json +21 -0
- data/spec/fixtures/categories/listPosts.json +46 -0
- data/spec/fixtures/categories/listThreads.json +54 -0
- data/spec/fixtures/exports/exportForum.json +4 -0
- data/spec/fixtures/faraday/error2.json +4 -0
- data/spec/fixtures/imports/details.json +4 -0
- data/spec/fixtures/imports/list.json +113 -0
- data/spec/fixtures/reports/domains.json +4 -0
- data/spec/fixtures/reports/ips.json +82 -0
- data/spec/fixtures/reports/threads.json +4 -0
- data/spec/fixtures/reports/users.json +82 -0
- metadata +36 -2
data/lib/disqussion/widget.rb
CHANGED
@@ -1,182 +1,182 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
VALID_COLORS = ['blue', 'grey', 'green', 'red', 'orange']
|
13
|
-
VALID_NUM_ITEMS = 5..20
|
14
|
-
VALID_DEFAULT_TABS = ['people', 'recent', 'popular']
|
15
|
-
VALID_AVATAR_SIZES = [24, 32, 48, 92, 128]
|
16
|
-
VALID_ORIENTATIONS = ['horizontal', 'vertical']
|
1
|
+
# From Norman Clarke's Disqus gem
|
2
|
+
# Needs to be refactored/rewrote to match new Disqus API
|
3
|
+
module Disqussion
|
4
|
+
# Disqus Widget generator.
|
5
|
+
#
|
6
|
+
# All of the methods accept various options, and "account" is required for
|
7
|
+
# all of them. You can avoid having to pass in the account each time by
|
8
|
+
# setting it in the defaults like this:
|
9
|
+
#
|
10
|
+
# Disqus::defaults[:account] = "my_account"
|
11
|
+
class Widget
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
VALID_COLORS = ['blue', 'grey', 'green', 'red', 'orange']
|
14
|
+
VALID_NUM_ITEMS = 5..20
|
15
|
+
VALID_DEFAULT_TABS = ['people', 'recent', 'popular']
|
16
|
+
VALID_AVATAR_SIZES = [24, 32, 48, 92, 128]
|
17
|
+
VALID_ORIENTATIONS = ['horizontal', 'vertical']
|
18
|
+
|
19
|
+
ROOT_PATH = 'http://disqus.com/forums/%s/'
|
20
|
+
THREAD = ROOT_PATH + 'embed.js'
|
21
|
+
COMBO = ROOT_PATH + 'combination_widget.js?num_items=%d&color=%s&default_tab=%s'
|
22
|
+
RECENT = ROOT_PATH + 'recent_comments_widget.js?num_items=%d&avatar_size=%d'
|
23
|
+
POPULAR = ROOT_PATH + 'popular_threads_widget.js?num_items=%d'
|
24
|
+
TOP = ROOT_PATH + 'top_commenters_widget.js?num_items=%d&avatar_size=%d&orientation=%s'
|
25
|
+
class << self
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
s % [opts[:account], opts[:account]]
|
27
|
+
# Show the main Disqus thread widget.
|
28
|
+
# Options:
|
29
|
+
# * <tt>account:</tt> Your Discus account (required).
|
30
|
+
def thread(opts = {})
|
31
|
+
opts = Disqus::defaults.merge(opts)
|
32
|
+
opts[:view_thread_text] ||= "View the discussion thread"
|
33
|
+
validate_opts!(opts)
|
34
|
+
s = ''
|
35
|
+
if opts[:developer]
|
36
|
+
s << '<script type="text/javascript">var disqus_developer = 1;</script>'
|
37
|
+
end
|
38
|
+
s << '<div id="disqus_thread"></div>'
|
39
|
+
s << '<script type="text/javascript" src="' + THREAD + '"></script>'
|
40
|
+
s << '<noscript><a href="http://%s.disqus.com/?url=ref">'
|
41
|
+
s << opts[:view_thread_text]
|
42
|
+
s << '</a></noscript>'
|
43
|
+
if opts[:show_powered_by]
|
44
|
+
s << '<a href="http://disqus.com" class="dsq-brlink">blog comments '
|
45
|
+
s << 'powered by <span class="logo-disqus">Disqus</span></a>'
|
47
46
|
end
|
47
|
+
s % [opts[:account], opts[:account]]
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}
|
50
|
+
# Loads Javascript to show the number of comments for the page.
|
51
|
+
#
|
52
|
+
# The Javascript sets the inner html to the comment count for any links
|
53
|
+
# on the page that have the anchor "disqus_thread". For example, "View
|
54
|
+
# Comments" below would be replaced by "1 comment" or "23 comments" etc.
|
55
|
+
#
|
56
|
+
# <a href="http://my.website/article-permalink#disqus_thread">View Comments</a>
|
57
|
+
# <a href="http://my.website/different-permalink#disqus_thread">View Comments</a>
|
58
|
+
# Options:
|
59
|
+
# * <tt>account:</tt> Your Discus account (required).
|
60
|
+
def comment_counts(opts = {})
|
61
|
+
opts = Disqus::defaults.merge(opts)
|
62
|
+
validate_opts!(opts)
|
63
|
+
s = <<-WHIMPER
|
64
|
+
<script type="text/javascript">
|
65
|
+
//<![CDATA[
|
66
|
+
(function() {
|
67
|
+
var links = document.getElementsByTagName('a');
|
68
|
+
var query = '?';
|
69
|
+
for(var i = 0; i < links.length; i++) {
|
70
|
+
if(links[i].href.indexOf('#disqus_thread') >= 0) {
|
71
|
+
query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
|
72
72
|
}
|
73
|
-
|
74
|
-
})
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
}
|
74
|
+
document.write('<' + 'script type="text/javascript" src="#{ROOT_PATH}get_num_replies.js' + query + '"></' + 'script>');
|
75
|
+
})();
|
76
|
+
//]]>
|
77
|
+
</script>
|
78
|
+
WHIMPER
|
79
|
+
s % opts[:account]
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
105
|
-
s % [opts[:account], opts[:num_items], opts[:avatar_size], opts[:orientation]]
|
82
|
+
# Show the top commenters Disqus thread widget.
|
83
|
+
# Options:
|
84
|
+
# * <tt>account:</tt> Your Discus account (required).
|
85
|
+
# * <tt>header:</tt> HTML snipper with header (default h2) tag and text.
|
86
|
+
# * <tt>show_powered_by:</tt> Show or hide the powered by Disqus text.
|
87
|
+
# * <tt>num_items:</tt>: How many items to show.
|
88
|
+
# * <tt>hide_mods:</tt> Don't show moderators.
|
89
|
+
# * <tt>hide_avatars:</tt> Don't show avatars.
|
90
|
+
# * <tt>avatar_size:</tt> Avatar size.
|
91
|
+
def top_commenters(opts = {})
|
92
|
+
opts = Disqus::defaults.merge(opts)
|
93
|
+
opts[:header] ||= '<h2 class="dsq-widget-title">Top Commenters</h2>'
|
94
|
+
validate_opts!(opts)
|
95
|
+
s = '<div id="dsq-topcommenters" class="dsq-widget">'
|
96
|
+
s << opts[:header]
|
97
|
+
s << '<script type="text/javascript" src="'
|
98
|
+
s << TOP
|
99
|
+
s << '&hide_avatars=1' if opts[:hide_avatars]
|
100
|
+
s << '&hide_mods=1' if opts[:hide_mods]
|
101
|
+
s << '"></script>'
|
102
|
+
s << '</div>'
|
103
|
+
if opts[:show_powered_by]
|
104
|
+
s << '<a href="http://disqus.com">Powered by Disqus</a>'
|
106
105
|
end
|
106
|
+
s % [opts[:account], opts[:num_items], opts[:avatar_size], opts[:orientation]]
|
107
|
+
end
|
107
108
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
# Show the recent comments Disqus widget.
|
130
|
-
# Options:
|
131
|
-
# * <tt>account:</tt> Your Discus account (required).
|
132
|
-
# * <tt>header:</tt> HTML snipper with header (default h2) tag and text.
|
133
|
-
# * <tt>num_items:</tt>: How many items to show.
|
134
|
-
# * <tt>hide_avatars:</tt> Don't show avatars.
|
135
|
-
# * <tt>avatar_size:</tt> Avatar size.
|
136
|
-
def recent_comments(opts = {})
|
137
|
-
opts = Disqus::defaults.merge(opts)
|
138
|
-
opts[:header] ||= '<h2 class="dsq-widget-title">Recent Comments</h2>'
|
139
|
-
validate_opts!(opts)
|
140
|
-
s = '<div id="dsq-recentcomments" class="dsq-widget">'
|
141
|
-
s << opts[:header]
|
142
|
-
s << '<script type="text/javascript" src="'
|
143
|
-
s << RECENT
|
144
|
-
s << '&hide_avatars=1' if opts[:hide_avatars]
|
145
|
-
s << '"></script>'
|
146
|
-
s << '</div>'
|
147
|
-
if opts[:show_powered_by]
|
148
|
-
s << '<a href="http://disqus.com">Powered by Disqus</a>'
|
149
|
-
end
|
150
|
-
s % [opts[:account], opts[:num_items], opts[:avatar_size]]
|
151
|
-
end
|
109
|
+
# Show the popular threads Disqus widget.
|
110
|
+
# Options:
|
111
|
+
# * <tt>account:</tt> Your Discus account (required).
|
112
|
+
# * <tt>header:</tt> HTML snipper with header (default h2) tag and text.
|
113
|
+
# * <tt>num_items:</tt>: How many items to show.
|
114
|
+
# * <tt>hide_mods:</tt> Don't show moderators.
|
115
|
+
def popular_threads(opts = {})
|
116
|
+
opts = Disqus::defaults.merge(opts)
|
117
|
+
opts[:header] ||= '<h2 class="dsq-widget-title">Popular Threads</h2>'
|
118
|
+
validate_opts!(opts)
|
119
|
+
s = '<div id="dsq-popthreads" class="dsq-widget">'
|
120
|
+
s << opts[:header]
|
121
|
+
s << '<script type="text/javascript" src="'
|
122
|
+
s << POPULAR
|
123
|
+
s << '&hide_mods=1' if opts[:hide_mods]
|
124
|
+
s << '"></script>'
|
125
|
+
s << '</div>'
|
126
|
+
s << '<a href="http://disqus.com">Powered by Disqus</a>' if opts[:show_powered_by]
|
127
|
+
s % [opts[:account], opts[:num_items]]
|
128
|
+
end
|
152
129
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
130
|
+
# Show the recent comments Disqus widget.
|
131
|
+
# Options:
|
132
|
+
# * <tt>account:</tt> Your Discus account (required).
|
133
|
+
# * <tt>header:</tt> HTML snipper with header (default h2) tag and text.
|
134
|
+
# * <tt>num_items:</tt>: How many items to show.
|
135
|
+
# * <tt>hide_avatars:</tt> Don't show avatars.
|
136
|
+
# * <tt>avatar_size:</tt> Avatar size.
|
137
|
+
def recent_comments(opts = {})
|
138
|
+
opts = Disqus::defaults.merge(opts)
|
139
|
+
opts[:header] ||= '<h2 class="dsq-widget-title">Recent Comments</h2>'
|
140
|
+
validate_opts!(opts)
|
141
|
+
s = '<div id="dsq-recentcomments" class="dsq-widget">'
|
142
|
+
s << opts[:header]
|
143
|
+
s << '<script type="text/javascript" src="'
|
144
|
+
s << RECENT
|
145
|
+
s << '&hide_avatars=1' if opts[:hide_avatars]
|
146
|
+
s << '"></script>'
|
147
|
+
s << '</div>'
|
148
|
+
if opts[:show_powered_by]
|
149
|
+
s << '<a href="http://disqus.com">Powered by Disqus</a>'
|
168
150
|
end
|
151
|
+
s % [opts[:account], opts[:num_items], opts[:avatar_size]]
|
152
|
+
end
|
169
153
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
154
|
+
# Show the Disqus combo widget. This is a three-tabbed box with links
|
155
|
+
# popular threads, top posters, and recent threads.
|
156
|
+
# Options:
|
157
|
+
# * <tt>:account:</tt> Your Discus account (required).
|
158
|
+
# * <tt>:num_items:</tt> How many items to show.
|
159
|
+
# * <tt>:hide_mods:</tt> Don't show moderators.
|
160
|
+
# * <tt>:default_tab:</tt> Should be 'people', 'recent', or 'popular'.
|
161
|
+
def combo(opts = {})
|
162
|
+
opts = Disqus::defaults.merge(opts)
|
163
|
+
validate_opts!(opts)
|
164
|
+
s = '<script type="text/javascript" src="'
|
165
|
+
s << COMBO
|
166
|
+
s << '&hide_mods=1' if opts[:hide_mods]
|
167
|
+
s << '"></script>'
|
168
|
+
s % [opts[:account], opts[:num_items], opts[:color], opts[:default_tab]]
|
169
|
+
end
|
170
|
+
|
171
|
+
private
|
172
|
+
|
173
|
+
def validate_opts!(opts)
|
174
|
+
raise ArgumentError.new("You must specify an :account") if !opts[:account]
|
175
|
+
raise ArgumentError.new("Invalid color") if opts[:color] && !VALID_COLORS.include?(opts[:color])
|
176
|
+
raise ArgumentError.new("Invalid num_items") if opts[:num_items] && !VALID_NUM_ITEMS.include?(opts[:num_items])
|
177
|
+
raise ArgumentError.new("Invalid default_tab") if opts[:default_tab] && !VALID_DEFAULT_TABS.include?(opts[:default_tab])
|
178
|
+
raise ArgumentError.new("Invalid avatar size") if opts[:avatar_size] && !VALID_AVATAR_SIZES.include?(opts[:avatar_size])
|
179
|
+
raise ArgumentError.new("Invalid orientation") if opts[:orientation] && !VALID_ORIENTATIONS.include?(opts[:orientation])
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
@@ -20,21 +20,14 @@ module Faraday
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def error_message(env)
|
23
|
-
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]}#{error_body(env[:body])}"
|
23
|
+
"#{env[:method].to_s.upcase} #{env[:url].to_s}: (#{env[:status]}) #{error_body(env[:body])}"
|
24
24
|
end
|
25
25
|
|
26
26
|
def error_body(body)
|
27
|
-
if body
|
27
|
+
if body['code'] && body['response']
|
28
|
+
"Disqus Error #{body['code']}: #{body['response']}"
|
29
|
+
else
|
28
30
|
nil
|
29
|
-
elsif body['error']
|
30
|
-
": #{body['error']}"
|
31
|
-
elsif body['errors']
|
32
|
-
first = body['errors'].to_a.first
|
33
|
-
if first.kind_of? Hash
|
34
|
-
": #{first['message'].chomp}"
|
35
|
-
else
|
36
|
-
": #{first.chomp}"
|
37
|
-
end
|
38
31
|
end
|
39
32
|
end
|
40
33
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Categories do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.categories
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".creates" do
|
11
|
+
before do
|
12
|
+
stub_post("categories/create.json", :body => { :forum => "the88", :title => "My category" }).
|
13
|
+
to_return(:body => fixture("categories/create.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns new category infos." do
|
17
|
+
@client.create("the88", "My category")
|
18
|
+
a_post("categories/create.json", :body => { :forum => "the88", :title => "My category" }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".details" do
|
24
|
+
before do
|
25
|
+
stub_get("categories/details.json", :query => { :category => "827231" }).
|
26
|
+
to_return(:body => fixture("categories/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns details on the requested forum." do
|
30
|
+
@client.details(827231)
|
31
|
+
a_get("categories/details.json", :query => { :category => "827231" }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".list" do
|
37
|
+
before do
|
38
|
+
stub_get("categories/list.json", :query => { :forum => "the88" }).
|
39
|
+
to_return(:body => fixture("categories/list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns a list of categories within a forum." do
|
43
|
+
@client.list(:forum => "the88")
|
44
|
+
a_get("categories/list.json", :query => { :forum => "the88" }).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".listPosts" do
|
50
|
+
before do
|
51
|
+
stub_get("categories/listPosts.json", :query => { :category => "827231" }).
|
52
|
+
to_return(:body => fixture("categories/listPosts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns a list of posts within a category." do
|
56
|
+
@client.listPosts(827231)
|
57
|
+
a_get("categories/listPosts.json", :query => { :category => "827231" }).
|
58
|
+
should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".listThreads" do
|
63
|
+
before do
|
64
|
+
stub_get("categories/listThreads.json", :query => { :category => "827231" }).
|
65
|
+
to_return(:body => fixture("categories/listThreads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns a list of threads within a category sorted by the date created." do
|
69
|
+
@client.listThreads(827231)
|
70
|
+
a_get("categories/listThreads.json", :query => { :category => "827231" }).
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Exports do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.exports
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".create" do
|
11
|
+
before do
|
12
|
+
stub_post("exports/exportForum.json", :body => { :forum => "the88" }).
|
13
|
+
to_return(:body => fixture("exports/exportForum.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "exports a forum." do
|
17
|
+
@client.exportForum("the88")
|
18
|
+
a_post("exports/exportForum.json", :body => { :forum => "the88" }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Imports do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.imports
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".details" do
|
11
|
+
before do
|
12
|
+
stub_get("imports/details.json", :query => { :group => "987" }).
|
13
|
+
to_return(:body => fixture("imports/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns ." do
|
17
|
+
@client.details(987)
|
18
|
+
a_get("imports/details.json", :query => { :group => "987" }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".list" do
|
24
|
+
before do
|
25
|
+
stub_get("imports/list.json", :query => { :forum => "the88" }).
|
26
|
+
to_return(:body => fixture("imports/list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns ." do
|
30
|
+
@client.list("the88")
|
31
|
+
a_get("imports/list.json", :query => { :forum => "the88" }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Reports do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.reports
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".domains" do
|
11
|
+
before do
|
12
|
+
stub_get("reports/domains.json", :query => { }).
|
13
|
+
to_return(:body => fixture("reports/domains.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns report on domains." do
|
17
|
+
@client.domains
|
18
|
+
a_get("reports/domains.json", :query => { }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".ips" do
|
24
|
+
before do
|
25
|
+
stub_get("reports/ips.json", :query => { }).
|
26
|
+
to_return(:body => fixture("reports/ips.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns report on ips." do
|
30
|
+
@client.ips
|
31
|
+
a_get("reports/ips.json", :query => { }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".threads" do
|
37
|
+
before do
|
38
|
+
stub_get("reports/threads.json", :query => { }).
|
39
|
+
to_return(:body => fixture("reports/threads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns report on threads." do
|
43
|
+
@client.threads
|
44
|
+
a_get("reports/threads.json", :query => { }).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".users" do
|
50
|
+
before do
|
51
|
+
stub_get("reports/users.json", :query => { }).
|
52
|
+
to_return(:body => fixture("reports/users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns report on users." do
|
56
|
+
@client.users
|
57
|
+
a_get("reports/users.json", :query => { }).
|
58
|
+
should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -16,13 +16,12 @@ describe Faraday::Response do
|
|
16
16
|
|
17
17
|
before do
|
18
18
|
stub_get('users/details.json').
|
19
|
-
|
20
|
-
to_return(:status => status)
|
19
|
+
to_return(:status => status, :body => fixture("faraday/error2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
21
20
|
end
|
22
21
|
|
23
22
|
it "should raise #{exception.name} error" do
|
24
23
|
lambda do
|
25
|
-
@client.details
|
24
|
+
@client.details
|
26
25
|
end.should raise_error(exception)
|
27
26
|
end
|
28
27
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"cursor": {
|
3
|
+
"prev": null,
|
4
|
+
"hasNext": false,
|
5
|
+
"next": "808233:0:0",
|
6
|
+
"hasPrev": false,
|
7
|
+
"total": null,
|
8
|
+
"id": "808233:0: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
|
+
}
|