adva_comments 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/adva_comments.gemspec +20 -0
- data/app/assets/javascripts/adva_comments/jquery.comments.js +41 -0
- data/app/assets/stylesheets/adva_comments/admin/comments.scss +34 -0
- data/app/assets/stylesheets/adva_comments/comments.scss +50 -0
- data/app/controllers/admin/comments_controller.rb +86 -0
- data/app/controllers/comments_controller.rb +109 -0
- data/app/helpers/admin/comments_helper.rb +32 -0
- data/app/helpers/comments_helper.rb +71 -0
- data/app/mailers/comment_mailer.rb +8 -0
- data/app/models/comment.rb +94 -0
- data/app/views/admin/articles/_comments_settings.html.erb +1 -0
- data/app/views/admin/comments/_form.html.erb +12 -0
- data/app/views/admin/comments/edit.html.erb +9 -0
- data/app/views/admin/comments/index.html.erb +43 -0
- data/app/views/admin/sections/_comments_settings.html.erb +7 -0
- data/app/views/admin/sites/_comments_settings.html.erb +7 -0
- data/app/views/comment_mailer/comment_notification.html.erb +12 -0
- data/app/views/comments/_comment.html.erb +13 -0
- data/app/views/comments/_form.html.erb +44 -0
- data/app/views/comments/_list.html.erb +8 -0
- data/app/views/comments/comments.atom.builder +16 -0
- data/app/views/comments/preview.html.erb +3 -0
- data/app/views/comments/show.html.erb +12 -0
- data/config/initializers/article.rb +13 -0
- data/config/initializers/content.rb +17 -0
- data/config/initializers/controllers.rb +25 -0
- data/config/initializers/menus.rb +24 -0
- data/config/initializers/section.rb +15 -0
- data/config/initializers/site.rb +11 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20080401000007_create_comments_table.rb +22 -0
- data/db/migrate/20080721141112_add_comment_board_id.rb +9 -0
- data/lib/action_controller/acts_as_commentable.rb +43 -0
- data/lib/active_record/has_many_comments.rb +49 -0
- data/lib/adva_comments/version.rb +3 -0
- data/lib/adva_comments.rb +19 -0
- data/lib/format.rb +3 -0
- data/test/contexts.rb +29 -0
- data/test/functional/admin/comments_controller_test.rb +200 -0
- data/test/functional/comments_controller_test.rb +133 -0
- data/test/functional/comments_routes_test.rb +17 -0
- data/test/test_helper.rb +4 -0
- data/test/unit/helpers/admin/comments_helper_test.rb +23 -0
- data/test/unit/helpers/comments_helper_test.rb +147 -0
- data/test/unit/models/comment_test.rb +150 -0
- data/test/unit/models/commentable_test.rb +30 -0
- data/test/unit/observers/activities_comment_observer_test.rb +45 -0
- metadata +132 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class CommentableModelTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@commentable = Content.new
|
7
|
+
end
|
8
|
+
|
9
|
+
test "has many comments" do
|
10
|
+
@commentable.should have_many(:comments)
|
11
|
+
end
|
12
|
+
|
13
|
+
test "has many approved_comments" do
|
14
|
+
@commentable.should have_many(:approved_comments)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "has many unapproved_comments" do
|
18
|
+
@commentable.should have_many(:unapproved_comments)
|
19
|
+
end
|
20
|
+
|
21
|
+
# FIXME how to specify this?
|
22
|
+
# test 'comments.by_author is a shortcut to find_all_by_author_id_and_author_type' do
|
23
|
+
# mock(@commentable.comments).find_all_by_author_id_and_author_type
|
24
|
+
# @commentable.comments.by_author(User.new)
|
25
|
+
# end
|
26
|
+
|
27
|
+
# FIXME
|
28
|
+
# test '#approved_comments_count returns the number of the approved comments'
|
29
|
+
# TODO and it really should be implemented as a Counter ...
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
|
+
|
3
|
+
if Rails.plugin?(:adva_activity)
|
4
|
+
class ActivitiesCommentObserverTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
Comment.old_add_observer(@observer = Activities::CommentObserver.instance)
|
8
|
+
@approved = Article.first.approved_comments.first
|
9
|
+
@unapproved = Article.first.unapproved_comments.first
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
super
|
14
|
+
Comment.delete_observer(@observer)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "logs a 'created' activity when the comment is a new_record" do
|
18
|
+
comment = Comment.create! :body => 'body',
|
19
|
+
:commentable => @approved.commentable,
|
20
|
+
:author => @approved.author
|
21
|
+
|
22
|
+
comment.activities.first.actions.should == ['created']
|
23
|
+
end
|
24
|
+
|
25
|
+
test "logs an 'edited' activity when the comment already exists" do
|
26
|
+
@approved.update_attributes! :body => 'body was updated'
|
27
|
+
@approved.activities.first.actions.should == ['edited']
|
28
|
+
end
|
29
|
+
|
30
|
+
test "logs an 'approved' activity when the comment is approved and :approved has changed" do
|
31
|
+
@unapproved.update_attributes! :approved => 1
|
32
|
+
@unapproved.activities.first.actions.should == ['approved']
|
33
|
+
end
|
34
|
+
|
35
|
+
test "logs a 'unapproved' activity when the comment is a draft and :approved has changed" do
|
36
|
+
@approved.update_attributes! :approved => 0
|
37
|
+
@approved.activities.first.actions.should == ['unapproved']
|
38
|
+
end
|
39
|
+
|
40
|
+
test "logs a 'deleted' activity when the comment is destroyed" do
|
41
|
+
@approved.destroy
|
42
|
+
@approved.activities.first.actions.should == ['deleted']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adva_comments
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Micah Geisel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: validates_email_format_of
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: invisible_captcha
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Adva Comments
|
42
|
+
email:
|
43
|
+
- micah@botandrose.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- adva_comments.gemspec
|
54
|
+
- app/assets/javascripts/adva_comments/jquery.comments.js
|
55
|
+
- app/assets/stylesheets/adva_comments/admin/comments.scss
|
56
|
+
- app/assets/stylesheets/adva_comments/comments.scss
|
57
|
+
- app/controllers/admin/comments_controller.rb
|
58
|
+
- app/controllers/comments_controller.rb
|
59
|
+
- app/helpers/admin/comments_helper.rb
|
60
|
+
- app/helpers/comments_helper.rb
|
61
|
+
- app/mailers/comment_mailer.rb
|
62
|
+
- app/models/comment.rb
|
63
|
+
- app/views/admin/articles/_comments_settings.html.erb
|
64
|
+
- app/views/admin/comments/_form.html.erb
|
65
|
+
- app/views/admin/comments/edit.html.erb
|
66
|
+
- app/views/admin/comments/index.html.erb
|
67
|
+
- app/views/admin/sections/_comments_settings.html.erb
|
68
|
+
- app/views/admin/sites/_comments_settings.html.erb
|
69
|
+
- app/views/comment_mailer/comment_notification.html.erb
|
70
|
+
- app/views/comments/_comment.html.erb
|
71
|
+
- app/views/comments/_form.html.erb
|
72
|
+
- app/views/comments/_list.html.erb
|
73
|
+
- app/views/comments/comments.atom.builder
|
74
|
+
- app/views/comments/preview.html.erb
|
75
|
+
- app/views/comments/show.html.erb
|
76
|
+
- config/initializers/article.rb
|
77
|
+
- config/initializers/content.rb
|
78
|
+
- config/initializers/controllers.rb
|
79
|
+
- config/initializers/menus.rb
|
80
|
+
- config/initializers/section.rb
|
81
|
+
- config/initializers/site.rb
|
82
|
+
- config/routes.rb
|
83
|
+
- db/migrate/20080401000007_create_comments_table.rb
|
84
|
+
- db/migrate/20080721141112_add_comment_board_id.rb
|
85
|
+
- lib/action_controller/acts_as_commentable.rb
|
86
|
+
- lib/active_record/has_many_comments.rb
|
87
|
+
- lib/adva_comments.rb
|
88
|
+
- lib/adva_comments/version.rb
|
89
|
+
- lib/format.rb
|
90
|
+
- test/contexts.rb
|
91
|
+
- test/functional/admin/comments_controller_test.rb
|
92
|
+
- test/functional/comments_controller_test.rb
|
93
|
+
- test/functional/comments_routes_test.rb
|
94
|
+
- test/test_helper.rb
|
95
|
+
- test/unit/helpers/admin/comments_helper_test.rb
|
96
|
+
- test/unit/helpers/comments_helper_test.rb
|
97
|
+
- test/unit/models/comment_test.rb
|
98
|
+
- test/unit/models/commentable_test.rb
|
99
|
+
- test/unit/observers/activities_comment_observer_test.rb
|
100
|
+
homepage: ''
|
101
|
+
licenses: []
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubygems_version: 3.2.3
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Engine for Adva CMS commenting component
|
122
|
+
test_files:
|
123
|
+
- test/contexts.rb
|
124
|
+
- test/functional/admin/comments_controller_test.rb
|
125
|
+
- test/functional/comments_controller_test.rb
|
126
|
+
- test/functional/comments_routes_test.rb
|
127
|
+
- test/test_helper.rb
|
128
|
+
- test/unit/helpers/admin/comments_helper_test.rb
|
129
|
+
- test/unit/helpers/comments_helper_test.rb
|
130
|
+
- test/unit/models/comment_test.rb
|
131
|
+
- test/unit/models/commentable_test.rb
|
132
|
+
- test/unit/observers/activities_comment_observer_test.rb
|