commontator 4.5.4 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/MIT-LICENSE +2 -1
- data/README.md +31 -34
- data/Rakefile +3 -2
- data/app/assets/stylesheets/commontator/application.css +1 -0
- data/app/assets/stylesheets/commontator/comments.css +1 -0
- data/app/assets/stylesheets/commontator/threads.css +13 -7
- data/{spec/dummy/tmp/cache/assets/test/sprockets/a473b3873e554893372a53d71f5e9879 → app/assets/stylesheets/commontator/threads.css~} +0 -0
- data/app/controllers/commontator/application_controller.rb +14 -14
- data/app/controllers/commontator/application_controller.rb~ +35 -0
- data/app/controllers/commontator/comments_controller.rb +8 -7
- data/app/controllers/commontator/comments_controller.rb~ +153 -0
- data/app/controllers/commontator/subscriptions_controller.rb +1 -0
- data/app/controllers/commontator/threads_controller.rb +7 -2
- data/app/helpers/commontator/application_helper.rb +1 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -10
- data/app/mailers/commontator/subscriptions_mailer.rb~ +44 -0
- data/app/models/commontator/comment.rb +14 -13
- data/app/models/commontator/comment.rb~ +119 -0
- data/app/models/commontator/subscription.rb +8 -4
- data/app/models/commontator/thread.rb +64 -43
- data/app/models/commontator/thread.rb~ +159 -0
- data/app/views/commontator/comments/_actions.html.erb +1 -0
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_form.html.erb +5 -1
- data/app/views/commontator/comments/_form.html.erb~ +39 -0
- data/app/views/commontator/comments/_list.html.erb +1 -1
- data/app/views/commontator/comments/_show.html.erb +5 -3
- data/app/views/commontator/comments/_show.html.erb~ +49 -0
- data/app/views/commontator/comments/_votes.html.erb +2 -1
- data/app/views/commontator/comments/_votes.html.erb~ +69 -0
- data/app/views/commontator/comments/cancel.js.erb +1 -0
- data/app/views/commontator/comments/create.js.erb +6 -4
- data/app/views/commontator/comments/create.js.erb~ +14 -0
- data/app/views/commontator/comments/delete.js.erb +1 -0
- data/app/views/commontator/comments/edit.js.erb +1 -0
- data/app/views/commontator/comments/new.js.erb +3 -1
- data/app/views/commontator/comments/new.js.erb~ +13 -0
- data/app/views/commontator/comments/update.js.erb +1 -0
- data/app/views/commontator/comments/vote.js.erb +1 -0
- data/app/views/commontator/shared/_thread.html.erb +4 -5
- data/app/views/commontator/subscriptions/_link.html.erb +2 -1
- data/app/views/commontator/subscriptions/_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/subscribe.js.erb +1 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +1 -0
- data/app/views/commontator/threads/_reply.html.erb +4 -2
- data/app/views/commontator/threads/_reply.html.erb~ +19 -0
- data/app/views/commontator/threads/_show.html.erb +44 -9
- data/app/views/commontator/threads/_show.html.erb~ +95 -0
- data/app/views/commontator/threads/_show.js.erb +19 -0
- data/app/views/commontator/threads/show.js.erb +4 -4
- data/config/initializers/commontator.rb +169 -132
- data/config/initializers/commontator.rb~ +238 -0
- data/config/locales/commontator/en.yml +12 -3
- data/config/locales/commontator/en.yml~ +104 -0
- data/config/routes.rb +1 -0
- data/db/migrate/0_install_commontator.rb +9 -11
- data/db/migrate/0_install_commontator.rb~ +54 -0
- data/lib/commontator.rb +57 -16
- data/lib/commontator.rb~ +142 -0
- data/lib/commontator/acts_as_commontable.rb +12 -14
- data/lib/commontator/acts_as_commontator.rb +1 -16
- data/lib/commontator/commontable_config.rb +1 -0
- data/lib/commontator/commontator_config.rb +1 -0
- data/lib/commontator/controller_includes.rb +3 -3
- data/lib/commontator/engine.rb +1 -0
- data/lib/commontator/link_renderer.rb +29 -0
- data/lib/commontator/security_transgression.rb +1 -0
- data/lib/commontator/shared_helper.rb +7 -5
- data/lib/commontator/version.rb +2 -1
- data/lib/tasks/commontator_tasks.rake +1 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +12 -11
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +2 -1
- data/spec/app/controllers/commontator/threads_controller_spec.rb +2 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb +2 -1
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +2 -1
- data/spec/app/models/commontator/comment_spec.rb +18 -11
- data/spec/app/models/commontator/comment_spec.rb~ +74 -0
- data/spec/app/models/commontator/subscription_spec.rb +18 -8
- data/spec/app/models/commontator/thread_spec.rb +28 -42
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -0
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/models/dummy_model.rb +1 -0
- data/spec/dummy/app/models/dummy_user.rb +7 -2
- data/spec/dummy/app/models/dummy_user.rb~ +16 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -0
- data/spec/dummy/config.ru +1 -0
- data/spec/dummy/config/boot.rb +1 -0
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/config/environment.rb +1 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/production.rb +1 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/commontator.rb +6 -1
- data/spec/dummy/config/initializers/commontator.rb~ +15 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +1 -0
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +1 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +1 -0
- data/spec/dummy/db/schema.rb +10 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +1 -0
- data/spec/dummy/public/422.html +1 -0
- data/spec/dummy/public/500.html +1 -0
- data/spec/dummy/script/rails +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a3fb9025f90ff05a6fd4afc7ded2692c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c69ee3cc5796188d873574179290a6ef +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +3 -2
- data/spec/lib/commontator/acts_as_commontator_spec.rb +2 -5
- data/spec/lib/commontator/commontable_config_spec.rb +8 -5
- data/spec/lib/commontator/commontator_config_spec.rb +2 -1
- data/spec/lib/commontator/controller_includes_spec.rb +2 -1
- data/spec/lib/commontator/shared_helper_spec.rb +2 -1
- data/spec/lib/commontator_spec.rb +2 -1
- data/spec/{test_helper.rb → spec_helper.rb} +0 -0
- metadata +154 -135
- data/lib/commontator/remote_link_renderer.rb +0 -10
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/log/development.log +0 -36
- data/spec/dummy/log/test.log +0 -22683
- data/spec/dummy/tmp/cache/assets/test/sprockets/afa63eb365bdf4f42584b17ac9176b9d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'acts_as_votable'
|
3
3
|
|
4
4
|
module Commontator
|
@@ -48,20 +48,27 @@ module Commontator
|
|
48
48
|
it 'must make proper timestamps' do
|
49
49
|
@comment.save!
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@comment.updated_timestamp.must_equal ''
|
51
|
+
@comment.created_timestamp.must_equal I18n.t('commontator.comment.status.created_at',
|
52
|
+
:created_at => I18n.l(@comment.created_at,
|
53
|
+
:format => :commontator))
|
54
|
+
@comment.updated_timestamp.must_equal I18n.t('commontator.comment.status.updated_at',
|
55
|
+
:editor_name => @user.name,
|
56
|
+
:updated_at => I18n.l(@comment.updated_at,
|
57
|
+
:format => :commontator))
|
55
58
|
|
59
|
+
user2 = DummyUser.create
|
56
60
|
@comment.body = 'Something else'
|
57
|
-
@comment.editor =
|
61
|
+
@comment.editor = user2
|
58
62
|
@comment.save!
|
59
63
|
|
60
|
-
@comment.created_timestamp.must_equal I18n.t('commontator.comment.status.created_at',
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
@comment.created_timestamp.must_equal I18n.t('commontator.comment.status.created_at',
|
65
|
+
:created_at => I18n.l(@comment.created_at,
|
66
|
+
:format => :commontator))
|
67
|
+
@comment.updated_timestamp.must_equal I18n.t('commontator.comment.status.updated_at',
|
68
|
+
:editor_name => user2.name,
|
69
|
+
:updated_at => I18n.l(@comment.updated_at,
|
70
|
+
:format => :commontator))
|
65
71
|
end
|
66
72
|
end
|
67
73
|
end
|
74
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'acts_as_votable'
|
3
|
+
|
4
|
+
module Commontator
|
5
|
+
describe Comment do
|
6
|
+
before do
|
7
|
+
setup_model_spec
|
8
|
+
@comment = Comment.new
|
9
|
+
@comment.thread = @thread
|
10
|
+
@comment.creator = @user
|
11
|
+
@comment.body = 'Something'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'must be votable if acts_as_votable is installed' do
|
15
|
+
Comment.must_respond_to(:acts_as_votable)
|
16
|
+
@comment.is_votable?.must_equal true
|
17
|
+
@comment.acts_as_votable_initialized.must_equal true
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'must know if it has been modified' do
|
21
|
+
@comment.save!
|
22
|
+
|
23
|
+
@comment.is_modified?.must_equal false
|
24
|
+
|
25
|
+
@comment.body = 'Something else'
|
26
|
+
@comment.editor = @user
|
27
|
+
@comment.save!
|
28
|
+
|
29
|
+
@comment.is_modified?.must_equal true
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'must know if it has been deleted' do
|
33
|
+
user = DummyUser.new
|
34
|
+
|
35
|
+
@comment.is_deleted?.must_equal false
|
36
|
+
@comment.editor.must_be_nil
|
37
|
+
|
38
|
+
@comment.delete_by(user)
|
39
|
+
|
40
|
+
@comment.is_deleted?.must_equal true
|
41
|
+
@comment.editor.must_equal user
|
42
|
+
|
43
|
+
@comment.undelete_by(user)
|
44
|
+
|
45
|
+
@comment.is_deleted?.must_equal false
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'must make proper timestamps' do
|
49
|
+
@comment.save!
|
50
|
+
|
51
|
+
@comment.created_timestamp.must_equal I18n.t('commontator.comment.status.created_at',
|
52
|
+
:created_at => I18n.l(@comment.created_at,
|
53
|
+
:format => :commontator))
|
54
|
+
@comment.updated_timestamp.must_equal I18n.t('commontator.comment.status.updated_at',
|
55
|
+
:editor_name => @user.name,
|
56
|
+
:updated_at => I18n.l(@comment.updated_at,
|
57
|
+
:format => :commontator))
|
58
|
+
|
59
|
+
user2 = @user = DummyUser.create
|
60
|
+
@comment.body = 'Something else'
|
61
|
+
@comment.editor = user2
|
62
|
+
@comment.save!
|
63
|
+
|
64
|
+
@comment.created_timestamp.must_equal I18n.t('commontator.comment.status.created_at',
|
65
|
+
:created_at => I18n.l(@comment.created_at,
|
66
|
+
:format => :commontator))
|
67
|
+
@comment.updated_timestamp.must_equal I18n.t('commontator.comment.status.updated_at',
|
68
|
+
:editor_name => user2.name,
|
69
|
+
:updated_at => I18n.l(@comment.updated_at,
|
70
|
+
:format => :commontator))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Commontator
|
4
4
|
describe Subscription do
|
@@ -7,22 +7,32 @@ module Commontator
|
|
7
7
|
@subscription = Subscription.new
|
8
8
|
@subscription.thread = @thread
|
9
9
|
@subscription.subscriber = @user
|
10
|
+
@subscription.save!
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'must count unread comments' do
|
13
|
-
@subscription.
|
14
|
+
@subscription.unread_comments.count.must_equal 0
|
14
15
|
|
15
|
-
|
16
|
+
comment = Comment.new
|
17
|
+
comment.thread = @thread
|
18
|
+
comment.creator = @user
|
19
|
+
comment.body = 'Something'
|
20
|
+
comment.save!
|
16
21
|
|
17
|
-
@subscription.
|
22
|
+
@subscription.reload.unread_comments.count.must_equal 1
|
18
23
|
|
19
|
-
|
24
|
+
comment = Comment.new
|
25
|
+
comment.thread = @thread
|
26
|
+
comment.creator = @user
|
27
|
+
comment.body = 'Something else'
|
28
|
+
comment.save!
|
20
29
|
|
21
|
-
@subscription.
|
30
|
+
@subscription.reload.unread_comments.count.must_equal 2
|
22
31
|
|
23
|
-
@subscription.
|
32
|
+
@subscription.touch
|
24
33
|
|
25
|
-
@subscription.
|
34
|
+
@subscription.reload.unread_comments.count.must_equal 0
|
26
35
|
end
|
27
36
|
end
|
28
37
|
end
|
38
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Commontator
|
4
4
|
describe Thread do
|
@@ -8,8 +8,8 @@ module Commontator
|
|
8
8
|
|
9
9
|
it 'must have a config' do
|
10
10
|
@thread.config.must_be_instance_of CommontableConfig
|
11
|
-
@thread.
|
12
|
-
@thread.config.must_equal Commontator
|
11
|
+
@thread.update_attribute(:commontable_id, nil)
|
12
|
+
Thread.find(@thread.id).config.must_equal Commontator
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'must order all comments' do
|
@@ -65,42 +65,23 @@ module Commontator
|
|
65
65
|
@thread.is_closed?.must_equal false
|
66
66
|
end
|
67
67
|
|
68
|
-
it 'must
|
68
|
+
it 'must mark comments as read' do
|
69
69
|
@thread.subscribe(@user)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
@thread
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
@thread.is_subscribed?(@user).must_equal false
|
81
|
-
@thread.is_subscribed?(user2).must_equal true
|
82
|
-
@thread.is_subscribed?(DummyUser.create).must_equal false
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'must add unread comments and mark comments as read' do
|
86
|
-
@thread.subscribe(@user)
|
87
|
-
user2 = DummyUser.create
|
88
|
-
@thread.subscribe(user2)
|
89
|
-
|
90
|
-
@thread.subscription_for(@user).unread.must_equal 0
|
91
|
-
@thread.subscription_for(user2).unread.must_equal 0
|
92
|
-
|
93
|
-
@thread.add_unread_except_for(@user)
|
94
|
-
@thread.add_unread_except_for(user2)
|
95
|
-
@thread.add_unread_except_for(@user)
|
70
|
+
|
71
|
+
subscription = @thread.subscription_for(@user)
|
72
|
+
subscription.unread_comments.count.must_equal 0
|
73
|
+
|
74
|
+
comment = Comment.new
|
75
|
+
comment.thread = @thread
|
76
|
+
comment.creator = @user
|
77
|
+
comment.body = 'Something'
|
78
|
+
comment.save!
|
96
79
|
|
97
|
-
|
98
|
-
@thread.subscription_for(user2).unread.must_equal 2
|
80
|
+
subscription.reload.unread_comments.count.must_equal 1
|
99
81
|
|
100
|
-
@thread.mark_as_read_for(
|
82
|
+
@thread.mark_as_read_for(@user)
|
101
83
|
|
102
|
-
|
103
|
-
@thread.subscription_for(user2).unread.must_equal 0
|
84
|
+
subscription.reload.unread_comments.count.must_equal 0
|
104
85
|
end
|
105
86
|
|
106
87
|
it 'must be able to clear comments' do
|
@@ -109,19 +90,23 @@ module Commontator
|
|
109
90
|
comment.creator = @user
|
110
91
|
comment.body = 'Something'
|
111
92
|
comment.save!
|
112
|
-
|
93
|
+
|
94
|
+
@thread.close(@user)
|
95
|
+
|
113
96
|
@thread.commontable.must_equal @commontable
|
114
97
|
@thread.comments.must_include comment
|
115
|
-
@thread.is_closed?.must_equal
|
98
|
+
@thread.is_closed?.must_equal true
|
99
|
+
@thread.closer.must_equal @user
|
100
|
+
|
101
|
+
@commontable = DummyModel.find(@commontable.id)
|
116
102
|
@commontable.thread.must_equal @thread
|
117
|
-
|
118
|
-
@thread.clear
|
103
|
+
|
104
|
+
@thread.clear
|
119
105
|
|
120
106
|
@thread.commontable.must_be_nil
|
121
107
|
@thread.comments.must_include comment
|
122
|
-
|
123
|
-
@
|
124
|
-
@commontable.reload
|
108
|
+
|
109
|
+
@commontable = DummyModel.find(@commontable.id)
|
125
110
|
@commontable.thread.wont_be_nil
|
126
111
|
@commontable.thread.wont_equal @thread
|
127
112
|
@commontable.thread.comments.wont_include comment
|
@@ -133,3 +118,4 @@ module Commontator
|
|
133
118
|
end
|
134
119
|
end
|
135
120
|
end
|
121
|
+
|
data/spec/dummy/README.md
CHANGED
data/spec/dummy/Rakefile
CHANGED
data/spec/dummy/config.ru
CHANGED
data/spec/dummy/config/boot.rb
CHANGED