commontator 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- data/spec/app/controllers/comments_controller_spec.rb~ +7 -0
- data/spec/app/controllers/commontator/application_controller_spec.rb~ +30 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +473 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +473 -0
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +99 -0
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +99 -0
- data/spec/app/controllers/commontator/threads_controller_spec.rb +121 -0
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +121 -0
- data/spec/app/controllers/threads_controller_spec.rb~ +12 -0
- data/spec/app/helpers/commontator/application_helper_spec.rb +7 -0
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +7 -0
- data/spec/app/helpers/commontator/threads_helper_spec.rb +17 -0
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +17 -0
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +38 -0
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb~ +37 -0
- data/spec/app/models/commontator/comment_spec.rb +60 -0
- data/spec/app/models/commontator/comment_spec.rb~ +60 -0
- data/spec/app/models/commontator/subscription_spec.rb +28 -0
- data/spec/app/models/commontator/subscription_spec.rb~ +28 -0
- data/spec/app/models/commontator/thread_spec.rb +130 -0
- data/spec/app/models/commontator/thread_spec.rb~ +130 -0
- data/spec/dummy/Gemfile~ +3 -0
- data/spec/dummy/README.md +3 -0
- data/spec/dummy/README.md~ +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/application_controller.rb~ +7 -0
- data/spec/dummy/app/controllers/dummies_controller.rb~ +17 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb +29 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb~ +29 -0
- data/spec/dummy/app/helpers/application_helper.rb +15 -0
- data/spec/dummy/app/helpers/application_helper.rb~ +15 -0
- data/spec/dummy/app/models/dummy.rb~ +3 -0
- data/spec/dummy/app/models/dummy_model.rb +3 -0
- data/spec/dummy/app/models/dummy_user.rb +9 -0
- data/spec/dummy/app/models/dummy_user.rb~ +9 -0
- data/spec/dummy/app/models/user.rb~ +5 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb~ +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/application.rb~ +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/commontator.rb +158 -0
- data/spec/dummy/config/initializers/commontator.rb~ +157 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/config/routes.rb~ +7 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/0_create_dummies.rb~ +48 -0
- data/spec/dummy/db/migrate/0_create_dummy_models.rb +7 -0
- data/spec/dummy/db/migrate/0_create_dummy_models.rb~ +7 -0
- data/spec/dummy/db/migrate/1_create_dummy_users.rb +7 -0
- data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +7 -0
- data/spec/dummy/db/migrate/1_create_users.rb~ +7 -0
- data/spec/dummy/db/migrate/2_install_commontator.rb +49 -0
- data/spec/dummy/db/migrate/2_install_commontator.rb~ +49 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +20 -0
- data/spec/dummy/db/schema.rb +84 -0
- data/spec/dummy/db/schema.rb~ +71 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +14298 -0
- data/spec/dummy/log/test.log +149321 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/tmp/cache/assets/CCB/1D0/sprockets%2F02d4b791eb831cf2057bf4703a1218d1 +0 -0
- data/spec/dummy/tmp/cache/assets/CD1/510/sprockets%2Fc69ee3cc5796188d873574179290a6ef +0 -0
- data/spec/dummy/tmp/cache/assets/D01/8B0/sprockets%2F0f196a1a50363b0a076ec6e1ee5417f6 +0 -0
- data/spec/dummy/tmp/cache/assets/D06/2F0/sprockets%2Fe1f674c11941d62aac1764ef3a7134e4 +0 -0
- data/spec/dummy/tmp/cache/assets/D54/060/sprockets%2Fe85565206c3e5fdf9dfeb367c85557b1 +0 -0
- data/spec/dummy/tmp/cache/assets/D9B/550/sprockets%2Fa41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/E01/2E0/sprockets%2Fa3fb9025f90ff05a6fd4afc7ded2692c +0 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +26 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb~ +26 -0
- data/spec/lib/commontator/acts_as_commontator_spec.rb +25 -0
- data/spec/lib/commontator/acts_as_commontator_spec.rb~ +25 -0
- data/spec/lib/commontator/commontable_config_spec.rb +26 -0
- data/spec/lib/commontator/commontable_config_spec.rb~ +26 -0
- data/spec/lib/commontator/commontator_config_spec.rb +26 -0
- data/spec/lib/commontator/commontator_config_spec.rb~ +26 -0
- data/spec/lib/commontator/controller_includes_spec.rb +15 -0
- data/spec/lib/commontator/controller_includes_spec.rb~ +15 -0
- data/spec/lib/commontator/shared_helper_spec.rb +12 -0
- data/spec/lib/commontator/shared_helper_spec.rb~ +12 -0
- data/spec/lib/commontator_spec.rb +23 -0
- data/spec/lib/commontator_spec.rb~ +23 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/spec_helper.rb~ +30 -0
- metadata +212 -2
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
describe SubscriptionsController do
|
5
|
+
before do
|
6
|
+
setup_controller_spec
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'wont create unless authorized' do
|
10
|
+
post :create, :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
|
+
post :create, :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
|
+
post :create, :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 create if authorized' do
|
28
|
+
sign_in @user
|
29
|
+
|
30
|
+
@user.can_read = true
|
31
|
+
post :create, :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
|
+
post :create, :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
|
+
post :create, :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 destroy unless authorized' do
|
54
|
+
@thread.subscribe(@user)
|
55
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
describe Commontator::SubscriptionsController do
|
5
|
+
before do
|
6
|
+
setup_controller_spec
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'wont create unless authorized' do
|
10
|
+
post :create, :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
|
+
post :create, :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
|
+
post :create, :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 create if authorized' do
|
28
|
+
sign_in @user
|
29
|
+
|
30
|
+
@user.can_read = true
|
31
|
+
post :create, :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
|
+
post :create, :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
|
+
post :create, :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 destroy unless authorized' do
|
54
|
+
@thread.subscribe(@user)
|
55
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
+
delete :destroy, :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
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_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
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_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
|