disqus_rails 0.0.5
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/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +296 -0
- data/Rakefile +1 -0
- data/disqus_rails.gemspec +27 -0
- data/lib/disqus_rails.rb +31 -0
- data/lib/disqus_rails/active_record/acts_as_disqusable.rb +24 -0
- data/lib/disqus_rails/active_record/acts_as_disquser.rb +48 -0
- data/lib/disqus_rails/api.rb +79 -0
- data/lib/disqus_rails/api.yml +855 -0
- data/lib/disqus_rails/category.rb +20 -0
- data/lib/disqus_rails/collection.rb +90 -0
- data/lib/disqus_rails/forum.rb +54 -0
- data/lib/disqus_rails/helpers.rb +64 -0
- data/lib/disqus_rails/model.rb +45 -0
- data/lib/disqus_rails/post.rb +106 -0
- data/lib/disqus_rails/thread.rb +130 -0
- data/lib/disqus_rails/user.rb +68 -0
- data/lib/disqus_rails/version.rb +3 -0
- data/spec/disqus_rails/active_record/acts_as_disqusable_spec.rb +118 -0
- data/spec/disqus_rails/active_record/acts_as_disquser_spec.rb +44 -0
- data/spec/disqus_rails/api_spec.rb +266 -0
- data/spec/disqus_rails/category_spec.rb +77 -0
- data/spec/disqus_rails/collection_spec.rb +9 -0
- data/spec/disqus_rails/forum_spec.rb +102 -0
- data/spec/disqus_rails/model_spec.rb +24 -0
- data/spec/disqus_rails/post_spec.rb +218 -0
- data/spec/disqus_rails/thread_spec.rb +174 -0
- data/spec/disqus_rails/user_spec.rb +101 -0
- data/spec/disqus_rails_spec.rb +17 -0
- data/spec/spec_helper.rb +13 -0
- data/vendor/assets/javascripts/disqus_rails.js.coffee +78 -0
- metadata +171 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails::Category do
|
4
|
+
let!(:category_hash) do
|
5
|
+
{
|
6
|
+
:code => 0,
|
7
|
+
:response => {
|
8
|
+
"id" => "0",
|
9
|
+
"forum" => "stubbed_forum_name",
|
10
|
+
"order" => 0,
|
11
|
+
"isDefault" => true,
|
12
|
+
"title" => "stubbed_title"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:category){ DisqusRails::Category.new(category_hash[:response]) }
|
18
|
+
|
19
|
+
let(:empty_collection_hash) do
|
20
|
+
{
|
21
|
+
:cursor => {
|
22
|
+
"prev" => "null",
|
23
|
+
"hasNext" => true,
|
24
|
+
"next" => "1368581473195442:0:0",
|
25
|
+
"hasPrev" => false,
|
26
|
+
"total" => "null",
|
27
|
+
"id" => "1368581473195442:0:0",
|
28
|
+
"more" => true
|
29
|
+
},
|
30
|
+
:code => 0,
|
31
|
+
:response => []
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should get category details information with find method" do
|
36
|
+
DisqusRails::Api::Categories
|
37
|
+
.should_receive(:details)
|
38
|
+
.with(:category => 0)
|
39
|
+
.and_return(category_hash)
|
40
|
+
|
41
|
+
DisqusRails::Category.find(0).should be_a_kind_of(DisqusRails::Category)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
it "should get category threads as DisqusRails::Threads class instance" do
|
46
|
+
DisqusRails::Api::Categories
|
47
|
+
.should_receive(:listThreads)
|
48
|
+
.and_return(empty_collection_hash)
|
49
|
+
|
50
|
+
category.threads.should be_a_kind_of(DisqusRails::Threads)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should get category posts as DisqusRails::Posts class instance" do
|
54
|
+
DisqusRails::Api::Categories
|
55
|
+
.should_receive(:listPosts)
|
56
|
+
.and_return(empty_collection_hash)
|
57
|
+
|
58
|
+
category.posts.should be_a_kind_of(DisqusRails::Posts)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should create category" do
|
62
|
+
DisqusRails::Api::Categories
|
63
|
+
.should_receive(:create)
|
64
|
+
.with(:forum => "stubbed_forum_name", :title => "stubbed_title")
|
65
|
+
.and_return(category_hash)
|
66
|
+
|
67
|
+
DisqusRails::Category.create(:forum => "stubbed_forum_name", :title => "stubbed_title").should be_a_kind_of DisqusRails::Category
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return list of categories" do
|
71
|
+
DisqusRails::Api::Categories
|
72
|
+
.should_receive(:list)
|
73
|
+
.and_return(empty_collection_hash)
|
74
|
+
|
75
|
+
DisqusRails::Category.where().should be_a_kind_of(DisqusRails::Categories)
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails::Forum do
|
4
|
+
let!(:forum_hash) do
|
5
|
+
{
|
6
|
+
:code => 0,
|
7
|
+
:response => {
|
8
|
+
"id" => "bobross",
|
9
|
+
"name" => "Bob Ross",
|
10
|
+
"founder" => "1",
|
11
|
+
"favicon" => {
|
12
|
+
"permalink" => "http://disqus.com/api/forums/favicons/bobross.jpg",
|
13
|
+
"cache" => "http://mediacdn.disqus.com/1091/images/favicon-default.png"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:forum){ DisqusRails::Forum.new(forum_hash[:response]) }
|
20
|
+
|
21
|
+
let(:empty_collection_hash) do
|
22
|
+
{
|
23
|
+
:cursor => {
|
24
|
+
"prev" => "null",
|
25
|
+
"hasNext" => true,
|
26
|
+
"next" => "1368581473195442:0:0",
|
27
|
+
"hasPrev" => false,
|
28
|
+
"total" => "null",
|
29
|
+
"id" => "1368581473195442:0:0",
|
30
|
+
"more" => true
|
31
|
+
},
|
32
|
+
:code => 0,
|
33
|
+
:response => []
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should get forum details information with find method" do
|
38
|
+
DisqusRails::Api::Forums
|
39
|
+
.should_receive(:details)
|
40
|
+
.with(:forum => "bobross")
|
41
|
+
.and_return(forum_hash)
|
42
|
+
|
43
|
+
DisqusRails::Forum.find("bobross").should be_a_kind_of(DisqusRails::Forum)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should get forum categories as DisqusRails::Categories class instance" do
|
47
|
+
DisqusRails::Api::Forums
|
48
|
+
.should_receive(:listCategories)
|
49
|
+
.and_return(empty_collection_hash)
|
50
|
+
|
51
|
+
forum.categories.should be_a_kind_of(DisqusRails::Categories)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should get forum threads as DisqusRails::Threads class instance" do
|
55
|
+
DisqusRails::Api::Forums
|
56
|
+
.should_receive(:listThreads)
|
57
|
+
.and_return(empty_collection_hash)
|
58
|
+
|
59
|
+
forum.threads.should be_a_kind_of(DisqusRails::Threads)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should get forum posts as DisqusRails::Posts class instance" do
|
63
|
+
DisqusRails::Api::Forums
|
64
|
+
.should_receive(:listPosts)
|
65
|
+
.and_return(empty_collection_hash)
|
66
|
+
|
67
|
+
forum.posts.should be_a_kind_of(DisqusRails::Posts)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should get forum users as DisqusRails::Users class instance" do
|
71
|
+
DisqusRails::Api::Forums
|
72
|
+
.should_receive(:listUsers)
|
73
|
+
.and_return(empty_collection_hash)
|
74
|
+
|
75
|
+
forum.users.should be_a_kind_of(DisqusRails::Users)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should get forum most active users as DisqusRails::Users class instance" do
|
79
|
+
DisqusRails::Api::Forums
|
80
|
+
.should_receive(:listMostActiveUsers)
|
81
|
+
.and_return(empty_collection_hash)
|
82
|
+
|
83
|
+
forum.most_active_users.should be_a_kind_of(DisqusRails::Users)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should get forum most liked users as DisqusRails::Users class instance" do
|
87
|
+
DisqusRails::Api::Forums
|
88
|
+
.should_receive(:listMostLikedUsers)
|
89
|
+
.and_return(empty_collection_hash)
|
90
|
+
|
91
|
+
forum.most_liked_users.should be_a_kind_of(DisqusRails::Users)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should create forum" do
|
95
|
+
DisqusRails::Api::Forums
|
96
|
+
.should_receive(:create)
|
97
|
+
.with(:website => "stubbed_website", :name => "stubbed_name", :short_name => "stubbed_short_name")
|
98
|
+
.and_return({:code => 0, :response => forum_hash})
|
99
|
+
|
100
|
+
DisqusRails::Forum.create(:website => "stubbed_website", :name => "stubbed_name", :short_name => "stubbed_short_name").should be_a_kind_of DisqusRails::Forum
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails::Model do
|
4
|
+
%w(Category Forum Post Thread User).each do |klass|
|
5
|
+
it "should create singleton method find in #{klass} class" do
|
6
|
+
klass_instance = DisqusRails.const_get(klass).new()
|
7
|
+
klass_instance.singleton_class.should respond_to(:find)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create singleton method where if #{klass} api class has list method" do
|
11
|
+
if DisqusRails::Api.const_get(klass.pluralize).respond_to?(:list)
|
12
|
+
klass_instance = DisqusRails.const_get(klass).new()
|
13
|
+
klass_instance.singleton_class.should respond_to(:where)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
%w(update_attributes reload).each do |method|
|
18
|
+
it "should create method #{method} in #{klass} class" do
|
19
|
+
klass_instance = DisqusRails.const_get(klass).new()
|
20
|
+
klass_instance.should respond_to(method)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,218 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails::Post do
|
4
|
+
let!(:post_hash) do
|
5
|
+
{
|
6
|
+
:code => 0,
|
7
|
+
:response => {
|
8
|
+
"isJuliaFlagged" => true,
|
9
|
+
"isFlagged" => false,
|
10
|
+
"forum" => "bobross",
|
11
|
+
"parent" => "null",
|
12
|
+
"author" => {
|
13
|
+
"username" => "disqus_api",
|
14
|
+
"about" => "",
|
15
|
+
"name" => "disqus_api",
|
16
|
+
"url" => "",
|
17
|
+
"isFollowing" => false,
|
18
|
+
"isFollowedBy" => false,
|
19
|
+
"profileUrl" => "http://disqus.com/disqus_api/",
|
20
|
+
"emailHash" => "67f79ed8e10b74abf07a8dfe101bbab2",
|
21
|
+
"avatar" => {
|
22
|
+
"permalink" => "http://disqus.com/api/users/avatars/disqus_api.jpg",
|
23
|
+
"cache" => "http://mediacdn.disqus.com/1091/images/noavatar92.png"
|
24
|
+
},
|
25
|
+
"id" => "1",
|
26
|
+
"isAnonymous" => false,
|
27
|
+
"email" => "example@disqus.com"
|
28
|
+
},
|
29
|
+
"media" => [],
|
30
|
+
"isApproved" => false,
|
31
|
+
"dislikes" => 0,
|
32
|
+
"raw_message" => "Hello There",
|
33
|
+
"id" => "4",
|
34
|
+
"thread" => "1",
|
35
|
+
"points" => 0,
|
36
|
+
"createdAt" => "2011-11-02T02:22:51",
|
37
|
+
"isEdited" => false,
|
38
|
+
"message" => "Hello There",
|
39
|
+
"isHighlighted" => false,
|
40
|
+
"ipAddress" => "127.0.0.1",
|
41
|
+
"isSpam" => false,
|
42
|
+
"isDeleted" => false,
|
43
|
+
"likes" => 0
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:updated_post_hash) do
|
49
|
+
updated_post_hash = post_hash
|
50
|
+
updated_post_hash[:response]["raw_message"] = "updated message"
|
51
|
+
updated_post_hash[:response]["message"] = "updated message"
|
52
|
+
updated_post_hash
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:post) do
|
56
|
+
DisqusRails::Post.new post_hash[:response]
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:simple_result) do
|
60
|
+
{
|
61
|
+
:code => 0,
|
62
|
+
:response => [{"id" => "4"}]
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:empty_collection_hash) do
|
67
|
+
{
|
68
|
+
:cursor => {
|
69
|
+
"prev" => "null",
|
70
|
+
"hasNext" => true,
|
71
|
+
"next" => "1368581473195442:0:0",
|
72
|
+
"hasPrev" => false,
|
73
|
+
"total" => "null",
|
74
|
+
"id" => "1368581473195442:0:0",
|
75
|
+
"more" => true
|
76
|
+
},
|
77
|
+
:code => 0,
|
78
|
+
:response => []
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should get post details information with find method" do
|
83
|
+
DisqusRails::Api::Posts
|
84
|
+
.should_receive(:details)
|
85
|
+
.with(:post => 1)
|
86
|
+
.and_return(post_hash)
|
87
|
+
|
88
|
+
DisqusRails::Post.find(1).should be_a_kind_of(DisqusRails::Post)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should create post" do
|
92
|
+
DisqusRails::Api::Posts
|
93
|
+
.should_receive(:create)
|
94
|
+
.with(:message => "stubbed_message")
|
95
|
+
.and_return(post_hash)
|
96
|
+
|
97
|
+
DisqusRails::Post.create(:message => "stubbed_message").author.should be_a_kind_of DisqusRails::User
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
it "should highlight post" do
|
102
|
+
DisqusRails::Api::Posts
|
103
|
+
.should_receive(:highlight)
|
104
|
+
.with(:post => post.id)
|
105
|
+
.and_return(simple_result)
|
106
|
+
|
107
|
+
post.highlight
|
108
|
+
|
109
|
+
post.isHighlighted.should be_true
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should unhighlight post" do
|
113
|
+
DisqusRails::Api::Posts
|
114
|
+
.should_receive(:unhighlight)
|
115
|
+
.with(:post => post.id)
|
116
|
+
.and_return(simple_result)
|
117
|
+
|
118
|
+
post.unhighlight
|
119
|
+
|
120
|
+
post.isHighlighted.should be_false
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should vote for post" do
|
124
|
+
DisqusRails::Api::Posts
|
125
|
+
.should_receive(:vote)
|
126
|
+
.with(:post => post.id, :vote => 1)
|
127
|
+
.and_return(simple_result)
|
128
|
+
|
129
|
+
post.vote(1)
|
130
|
+
|
131
|
+
post.vote.should == 1
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should report post" do
|
135
|
+
DisqusRails::Api::Posts
|
136
|
+
.should_receive(:report)
|
137
|
+
.with(:post => post.id)
|
138
|
+
.and_return(simple_result)
|
139
|
+
|
140
|
+
post.report
|
141
|
+
|
142
|
+
post.isFlagged.should be_true
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should approve post" do
|
146
|
+
DisqusRails::Api::Posts
|
147
|
+
.should_receive(:approve)
|
148
|
+
.with(:post => post.id)
|
149
|
+
.and_return(simple_result)
|
150
|
+
|
151
|
+
post.approve
|
152
|
+
|
153
|
+
post.isApproved.should be_true
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should mark post as spam" do
|
157
|
+
DisqusRails::Api::Posts
|
158
|
+
.should_receive(:spam)
|
159
|
+
.with(:post => post.id)
|
160
|
+
.and_return(simple_result)
|
161
|
+
|
162
|
+
post.spam
|
163
|
+
|
164
|
+
post.isSpam.should be_true
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should remove post" do
|
168
|
+
DisqusRails::Api::Posts
|
169
|
+
.should_receive(:remove)
|
170
|
+
.with(:post => post.id)
|
171
|
+
.and_return(simple_result)
|
172
|
+
|
173
|
+
post.remove
|
174
|
+
|
175
|
+
post.isDeleted.should be_true
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should restore post" do
|
179
|
+
post.isDeleted = true
|
180
|
+
|
181
|
+
DisqusRails::Api::Posts
|
182
|
+
.should_receive(:restore)
|
183
|
+
.with(:post => post.id)
|
184
|
+
.and_return(simple_result)
|
185
|
+
|
186
|
+
post.restore
|
187
|
+
|
188
|
+
post.isDeleted.should be_false
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should update post" do
|
192
|
+
|
193
|
+
DisqusRails::Api::Posts
|
194
|
+
.should_receive(:update)
|
195
|
+
.with(:post => post.id, :message => "updated message")
|
196
|
+
.and_return(updated_post_hash)
|
197
|
+
|
198
|
+
post.update("updated message")
|
199
|
+
|
200
|
+
post.message.should == "updated message"
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should return list of posts" do
|
204
|
+
DisqusRails::Api::Posts
|
205
|
+
.should_receive(:list)
|
206
|
+
.and_return(empty_collection_hash)
|
207
|
+
|
208
|
+
DisqusRails::Post.where().should be_a_kind_of(DisqusRails::Posts)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should return list of popular posts" do
|
212
|
+
DisqusRails::Api::Posts
|
213
|
+
.should_receive(:listPopular)
|
214
|
+
.and_return(empty_collection_hash)
|
215
|
+
|
216
|
+
DisqusRails::Post.popular.should be_a_kind_of(DisqusRails::Posts)
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails::Thread do
|
4
|
+
let!(:thread_hash) do
|
5
|
+
{
|
6
|
+
:code => 0,
|
7
|
+
:response => {
|
8
|
+
"category" => "1",
|
9
|
+
"reactions" => 0,
|
10
|
+
"identifiers" => [],
|
11
|
+
"forum" => "bobross",
|
12
|
+
"title" => "Hello World",
|
13
|
+
"dislikes" => 0,
|
14
|
+
"isDeleted" => false,
|
15
|
+
"author" => "1",
|
16
|
+
"userScore" => 0,
|
17
|
+
"id" => "3",
|
18
|
+
"isClosed" => false,
|
19
|
+
"posts" => 0,
|
20
|
+
"link" => "null",
|
21
|
+
"likes" => 0,
|
22
|
+
"message" => "",
|
23
|
+
"ipAddress" => "127.0.0.1",
|
24
|
+
"slug" => "hello_world",
|
25
|
+
"createdAt" => "2011-11-02T02:22:41"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:thread) do
|
31
|
+
DisqusRails::Thread.new thread_hash[:response]
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:empty_collection_hash) do
|
35
|
+
{
|
36
|
+
:cursor => {
|
37
|
+
"prev" => "null",
|
38
|
+
"hasNext" => true,
|
39
|
+
"next" => "1368581473195442:0:0",
|
40
|
+
"hasPrev" => false,
|
41
|
+
"total" => "null",
|
42
|
+
"id" => "1368581473195442:0:0",
|
43
|
+
"more" => true
|
44
|
+
},
|
45
|
+
:code => 0,
|
46
|
+
:response => []
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
let(:simple_result) do
|
51
|
+
{
|
52
|
+
:code => 0,
|
53
|
+
:response => [{"id" => "4"}]
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
let(:updated_thread_hash) do
|
58
|
+
updated_thread_hash = thread_hash
|
59
|
+
updated_thread_hash[:response]["title"] = "updated thread title"
|
60
|
+
updated_thread_hash
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should get threads details information with find method" do
|
64
|
+
DisqusRails::Api::Threads
|
65
|
+
.should_receive(:details)
|
66
|
+
.with(:thread => 3)
|
67
|
+
.and_return(thread_hash)
|
68
|
+
|
69
|
+
DisqusRails::Thread.find(3).should be_a_kind_of(DisqusRails::Thread)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should get thread posts as DisqusRails::Posts class instance" do
|
73
|
+
DisqusRails::Api::Threads
|
74
|
+
.should_receive(:listPosts)
|
75
|
+
.and_return(empty_collection_hash)
|
76
|
+
|
77
|
+
thread.posts.should be_a_kind_of(DisqusRails::Posts)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should create thread" do
|
81
|
+
DisqusRails::Api::Threads
|
82
|
+
.should_receive(:create)
|
83
|
+
.with(:forum => "stubbed_forum", :title => "stubbed_title")
|
84
|
+
.and_return(thread_hash)
|
85
|
+
|
86
|
+
DisqusRails::Thread.create(:forum => "stubbed_forum", :title => "stubbed_title").should be_a_kind_of DisqusRails::Thread
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should open thread" do
|
90
|
+
DisqusRails::Api::Threads
|
91
|
+
.should_receive(:open)
|
92
|
+
.with(:thread => thread.id)
|
93
|
+
.and_return(simple_result)
|
94
|
+
|
95
|
+
thread.open
|
96
|
+
|
97
|
+
thread.isClosed.should be_false
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should close thread" do
|
101
|
+
DisqusRails::Api::Threads
|
102
|
+
.should_receive(:close)
|
103
|
+
.with(:thread => thread.id)
|
104
|
+
.and_return(simple_result)
|
105
|
+
|
106
|
+
thread.close
|
107
|
+
|
108
|
+
thread.isClosed.should be_true
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should subscribe for a thread" do
|
112
|
+
DisqusRails::Api::Threads
|
113
|
+
.should_receive(:subscribe)
|
114
|
+
.with(:thread => thread.id, :email => nil)
|
115
|
+
.and_return(simple_result)
|
116
|
+
|
117
|
+
thread.subscribe
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should unsubscribe from a thread" do
|
121
|
+
DisqusRails::Api::Threads
|
122
|
+
.should_receive(:unsubscribe)
|
123
|
+
.with(:thread => thread.id, :email => nil)
|
124
|
+
.and_return(simple_result)
|
125
|
+
|
126
|
+
thread.unsubscribe
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should vote for a thread" do
|
130
|
+
DisqusRails::Api::Threads
|
131
|
+
.should_receive(:vote)
|
132
|
+
.with(:thread => thread.id, :vote => 1)
|
133
|
+
.and_return(simple_result)
|
134
|
+
|
135
|
+
thread.vote(1)
|
136
|
+
|
137
|
+
thread.vote.should == 1
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should update thread" do
|
141
|
+
DisqusRails::Api::Threads
|
142
|
+
.should_receive(:update)
|
143
|
+
.with(:title => "updated thread title", :thread => thread.id)
|
144
|
+
.and_return(updated_thread_hash)
|
145
|
+
|
146
|
+
thread.update(:title => "updated thread title")
|
147
|
+
|
148
|
+
thread.title.should == "updated thread title"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should return list of threads" do
|
152
|
+
DisqusRails::Api::Threads
|
153
|
+
.should_receive(:list)
|
154
|
+
.and_return(empty_collection_hash)
|
155
|
+
|
156
|
+
DisqusRails::Thread.where().should be_a_kind_of(DisqusRails::Threads)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return list of popular threads" do
|
160
|
+
DisqusRails::Api::Threads
|
161
|
+
.should_receive(:listPopular)
|
162
|
+
.and_return(empty_collection_hash)
|
163
|
+
|
164
|
+
DisqusRails::Thread.popular.should be_a_kind_of(DisqusRails::Threads)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should return list of hot threads" do
|
168
|
+
DisqusRails::Api::Threads
|
169
|
+
.should_receive(:listHot)
|
170
|
+
.and_return(empty_collection_hash)
|
171
|
+
|
172
|
+
DisqusRails::Thread.hot.should be_a_kind_of(DisqusRails::Threads)
|
173
|
+
end
|
174
|
+
end
|