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,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails::User do
|
4
|
+
let!(:user_hash) do
|
5
|
+
{
|
6
|
+
:code => 0,
|
7
|
+
:response => {
|
8
|
+
"username" => "disqus_api",
|
9
|
+
"about" => "",
|
10
|
+
"name" => "disqus_api",
|
11
|
+
"url" => "",
|
12
|
+
"isFollowing" => false,
|
13
|
+
"isFollowedBy" => false,
|
14
|
+
"profileUrl" => "http://disqus.com/disqus_api/",
|
15
|
+
"emailHash" => "67f79ed8e10b74abf07a8dfe101bbab2",
|
16
|
+
"avatar" => {
|
17
|
+
"permalink" => "http://disqus.com/api/users/avatars/disqus_api.jpg",
|
18
|
+
"cache" => "http://mediacdn.disqus.com/1091/images/noavatar92.png"
|
19
|
+
}
|
20
|
+
},
|
21
|
+
:id => "1",
|
22
|
+
:isAnonymous => false,
|
23
|
+
:email => "example@disqus.com"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:user){ DisqusRails::User.new(user_hash[:response]) }
|
28
|
+
|
29
|
+
let(:empty_collection_hash) do
|
30
|
+
{
|
31
|
+
:cursor => {
|
32
|
+
"prev" => "null",
|
33
|
+
"hasNext" => true,
|
34
|
+
"next" => "1368581473195442:0:0",
|
35
|
+
"hasPrev" => false,
|
36
|
+
"total" => "null",
|
37
|
+
"id" => "1368581473195442:0:0",
|
38
|
+
"more" => true
|
39
|
+
},
|
40
|
+
:code => 0,
|
41
|
+
:response => []
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should get user details information with find method" do
|
46
|
+
DisqusRails::Api::Users
|
47
|
+
.should_receive(:details)
|
48
|
+
.with(:user => 1)
|
49
|
+
.and_return(user_hash)
|
50
|
+
|
51
|
+
DisqusRails::User.find(1).should be_a_kind_of(DisqusRails::User)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should get user forums as DisqusRails::Forums class instance" do
|
55
|
+
DisqusRails::Api::Users
|
56
|
+
.should_receive(:listForums)
|
57
|
+
.and_return(empty_collection_hash)
|
58
|
+
|
59
|
+
user.forums.should be_a_kind_of(DisqusRails::Forums)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should get user active forums as DisqusRails::Forums class instance" do
|
63
|
+
DisqusRails::Api::Users
|
64
|
+
.should_receive(:listActiveForums)
|
65
|
+
.and_return(empty_collection_hash)
|
66
|
+
|
67
|
+
user.active_forums.should be_a_kind_of(DisqusRails::Forums)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should get user active threads as DisqusRails::Threads class instance" do
|
71
|
+
DisqusRails::Api::Users
|
72
|
+
.should_receive(:listActiveThreads)
|
73
|
+
.and_return(empty_collection_hash)
|
74
|
+
|
75
|
+
user.active_threads.should be_a_kind_of(DisqusRails::Threads)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should get user posts as DisqusRails::Posts class instance" do
|
79
|
+
DisqusRails::Api::Users
|
80
|
+
.should_receive(:listPosts)
|
81
|
+
.and_return(empty_collection_hash)
|
82
|
+
|
83
|
+
user.posts.should be_a_kind_of(DisqusRails::Posts)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should get user followers as DisqusRails::Users class instance" do
|
87
|
+
DisqusRails::Api::Users
|
88
|
+
.should_receive(:listFollowers)
|
89
|
+
.and_return(empty_collection_hash)
|
90
|
+
|
91
|
+
user.followers.should be_a_kind_of(DisqusRails::Users)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should get users following users as DisqusRails::Users class instance" do
|
95
|
+
DisqusRails::Api::Users
|
96
|
+
.should_receive(:listFollowing)
|
97
|
+
.and_return(empty_collection_hash)
|
98
|
+
|
99
|
+
user.following.should be_a_kind_of(DisqusRails::Users)
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisqusRails do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
DisqusRails.setup do |config|
|
7
|
+
config::SHORT_NAME = "stubbed_short_name"
|
8
|
+
config::SECRET_KEY = "stubbed_secret_key"
|
9
|
+
config::PUBLIC_KEY = "stubbed_public_key"
|
10
|
+
config::ACCESS_TOKEN = "stubbed_access_token"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
%w(SHORT_NAME SECRET_KEY PUBLIC_KEY ACCESS_TOKEN).each do |config_const|
|
15
|
+
it { should be_const_defined config_const }
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
class @DisqusRails
|
2
|
+
|
3
|
+
constructor: (attributes)->
|
4
|
+
@short_name = attributes['short_name']
|
5
|
+
@public_key = attributes['public_key']
|
6
|
+
@sso = attributes['sso']
|
7
|
+
|
8
|
+
if attributes['remote_auth_s3'] then @remote_auth_s3 = attributes['remote_auth_s3']
|
9
|
+
if attributes['reset'] then reset = attributes['reset']
|
10
|
+
|
11
|
+
@registerDisqusConfig()
|
12
|
+
|
13
|
+
if reset
|
14
|
+
@isResetting = false
|
15
|
+
@registerResetFunction()
|
16
|
+
|
17
|
+
reset: ->
|
18
|
+
unless @isResetting
|
19
|
+
@isResetting = true
|
20
|
+
that = this
|
21
|
+
DISQUS.reset
|
22
|
+
reload: true
|
23
|
+
config: ->
|
24
|
+
this.page.identifier = that.disqusable_id
|
25
|
+
this.page.title = that.disqusable_title
|
26
|
+
|
27
|
+
registerResetFunction: ->
|
28
|
+
$(document).on "disqus:on_ready", =>
|
29
|
+
@reset()
|
30
|
+
|
31
|
+
registerDisqusConfig: ->
|
32
|
+
that = this
|
33
|
+
window.disqus_config = ->
|
34
|
+
if that.remote_auth_s3 && that.sso
|
35
|
+
this.page.remote_auth_s3 = that.remote_auth_s3
|
36
|
+
this.page.api_key = that.public_key
|
37
|
+
this.sso = that.sso
|
38
|
+
|
39
|
+
@callbacks.afterRender = [->
|
40
|
+
$(document).trigger "disqus:after_render"
|
41
|
+
]
|
42
|
+
@callbacks.onInit = [->
|
43
|
+
$(document).trigger "disqus:on_init"
|
44
|
+
]
|
45
|
+
@callbacks.onNewComment = [->
|
46
|
+
$(document).trigger "disqus:on_new_comment"
|
47
|
+
]
|
48
|
+
@callbacks.onPaginate = [->
|
49
|
+
$(document).trigger "disqus:on_paginate"
|
50
|
+
]
|
51
|
+
@callbacks.onReady = [->
|
52
|
+
$(document).trigger "disqus:on_ready"
|
53
|
+
]
|
54
|
+
@callbacks.preData = [->
|
55
|
+
$(document).trigger "disqus:pre_data"
|
56
|
+
]
|
57
|
+
@callbacks.preInit = [->
|
58
|
+
$(document).trigger "disqus:pre_init"
|
59
|
+
]
|
60
|
+
@callbacks.preReset = [->
|
61
|
+
$(document).trigger "disqus:pre_reset"
|
62
|
+
]
|
63
|
+
|
64
|
+
draw_thread: (disqusable_id, disqusable_title)->
|
65
|
+
|
66
|
+
@disqusable_id = disqusable_id
|
67
|
+
@disqusable_title = disqusable_title
|
68
|
+
|
69
|
+
window.disqus_shortname = @short_name
|
70
|
+
window.disqus_title = @disqusable_title || document.title
|
71
|
+
|
72
|
+
(->
|
73
|
+
dsq = document.createElement("script")
|
74
|
+
dsq.type = "text/javascript"
|
75
|
+
dsq.async = true
|
76
|
+
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js"
|
77
|
+
(document.getElementsByTagName("head")[0] or document.getElementsByTagName("body")[0]).appendChild dsq
|
78
|
+
)()
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: disqus_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anton Kyrychenko
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Disqus 2012 Ruby on Rails wrapper
|
95
|
+
email:
|
96
|
+
- kyrychenkoanton@gmail.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Gemfile
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.md
|
105
|
+
- Rakefile
|
106
|
+
- disqus_rails.gemspec
|
107
|
+
- lib/disqus_rails.rb
|
108
|
+
- lib/disqus_rails/active_record/acts_as_disqusable.rb
|
109
|
+
- lib/disqus_rails/active_record/acts_as_disquser.rb
|
110
|
+
- lib/disqus_rails/api.rb
|
111
|
+
- lib/disqus_rails/api.yml
|
112
|
+
- lib/disqus_rails/category.rb
|
113
|
+
- lib/disqus_rails/collection.rb
|
114
|
+
- lib/disqus_rails/forum.rb
|
115
|
+
- lib/disqus_rails/helpers.rb
|
116
|
+
- lib/disqus_rails/model.rb
|
117
|
+
- lib/disqus_rails/post.rb
|
118
|
+
- lib/disqus_rails/thread.rb
|
119
|
+
- lib/disqus_rails/user.rb
|
120
|
+
- lib/disqus_rails/version.rb
|
121
|
+
- spec/disqus_rails/active_record/acts_as_disqusable_spec.rb
|
122
|
+
- spec/disqus_rails/active_record/acts_as_disquser_spec.rb
|
123
|
+
- spec/disqus_rails/api_spec.rb
|
124
|
+
- spec/disqus_rails/category_spec.rb
|
125
|
+
- spec/disqus_rails/collection_spec.rb
|
126
|
+
- spec/disqus_rails/forum_spec.rb
|
127
|
+
- spec/disqus_rails/model_spec.rb
|
128
|
+
- spec/disqus_rails/post_spec.rb
|
129
|
+
- spec/disqus_rails/thread_spec.rb
|
130
|
+
- spec/disqus_rails/user_spec.rb
|
131
|
+
- spec/disqus_rails_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- vendor/assets/javascripts/disqus_rails.js.coffee
|
134
|
+
homepage: https://github.com/sandric/disqus_rails
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.24
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Integrates Disqus service into your Ruby on Rails application
|
159
|
+
test_files:
|
160
|
+
- spec/disqus_rails/active_record/acts_as_disqusable_spec.rb
|
161
|
+
- spec/disqus_rails/active_record/acts_as_disquser_spec.rb
|
162
|
+
- spec/disqus_rails/api_spec.rb
|
163
|
+
- spec/disqus_rails/category_spec.rb
|
164
|
+
- spec/disqus_rails/collection_spec.rb
|
165
|
+
- spec/disqus_rails/forum_spec.rb
|
166
|
+
- spec/disqus_rails/model_spec.rb
|
167
|
+
- spec/disqus_rails/post_spec.rb
|
168
|
+
- spec/disqus_rails/thread_spec.rb
|
169
|
+
- spec/disqus_rails/user_spec.rb
|
170
|
+
- spec/disqus_rails_spec.rb
|
171
|
+
- spec/spec_helper.rb
|