fuck_comments 2.3.4

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.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +30 -0
  3. data/.ruby-gemset.example +1 -0
  4. data/.ruby-version.example +1 -0
  5. data/.rvmrc.example +1 -0
  6. data/.travis.yml +5 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +338 -0
  10. data/Rakefile +1 -0
  11. data/app/assets/javascripts/the_comments.js.coffee +108 -0
  12. data/app/assets/javascripts/the_comments_manage.js.coffee +27 -0
  13. data/app/assets/stylesheets/the_comments.css.scss +248 -0
  14. data/app/controllers/_templates_/comments_controller.rb +44 -0
  15. data/app/controllers/concerns/the_comments/controller.rb +197 -0
  16. data/app/controllers/concerns/the_comments/view_token.rb +20 -0
  17. data/app/helpers/render_comments_tree_helper.rb +111 -0
  18. data/app/models/_templates_/comment.rb +38 -0
  19. data/app/models/concerns/the_comments/comment.rb +116 -0
  20. data/app/models/concerns/the_comments/comment_states.rb +80 -0
  21. data/app/models/concerns/the_comments/commentable.rb +69 -0
  22. data/app/models/concerns/the_comments/user.rb +56 -0
  23. data/app/views/the_comments/_tree.html.erb +3 -0
  24. data/app/views/the_comments/haml/_additional_info.html.haml +13 -0
  25. data/app/views/the_comments/haml/_comment.html.haml +1 -0
  26. data/app/views/the_comments/haml/_comment_body.html.haml +25 -0
  27. data/app/views/the_comments/haml/_comment_edit.html.haml +26 -0
  28. data/app/views/the_comments/haml/_form.html.haml +8 -0
  29. data/app/views/the_comments/haml/_guest_form.html.haml +22 -0
  30. data/app/views/the_comments/haml/_logined_form.html.haml +18 -0
  31. data/app/views/the_comments/haml/_manage_controls.html.haml +30 -0
  32. data/app/views/the_comments/haml/_sidebar.html.haml +9 -0
  33. data/app/views/the_comments/haml/_sidebar_admin.html.haml +12 -0
  34. data/app/views/the_comments/haml/_sidebar_backlink.html.haml +3 -0
  35. data/app/views/the_comments/haml/_sidebar_user.html.haml +29 -0
  36. data/app/views/the_comments/haml/_tree.html.haml +16 -0
  37. data/app/views/the_comments/haml/manage.html.haml +26 -0
  38. data/app/views/the_comments/slim/_additional_info.html.slim +13 -0
  39. data/app/views/the_comments/slim/_comment.html.slim +1 -0
  40. data/app/views/the_comments/slim/_comment_body.html.slim +24 -0
  41. data/app/views/the_comments/slim/_comment_edit.html.slim +26 -0
  42. data/app/views/the_comments/slim/_form.html.slim +8 -0
  43. data/app/views/the_comments/slim/_guest_form.html.slim +22 -0
  44. data/app/views/the_comments/slim/_logined_form.html.slim +18 -0
  45. data/app/views/the_comments/slim/_manage_controls.html.slim +30 -0
  46. data/app/views/the_comments/slim/_sidebar.html.slim +9 -0
  47. data/app/views/the_comments/slim/_sidebar_admin.html.slim +12 -0
  48. data/app/views/the_comments/slim/_sidebar_backlink.html.slim +3 -0
  49. data/app/views/the_comments/slim/_sidebar_user.html.slim +29 -0
  50. data/app/views/the_comments/slim/_tree.html.slim +16 -0
  51. data/app/views/the_comments/slim/index.html.slim +18 -0
  52. data/app/views/the_comments/slim/manage.html.slim +26 -0
  53. data/app/views/the_comments/slim/my_comments.html.slim +28 -0
  54. data/config/initializers/the_comments.rb +15 -0
  55. data/config/locales/en.yml +68 -0
  56. data/config/locales/ru.yml +71 -0
  57. data/config/routes.rb +38 -0
  58. data/db/migrate/20130101010101_the_comments_change_user.rb +18 -0
  59. data/db/migrate/20130101010102_the_comments_create_comments.rb +50 -0
  60. data/db/migrate/20130101010103_the_comments_change_commentable.rb +13 -0
  61. data/docs/admin_ui_installation.md +145 -0
  62. data/docs/advanced_installation.md +185 -0
  63. data/docs/comment_api.md +58 -0
  64. data/docs/commentable_api.md +59 -0
  65. data/docs/config_file.md +27 -0
  66. data/docs/content_preprocessors.md +73 -0
  67. data/docs/customazation_of_views.md +30 -0
  68. data/docs/denormalization_and_recent_comments.md +40 -0
  69. data/docs/documentation.md +29 -0
  70. data/docs/generators.md +74 -0
  71. data/docs/pagination.md +123 -0
  72. data/docs/routes.md +77 -0
  73. data/docs/screencast.jpg +0 -0
  74. data/docs/the_comments.jpg +0 -0
  75. data/docs/the_comments_view_1.gif +0 -0
  76. data/docs/the_comments_view_2.gif +0 -0
  77. data/docs/the_comments_view_3.gif +0 -0
  78. data/docs/the_comments_view_4.gif +0 -0
  79. data/docs/the_comments_view_5.gif +0 -0
  80. data/docs/user_api.md +75 -0
  81. data/docs/what_is_comcoms.md +63 -0
  82. data/docs/whats_wrong_with_other_gems.md +28 -0
  83. data/docs/where_is_example_application.md +37 -0
  84. data/gem_version.rb +3 -0
  85. data/lib/generators/the_comments/USAGE +44 -0
  86. data/lib/generators/the_comments/the_comments_generator.rb +56 -0
  87. data/lib/generators/the_comments/views_generator.rb +79 -0
  88. data/lib/the_comments/config.rb +39 -0
  89. data/lib/the_comments/version.rb +1 -0
  90. data/lib/the_comments.rb +27 -0
  91. data/spec/dummy_app/.gitignore +18 -0
  92. data/spec/dummy_app/.rspec +1 -0
  93. data/spec/dummy_app/Gemfile +43 -0
  94. data/spec/dummy_app/README.md +33 -0
  95. data/spec/dummy_app/Rakefile +6 -0
  96. data/spec/dummy_app/app/assets/images/.keep +0 -0
  97. data/spec/dummy_app/app/assets/javascripts/admin_panel.js +5 -0
  98. data/spec/dummy_app/app/assets/javascripts/application.js +16 -0
  99. data/spec/dummy_app/app/assets/stylesheets/admin_panel.css +3 -0
  100. data/spec/dummy_app/app/assets/stylesheets/app.css.scss +4 -0
  101. data/spec/dummy_app/app/assets/stylesheets/application.css +16 -0
  102. data/spec/dummy_app/app/controllers/application_controller.rb +7 -0
  103. data/spec/dummy_app/app/controllers/comments_controller.rb +28 -0
  104. data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
  105. data/spec/dummy_app/app/controllers/posts_controller.rb +13 -0
  106. data/spec/dummy_app/app/controllers/users_controller.rb +7 -0
  107. data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
  108. data/spec/dummy_app/app/mailers/.keep +0 -0
  109. data/spec/dummy_app/app/models/.keep +0 -0
  110. data/spec/dummy_app/app/models/comment.rb +32 -0
  111. data/spec/dummy_app/app/models/concerns/.keep +0 -0
  112. data/spec/dummy_app/app/models/post.rb +17 -0
  113. data/spec/dummy_app/app/models/user.rb +21 -0
  114. data/spec/dummy_app/app/views/layouts/admin.html.haml +25 -0
  115. data/spec/dummy_app/app/views/layouts/application.html.haml +20 -0
  116. data/spec/dummy_app/app/views/posts/index.html.haml +22 -0
  117. data/spec/dummy_app/app/views/posts/show.html.haml +7 -0
  118. data/spec/dummy_app/bin/bundle +3 -0
  119. data/spec/dummy_app/bin/rails +4 -0
  120. data/spec/dummy_app/bin/rake +4 -0
  121. data/spec/dummy_app/config/application.rb +23 -0
  122. data/spec/dummy_app/config/boot.rb +4 -0
  123. data/spec/dummy_app/config/database.yml +11 -0
  124. data/spec/dummy_app/config/environment.rb +5 -0
  125. data/spec/dummy_app/config/environments/development.rb +29 -0
  126. data/spec/dummy_app/config/environments/production.rb +80 -0
  127. data/spec/dummy_app/config/environments/test.rb +36 -0
  128. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
  129. data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
  130. data/spec/dummy_app/config/initializers/inflections.rb +16 -0
  131. data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
  132. data/spec/dummy_app/config/initializers/secret_token.rb +12 -0
  133. data/spec/dummy_app/config/initializers/session_store.rb +3 -0
  134. data/spec/dummy_app/config/initializers/sorcery.rb +437 -0
  135. data/spec/dummy_app/config/initializers/the_comments.rb +15 -0
  136. data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
  137. data/spec/dummy_app/config/locales/en.yml +23 -0
  138. data/spec/dummy_app/config/routes.rb +19 -0
  139. data/spec/dummy_app/config.ru +4 -0
  140. data/spec/dummy_app/db/migrate/20130712061503_sorcery_core.rb +16 -0
  141. data/spec/dummy_app/db/migrate/20130712065951_create_posts.rb +11 -0
  142. data/spec/dummy_app/db/migrate/20131027185332_change_user.the_comments_engine.rb +19 -0
  143. data/spec/dummy_app/db/migrate/20131027185333_create_comments.the_comments_engine.rb +51 -0
  144. data/spec/dummy_app/db/migrate/20131027185334_change_commentable.the_comments_engine.rb +14 -0
  145. data/spec/dummy_app/db/schema.rb +74 -0
  146. data/spec/dummy_app/db/seeds.rb +42 -0
  147. data/spec/dummy_app/lib/assets/.keep +0 -0
  148. data/spec/dummy_app/lib/tasks/.keep +0 -0
  149. data/spec/dummy_app/lib/tasks/app_bootstrap.rake +15 -0
  150. data/spec/dummy_app/log/.keep +0 -0
  151. data/spec/dummy_app/public/404.html +58 -0
  152. data/spec/dummy_app/public/422.html +58 -0
  153. data/spec/dummy_app/public/500.html +57 -0
  154. data/spec/dummy_app/public/favicon.ico +0 -0
  155. data/spec/dummy_app/public/robots.txt +5 -0
  156. data/spec/dummy_app/spec/factories/post.rb +6 -0
  157. data/spec/dummy_app/spec/factories/user.rb +6 -0
  158. data/spec/dummy_app/spec/models/user_counters_spec.rb +339 -0
  159. data/spec/dummy_app/spec/spec_helper.rb +29 -0
  160. data/spec/dummy_app/test/controllers/.keep +0 -0
  161. data/spec/dummy_app/test/fixtures/.keep +0 -0
  162. data/spec/dummy_app/test/helpers/.keep +0 -0
  163. data/spec/dummy_app/test/integration/.keep +0 -0
  164. data/spec/dummy_app/test/mailers/.keep +0 -0
  165. data/spec/dummy_app/test/models/.keep +0 -0
  166. data/spec/dummy_app/test/test_helper.rb +15 -0
  167. data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
  168. data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
  169. data/the_comments.gemspec +23 -0
  170. data/views_converter.rb +16 -0
  171. metadata +332 -0
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :post, class: Post do
3
+ sequence(:title) { Faker::Lorem.sentence }
4
+ sequence(:content) { Faker::Lorem.sentence }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :user, class: User do
3
+ sequence(:username) { Faker::Name.name }
4
+ sequence(:email) { Faker::Internet.email }
5
+ end
6
+ end
@@ -0,0 +1,339 @@
1
+ require 'spec_helper'
2
+
3
+ def destroy_all
4
+ User.destroy_all
5
+ 3.times{ begin; Comment.destroy_all; rescue; end; }
6
+ end
7
+
8
+ # --------------------------------------
9
+ # Helpers
10
+ # --------------------------------------
11
+ def my_comments_count_assert user, count
12
+ user.my_comments.active.count.should eq count
13
+ user.my_comments_count.should eq count
14
+ end
15
+
16
+ def comments_count_assert(obj, values)
17
+ obj.comments.with_state(:draft).count.should eq values[0]
18
+ obj.comments.with_state(:published).count.should eq values[1]
19
+ obj.comments.with_state(:deleted).count.should eq values[2]
20
+ end
21
+
22
+ def comments_counters_assert(obj, values)
23
+ obj.draft_comments_count.should eq values[0]
24
+ obj.published_comments_count.should eq values[1]
25
+ obj.deleted_comments_count.should eq values[2]
26
+ end
27
+
28
+ def comcoms_count_assert(obj, values)
29
+ obj.comcoms.with_state(:draft).count.should eq values[0]
30
+ obj.comcoms.with_state(:published).count.should eq values[1]
31
+ obj.comcoms.with_state(:deleted).count.should eq values[2]
32
+ end
33
+
34
+ def comcoms_counters_assert(obj, values)
35
+ obj.draft_comcoms_count.should eq values[0]
36
+ obj.published_comcoms_count.should eq values[1]
37
+ obj.deleted_comcoms_count.should eq values[2]
38
+ end
39
+
40
+ # --------------------------------------
41
+ # init functions
42
+ # --------------------------------------
43
+ def create_users_and_post
44
+ @user = FactoryGirl.create(:user)
45
+ @post_holder = FactoryGirl.create(:user)
46
+ @post = FactoryGirl.create(:post, user: @post_holder)
47
+ end
48
+
49
+ def base_test_situation
50
+ create_users_and_post
51
+
52
+ 3.times do
53
+ @comment = Comment.create!(
54
+ user: @user,
55
+ commentable: @post,
56
+ title: Faker::Lorem.sentence,
57
+ raw_content: Faker::Lorem.paragraphs(3).join
58
+ )
59
+ end
60
+
61
+ @user.reload
62
+ @post_holder.reload
63
+ end
64
+
65
+ def tree_test_situation
66
+ create_users_and_post
67
+
68
+ # LEVEL 1
69
+ 3.times do
70
+ Comment.create!(
71
+ user: @user,
72
+ commentable: @post,
73
+ title: Faker::Lorem.sentence,
74
+ raw_content: Faker::Lorem.paragraphs(3).join,
75
+ state: :published
76
+ )
77
+ end
78
+ # LEVEL 2
79
+ parent_comment = Comment.first
80
+ 3.times do
81
+ Comment.create!(
82
+ user: @user,
83
+ commentable: @post,
84
+ parent_id: parent_comment.id,
85
+ title: Faker::Lorem.sentence,
86
+ raw_content: Faker::Lorem.paragraphs(3).join,
87
+ state: :published
88
+ )
89
+ end
90
+ # LEVEL 3
91
+ parent_comment = Comment.first.children.first
92
+ 3.times do
93
+ Comment.create!(
94
+ user: @user,
95
+ commentable: @post,
96
+ parent_id: parent_comment.id,
97
+ title: Faker::Lorem.sentence,
98
+ raw_content: Faker::Lorem.paragraphs(3).join,
99
+ state: :published
100
+ )
101
+ end
102
+
103
+ @user.reload
104
+ @post_holder.reload
105
+ end
106
+ # --------------------------------------
107
+ # ~ init functions
108
+ # --------------------------------------
109
+
110
+ describe User do
111
+ context 'User leave comment to the post' do
112
+ after(:all){ destroy_all }
113
+
114
+ before(:all){ create_users_and_post }
115
+
116
+ it 'should be User' do
117
+ @user.should be_instance_of User
118
+ @post_holder.should be_instance_of User
119
+ end
120
+
121
+ it 'Post should has owner' do
122
+ @post.user.should eq @post_holder
123
+ end
124
+
125
+ it 'should be Post' do
126
+ @post.should be_instance_of Post
127
+ end
128
+
129
+ it 'Create new comment' do
130
+ @comment = Comment.create!(
131
+ user: @user,
132
+ commentable: @post,
133
+ title: Faker::Lorem.sentence,
134
+ raw_content: Faker::Lorem.paragraphs(3).join
135
+ )
136
+
137
+ @comment.user.should eq @user
138
+ @comment.holder.should eq @post_holder
139
+ end
140
+ end
141
+
142
+ context "Written by me counters" do
143
+ after(:all) { destroy_all }
144
+ before(:all){ create_users_and_post }
145
+ it 'should has correct My counters values' do
146
+ @comment = Comment.create!(
147
+ user: @user,
148
+ commentable: @post,
149
+ title: Faker::Lorem.sentence,
150
+ raw_content: Faker::Lorem.paragraphs(3).join
151
+ )
152
+ @user.reload
153
+ @user.my_comments_count.should eq 1
154
+ @user.my_draft_comments_count.should eq 1
155
+ @user.my_published_comments_count.should eq 0
156
+ end
157
+ end
158
+
159
+ context "Commentable Denormalization" do
160
+ after(:all) { destroy_all }
161
+ before(:all) do
162
+ base_test_situation
163
+ end
164
+
165
+ it 'should have denormalized fields' do
166
+ title = "New Title!"
167
+ @post.update_attribute(:title, title)
168
+ @post.title.should eq title
169
+ @comment = @post.comments.first
170
+ @comment.commentable_title.should eq title
171
+ end
172
+ end
173
+
174
+ context 'User leave 3 comments and Instances has expectable counter values' do
175
+ after(:all) { destroy_all }
176
+
177
+ before(:all){ base_test_situation }
178
+
179
+ describe 'User counters' do
180
+ it 'my_comments counter' do
181
+ my_comments_count_assert(@user, 3)
182
+ end
183
+
184
+ it 'Comcoms counters' do
185
+ @user.comcoms.count.should eq 0
186
+
187
+ comcoms_counters_assert(@user, [0,0,0])
188
+ end
189
+ end
190
+
191
+ describe 'Holder counters' do
192
+ it 'my_comments counter' do
193
+ my_comments_count_assert(@post_holder, 0)
194
+ end
195
+
196
+ it 'Comcoms counters' do
197
+ @post_holder.comcoms.count.should eq 3
198
+ comcoms_counters_assert(@post_holder, [3,0,0])
199
+ end
200
+ end
201
+ end
202
+
203
+ context 'User leave 3 comments, 1 Comment DRAFT => PUBLISHED' do
204
+ after(:all) { destroy_all }
205
+
206
+ before(:all) do
207
+ base_test_situation
208
+ @comment = Comment.first
209
+ @comment.to_published
210
+
211
+ @user.reload
212
+ @post.reload
213
+ @comment.reload
214
+ @post_holder.reload
215
+ end
216
+
217
+ describe 'User counters' do
218
+ it 'has expectable values' do
219
+ comments_counters_assert @user, [0,0,0]
220
+ comments_count_assert @user, [0,0,0]
221
+ comcoms_counters_assert @user, [0,0,0]
222
+ comcoms_count_assert @user, [0,0,0]
223
+ my_comments_count_assert @user, 3
224
+ end
225
+ end
226
+
227
+ describe 'Holder counters' do
228
+ it 'has expectable values' do
229
+ @post_holder.comcoms.count.should eq 3
230
+
231
+ my_comments_count_assert(@post_holder, 0)
232
+ comcoms_count_assert @post_holder, [2,1,0]
233
+ comcoms_counters_assert @post_holder, [2,1,0]
234
+ end
235
+ end
236
+ end
237
+
238
+ context '3 comments, 1 Comment DRAFT => DELETE' do
239
+ after(:all) { destroy_all }
240
+
241
+ before(:all) do
242
+ base_test_situation
243
+ @comment = Comment.first
244
+ @comment.to_published
245
+ @comment.to_deleted
246
+
247
+ @user.reload
248
+ @post.reload
249
+ @comment.reload
250
+ @post_holder.reload
251
+ end
252
+
253
+ it 'has correct counters values' do
254
+ comments_counters_assert @user, [0,0,0]
255
+ comments_count_assert @user, [0,0,0]
256
+ comcoms_count_assert @user, [0,0,0]
257
+ my_comments_count_assert @user, 2
258
+ @user.my_comments.count.should eq 3
259
+
260
+ comments_counters_assert @post_holder, [0,0,0]
261
+ comments_count_assert @post_holder, [0,0,0]
262
+ comcoms_count_assert @post_holder, [2,0,1]
263
+ my_comments_count_assert @post_holder, 0
264
+ @post_holder.my_comments.count.should eq 0
265
+
266
+ comments_count_assert @post, [2,0,1]
267
+ comments_counters_assert @post, [2,0,1]
268
+ end
269
+ end
270
+
271
+ context 'Comments tree, 1 branch to deleted' do
272
+ after(:each) { destroy_all }
273
+ before(:each){ tree_test_situation }
274
+
275
+ it 'has correct counters values before deleting' do
276
+ Comment.count.should eq 9
277
+
278
+ my_comments_count_assert @user, 9
279
+ comments_count_assert @user, [0,0,0]
280
+
281
+ my_comments_count_assert @post_holder, 0
282
+ comments_count_assert @post_holder, [0,0,0]
283
+
284
+ comcoms_count_assert @post_holder, [0,9,0]
285
+ comcoms_counters_assert @post_holder, [0,9,0]
286
+
287
+ comments_count_assert @post, [0,9,0]
288
+ comments_counters_assert @post, [0,9,0]
289
+ end
290
+
291
+ it 'has correct counters values after branch deleting' do
292
+ @comment = Comment.first.children.first
293
+ @comment.to_deleted
294
+
295
+ @user.reload
296
+ @post.reload
297
+ @post_holder.reload
298
+
299
+ Comment.with_state(:published).count.should eq 5
300
+ Comment.with_state(:deleted).count.should eq 4
301
+
302
+ my_comments_count_assert @user, 5
303
+ comments_count_assert @user, [0,0,0]
304
+
305
+ my_comments_count_assert @post_holder, 0
306
+ comments_count_assert @post_holder, [0,0,0]
307
+
308
+ comcoms_count_assert @post_holder, [0,5,4]
309
+ comcoms_counters_assert @post_holder, [0,5,4]
310
+
311
+ comments_count_assert @post, [0,5,4]
312
+ comments_counters_assert @post, [0,5,4]
313
+ end
314
+
315
+ # This code helps to me to catch logic bugs
316
+ # there is no any asserts
317
+ # context "callbacks catch" do
318
+ # after(:all) { destroy_all }
319
+ # it "before validation callback with increment! must be call manually" do
320
+ # @user = FactoryGirl.create(:user)
321
+ # @post_holder = FactoryGirl.create(:user)
322
+ # @post = FactoryGirl.create(:post, user: @post_holder)
323
+
324
+ # Comment.create!(
325
+ # user: @user,
326
+ # commentable: @post,
327
+ # title: Faker::Lorem.sentence,
328
+ # raw_content: Faker::Lorem.paragraphs(3).join,
329
+ # state: :deleted
330
+ # )
331
+ # Comment.first.to_published
332
+ # end
333
+ # end
334
+
335
+ # it 'has correct counters after comment destroy' do
336
+ # pending("has correct counters after comment destroy")
337
+ # end
338
+ end
339
+ end
@@ -0,0 +1,29 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
8
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
9
+
10
+ RSpec.configure do |config|
11
+ config.infer_base_class_for_anonymous_controllers = false
12
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
13
+ config.use_transactional_fixtures = true
14
+ config.order = "random"
15
+
16
+ # DatabaseCleaner
17
+ # config.before(:suite) do
18
+ # DatabaseCleaner.strategy = :transaction
19
+ # DatabaseCleaner.clean_with(:truncation)
20
+ # end
21
+
22
+ # config.before(:each) do
23
+ # DatabaseCleaner.start
24
+ # end
25
+
26
+ # config.after(:each) do
27
+ # DatabaseCleaner.clean
28
+ # end
29
+ end