ideaoforder-acts_as_disqusable 0.4.0

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/test/merb_test.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+
3
+ module Merb
4
+ class Controller
5
+ end
6
+ end
7
+
8
+ class MerbTest < Test::Unit::TestCase
9
+
10
+ def test_view_helpers_should_be_included
11
+ require 'disqus'
12
+ assert Merb::Controller.new.disqus_thread
13
+ end
14
+
15
+ end
data/test/post_test.rb ADDED
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class PostTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ require 'disqus'
7
+ Disqus.defaults[:api_key] = DISQUS_TEST["api_key"]
8
+ end
9
+
10
+ def test_post_list
11
+ mock_api_call(:get_thread_posts)
12
+ list = Disqus::Post.list(create_thread)
13
+ assert_equal 2, list.size
14
+ assert_equal list.first.message, "This is a mock post"
15
+ end
16
+
17
+
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+
3
+ class Rails
4
+ end
5
+
6
+ module ActionView
7
+ class Base
8
+ end
9
+ end
10
+
11
+ class RailsTest < Test::Unit::TestCase
12
+
13
+ def test_view_helpers_should_be_included
14
+ require 'disqus'
15
+ assert ActionView::Base.new.disqus_thread
16
+ end
17
+
18
+ end
@@ -0,0 +1 @@
1
+ {"message": "user_api_key BAD could not be converted to UserKey object", "code": "input-invalid", "succeeded": false}
@@ -0,0 +1,23 @@
1
+ {
2
+ "message": {
3
+ "id": "12345",
4
+ "forum": "1234",
5
+ "thread": "123",
6
+ "created_at": "2008-01-03 14:44:07.627492",
7
+ "message": "This is a mock post",
8
+ "parent_post": null,
9
+ "shown": true,
10
+ "is_anonymous": false,
11
+ "author": {
12
+ "id":12,
13
+ "username":"testuser",
14
+ "display_name":"Test User",
15
+ "url":"http://www.example.com/testuser",
16
+ "email_hash":"thisisanMD5hash",
17
+ "has_avatar": true
18
+ }
19
+ },
20
+ "code": "ok",
21
+ "succeeded": true
22
+ }
23
+
@@ -0,0 +1 @@
1
+ {"message": "FAKE_FORUM_API_KEY", "code": "ok", "succeeded": true}
@@ -0,0 +1,12 @@
1
+ {
2
+ "message": [
3
+ {
4
+ "created_at": "2008-01-03 14:44:07.627492",
5
+ "shortname": "disqus-test",
6
+ "id": "1234",
7
+ "name": "Disqus Test"
8
+ }
9
+ ],
10
+ "code": "ok",
11
+ "succeeded": true
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "message":{
3
+ "1001":[10,12],
4
+ "1002":[15,20],
5
+ "1003":[20,20],
6
+ "1004":[10,10],
7
+ "1005":[5,10]
8
+ },
9
+ "succeeded":true,
10
+ "code":"ok"
11
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "message":{
3
+ "slug": "test_thread",
4
+ "forum": "60732",
5
+ "title": "Test thread",
6
+ "url": "FAKE_URL",
7
+ "id": "7651269",
8
+ "identifier": null,
9
+ "created_at": "2008-11-28T01:47",
10
+ "allow_comments": true
11
+ },
12
+ "succeeded": true,
13
+ "code": "ok"
14
+ }
15
+
16
+
17
+
18
+
@@ -0,0 +1,16 @@
1
+ {
2
+ "message": [
3
+ {
4
+ "id": "12345",
5
+ "forum": "1234",
6
+ "slug": "this_is_a_thread",
7
+ "title": "This is a thread",
8
+ "created_at": "2008-01-03 14:44:07.627492",
9
+ "allow_comments": true,
10
+ "url":"http://www.example.com/testthread",
11
+ "identifier": "this_is_the_thread_identifier"
12
+ }
13
+ ],
14
+ "code": "ok",
15
+ "succeeded": true
16
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "message": [{
3
+ "id": "12345",
4
+ "forum": "1234",
5
+ "thread": "123",
6
+ "created_at": "2008-01-03 14:44:07.627492",
7
+ "message": "This is a mock post",
8
+ "parent_post": null,
9
+ "shown": true,
10
+ "is_anonymous": false,
11
+ "author": {
12
+ "id":12,
13
+ "username":"testuser",
14
+ "display_name":"Test User",
15
+ "url":"http://www.example.com/testuser",
16
+ "email_hash":"thisisanMD5hash",
17
+ "has_avatar": true
18
+ }
19
+ },{
20
+ "id": "23456",
21
+ "forum": "1234",
22
+ "thread": "123",
23
+ "created_at": "2008-01-03 14:44:07.627492",
24
+ "message": "This is another mock post",
25
+ "parent_post": null,
26
+ "shown": true,
27
+ "is_anonymous": true,
28
+ "anonymous_author": {
29
+ "id":12,
30
+ "name":"Anonymous Coward",
31
+ "email_hash":"thisisanMD5hash"
32
+ }
33
+ }],
34
+ "code": "ok",
35
+ "succeeded": true
36
+ }
37
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "message":{
3
+ "thread":{
4
+ "slug": "test_thread",
5
+ "forum": "60732",
6
+ "title": "Test thread",
7
+ "url": "FAKE_URL",
8
+ "id": "7651269",
9
+ "identifier": "FAKE_IDENTIFIER",
10
+ "created_at": "2008-11-28T01:47",
11
+ "allow_comments": true
12
+ },
13
+ "created": false
14
+ },
15
+ "succeeded": true,
16
+ "code": "ok"
17
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "message":{},
3
+ "succeeded": true,
4
+ "code": "ok"
5
+ }
@@ -0,0 +1,32 @@
1
+ require 'test/unit'
2
+ require 'yaml'
3
+ require 'disqus/api'
4
+ require 'disqus/forum'
5
+ require 'disqus/thread'
6
+ require 'disqus/post'
7
+ require 'disqus/author'
8
+ require 'mocha'
9
+
10
+ DISQUS_TEST = YAML.load(File.read(File.dirname(__FILE__) + "/config.yml"))
11
+
12
+ def create_forum
13
+ forum = Disqus::Forum.new(1234, "disqus-test", "Disqus Test", "2008-01-03 14:44:07.627492")
14
+ forum.stubs(:key).returns("FAKE_FORUM_API_KEY")
15
+ forum
16
+ end
17
+
18
+ def create_thread
19
+ mock_forum = mock()
20
+ mock_forum.stubs(:key).returns("FAKE_FORUM_API_KEY")
21
+ Disqus::Thread.new("7651269", mock_forum, "test_thread", "Test thread", "2008-11-28T01:47", true, "FAKE_URL", nil)
22
+ end
23
+
24
+
25
+ def mock_api_call(method_name)
26
+ Disqus::Api.expects(method_name.to_sym).returns(JSON.parse(File.read(File.dirname(__FILE__) + "/responses/#{method_name}.json")))
27
+ end
28
+
29
+ def stub_api_call(method_name)
30
+ Disqus::Api.stubs(method_name.to_sym).returns(JSON.parse(File.read(File.dirname(__FILE__) + "/responses/#{method_name}.json")))
31
+ end
32
+
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ThreadTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ require 'disqus'
7
+ Disqus.defaults[:api_key] = DISQUS_TEST["api_key"]
8
+ stub_api_call(:get_forum_api_key)
9
+ end
10
+
11
+ def test_thread_list
12
+ mock_api_call(:get_thread_list)
13
+ forum = create_forum
14
+ list = Disqus::Thread.list(forum)
15
+ assert_equal 1, list.size
16
+ assert_equal list, [Disqus::Thread.new( 12345,
17
+ create_forum,
18
+ "this_is_a_thread",
19
+ "This is a thread",
20
+ "2008-01-03 14:44:07.627492",
21
+ true,
22
+ "http://www.example.com/testthread",
23
+ "this_is_the_thread_identifier" )]
24
+ end
25
+
26
+ end
27
+
28
+
@@ -0,0 +1,37 @@
1
+ require 'test/unit'
2
+ require 'disqus'
3
+ require 'disqus/view_helpers'
4
+
5
+ class ViewHelpersTest < Test::Unit::TestCase
6
+
7
+ include Disqus::ViewHelpers
8
+
9
+ def setup
10
+ Disqus::defaults[:account] = "tests"
11
+ end
12
+
13
+ def test_disqus_thread
14
+ assert disqus_thread
15
+ end
16
+
17
+ def test_disqus_comment_counts
18
+ assert disqus_comment_counts
19
+ end
20
+
21
+ def test_disqus_top_commenters
22
+ assert disqus_top_commenters
23
+ end
24
+
25
+ def test_disqus_popular_threads
26
+ assert disqus_popular_threads
27
+ end
28
+
29
+ def test_disqus_recent_comments
30
+ assert disqus_recent_comments
31
+ end
32
+
33
+ def test_disqus_combo
34
+ assert disqus_combo
35
+ end
36
+
37
+ end
@@ -0,0 +1,58 @@
1
+ require 'test/unit'
2
+ require 'disqus'
3
+
4
+ class DisqusWidgetTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ Disqus::defaults[:account] = "tests"
8
+ end
9
+
10
+ def test_thread
11
+ assert Disqus::Widget::thread
12
+ end
13
+
14
+ def test_comment_counts
15
+ assert Disqus::Widget::comment_counts
16
+ end
17
+
18
+ def test_combo
19
+ assert Disqus::Widget::combo
20
+ end
21
+
22
+ def test_recent_comments
23
+ assert Disqus::Widget::recent_comments
24
+ end
25
+
26
+ def test_popular_threads
27
+ assert Disqus::Widget::popular_threads
28
+ end
29
+
30
+ def test_top_commenters
31
+ assert Disqus::Widget::top_commenters
32
+ end
33
+
34
+ def test_invalid_default_tab
35
+ assert_raises ArgumentError do
36
+ Disqus::Widget::combo(:default_tab => "test")
37
+ end
38
+ end
39
+
40
+ def test_invalid_color
41
+ assert_raises ArgumentError do
42
+ Disqus::Widget::combo(:color => "test")
43
+ end
44
+ end
45
+
46
+ def test_invalid_num_items
47
+ assert_raises ArgumentError do
48
+ Disqus::Widget::combo(:num_items => 100)
49
+ end
50
+ end
51
+
52
+ def test_invalid_avatar_size
53
+ assert_raises ArgumentError do
54
+ Disqus::Widget::top_commenters(:avatar_size => 100)
55
+ end
56
+ end
57
+
58
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ideaoforder-acts_as_disqusable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Dickson
8
+ - Thomas Reynolds
9
+ - Norman Clarke
10
+ - Matthew Van Horn
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-08-05 00:00:00 -07:00
16
+ default_executable:
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: httparty
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.4
27
+ version:
28
+ description: Uses the Disqus API to make model(s) comment-on-able
29
+ email: mark@sitesteaders.com
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - README.rdoc
36
+ files:
37
+ - .gitignore
38
+ - MIT-LICENSE
39
+ - Manifest.txt
40
+ - README.rdoc
41
+ - Rakefile
42
+ - VERSION
43
+ - acts_as_disqusable.gemspec
44
+ - lib/acts_as_disqusable.rb
45
+ - lib/acts_as_disqusable/author.rb
46
+ - lib/acts_as_disqusable/forum.rb
47
+ - lib/acts_as_disqusable/post.rb
48
+ - lib/acts_as_disqusable/thread.rb
49
+ - lib/disqus.rb
50
+ - tasks/rcov.rake
51
+ - test/api_test.rb
52
+ - test/config.yml.sample
53
+ - test/forum_test.rb
54
+ - test/merb_test.rb
55
+ - test/post_test.rb
56
+ - test/rails_test.rb
57
+ - test/responses/bad_api_key.json
58
+ - test/responses/create_post.json
59
+ - test/responses/get_forum_api_key.json
60
+ - test/responses/get_forum_list.json
61
+ - test/responses/get_num_posts.json
62
+ - test/responses/get_thread_by_url.json
63
+ - test/responses/get_thread_list.json
64
+ - test/responses/get_thread_posts.json
65
+ - test/responses/thread_by_identifier.json
66
+ - test/responses/update_thread.json
67
+ - test/test_helper.rb
68
+ - test/thread_test.rb
69
+ - test/view_helpers_test.rb
70
+ - test/widget_test.rb
71
+ has_rdoc: false
72
+ homepage: http://github.com/ideaoforder/disqus
73
+ licenses:
74
+ post_install_message:
75
+ rdoc_options:
76
+ - --charset=UTF-8
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ requirements: []
92
+
93
+ rubyforge_project:
94
+ rubygems_version: 1.3.5
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Uses the Disqus API to make model(s) comment-on-able
98
+ test_files:
99
+ - test/merb_test.rb
100
+ - test/view_helpers_test.rb
101
+ - test/widget_test.rb
102
+ - test/api_test.rb
103
+ - test/post_test.rb
104
+ - test/thread_test.rb
105
+ - test/rails_test.rb
106
+ - test/forum_test.rb
107
+ - test/test_helper.rb