commontator 0.4.1 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -23
- data/app/assets/stylesheets/commontator/comments.css +1 -1
- data/app/assets/stylesheets/commontator/comments.css~ +0 -4
- data/app/controllers/commontator/application_controller.rb +4 -5
- data/app/controllers/commontator/application_controller.rb~ +5 -5
- data/app/controllers/commontator/comments_controller.rb +30 -30
- data/app/controllers/commontator/comments_controller.rb~ +31 -31
- data/app/controllers/commontator/subscriptions_controller.rb +8 -7
- data/app/controllers/commontator/subscriptions_controller.rb~ +6 -7
- data/app/controllers/commontator/threads_controller.rb +8 -9
- data/app/controllers/commontator/threads_controller.rb~ +9 -10
- data/app/helpers/commontator/comments_helper.rb~ +14 -24
- data/app/helpers/commontator/subscriptions_helper.rb~ +3 -3
- data/app/helpers/commontator/threads_helper.rb +0 -8
- data/app/helpers/commontator/threads_helper.rb~ +5 -5
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -8
- data/app/mailers/commontator/subscriptions_mailer.rb~ +9 -10
- data/app/models/commontator/comment.rb +14 -6
- data/app/models/commontator/comment.rb~ +15 -12
- data/app/views/commontator/comments/_actions.html.erb +6 -5
- data/app/views/commontator/comments/_actions.html.erb~ +6 -5
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_body.html.erb~ +1 -2
- data/app/views/commontator/comments/_form.html.erb +8 -3
- data/app/views/commontator/comments/_form.html.erb~ +7 -4
- data/app/views/commontator/comments/_show.html.erb +11 -8
- data/app/views/commontator/comments/_show.html.erb~ +11 -8
- data/app/views/commontator/comments/_votes.html.erb +7 -6
- data/app/views/commontator/comments/create.js.erb +4 -2
- data/app/views/commontator/comments/delete.js.erb +5 -3
- data/app/views/commontator/comments/delete.js.erb~ +5 -3
- data/app/views/commontator/comments/update.js.erb +1 -1
- data/app/views/commontator/comments/update.js.erb~ +1 -1
- data/app/views/commontator/comments/vote.js.erb +2 -1
- data/app/views/commontator/shared/_thread.html.erb +17 -0
- data/app/views/commontator/shared/_thread.html.erb~ +16 -0
- data/app/views/commontator/shared/_thread_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/_link.html.erb +3 -2
- data/app/views/commontator/subscriptions/subscribe.js.erb +2 -1
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +1 -1
- data/app/views/commontator/threads/_show.html.erb +18 -11
- data/app/views/commontator/threads/_show.html.erb~ +18 -11
- data/app/views/commontator/threads/show.js.erb +2 -1
- data/config/initializers/commontator.rb +14 -14
- data/db/migrate/0_install_commontator.rb +3 -3
- data/lib/commontator.rb +5 -6
- data/lib/commontator.rb~ +5 -6
- data/lib/commontator/acts_as_commontable.rb +2 -0
- data/lib/commontator/acts_as_commontator.rb +2 -0
- data/lib/commontator/controller_includes.rb +23 -0
- data/lib/commontator/controller_includes.rb~ +23 -0
- data/lib/commontator/shared_helper.rb +42 -0
- data/lib/commontator/shared_helper.rb~ +42 -0
- data/lib/commontator/shared_methods.rb~ +24 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- data/test/dummy/config/initializers/commontator.rb +15 -15
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/1_install_commontator.commontator.rb +3 -3
- data/test/dummy/db/schema.rb +3 -3
- data/test/dummy/log/development.log +64 -0
- metadata +10 -70
- data/app/assets/stylesheets/commontator/application.css~ +0 -88
- data/app/assets/stylesheets/commontator/threads.css~ +0 -13
- data/app/helpers/commontator/application_helper.rb~ +0 -11
- data/app/helpers/commontator/comments_helper.rb +0 -51
- data/app/helpers/commontator/commontable_helper.rb~ +0 -9
- data/app/helpers/commontator/commontator_helper.rb +0 -8
- data/app/helpers/commontator/commontator_helper.rb~ +0 -8
- data/app/helpers/commontator/subscriptions_helper.rb +0 -8
- data/app/mailers/commontator/subscription_mailer.rb~ +0 -38
- data/app/models/commontator/subscription.rb~ +0 -21
- data/app/models/commontator/thread.rb~ +0 -143
- data/app/views/commontator/comments/_votes.html.erb~ +0 -62
- data/app/views/commontator/comments/create.js.erb~ +0 -15
- data/app/views/commontator/comments/destroy.js.erb~ +0 -1
- data/app/views/commontator/comments/edit.html.erb~ +0 -6
- data/app/views/commontator/comments/edit.js.erb~ +0 -5
- data/app/views/commontator/comments/new.html.erb~ +0 -8
- data/app/views/commontator/comments/new.js.erb~ +0 -12
- data/app/views/commontator/comments/vote.js.erb~ +0 -5
- data/app/views/commontator/shared/_thread_link.html.erb +0 -13
- data/app/views/commontator/subscriptions/_index.html.erb~ +0 -16
- data/app/views/commontator/subscriptions/_link.html.erb~ +0 -15
- data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +0 -13
- data/app/views/commontator/subscriptions/create.js.erb~ +0 -5
- data/app/views/commontator/subscriptions/destroy.js.erb~ +0 -3
- data/app/views/commontator/subscriptions/index.html.erb~ +0 -16
- data/app/views/commontator/subscriptions/subscribe.js.erb~ +0 -5
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +0 -6
- data/app/views/commontator/threads/_actions.html.erb~ +0 -28
- data/app/views/commontator/threads/_link.html.erb~ +0 -14
- data/app/views/commontator/threads/close.js.erb~ +0 -5
- data/app/views/commontator/threads/show.html.erb~ +0 -3
- data/app/views/commontator/threads/show.js.erb~ +0 -6
- data/config/initializers/commontator.rb~ +0 -179
- data/config/routes.rb~ +0 -24
- data/db/migrate/0_install_commontator.rb~ +0 -48
- data/lib/commontator/acts_as_commontable.rb~ +0 -39
- data/lib/commontator/acts_as_commontator.rb~ +0 -28
- data/lib/commontator/commontable_config.rb~ +0 -13
- data/lib/commontator/commontator_config.rb~ +0 -13
- data/lib/commontator/routes.rb~ +0 -37
- data/lib/tasks/commontator_tasks.rake~ +0 -41
- data/test/dummy/config/initializers/commontator.rb~ +0 -179
- data/test/dummy/config/routes.rb~ +0 -3
- data/test/functional/comment_thread_subscriptions_controller_test.rb~ +0 -125
- data/test/functional/comments_controller_test.rb~ +0 -184
- data/test/functional/subscriptions_controller_test.rb~ +0 -122
- data/test/unit/comment_test.rb~ +0 -38
- data/test/unit/comment_thread_subscription_test.rb~ +0 -18
- data/test/unit/comment_thread_test.rb~ +0 -60
- data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +0 -7
- data/test/unit/helpers/comments_helper_test.rb~ +0 -7
- data/test/unit/helpers/subscriptions_helper_test.rb~ +0 -4
- data/test/unit/subscription_test.rb~ +0 -15
- data/test/unit/thread_test.rb~ +0 -57
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CommentThreadSubscriptionsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@question = FactoryGirl.create(:simple_question)
|
7
|
-
@user = FactoryGirl.create(:user)
|
8
|
-
FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
|
9
|
-
@published_question = make_simple_question(:method => :create, :published => true)
|
10
|
-
@user2 = FactoryGirl.create(:user)
|
11
|
-
end
|
12
|
-
|
13
|
-
test "should not get index not logged in" do
|
14
|
-
get :index
|
15
|
-
assert_redirected_to login_path
|
16
|
-
end
|
17
|
-
|
18
|
-
test "should get index" do
|
19
|
-
user_login
|
20
|
-
get :index
|
21
|
-
assert_response :success
|
22
|
-
end
|
23
|
-
|
24
|
-
test "should not create comment_thread_subscription not logged in" do
|
25
|
-
assert_difference('CommentThreadSubscription.count', 0) do
|
26
|
-
get :create, :question_id => @question.to_param
|
27
|
-
end
|
28
|
-
|
29
|
-
assert_redirected_to login_path
|
30
|
-
end
|
31
|
-
|
32
|
-
test "should not create comment_thread_subscription not authorized" do
|
33
|
-
user_login
|
34
|
-
assert_difference('CommentThreadSubscription.count', 0) do
|
35
|
-
get :create, :question_id => @question.to_param
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_response(403)
|
39
|
-
end
|
40
|
-
|
41
|
-
test "should not create comment_thread_subscription already subscribed" do
|
42
|
-
sign_in @user
|
43
|
-
FactoryGirl.create(:comment_thread_subscription,
|
44
|
-
:user => @user, :comment_thread => @question.comment_thread)
|
45
|
-
assert_difference('CommentThreadSubscription.count', 0) do
|
46
|
-
get :create, :question_id => @question.to_param
|
47
|
-
end
|
48
|
-
|
49
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
50
|
-
end
|
51
|
-
|
52
|
-
test "should create comment_thread_subscription" do
|
53
|
-
sign_in @user
|
54
|
-
assert_difference('CommentThreadSubscription.count') do
|
55
|
-
get :create, :question_id => @question.to_param
|
56
|
-
end
|
57
|
-
|
58
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
59
|
-
end
|
60
|
-
|
61
|
-
test "should create comment_thread_subscription published question" do
|
62
|
-
user_login
|
63
|
-
assert_difference('CommentThreadSubscription.count') do
|
64
|
-
get :create, :question_id => @published_question.to_param
|
65
|
-
end
|
66
|
-
|
67
|
-
assert_redirected_to question_comments_path(@published_question.to_param)
|
68
|
-
end
|
69
|
-
|
70
|
-
test "should not destroy comment_thread_subscription not logged in" do
|
71
|
-
FactoryGirl.create(:comment_thread_subscription,
|
72
|
-
:user => @user, :comment_thread => @question.comment_thread)
|
73
|
-
assert_difference('CommentThreadSubscription.count', 0) do
|
74
|
-
get :destroy, :question_id => @question.to_param
|
75
|
-
end
|
76
|
-
|
77
|
-
assert_redirected_to login_path
|
78
|
-
end
|
79
|
-
|
80
|
-
test "should not destroy comment_thread_subscription not authorized" do
|
81
|
-
user_login
|
82
|
-
FactoryGirl.create(:comment_thread_subscription,
|
83
|
-
:user => @user, :comment_thread => @question.comment_thread)
|
84
|
-
assert_difference('CommentThreadSubscription.count', 0) do
|
85
|
-
get :destroy, :question_id => @question.to_param
|
86
|
-
end
|
87
|
-
|
88
|
-
assert_response(403)
|
89
|
-
end
|
90
|
-
|
91
|
-
test "should not destroy comment_thread_subscription no subscription" do
|
92
|
-
sign_in @user
|
93
|
-
assert_difference('CommentThreadSubscription.count', 0) do
|
94
|
-
get :destroy, :question_id => @question.to_param
|
95
|
-
end
|
96
|
-
|
97
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
98
|
-
end
|
99
|
-
|
100
|
-
test "should destroy comment_thread_subscription" do
|
101
|
-
sign_in @user
|
102
|
-
FactoryGirl.create(:comment_thread_subscription,
|
103
|
-
:user => @user, :comment_thread => @question.comment_thread)
|
104
|
-
assert_difference('CommentThreadSubscription.count', -1) do
|
105
|
-
get :destroy, :question_id => @question.to_param
|
106
|
-
end
|
107
|
-
|
108
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
109
|
-
end
|
110
|
-
|
111
|
-
test "should destroy comment_thread_subscription published question" do
|
112
|
-
sign_in @user2
|
113
|
-
FactoryGirl.create(:comment_thread_subscription,
|
114
|
-
:user => @user2, :comment_thread => @published_question.comment_thread)
|
115
|
-
assert_difference('CommentThreadSubscription.count', -1) do
|
116
|
-
get :destroy, :question_id => @published_question.to_param
|
117
|
-
end
|
118
|
-
|
119
|
-
assert_redirected_to question_comments_path(@published_question.to_param)
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
data/test/unit/comment_test.rb~
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
|
2
|
-
# License version 3 or later. See the COPYRIGHT file for details.
|
3
|
-
|
4
|
-
require 'test_helper'
|
5
|
-
|
6
|
-
class CommentTest < ActiveSupport::TestCase
|
7
|
-
|
8
|
-
test "cannot mass-assign comment_thread, creator" do
|
9
|
-
ct = FactoryGirl.create(:comment_thread)
|
10
|
-
u = FactoryGirl.create(:user)
|
11
|
-
c = Comment.new(:comment_thread => ct, :creator => u)
|
12
|
-
assert c.comment_thread != ct
|
13
|
-
assert c.creator != u
|
14
|
-
end
|
15
|
-
|
16
|
-
test "is_modified" do
|
17
|
-
c = FactoryGirl.create(:comment)
|
18
|
-
assert !c.is_modified?
|
19
|
-
c.message = 'Another message'
|
20
|
-
c.save!
|
21
|
-
assert c.is_modified?
|
22
|
-
end
|
23
|
-
|
24
|
-
test "must have comment_thread and creator" do
|
25
|
-
ct = FactoryGirl.create(:comment_thread)
|
26
|
-
u = FactoryGirl.create(:user)
|
27
|
-
c = Comment.new(:message => "Some message")
|
28
|
-
assert !c.save
|
29
|
-
c.comment_thread = ct
|
30
|
-
assert !c.save
|
31
|
-
c.comment_thread = nil
|
32
|
-
c.creator = u
|
33
|
-
assert !c.save
|
34
|
-
c.comment_thread = ct
|
35
|
-
c.save!
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
|
2
|
-
# License version 3 or later. See the COPYRIGHT file for details.
|
3
|
-
|
4
|
-
require 'test_helper'
|
5
|
-
|
6
|
-
class CommentThreadSubscriptionTest < ActiveSupport::TestCase
|
7
|
-
|
8
|
-
test 'one comment_thread_subscription per user per thread' do
|
9
|
-
u = FactoryGirl.create(:user)
|
10
|
-
ct = FactoryGirl.create(:comment_thread)
|
11
|
-
cts0 = CommentThreadSubscription.create(:user => u, :comment_thread => ct)
|
12
|
-
cts1 = CommentThreadSubscription.new(:user => u, :comment_thread => ct)
|
13
|
-
assert !cts1.save
|
14
|
-
cts0.destroy
|
15
|
-
cts1.save!
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
|
2
|
-
# License version 3 or later. See the COPYRIGHT file for details.
|
3
|
-
|
4
|
-
require 'test_helper'
|
5
|
-
|
6
|
-
class CommentThreadTest < ActiveSupport::TestCase
|
7
|
-
|
8
|
-
test 'cannot mass-assign commentable, comments and comment_thread_subscriptions' do
|
9
|
-
sq = FactoryGirl.create(:simple_question)
|
10
|
-
c = [FactoryGirl.create(:comment)]
|
11
|
-
cts = [FactoryGirl.create(:comment_thread_subscription)]
|
12
|
-
ct = CommentThread.new(:commentable => sq,
|
13
|
-
:comments => c,
|
14
|
-
:comment_thread_subscriptions => cts)
|
15
|
-
assert ct.commentable != sq
|
16
|
-
assert ct.comments != c
|
17
|
-
assert ct.comment_thread_subscriptions != cts
|
18
|
-
end
|
19
|
-
|
20
|
-
test 'clear' do
|
21
|
-
u = FactoryGirl.create(:user)
|
22
|
-
q = FactoryGirl.create(:simple_question)
|
23
|
-
ct = q.comment_thread
|
24
|
-
c = Comment.new
|
25
|
-
c.comment_thread = ct
|
26
|
-
c.creator = u
|
27
|
-
c.save!
|
28
|
-
|
29
|
-
assert !q.comment_thread.comments.empty?
|
30
|
-
assert_equal q.comment_thread, ct
|
31
|
-
|
32
|
-
ct.clear!
|
33
|
-
q.reload
|
34
|
-
|
35
|
-
assert q.comment_thread.comments.empty?
|
36
|
-
assert q.comment_thread != ct
|
37
|
-
end
|
38
|
-
|
39
|
-
test 'subscribe' do
|
40
|
-
u = FactoryGirl.create(:user)
|
41
|
-
ct = FactoryGirl.create(:comment_thread)
|
42
|
-
|
43
|
-
assert !ct.subscription_for(u)
|
44
|
-
assert ct.subscribe!(u)
|
45
|
-
assert ct.subscription_for(u)
|
46
|
-
assert ct.subscribe!(u)
|
47
|
-
end
|
48
|
-
|
49
|
-
test 'unsubscribe' do
|
50
|
-
u = FactoryGirl.create(:user)
|
51
|
-
ct = FactoryGirl.create(:comment_thread)
|
52
|
-
|
53
|
-
assert !ct.unsubscribe!(u)
|
54
|
-
assert ct.subscribe!(u)
|
55
|
-
assert ct.subscription_for(u)
|
56
|
-
assert ct.unsubscribe!(u)
|
57
|
-
assert !ct.subscription_for(u)
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SubscriptionTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'one comment_thread_subscription per user per thread' do
|
6
|
-
u = FactoryGirl.create(:user)
|
7
|
-
ct = FactoryGirl.create(:thread)
|
8
|
-
cts0 = Subscription.create(:user => u, :thread => ct)
|
9
|
-
cts1 = Subscription.new(:user => u, :thread => ct)
|
10
|
-
assert !cts1.save
|
11
|
-
cts0.destroy
|
12
|
-
cts1.save!
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
data/test/unit/thread_test.rb~
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ThreadTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'cannot mass-assign commentable, comments and subscriptions' do
|
6
|
-
sq = FactoryGirl.create(:simple_question)
|
7
|
-
c = [FactoryGirl.create(:comment)]
|
8
|
-
cts = [FactoryGirl.create(:subscription)]
|
9
|
-
ct = Commontator::Thread.new(:commentable => sq,
|
10
|
-
:comments => c,
|
11
|
-
:subscriptions => cts)
|
12
|
-
assert ct.commentable != sq
|
13
|
-
assert ct.comments != c
|
14
|
-
assert ct.comment_thread_subscriptions != cts
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'clear' do
|
18
|
-
u = FactoryGirl.create(:user)
|
19
|
-
q = FactoryGirl.create(:simple_question)
|
20
|
-
ct = q.comment_thread
|
21
|
-
c = Comment.new
|
22
|
-
c.comment_thread = ct
|
23
|
-
c.creator = u
|
24
|
-
c.save!
|
25
|
-
|
26
|
-
assert !q.comment_thread.comments.empty?
|
27
|
-
assert_equal q.comment_thread, ct
|
28
|
-
|
29
|
-
ct.clear!
|
30
|
-
q.reload
|
31
|
-
|
32
|
-
assert q.comment_thread.comments.empty?
|
33
|
-
assert q.comment_thread != ct
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'subscribe' do
|
37
|
-
u = FactoryGirl.create(:user)
|
38
|
-
ct = FactoryGirl.create(:comment_thread)
|
39
|
-
|
40
|
-
assert !ct.subscription_for(u)
|
41
|
-
assert ct.subscribe!(u)
|
42
|
-
assert ct.subscription_for(u)
|
43
|
-
assert ct.subscribe!(u)
|
44
|
-
end
|
45
|
-
|
46
|
-
test 'unsubscribe' do
|
47
|
-
u = FactoryGirl.create(:user)
|
48
|
-
ct = FactoryGirl.create(:comment_thread)
|
49
|
-
|
50
|
-
assert !ct.unsubscribe!(u)
|
51
|
-
assert ct.subscribe!(u)
|
52
|
-
assert ct.subscription_for(u)
|
53
|
-
assert ct.unsubscribe!(u)
|
54
|
-
assert !ct.subscription_for(u)
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|