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,63 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::API do
|
4
|
+
before do
|
5
|
+
@keys = Disqussion::Configuration::VALID_OPTIONS_KEYS
|
6
|
+
end
|
7
|
+
|
8
|
+
context "with module configuration" do
|
9
|
+
before do
|
10
|
+
Disqussion.configure do |config|
|
11
|
+
@keys.each do |key|
|
12
|
+
config.send("#{key}=", key)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
Disqussion.reset
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should inherit module configuration" do
|
22
|
+
api = Disqussion::API.new
|
23
|
+
@keys.each do |key|
|
24
|
+
api.send(key).should == key
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with class configuration" do
|
29
|
+
before do
|
30
|
+
@configuration = {
|
31
|
+
:api_key => 'key',
|
32
|
+
:api_secret => 'secret',
|
33
|
+
:adapter => :typhoeus,
|
34
|
+
:endpoint => 'http://disqus.com/api',
|
35
|
+
:format => :json,
|
36
|
+
:proxy => 'http://the88:bar@proxy.example.com:8080',
|
37
|
+
:user_agent => 'Custom User Agent',
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
context "during initialization" do
|
42
|
+
it "should override module configuration" do
|
43
|
+
api = Disqussion::API.new(@configuration)
|
44
|
+
@keys.each do |key|
|
45
|
+
api.send(key).should == @configuration[key] if @configuration[key]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "after initilization" do
|
51
|
+
it "should override module configuration after initialization" do
|
52
|
+
api = Disqussion::API.new
|
53
|
+
@configuration.each do |key, value|
|
54
|
+
api.send("#{key}=", value)
|
55
|
+
end
|
56
|
+
@keys.each do |key|
|
57
|
+
api.send(key).should == @configuration[key] if @configuration[key]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Applications do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.applications
|
8
|
+
end
|
9
|
+
|
10
|
+
context "listUsage" do
|
11
|
+
before do
|
12
|
+
stub_get("applications/listUsage.json").
|
13
|
+
to_return(:body => fixture("applications/listUsage.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the API usage per day for this application." do
|
17
|
+
@client.listUsage
|
18
|
+
a_get("applications/listUsage.json").should have_been_made
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Forums do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.forums
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".create" do
|
11
|
+
before do
|
12
|
+
stub_get("forums/create.json", :query => { :website => "the88", :name => "My Forum", :short_name => "myforum" }).
|
13
|
+
to_return(:body => fixture("forums/create.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns new forum infos." do
|
17
|
+
@client.create("the88", "My Forum", "myforum")
|
18
|
+
a_get("forums/create.json", :query => { :website => "the88", :name => "My Forum", :short_name => "myforum" }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".details" do
|
24
|
+
before do
|
25
|
+
stub_get("forums/details.json", :query => { :forum => "the88" }).
|
26
|
+
to_return(:body => fixture("forums/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("the88")
|
31
|
+
a_get("forums/details.json", :query => { :forum => "the88" }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".listPosts" do
|
37
|
+
before do
|
38
|
+
stub_get("forums/listPosts.json", :query => { :forum => "the88" }).
|
39
|
+
to_return(:body => fixture("forums/listPosts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns details on the requested list of posts." do
|
43
|
+
@client.listPosts("the88")
|
44
|
+
a_get("forums/listPosts.json", :query => { :forum => "the88" }).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".listCategories" do
|
50
|
+
before do
|
51
|
+
stub_get("forums/listCategories.json", :query => { :forum => "the88" }).
|
52
|
+
to_return(:body => fixture("forums/listCategories.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns details on the requested list of categories." do
|
56
|
+
@client.listCategories("the88")
|
57
|
+
a_get("forums/listCategories.json", :query => { :forum => "the88" }).
|
58
|
+
should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".listMostLikedUsers" do
|
63
|
+
pending
|
64
|
+
end
|
65
|
+
|
66
|
+
describe ".listThreads" do
|
67
|
+
before do
|
68
|
+
stub_get("forums/listThreads.json", :query => { :forum => "the88" }).
|
69
|
+
to_return(:body => fixture("forums/listThreads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns details on the requested list of threads." do
|
73
|
+
@client.listThreads("the88")
|
74
|
+
a_get("forums/listThreads.json", :query => { :forum => "the88" }).
|
75
|
+
should have_been_made
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Posts do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.posts
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".approve" do
|
11
|
+
before do
|
12
|
+
stub_post("posts/approve.json", :body => { :post => "199088808" }).
|
13
|
+
to_return(:body => fixture("posts/approve.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "approves a post." do
|
17
|
+
@client.approve(199088808)
|
18
|
+
a_post("posts/approve.json", :body => { :post => "199088808" }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".create" do
|
24
|
+
before do
|
25
|
+
stub_post("posts/create.json", :body => { :message => "Nice post!" }).
|
26
|
+
to_return(:body => fixture("posts/create.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "create a post." do
|
30
|
+
@client.create("Nice post!")
|
31
|
+
a_post("posts/create.json", :body => { :message => "Nice post!" }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".details" do
|
37
|
+
before do
|
38
|
+
stub_get("posts/details.json", :query => { :post => "199088808" }).
|
39
|
+
to_return(:body => fixture("posts/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns details on the requested post." do
|
43
|
+
@client.details(199088808)
|
44
|
+
a_get("posts/details.json", :query => { :post => "199088808" }).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".highlight" do
|
50
|
+
before do
|
51
|
+
stub_post("posts/highlight.json", :body => { :post => "199088808" }).
|
52
|
+
to_return(:body => fixture("posts/highlight.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns id of the highlighted post." do
|
56
|
+
@client.highlight(199088808)
|
57
|
+
a_post("posts/highlight.json", :body => { :post => "199088808" }).
|
58
|
+
should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".list" do
|
63
|
+
before do
|
64
|
+
stub_get("posts/list.json", :query => { :thread => "293757871" }).
|
65
|
+
to_return(:body => fixture("posts/list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns a list of posts for thread '293757871' ordered by the date created." do
|
69
|
+
@client.list(:thread => 293757871)
|
70
|
+
a_get("posts/list.json", :query => { :thread => "293757871" }).
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".remove" do
|
76
|
+
before do
|
77
|
+
stub_post("posts/remove.json", :body => { :post => "199088808" }).
|
78
|
+
to_return(:body => fixture("posts/remove.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns id of the removed post." do
|
82
|
+
@client.remove(199088808)
|
83
|
+
a_post("posts/remove.json", :body => { :post => "199088808" }).
|
84
|
+
should have_been_made
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe ".report" do
|
89
|
+
before do
|
90
|
+
stub_post("posts/report.json", :body => { :post => "199088808" }).
|
91
|
+
to_return(:body => fixture("posts/report.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns id of the removed post." do
|
95
|
+
@client.report(199088808)
|
96
|
+
a_post("posts/report.json", :body => { :post => "199088808" }).
|
97
|
+
should have_been_made
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe ".restore" do
|
102
|
+
before do
|
103
|
+
stub_post("posts/restore.json", :body => { :post => "199088808" }).
|
104
|
+
to_return(:body => fixture("posts/restore.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
105
|
+
end
|
106
|
+
|
107
|
+
it "returns id of the restored post." do
|
108
|
+
@client.restore(199088808)
|
109
|
+
a_post("posts/restore.json", :body => { :post => "199088808" }).
|
110
|
+
should have_been_made
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ".spam" do
|
115
|
+
before do
|
116
|
+
stub_post("posts/spam.json", :body => { :post => "199088808" }).
|
117
|
+
to_return(:body => fixture("posts/spam.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
118
|
+
end
|
119
|
+
|
120
|
+
it "returns id of post marked as spam." do
|
121
|
+
@client.spam(199088808)
|
122
|
+
a_post("posts/spam.json", :body => { :post => "199088808" }).
|
123
|
+
should have_been_made
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe ".unhighlight" do
|
128
|
+
before do
|
129
|
+
stub_post("posts/unhighlight.json", :body => { :post => "199088808" }).
|
130
|
+
to_return(:body => fixture("posts/unhighlight.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns id of post unhighlighted." do
|
134
|
+
@client.unhighlight(199088808)
|
135
|
+
a_post("posts/unhighlight.json", :body => { :post => "199088808" }).
|
136
|
+
should have_been_made
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe ".vote" do
|
141
|
+
before do
|
142
|
+
stub_post("posts/vote.json", :body => { :vote => "1", :post => "199088808" }).
|
143
|
+
to_return(:body => fixture("posts/vote.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
144
|
+
end
|
145
|
+
|
146
|
+
it "returns id of post." do
|
147
|
+
@client.vote(1, 199088808)
|
148
|
+
a_post("posts/vote.json", :body => { :vote => "1", :post => "199088808" }).
|
149
|
+
should have_been_made
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Reactions do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.reactions
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".domains" do
|
11
|
+
before do
|
12
|
+
stub_get("reactions/domains.json", :query => { }).
|
13
|
+
to_return(:body => fixture("reactions/domains.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns ???" do
|
17
|
+
@client.domains
|
18
|
+
a_get("reactions/domains.json", :query => { }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".ips" do
|
24
|
+
before do
|
25
|
+
stub_get("reactions/ips.json", :query => { }).
|
26
|
+
to_return(:body => fixture("reactions/ips.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns ???" do
|
30
|
+
@client.ips
|
31
|
+
a_get("reactions/ips.json", :query => { }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".threads" do
|
37
|
+
before do
|
38
|
+
stub_get("reactions/threads.json", :query => { }).
|
39
|
+
to_return(:body => fixture("reactions/threads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns ???" do
|
43
|
+
@client.threads
|
44
|
+
a_get("reactions/threads.json", :query => { }).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".users" do
|
50
|
+
before do
|
51
|
+
stub_get("reactions/users.json", :query => { }).
|
52
|
+
to_return(:body => fixture("reactions/users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns ???" do
|
56
|
+
@client.users
|
57
|
+
a_get("reactions/users.json", :query => { }).
|
58
|
+
should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Threads do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.threads
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".close" do
|
11
|
+
before do
|
12
|
+
stub_post("threads/close.json", :body => { :thread => "mythread" }).
|
13
|
+
to_return(:body => fixture("threads/close.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns code 0 response." do
|
17
|
+
@client.close("mythread")
|
18
|
+
a_post("threads/close.json", :body => { :thread => "mythread" }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".details" do
|
24
|
+
before do
|
25
|
+
stub_get("threads/details.json", :query => { :thread => "mythread" }).
|
26
|
+
to_return(:body => fixture("threads/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns thread details." do
|
30
|
+
@client.details("mythread")
|
31
|
+
a_get("threads/details.json", :query => { :thread => "mythread" }).
|
32
|
+
should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".list" do
|
37
|
+
before do
|
38
|
+
stub_get("threads/list.json", :query => { :forum => "the88" }).
|
39
|
+
to_return(:body => fixture("threads/list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns a list of threads sorted by the date created." do
|
43
|
+
@client.list(:forum => "the88")
|
44
|
+
a_get("threads/list.json", :query => { :forum => "the88" }).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".listMostLiked" do
|
50
|
+
before do
|
51
|
+
stub_get("threads/listMostLiked.json", :query => { :forum => "the88" }).
|
52
|
+
to_return(:body => fixture("threads/listMostLiked.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns a list of threads sorted by number of likes." do
|
56
|
+
@client.listMostLiked(:forum => "the88")
|
57
|
+
a_get("threads/listMostLiked.json", :query => { :forum => "the88" }).
|
58
|
+
should have_been_made
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".listPosts" do
|
63
|
+
before do
|
64
|
+
stub_get("threads/listPosts.json", :query => { :thread => "mythread" }).
|
65
|
+
to_return(:body => fixture("threads/listPosts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns a list of threads sorted by number of likes." do
|
69
|
+
@client.listPosts("mythread")
|
70
|
+
a_get("threads/listPosts.json", :query => { :thread => "mythread" }).
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".open" do
|
76
|
+
before do
|
77
|
+
stub_post("threads/open.json", :body => { :thread => "12345678" }).
|
78
|
+
to_return(:body => fixture("threads/open.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns code 0 response." do
|
82
|
+
@client.open(12345678)
|
83
|
+
a_post("threads/open.json", :body => { :thread => "12345678" }).
|
84
|
+
should have_been_made
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe ".remove" do
|
89
|
+
before do
|
90
|
+
stub_post("threads/remove.json", :body => { :thread => "12345678" }).
|
91
|
+
to_return(:body => fixture("threads/remove.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns code 0 response." do
|
95
|
+
@client.remove(12345678)
|
96
|
+
a_post("threads/remove.json", :body => { :thread => "12345678" }).
|
97
|
+
should have_been_made
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe ".restore" do
|
102
|
+
before do
|
103
|
+
stub_post("threads/restore.json", :body => { :thread => "12345678" }).
|
104
|
+
to_return(:body => fixture("threads/restore.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
105
|
+
end
|
106
|
+
|
107
|
+
it "returns code 0 response." do
|
108
|
+
@client.restore(12345678)
|
109
|
+
a_post("threads/restore.json", :body => { :thread => "12345678" }).
|
110
|
+
should have_been_made
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ".vote" do
|
115
|
+
before do
|
116
|
+
stub_post("threads/vote.json", :body => { :vote => "1", :thread => "12345678" }).
|
117
|
+
to_return(:body => fixture("threads/vote.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
118
|
+
end
|
119
|
+
|
120
|
+
it "returns code 0 response." do
|
121
|
+
@client.vote(1, 12345678)
|
122
|
+
a_post("threads/vote.json", :body => { :vote => "1", :thread => "12345678" }).
|
123
|
+
should have_been_made
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Trends do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.trends
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".listTreads" do
|
11
|
+
before do
|
12
|
+
stub_get("trends/listTreads.json", :query => { }).
|
13
|
+
to_return(:body => fixture("trends/listTreads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the list of trending threads." do
|
17
|
+
@client.listTreads
|
18
|
+
a_get("trends/listTreads.json", :query => { }).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Users do
|
4
|
+
Disqussion::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Disqussion::Client.users
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".details" do
|
11
|
+
it "get the correct resource" do
|
12
|
+
stub_get("users/details.json").
|
13
|
+
to_return(:body => fixture("users/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
|
15
|
+
@client.details
|
16
|
+
|
17
|
+
a_get("users/details.json").should have_been_made
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".follow" do
|
22
|
+
it "get the correct resource" do
|
23
|
+
stub_post("users/follow.json", :body => { :target => "12345678" }).
|
24
|
+
to_return(:body => fixture("users/follow.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
25
|
+
|
26
|
+
@client.follow(12345678)
|
27
|
+
|
28
|
+
a_post("users/follow.json", :body => { :target => "12345678"}).should have_been_made
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Disqussion::Client do
|
4
|
+
context ".new" do
|
5
|
+
before do
|
6
|
+
@client = Disqussion::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "connect using the endpoint configuration" do
|
10
|
+
endpoint = URI.parse(@client.api_endpoint)
|
11
|
+
connection = @client.send(:connection).build_url(nil).to_s
|
12
|
+
connection.should == endpoint.to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|