commontator 4.0.1 → 4.0.2
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 +4 -4
- data/README.md +3 -5
- data/app/controllers/commontator/comments_controller.rb +6 -6
- data/app/controllers/commontator/subscriptions_controller.rb +2 -2
- data/app/controllers/commontator/threads_controller.rb +2 -2
- data/app/views/commontator/comments/_actions.html.erb +1 -1
- data/app/views/commontator/comments/_votes.html.erb +4 -4
- data/app/views/commontator/shared/_thread.html.erb +1 -1
- data/app/views/commontator/subscriptions/_link.html.erb +1 -1
- data/app/views/commontator/threads/_show.html.erb +1 -1
- data/config/routes.rb +9 -9
- data/lib/commontator/version.rb +1 -1
- data/spec/app/controllers/commontator/comments_controller_spec.rb +40 -40
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +12 -12
- data/spec/app/controllers/commontator/threads_controller_spec.rb +12 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +4176 -0
- metadata +4 -91
- data/app/controllers/commontator/application_controller.rb~ +0 -27
- data/app/controllers/commontator/comments_controller.rb~ +0 -144
- data/app/controllers/commontator/subscriptions_controller.rb~ +0 -32
- data/app/controllers/commontator/threads_controller.rb~ +0 -42
- data/app/mailers/commontator/subscriptions_mailer.rb~ +0 -50
- data/app/models/commontator/comment.rb~ +0 -104
- data/app/models/commontator/subscription.rb~ +0 -18
- data/app/models/commontator/thread.rb~ +0 -124
- data/app/models/commontator/tree.rb~ +0 -123
- data/app/views/commontator/comments/_actions.html.erb~ +0 -30
- data/app/views/commontator/comments/_body.html.erb~ +0 -8
- data/app/views/commontator/comments/_form.html.erb~ +0 -38
- data/app/views/commontator/comments/_show.html.erb~ +0 -44
- data/app/views/commontator/comments/_votes.html.erb~ +0 -57
- data/app/views/commontator/comments/delete.js.erb~ +0 -17
- data/app/views/commontator/shared/_thread.html.erb~ +0 -20
- data/app/views/commontator/subscriptions/_link.html.erb~ +0 -16
- data/app/views/commontator/threads/_show.html.erb~ +0 -62
- data/config/initializers/commontator.rb~ +0 -171
- data/config/routes.rb~ +0 -22
- data/db/migrate/0_install.rb~ +0 -50
- data/lib/commontator.rb~ +0 -61
- data/lib/commontator/acts_as_commontable.rb~ +0 -45
- data/lib/commontator/acts_as_commontator.rb~ +0 -31
- data/lib/commontator/controller_includes.rb~ +0 -22
- data/lib/commontator/security_transgression.rb~ +0 -3
- data/lib/commontator/shared_helper.rb~ +0 -42
- data/lib/commontator/version.rb~ +0 -3
- data/lib/tasks/commontator_tasks.rake~ +0 -42
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +0 -563
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +0 -99
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +0 -121
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +0 -9
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +0 -17
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb~ +0 -30
- data/spec/app/models/commontator/comment_observer_spec.rb~ +0 -27
- data/spec/app/models/commontator/comment_spec.rb~ +0 -61
- data/spec/app/models/commontator/subscription_spec.rb~ +0 -28
- data/spec/app/models/commontator/thread_spec.rb~ +0 -130
- data/spec/dummy/README.md~ +0 -3
- data/spec/dummy/Rakefile~ +0 -7
- data/spec/dummy/config.ru~ +0 -4
- data/spec/dummy/config/application.rb~ +0 -23
- data/spec/dummy/config/environment.rb~ +0 -5
- data/spec/dummy/config/environments/development.rb~ +0 -31
- data/spec/dummy/config/environments/production.rb~ +0 -67
- data/spec/dummy/config/environments/test.rb~ +0 -31
- data/spec/dummy/config/initializers/secret_token.rb~ +0 -12
- data/spec/lib/commontator/acts_as_commontable_spec.rb~ +0 -26
- data/spec/lib/commontator/acts_as_commontator_spec.rb~ +0 -25
- data/spec/lib/commontator/commontable_config_spec.rb~ +0 -26
- data/spec/lib/commontator/commontator_config_spec.rb~ +0 -26
- data/spec/lib/commontator/controller_includes_spec.rb~ +0 -15
- data/spec/lib/commontator/shared_helper_spec.rb~ +0 -16
- data/spec/lib/commontator_spec.rb~ +0 -23
- data/spec/minitest_helper.rb~ +0 -35
- data/spec/spec_helper.rb~ +0 -36
- data/spec/test_helper.rb~ +0 -37
@@ -1,99 +0,0 @@
|
|
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
|
-
post :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
-
patch :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
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
describe ThreadsController do
|
5
|
-
before do
|
6
|
-
setup_controller_spec
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'wont 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 'wont 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
|
-
assigns(:thread).is_closed?.must_equal false
|
46
|
-
|
47
|
-
@user.can_read = true
|
48
|
-
put :close, :id => @thread.id, :use_route => :commontator
|
49
|
-
assert_response 403
|
50
|
-
assigns(:thread).is_closed?.must_equal false
|
51
|
-
|
52
|
-
@user.can_edit = true
|
53
|
-
@thread.close.must_equal true
|
54
|
-
put :close, :id => @thread.id, :use_route => :commontator
|
55
|
-
assert_redirected_to @thread
|
56
|
-
assigns(:thread).errors.wont_be_empty
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'must close if authorized and open' do
|
60
|
-
sign_in @user
|
61
|
-
|
62
|
-
@user.can_edit = true
|
63
|
-
put :close, :id => @thread.id, :use_route => :commontator
|
64
|
-
assert_redirected_to @thread
|
65
|
-
assigns(:thread).errors.must_be_empty
|
66
|
-
assigns(:thread).is_closed?.must_equal true
|
67
|
-
assigns(:thread).closer.must_equal @user
|
68
|
-
|
69
|
-
assigns(:thread).reopen.must_equal true
|
70
|
-
@user.can_edit = false
|
71
|
-
@user.is_admin = true
|
72
|
-
put :close, :id => @thread.id, :use_route => :commontator
|
73
|
-
assert_redirected_to @thread
|
74
|
-
assigns(:thread).errors.must_be_empty
|
75
|
-
assigns(:thread).is_closed?.must_equal true
|
76
|
-
assigns(:thread).closer.must_equal @user
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'wont reopen unless authorized and closed' do
|
80
|
-
@thread.close.must_equal true
|
81
|
-
put :reopen, :id => @thread.id, :use_route => :commontator
|
82
|
-
assert_response 403
|
83
|
-
assigns(:thread).is_closed?.must_equal true
|
84
|
-
|
85
|
-
sign_in @user
|
86
|
-
put :reopen, :id => @thread.id, :use_route => :commontator
|
87
|
-
assert_response 403
|
88
|
-
assigns(:thread).is_closed?.must_equal true
|
89
|
-
|
90
|
-
@user.can_read = true
|
91
|
-
put :reopen, :id => @thread.id, :use_route => :commontator
|
92
|
-
assert_response 403
|
93
|
-
assigns(:thread).is_closed?.must_equal true
|
94
|
-
|
95
|
-
@thread.reopen.must_equal true
|
96
|
-
@user.can_edit = true
|
97
|
-
put :reopen, :id => @thread.id, :use_route => :commontator
|
98
|
-
assert_redirected_to @thread
|
99
|
-
assigns(:thread).errors.wont_be_empty
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'must reopen if authorized and closed' do
|
103
|
-
sign_in @user
|
104
|
-
|
105
|
-
@thread.close.must_equal true
|
106
|
-
@user.can_edit = true
|
107
|
-
put :reopen, :id => @thread.id, :use_route => :commontator
|
108
|
-
assert_redirected_to @thread
|
109
|
-
assigns(:thread).errors.must_be_empty
|
110
|
-
assigns(:thread).is_closed?.must_equal false
|
111
|
-
|
112
|
-
assigns(:thread).close.must_equal true
|
113
|
-
@user.can_edit = false
|
114
|
-
@user.is_admin = true
|
115
|
-
put :reopen, :id => @thread.id, :use_route => :commontator
|
116
|
-
assert_redirected_to @thread
|
117
|
-
assigns(:thread).errors.must_be_empty
|
118
|
-
assigns(:thread).is_closed?.must_equal false
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
describe ThreadsHelper do
|
5
|
-
before do
|
6
|
-
setup_helper_spec
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'must print commontable name' do
|
10
|
-
commontable_name(@thread).must_equal 'dummy model'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'must print commontable id' do
|
14
|
-
commontable_id(@thread).must_equal @thread.commontable_id
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
describe SubscriptionsMailer do
|
5
|
-
before do
|
6
|
-
setup_mailer_spec
|
7
|
-
@user2 = DummyUser.create
|
8
|
-
@thread.subscribe(@user)
|
9
|
-
@thread.subscribe(@user2)
|
10
|
-
@comment = Comment.new
|
11
|
-
@comment.thread = @thread
|
12
|
-
@comment.creator = @user
|
13
|
-
@comment.body = 'Something'
|
14
|
-
@comment.save!
|
15
|
-
@recipients = @thread.active_subscribers.reject{|s| s == @user}
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'must create deliverable mail' do
|
19
|
-
mail = SubscriptionsMailer.comment_created(@comment, @recipients)
|
20
|
-
mail.must_be_instance_of Mail::Message
|
21
|
-
mail.to.must_be_nil
|
22
|
-
mail.cc.must_be_nil
|
23
|
-
mail.bcc.size.must_equal 1
|
24
|
-
mail.bcc.must_include @user2.email
|
25
|
-
mail.subject.wont_be_empty
|
26
|
-
mail.body.wont_be_empty
|
27
|
-
mail.deliver.must_equal mail
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
describe CommentObserver do
|
5
|
-
before do
|
6
|
-
setup_model_spec
|
7
|
-
@comment_observer = CommentObserver.instance
|
8
|
-
@thread.subscribe(@user)
|
9
|
-
@comment = Comment.new
|
10
|
-
@comment.thread = @thread
|
11
|
-
@comment.creator = @user
|
12
|
-
@comment.body = 'Something'
|
13
|
-
@comment.save!
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'wont send mail unless recipients not empty' do
|
17
|
-
@comment_observer.after_create(@comment).must_be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'must send mail if recipients not empty' do
|
21
|
-
@user2 = DummyUser.create
|
22
|
-
@thread.subscribe(@user2)
|
23
|
-
@comment.reload
|
24
|
-
@comment_observer.after_create(@comment).must_be_instance_of Mail::Message
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'minitest_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.timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
|
52
|
-
|
53
|
-
@comment.body = 'Something else'
|
54
|
-
@comment.editor = @user
|
55
|
-
@comment.save!
|
56
|
-
|
57
|
-
@comment.timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}" + \
|
58
|
-
" | Last #{@thread.config.comment_edit_verb_past} on #{@comment.updated_at.strftime(@thread.config.timestamp_format)}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
describe Subscription do
|
5
|
-
before do
|
6
|
-
setup_model_spec
|
7
|
-
@subscription = Subscription.new
|
8
|
-
@subscription.thread = @thread
|
9
|
-
@subscription.subscriber = @user
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'must count unread comments' do
|
13
|
-
@subscription.unread.must_equal 0
|
14
|
-
|
15
|
-
@subscription.add_unread
|
16
|
-
|
17
|
-
@subscription.unread.must_equal 1
|
18
|
-
|
19
|
-
@subscription.add_unread
|
20
|
-
|
21
|
-
@subscription.unread.must_equal 2
|
22
|
-
|
23
|
-
@subscription.mark_as_read
|
24
|
-
|
25
|
-
@subscription.unread.must_equal 0
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
|
3
|
-
module Commontator
|
4
|
-
describe Thread do
|
5
|
-
before do
|
6
|
-
setup_model_spec
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'must have a config' do
|
10
|
-
@thread.config.must_be_instance_of CommontableConfig
|
11
|
-
@thread.commontable = nil
|
12
|
-
@thread.config.must_equal Commontator
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'must order all comments' do
|
16
|
-
comment = Comment.new
|
17
|
-
comment.thread = @thread
|
18
|
-
comment.creator = @user
|
19
|
-
comment.body = 'Something'
|
20
|
-
comment.save!
|
21
|
-
comment2 = Comment.new
|
22
|
-
comment2.thread = @thread
|
23
|
-
comment2.creator = @user
|
24
|
-
comment2.body = 'Something else'
|
25
|
-
comment2.save!
|
26
|
-
|
27
|
-
comments = @thread.comments
|
28
|
-
ordered_comments = @thread.ordered_comments
|
29
|
-
|
30
|
-
comments.each { |c| ordered_comments.must_include c }
|
31
|
-
ordered_comments.each { |oc| comments.must_include oc }
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'must list all subscribers' do
|
35
|
-
@thread.subscribe(@user)
|
36
|
-
@thread.subscribe(DummyUser.create)
|
37
|
-
|
38
|
-
@thread.subscriptions.each { |sp| \
|
39
|
-
@thread.subscribers.must_include sp.subscriber }
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'must find the subscription for each user' do
|
43
|
-
@thread.subscribe(@user)
|
44
|
-
user2 = DummyUser.create
|
45
|
-
@thread.subscribe(user2)
|
46
|
-
|
47
|
-
subscription = @thread.subscription_for(@user)
|
48
|
-
subscription.thread.must_equal @thread
|
49
|
-
subscription.subscriber.must_equal @user
|
50
|
-
subscription = @thread.subscription_for(user2)
|
51
|
-
subscription.thread.must_equal @thread
|
52
|
-
subscription.subscriber.must_equal user2
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'must know if it is closed' do
|
56
|
-
@thread.is_closed?.must_equal false
|
57
|
-
|
58
|
-
@thread.close(@user)
|
59
|
-
|
60
|
-
@thread.is_closed?.must_equal true
|
61
|
-
@thread.closer.must_equal @user
|
62
|
-
|
63
|
-
@thread.reopen
|
64
|
-
|
65
|
-
@thread.is_closed?.must_equal false
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'must know if an user is subscribed' do
|
69
|
-
@thread.subscribe(@user)
|
70
|
-
user2 = DummyUser.create
|
71
|
-
|
72
|
-
@thread.subscribe(user2)
|
73
|
-
|
74
|
-
@thread.is_subscribed?(@user).must_equal true
|
75
|
-
@thread.is_subscribed?(user2).must_equal true
|
76
|
-
@thread.is_subscribed?(DummyUser.create).must_equal false
|
77
|
-
|
78
|
-
@thread.unsubscribe(@user)
|
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)
|
96
|
-
|
97
|
-
@thread.subscription_for(@user).unread.must_equal 1
|
98
|
-
@thread.subscription_for(user2).unread.must_equal 2
|
99
|
-
|
100
|
-
@thread.mark_as_read_for(user2)
|
101
|
-
|
102
|
-
@thread.subscription_for(@user).unread.must_equal 1
|
103
|
-
@thread.subscription_for(user2).unread.must_equal 0
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'must be able to clear comments' do
|
107
|
-
comment = Comment.new
|
108
|
-
comment.thread = @thread
|
109
|
-
comment.creator = @user
|
110
|
-
comment.body = 'Something'
|
111
|
-
comment.save!
|
112
|
-
|
113
|
-
@thread.commontable.must_equal @commontable
|
114
|
-
@thread.comments.must_include comment
|
115
|
-
@thread.is_closed?.must_equal false
|
116
|
-
@commontable.thread.must_equal @thread
|
117
|
-
|
118
|
-
@thread.clear(@user)
|
119
|
-
|
120
|
-
@thread.commontable.must_be_nil
|
121
|
-
@thread.comments.must_include comment
|
122
|
-
@thread.is_closed?.must_equal true
|
123
|
-
@thread.closer.must_equal @user
|
124
|
-
@commontable.reload
|
125
|
-
@commontable.thread.wont_be_nil
|
126
|
-
@commontable.thread.wont_equal @thread
|
127
|
-
@commontable.thread.comments.wont_include comment
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|