disqus_rails 0.0.6 → 0.0.7

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.
@@ -1,101 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
-
4
- require 'rails/all'
5
- require 'disqus_rails'
6
-
7
- ActiveRecord::Base.establish_connection(
8
- :adapter => 'sqlite3',
9
- :database => ':memory:'
10
- )
11
-
12
- RSpec.configure do |config|
13
- end
@@ -1,78 +0,0 @@
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
- )()