commontator 4.0.2 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/app/assets/stylesheets/commontator/comments.css +16 -5
- data/app/assets/stylesheets/commontator/comments.css~ +98 -0
- data/app/controllers/commontator/application_controller.rb +6 -3
- data/app/controllers/commontator/application_controller.rb~ +30 -0
- data/app/controllers/commontator/threads_controller.rb +2 -0
- data/app/controllers/commontator/threads_controller.rb~ +44 -0
- data/app/helpers/commontator/threads_helper.rb +1 -8
- data/app/helpers/commontator/threads_helper.rb~ +11 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +2 -4
- data/app/mailers/commontator/subscriptions_mailer.rb~ +50 -0
- data/app/models/commontator/comment.rb +23 -19
- data/app/models/commontator/comment.rb~ +106 -0
- data/app/models/commontator/thread.rb +10 -10
- data/app/models/commontator/thread.rb~ +124 -0
- data/app/views/commontator/comments/_show.html.erb +36 -34
- data/app/views/commontator/comments/_show.html.erb~ +47 -0
- data/app/views/commontator/comments/_votes.html.erb +6 -2
- data/app/views/commontator/comments/_votes.html.erb~ +61 -0
- data/app/views/commontator/comments/delete.js.erb +2 -2
- data/app/views/commontator/comments/delete.js.erb~ +17 -0
- data/app/views/commontator/comments/update.js.erb +2 -2
- data/app/views/commontator/comments/update.js.erb~ +7 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +2 -2
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb~ +6 -0
- data/app/views/commontator/threads/_show.html.erb +3 -7
- data/app/views/commontator/threads/_show.html.erb~ +58 -0
- data/config/initializers/commontator.rb +52 -47
- data/config/initializers/commontator.rb~ +176 -0
- data/lib/commontator.rb +6 -7
- data/lib/commontator.rb~ +61 -0
- data/lib/commontator/controller_includes.rb +1 -3
- data/lib/commontator/controller_includes.rb~ +22 -0
- data/lib/commontator/shared_helper.rb +3 -8
- data/lib/commontator/shared_helper.rb~ +37 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +3 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +64 -45
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +580 -0
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +3 -3
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +99 -0
- data/spec/app/controllers/commontator/threads_controller_spec.rb +15 -9
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +126 -0
- data/spec/app/helpers/commontator/application_helper_spec.rb +1 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +9 -0
- data/spec/app/helpers/commontator/threads_helper_spec.rb +1 -5
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +13 -0
- data/spec/app/models/commontator/comment_spec.rb +4 -3
- data/spec/app/models/commontator/comment_spec.rb~ +62 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/application.rb~ +27 -0
- data/spec/dummy/config/initializers/commontator.rb +67 -55
- data/spec/dummy/config/initializers/commontator.rb~ +176 -0
- data/spec/dummy/config/initializers/commontator2.rb~ +169 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +84489 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/02d4b791eb831cf2057bf4703a1218d1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0f196a1a50363b0a076ec6e1ee5417f6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e1f674c11941d62aac1764ef3a7134e4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e85565206c3e5fdf9dfeb367c85557b1 +0 -0
- data/spec/lib/commontator/commontable_config_spec.rb +1 -1
- data/spec/lib/commontator/commontable_config_spec.rb~ +26 -0
- data/spec/lib/commontator/commontator_config_spec.rb +5 -5
- data/spec/lib/commontator/commontator_config_spec.rb~ +26 -0
- data/spec/lib/commontator_spec.rb +6 -4
- data/spec/lib/commontator_spec.rb~ +28 -0
- data/spec/test_helper.rb +4 -4
- data/spec/test_helper.rb~ +37 -0
- metadata +46 -2
@@ -6,7 +6,7 @@ module Commontator
|
|
6
6
|
setup_controller_spec
|
7
7
|
end
|
8
8
|
|
9
|
-
it '
|
9
|
+
it "won't subscribe unless authorized" do
|
10
10
|
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
11
11
|
assert_response 403
|
12
12
|
@thread.subscription_for(nil).must_be_nil
|
@@ -50,7 +50,7 @@ module Commontator
|
|
50
50
|
@thread.subscription_for(@user).wont_be_nil
|
51
51
|
end
|
52
52
|
|
53
|
-
it '
|
53
|
+
it "won't unsubscribe unless authorized" do
|
54
54
|
@thread.subscribe(@user)
|
55
55
|
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
56
56
|
assert_response 403
|
@@ -69,7 +69,7 @@ module Commontator
|
|
69
69
|
assigns(:thread).errors.wont_be_empty
|
70
70
|
end
|
71
71
|
|
72
|
-
it 'must
|
72
|
+
it 'must unsubscribe if authorized' do
|
73
73
|
sign_in @user
|
74
74
|
|
75
75
|
@thread.subscribe(@user)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
describe SubscriptionsController do
|
5
|
+
before do
|
6
|
+
setup_controller_spec
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'wont subscribe unless authorized' do
|
10
|
+
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
11
|
+
assert_response 403
|
12
|
+
@thread.subscription_for(nil).must_be_nil
|
13
|
+
@thread.subscription_for(@user).must_be_nil
|
14
|
+
|
15
|
+
sign_in @user
|
16
|
+
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
17
|
+
assert_response 403
|
18
|
+
@thread.subscription_for(@user).must_be_nil
|
19
|
+
|
20
|
+
@thread.subscribe(@user)
|
21
|
+
@user.can_read = true
|
22
|
+
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
23
|
+
assert_redirected_to @thread
|
24
|
+
assigns(:thread).errors.wont_be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'must subscribe if authorized' do
|
28
|
+
sign_in @user
|
29
|
+
|
30
|
+
@user.can_read = true
|
31
|
+
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
32
|
+
assert_redirected_to @thread
|
33
|
+
assigns(:thread).errors.must_be_empty
|
34
|
+
@thread.subscription_for(@user).wont_be_nil
|
35
|
+
|
36
|
+
@thread.unsubscribe(@user)
|
37
|
+
@user.can_read = false
|
38
|
+
@user.can_edit = true
|
39
|
+
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
40
|
+
assert_redirected_to @thread
|
41
|
+
assigns(:thread).errors.must_be_empty
|
42
|
+
@thread.subscription_for(@user).wont_be_nil
|
43
|
+
|
44
|
+
@thread.unsubscribe(@user)
|
45
|
+
@user.can_edit = false
|
46
|
+
@user.is_admin = true
|
47
|
+
put :subscribe, :thread_id => @thread.id, :use_route => :commontator
|
48
|
+
assert_redirected_to @thread
|
49
|
+
assigns(:thread).errors.must_be_empty
|
50
|
+
@thread.subscription_for(@user).wont_be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'wont unsubscribe unless authorized' do
|
54
|
+
@thread.subscribe(@user)
|
55
|
+
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
56
|
+
assert_response 403
|
57
|
+
@thread.subscription_for(nil).must_be_nil
|
58
|
+
@thread.subscription_for(@user).wont_be_nil
|
59
|
+
|
60
|
+
sign_in @user
|
61
|
+
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
62
|
+
assert_response 403
|
63
|
+
@thread.subscription_for(@user).wont_be_nil
|
64
|
+
|
65
|
+
@thread.unsubscribe(@user)
|
66
|
+
@user.can_read = true
|
67
|
+
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
68
|
+
assert_redirected_to @thread
|
69
|
+
assigns(:thread).errors.wont_be_empty
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'must destroy if authorized' do
|
73
|
+
sign_in @user
|
74
|
+
|
75
|
+
@thread.subscribe(@user)
|
76
|
+
@user.can_read = true
|
77
|
+
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
78
|
+
assert_redirected_to @thread
|
79
|
+
assigns(:thread).errors.must_be_empty
|
80
|
+
@thread.subscription_for(@user).must_be_nil
|
81
|
+
|
82
|
+
@thread.subscribe(@user)
|
83
|
+
@user.can_read = false
|
84
|
+
@user.can_edit = true
|
85
|
+
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
86
|
+
assert_redirected_to @thread
|
87
|
+
assigns(:thread).errors.must_be_empty
|
88
|
+
@thread.subscription_for(@user).must_be_nil
|
89
|
+
|
90
|
+
@thread.subscribe(@user)
|
91
|
+
@user.can_edit = false
|
92
|
+
@user.is_admin = true
|
93
|
+
put :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
|
94
|
+
assert_redirected_to @thread
|
95
|
+
assigns(:thread).errors.must_be_empty
|
96
|
+
@thread.subscription_for(@user).must_be_nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -6,7 +6,7 @@ module Commontator
|
|
6
6
|
setup_controller_spec
|
7
7
|
end
|
8
8
|
|
9
|
-
it '
|
9
|
+
it "won't show unless authorized" do
|
10
10
|
get :show, :id => @thread.id, :use_route => :commontator
|
11
11
|
assert_response 403
|
12
12
|
|
@@ -34,20 +34,23 @@ module Commontator
|
|
34
34
|
assert_redirected_to commontable_path
|
35
35
|
end
|
36
36
|
|
37
|
-
it '
|
37
|
+
it "won't close unless authorized and open" do
|
38
38
|
put :close, :id => @thread.id, :use_route => :commontator
|
39
39
|
assert_response 403
|
40
|
-
|
40
|
+
@thread.reload
|
41
|
+
@thread.is_closed?.must_equal false
|
41
42
|
|
42
43
|
sign_in @user
|
43
44
|
put :close, :id => @thread.id, :use_route => :commontator
|
44
45
|
assert_response 403
|
45
|
-
|
46
|
+
@thread.reload
|
47
|
+
@thread.is_closed?.must_equal false
|
46
48
|
|
47
49
|
@user.can_read = true
|
48
50
|
put :close, :id => @thread.id, :use_route => :commontator
|
49
51
|
assert_response 403
|
50
|
-
|
52
|
+
@thread.reload
|
53
|
+
@thread.is_closed?.must_equal false
|
51
54
|
|
52
55
|
@user.can_edit = true
|
53
56
|
@thread.close.must_equal true
|
@@ -76,21 +79,24 @@ module Commontator
|
|
76
79
|
assigns(:thread).closer.must_equal @user
|
77
80
|
end
|
78
81
|
|
79
|
-
it '
|
82
|
+
it "won't reopen unless authorized and closed" do
|
80
83
|
@thread.close.must_equal true
|
81
84
|
put :reopen, :id => @thread.id, :use_route => :commontator
|
82
85
|
assert_response 403
|
83
|
-
|
86
|
+
@thread.reload
|
87
|
+
@thread.is_closed?.must_equal true
|
84
88
|
|
85
89
|
sign_in @user
|
86
90
|
put :reopen, :id => @thread.id, :use_route => :commontator
|
87
91
|
assert_response 403
|
88
|
-
|
92
|
+
@thread.reload
|
93
|
+
@thread.is_closed?.must_equal true
|
89
94
|
|
90
95
|
@user.can_read = true
|
91
96
|
put :reopen, :id => @thread.id, :use_route => :commontator
|
92
97
|
assert_response 403
|
93
|
-
|
98
|
+
@thread.reload
|
99
|
+
@thread.is_closed?.must_equal true
|
94
100
|
|
95
101
|
@thread.reopen.must_equal true
|
96
102
|
@user.can_edit = true
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
describe ThreadsController do
|
5
|
+
before do
|
6
|
+
setup_controller_spec
|
7
|
+
end
|
8
|
+
|
9
|
+
it "won't show unless authorized" do
|
10
|
+
get :show, :id => @thread.id, :use_route => :commontator
|
11
|
+
assert_response 403
|
12
|
+
|
13
|
+
sign_in @user
|
14
|
+
get :show, :id => @thread.id, :use_route => :commontator
|
15
|
+
assert_response 403
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'must show if authorized' do
|
19
|
+
commontable_path = Rails.application.routes.url_helpers.dummy_model_path(@commontable)
|
20
|
+
sign_in @user
|
21
|
+
|
22
|
+
@user.can_read = true
|
23
|
+
get :show, :id => @thread.id, :use_route => :commontator
|
24
|
+
assert_redirected_to commontable_path
|
25
|
+
|
26
|
+
@user.can_read = false
|
27
|
+
@user.can_edit = true
|
28
|
+
get :show, :id => @thread.id, :use_route => :commontator
|
29
|
+
assert_redirected_to commontable_path
|
30
|
+
|
31
|
+
@user.can_edit = false
|
32
|
+
@user.is_admin = true
|
33
|
+
get :show, :id => @thread.id, :use_route => :commontator
|
34
|
+
assert_redirected_to commontable_path
|
35
|
+
end
|
36
|
+
|
37
|
+
it "won't close unless authorized and open" do
|
38
|
+
put :close, :id => @thread.id, :use_route => :commontator
|
39
|
+
assert_response 403
|
40
|
+
assigns(:thread).is_closed?.must_equal false
|
41
|
+
|
42
|
+
sign_in @user
|
43
|
+
put :close, :id => @thread.id, :use_route => :commontator
|
44
|
+
assert_response 403
|
45
|
+
@thread.reload
|
46
|
+
@thread.is_closed?.must_equal false
|
47
|
+
|
48
|
+
@user.can_read = true
|
49
|
+
put :close, :id => @thread.id, :use_route => :commontator
|
50
|
+
assert_response 403
|
51
|
+
@thread.reload
|
52
|
+
@thread.is_closed?.must_equal false
|
53
|
+
|
54
|
+
@user.can_edit = true
|
55
|
+
@thread.close.must_equal true
|
56
|
+
put :close, :id => @thread.id, :use_route => :commontator
|
57
|
+
assert_redirected_to @thread
|
58
|
+
assigns(:thread).errors.wont_be_empty
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'must close if authorized and open' do
|
62
|
+
sign_in @user
|
63
|
+
|
64
|
+
@user.can_edit = true
|
65
|
+
put :close, :id => @thread.id, :use_route => :commontator
|
66
|
+
assert_redirected_to @thread
|
67
|
+
assigns(:thread).errors.must_be_empty
|
68
|
+
assigns(:thread).is_closed?.must_equal true
|
69
|
+
assigns(:thread).closer.must_equal @user
|
70
|
+
|
71
|
+
assigns(:thread).reopen.must_equal true
|
72
|
+
@user.can_edit = false
|
73
|
+
@user.is_admin = true
|
74
|
+
put :close, :id => @thread.id, :use_route => :commontator
|
75
|
+
assert_redirected_to @thread
|
76
|
+
assigns(:thread).errors.must_be_empty
|
77
|
+
assigns(:thread).is_closed?.must_equal true
|
78
|
+
assigns(:thread).closer.must_equal @user
|
79
|
+
end
|
80
|
+
|
81
|
+
it "won't reopen unless authorized and closed" do
|
82
|
+
@thread.close.must_equal true
|
83
|
+
put :reopen, :id => @thread.id, :use_route => :commontator
|
84
|
+
assert_response 403
|
85
|
+
@thread.reload
|
86
|
+
@thread.is_closed?.must_equal true
|
87
|
+
|
88
|
+
sign_in @user
|
89
|
+
put :reopen, :id => @thread.id, :use_route => :commontator
|
90
|
+
assert_response 403
|
91
|
+
@thread.reload
|
92
|
+
@thread.is_closed?.must_equal true
|
93
|
+
|
94
|
+
@user.can_read = true
|
95
|
+
put :reopen, :id => @thread.id, :use_route => :commontator
|
96
|
+
assert_response 403
|
97
|
+
@thread.reload
|
98
|
+
@thread.is_closed?.must_equal true
|
99
|
+
|
100
|
+
@thread.reopen.must_equal true
|
101
|
+
@user.can_edit = true
|
102
|
+
put :reopen, :id => @thread.id, :use_route => :commontator
|
103
|
+
assert_redirected_to @thread
|
104
|
+
assigns(:thread).errors.wont_be_empty
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'must reopen if authorized and closed' do
|
108
|
+
sign_in @user
|
109
|
+
|
110
|
+
@thread.close.must_equal true
|
111
|
+
@user.can_edit = true
|
112
|
+
put :reopen, :id => @thread.id, :use_route => :commontator
|
113
|
+
assert_redirected_to @thread
|
114
|
+
assigns(:thread).errors.must_be_empty
|
115
|
+
assigns(:thread).is_closed?.must_equal false
|
116
|
+
|
117
|
+
assigns(:thread).close.must_equal true
|
118
|
+
@user.can_edit = false
|
119
|
+
@user.is_admin = true
|
120
|
+
put :reopen, :id => @thread.id, :use_route => :commontator
|
121
|
+
assert_redirected_to @thread
|
122
|
+
assigns(:thread).errors.must_be_empty
|
123
|
+
assigns(:thread).is_closed?.must_equal false
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -7,11 +7,7 @@ module Commontator
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'must print commontable name' do
|
10
|
-
commontable_name(@thread).must_equal '
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'must print commontable id' do
|
14
|
-
commontable_id(@thread).must_equal @thread.commontable_id
|
10
|
+
commontable_name(@thread).must_equal 'DummyModel #2'
|
15
11
|
end
|
16
12
|
end
|
17
13
|
end
|
@@ -48,14 +48,15 @@ module Commontator
|
|
48
48
|
it 'must make proper timestamps' do
|
49
49
|
@comment.save!
|
50
50
|
|
51
|
-
@comment.
|
51
|
+
@comment.created_timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
|
52
|
+
@comment.updated_timestamp.must_equal ''
|
52
53
|
|
53
54
|
@comment.body = 'Something else'
|
54
55
|
@comment.editor = @user
|
55
56
|
@comment.save!
|
56
57
|
|
57
|
-
@comment.
|
58
|
-
|
58
|
+
@comment.created_timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
|
59
|
+
@comment.updated_timestamp.must_equal "Last #{@thread.config.comment_edit_verb_past} on #{@comment.updated_at.strftime(@thread.config.timestamp_format)}"
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test_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 "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
|
52
|
+
@comment.updated_timestamp.must_equal ''
|
53
|
+
|
54
|
+
@comment.body = 'Something else'
|
55
|
+
@comment.editor = @user
|
56
|
+
@comment.save!
|
57
|
+
|
58
|
+
@comment.created_timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
|
59
|
+
@comment.updated_timestamp.must_equal 'Last #{@thread.config.comment_edit_verb_past} on #{@comment.updated_at.strftime(@thread.config.timestamp_format)}'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|