commontator 0.5.14 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +47 -10
- data/Rakefile +6 -5
- data/app/controllers/commontator/application_controller.rb +3 -1
- data/app/controllers/commontator/application_controller.rb~ +5 -2
- data/app/controllers/commontator/comments_controller.rb +9 -10
- data/app/controllers/commontator/comments_controller.rb~ +9 -10
- data/app/controllers/commontator/commontator_controller.rb~ +22 -0
- data/app/controllers/commontator/subscriptions_controller.rb +2 -2
- data/app/controllers/commontator/subscriptions_controller.rb~ +3 -3
- data/app/controllers/commontator/threads_controller.rb +4 -3
- data/app/controllers/commontator/threads_controller.rb~ +5 -3
- data/app/helpers/commontator/commontator_helper.rb~ +7 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +2 -1
- data/app/mailers/commontator/subscriptions_mailer.rb~ +3 -1
- data/app/models/commontator/comment.rb +13 -9
- data/app/models/commontator/comment.rb~ +14 -10
- data/app/models/commontator/subscription.rb +3 -3
- data/app/models/commontator/subscription.rb~ +19 -0
- data/app/models/commontator/thread.rb +17 -41
- data/app/models/commontator/thread.rb~ +119 -0
- data/app/views/commontator/shared/_thread.html.erb +4 -1
- data/app/views/commontator/shared/_thread.html.erb~ +5 -2
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +1 -1
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +6 -0
- data/config/initializers/commontator.rb +42 -64
- data/{test/dummy/config/initializers/commontator.rb → config/initializers/commontator.rb~} +42 -64
- data/db/migrate/0_install_commontator.rb +1 -1
- data/{test/dummy/db/migrate/1_install_commontator.commontator.rb → db/migrate/0_install_commontator.rb~} +1 -2
- data/lib/commontator.rb +7 -12
- data/lib/commontator.rb~ +7 -12
- data/lib/commontator/commontable_config.rb +1 -1
- data/lib/commontator/commontable_config.rb~ +13 -0
- data/lib/commontator/commontator_config.rb +1 -1
- data/lib/commontator/commontator_config.rb~ +13 -0
- data/lib/commontator/controller_includes.rb +1 -0
- data/lib/commontator/controller_includes.rb~ +1 -1
- data/lib/commontator/security_transgression.rb +3 -0
- data/{test/dummy/public/favicon.ico → lib/commontator/security_transgression.rb~} +0 -0
- data/lib/commontator/shared_helper.rb +1 -1
- data/lib/commontator/shared_helper.rb~ +2 -2
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- metadata +46 -89
- data/test/commontator_test.rb +0 -7
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -59
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -37
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +0 -61
- data/test/dummy/log/development.log +0 -414
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/script/rails +0 -6
- data/test/functional/comments_controller_test.rb +0 -181
- data/test/functional/subscriptions_controller_test.rb +0 -122
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -15
- data/test/unit/comment_test.rb +0 -35
- data/test/unit/helpers/comments_helper_test.rb +0 -4
- 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
data/test/dummy/public/404.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/404.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/test/dummy/public/422.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
</div>
|
24
|
-
</body>
|
25
|
-
</html>
|
data/test/dummy/script/rails
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
@@ -1,181 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CommentsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@comment = FactoryGirl.create(:comment)
|
7
|
-
@question = @comment.comment_thread.commentable
|
8
|
-
@user = @comment.creator
|
9
|
-
FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
|
10
|
-
@published_question = make_simple_question(:method => :create, :published => true)
|
11
|
-
@published_comment = FactoryGirl.create(:comment,
|
12
|
-
:comment_thread => @published_question.comment_thread)
|
13
|
-
end
|
14
|
-
|
15
|
-
test "should not get index not logged in" do
|
16
|
-
get :index, :question_id => @question.to_param
|
17
|
-
assert_redirected_to login_path
|
18
|
-
end
|
19
|
-
|
20
|
-
test "should not get index not authorized" do
|
21
|
-
user_login
|
22
|
-
get :index, :question_id => @question.to_param
|
23
|
-
assert_response(403)
|
24
|
-
end
|
25
|
-
|
26
|
-
test "should get index" do
|
27
|
-
sign_in @user
|
28
|
-
get :index, :question_id => @question.to_param
|
29
|
-
assert_response :success
|
30
|
-
end
|
31
|
-
|
32
|
-
test "should get index published question" do
|
33
|
-
user_login
|
34
|
-
get :index, :question_id => @published_question.to_param
|
35
|
-
assert_response :success
|
36
|
-
end
|
37
|
-
|
38
|
-
test "should not get new not logged in" do
|
39
|
-
get :new, :question_id => @question.to_param
|
40
|
-
assert_redirected_to login_path
|
41
|
-
end
|
42
|
-
|
43
|
-
test "should not get new not authorized" do
|
44
|
-
user_login
|
45
|
-
get :new, :question_id => @question.to_param
|
46
|
-
assert_response(403)
|
47
|
-
end
|
48
|
-
|
49
|
-
test "should get new" do
|
50
|
-
sign_in @user
|
51
|
-
get :new, :question_id => @question.to_param
|
52
|
-
assert_response :success
|
53
|
-
assert_not_nil assigns(:comments)
|
54
|
-
end
|
55
|
-
|
56
|
-
test "should get new published question" do
|
57
|
-
user_login
|
58
|
-
get :new, :question_id => @published_question.to_param
|
59
|
-
assert_response :success
|
60
|
-
assert_not_nil assigns(:comments)
|
61
|
-
end
|
62
|
-
|
63
|
-
test "should not create comment not logged in" do
|
64
|
-
assert_difference('Comment.count', 0) do
|
65
|
-
post :create, :question_id => @question.to_param, :comment => @comment.attributes
|
66
|
-
end
|
67
|
-
|
68
|
-
assert_redirected_to login_path
|
69
|
-
end
|
70
|
-
|
71
|
-
test "should not create comment not authorized" do
|
72
|
-
user_login
|
73
|
-
assert_difference('Comment.count', 0) do
|
74
|
-
post :create, :question_id => @question.to_param, :comment => @comment.attributes
|
75
|
-
end
|
76
|
-
|
77
|
-
assert_response(403)
|
78
|
-
end
|
79
|
-
|
80
|
-
test "should create comment" do
|
81
|
-
sign_in @user
|
82
|
-
assert_difference('Comment.count') do
|
83
|
-
post :create, :question_id => @question.to_param, :comment => @comment.attributes
|
84
|
-
end
|
85
|
-
|
86
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
87
|
-
end
|
88
|
-
|
89
|
-
test "should create comment published question" do
|
90
|
-
user_login
|
91
|
-
assert_difference('Comment.count') do
|
92
|
-
post :create, :question_id => @published_question.to_param, :comment => @comment.attributes
|
93
|
-
end
|
94
|
-
|
95
|
-
assert_redirected_to question_comments_path(@published_question.to_param)
|
96
|
-
end
|
97
|
-
|
98
|
-
test "should not show comment not logged in" do
|
99
|
-
get :show, :id => @comment.to_param
|
100
|
-
assert_redirected_to login_path
|
101
|
-
end
|
102
|
-
|
103
|
-
test "should not show comment not authorized" do
|
104
|
-
user_login
|
105
|
-
get :show, :id => @comment.to_param
|
106
|
-
assert_response(403)
|
107
|
-
end
|
108
|
-
|
109
|
-
test "should show comment" do
|
110
|
-
sign_in @user
|
111
|
-
get :show, :id => @comment.to_param
|
112
|
-
assert_response :success
|
113
|
-
end
|
114
|
-
|
115
|
-
test "should show comment published question" do
|
116
|
-
user_login
|
117
|
-
get :show, :id => @published_comment.to_param
|
118
|
-
assert_response :success
|
119
|
-
end
|
120
|
-
|
121
|
-
test "should not get edit not logged in" do
|
122
|
-
get :edit, :id => @comment.to_param
|
123
|
-
assert_redirected_to login_path
|
124
|
-
end
|
125
|
-
|
126
|
-
test "should not get edit not authorized" do
|
127
|
-
user_login
|
128
|
-
get :edit, :id => @comment.to_param
|
129
|
-
assert_response(403)
|
130
|
-
end
|
131
|
-
|
132
|
-
test "should get edit" do
|
133
|
-
sign_in @user
|
134
|
-
get :edit, :id => @comment.to_param
|
135
|
-
assert_response :success
|
136
|
-
end
|
137
|
-
|
138
|
-
test "should not update comment not logged in" do
|
139
|
-
put :update, :id => @comment.to_param
|
140
|
-
assert_redirected_to login_path
|
141
|
-
end
|
142
|
-
|
143
|
-
test "should not update comment not authorized" do
|
144
|
-
user_login
|
145
|
-
put :update, :id => @comment.to_param
|
146
|
-
assert_response(403)
|
147
|
-
end
|
148
|
-
|
149
|
-
test "should update comment" do
|
150
|
-
sign_in @user
|
151
|
-
put :update, :id => @comment.to_param
|
152
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
153
|
-
end
|
154
|
-
|
155
|
-
test "should not destroy comment not logged in" do
|
156
|
-
assert_difference('Comment.count', 0) do
|
157
|
-
delete :destroy, :id => @comment.to_param
|
158
|
-
end
|
159
|
-
|
160
|
-
assert_redirected_to login_path
|
161
|
-
end
|
162
|
-
|
163
|
-
test "should not destroy comment not authorized" do
|
164
|
-
user_login
|
165
|
-
assert_difference('Comment.count', 0) do
|
166
|
-
delete :destroy, :id => @comment.to_param
|
167
|
-
end
|
168
|
-
|
169
|
-
assert_response(403)
|
170
|
-
end
|
171
|
-
|
172
|
-
test "should destroy comment" do
|
173
|
-
sign_in @user
|
174
|
-
assert_difference('Comment.count', -1) do
|
175
|
-
delete :destroy, :id => @comment.to_param
|
176
|
-
end
|
177
|
-
|
178
|
-
assert_redirected_to question_comments_path(@question.to_param)
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SubscriptionsControllerTest < 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 subscription not logged in" do
|
25
|
-
assert_difference('Subscription.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 subscription not authorized" do
|
33
|
-
user_login
|
34
|
-
assert_difference('Subscription.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 subscription already subscribed" do
|
42
|
-
sign_in @user
|
43
|
-
FactoryGirl.create(:subscription,
|
44
|
-
:user => @user, :thread => @question.thread)
|
45
|
-
assert_difference('Subscription.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 subscription" do
|
53
|
-
sign_in @user
|
54
|
-
assert_difference('Subscription.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 subscription published question" do
|
62
|
-
user_login
|
63
|
-
assert_difference('Subscription.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/test_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
-
require "rails/test_help"
|
6
|
-
|
7
|
-
Rails.backtrace_cleaner.remove_silencers!
|
8
|
-
|
9
|
-
# Load support files
|
10
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
-
|
12
|
-
# Load fixtures from the engine
|
13
|
-
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
-
end
|
data/test/unit/comment_test.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CommentTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test "cannot mass-assign comment_thread, creator" do
|
6
|
-
ct = FactoryGirl.create(:comment_thread)
|
7
|
-
u = FactoryGirl.create(:user)
|
8
|
-
c = Comment.new(:comment_thread => ct, :creator => u)
|
9
|
-
assert c.comment_thread != ct
|
10
|
-
assert c.creator != u
|
11
|
-
end
|
12
|
-
|
13
|
-
test "is_modified" do
|
14
|
-
c = FactoryGirl.create(:comment)
|
15
|
-
assert !c.is_modified?
|
16
|
-
c.message = 'Another message'
|
17
|
-
c.save!
|
18
|
-
assert c.is_modified?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "must have comment_thread and creator" do
|
22
|
-
ct = FactoryGirl.create(:comment_thread)
|
23
|
-
u = FactoryGirl.create(:user)
|
24
|
-
c = Comment.new(:message => "Some message")
|
25
|
-
assert !c.save
|
26
|
-
c.comment_thread = ct
|
27
|
-
assert !c.save
|
28
|
-
c.comment_thread = nil
|
29
|
-
c.creator = u
|
30
|
-
assert !c.save
|
31
|
-
c.comment_thread = ct
|
32
|
-
c.save!
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|