inkwell 0.0.3 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/app/models/inkwell/comment.rb +23 -3
  2. data/lib/acts_as_inkwell_post/base.rb +23 -3
  3. data/lib/acts_as_inkwell_user/base.rb +26 -15
  4. data/lib/inkwell/version.rb +1 -1
  5. data/test/dummy/db/test.sqlite3 +0 -0
  6. data/test/dummy/log/development.log +5 -0
  7. data/test/dummy/log/test.log +28689 -0
  8. data/test/dummy/spec/functional/blogline_spec.rb +1 -1
  9. data/test/dummy/spec/functional/comments_spec.rb +34 -13
  10. data/test/dummy/spec/functional/favorite_spec.rb +26 -3
  11. data/test/dummy/spec/functional/reblog_spec.rb +27 -1
  12. data/test/dummy/spec/functional/timeline_spec.rb +2 -2
  13. data/test/dummy_without_community/Rakefile +7 -0
  14. data/test/dummy_without_community/app/assets/javascripts/application.js +9 -0
  15. data/test/dummy_without_community/app/assets/stylesheets/application.css +7 -0
  16. data/test/dummy_without_community/app/controllers/application_controller.rb +3 -0
  17. data/test/dummy_without_community/app/helpers/application_helper.rb +2 -0
  18. data/test/dummy_without_community/app/models/post.rb +6 -0
  19. data/test/dummy_without_community/app/models/user.rb +7 -0
  20. data/test/dummy_without_community/app/views/layouts/application.html.erb +14 -0
  21. data/test/dummy_without_community/config.ru +4 -0
  22. data/test/dummy_without_community/config/application.rb +51 -0
  23. data/test/dummy_without_community/config/boot.rb +10 -0
  24. data/test/dummy_without_community/config/database.yml +25 -0
  25. data/test/dummy_without_community/config/environment.rb +5 -0
  26. data/test/dummy_without_community/config/environments/development.rb +30 -0
  27. data/test/dummy_without_community/config/environments/production.rb +60 -0
  28. data/test/dummy_without_community/config/environments/test.rb +42 -0
  29. data/test/dummy_without_community/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy_without_community/config/initializers/inflections.rb +10 -0
  31. data/test/dummy_without_community/config/initializers/inkwell.rb +6 -0
  32. data/test/dummy_without_community/config/initializers/mime_types.rb +5 -0
  33. data/test/dummy_without_community/config/initializers/secret_token.rb +7 -0
  34. data/test/dummy_without_community/config/initializers/session_store.rb +8 -0
  35. data/test/dummy_without_community/config/initializers/wrap_parameters.rb +14 -0
  36. data/test/dummy_without_community/config/locales/en.yml +5 -0
  37. data/test/dummy_without_community/config/routes.rb +4 -0
  38. data/test/dummy_without_community/db/migrate/20121202111750_create_posts.rb +11 -0
  39. data/test/dummy_without_community/db/migrate/20121202112556_create_users.rb +9 -0
  40. data/test/dummy_without_community/db/migrate/20130120124010_create_inkwell_timeline_items.rb +13 -0
  41. data/test/dummy_without_community/db/migrate/20130120124011_add_columns_to_posts.rb +7 -0
  42. data/test/dummy_without_community/db/migrate/20130120124012_create_inkwell_blog_items.rb +12 -0
  43. data/test/dummy_without_community/db/migrate/20130120124013_create_inkwell_favorite_items.rb +11 -0
  44. data/test/dummy_without_community/db/migrate/20130120124014_add_columns_to_users.rb +6 -0
  45. data/test/dummy_without_community/db/migrate/20130120124015_create_inkwell_comments.rb +16 -0
  46. data/test/dummy_without_community/db/schema.rb +75 -0
  47. data/test/dummy_without_community/db/seeds.rb +7 -0
  48. data/test/dummy_without_community/public/404.html +26 -0
  49. data/test/dummy_without_community/public/422.html +26 -0
  50. data/test/dummy_without_community/public/500.html +26 -0
  51. data/test/dummy_without_community/public/favicon.ico +0 -0
  52. data/test/dummy_without_community/script/rails +6 -0
  53. data/test/dummy_without_community/spec/functional/blogline_spec.rb +70 -0
  54. data/test/dummy_without_community/spec/functional/comments_spec.rb +416 -0
  55. data/test/dummy_without_community/spec/functional/favorite_spec.rb +259 -0
  56. data/test/dummy_without_community/spec/functional/following_spec.rb +120 -0
  57. data/test/dummy_without_community/spec/functional/reblog_spec.rb +179 -0
  58. data/test/dummy_without_community/spec/functional/timeline_spec.rb +68 -0
  59. data/test/dummy_without_community/spec/spec_helper.rb +52 -0
  60. metadata +96 -2
File without changes
@@ -0,0 +1,6 @@
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'
@@ -0,0 +1,70 @@
1
+ require "spec_helper"
2
+
3
+ describe "BlogLine" do
4
+
5
+ before(:each) do
6
+ @salkar = User.create :nick => "Salkar"
7
+ @morozovm = User.create :nick => "Morozovm"
8
+ @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
9
+ end
10
+
11
+ it "blogitem record should been created for new post" do
12
+ @salkar.blog_items.size.should == 1
13
+ item = @salkar.blog_items.first
14
+ item.user_id.should == @salkar.id
15
+ item.item_id.should == @salkar_post.id
16
+ item.is_reblog.should == false
17
+ item.is_comment.should == false
18
+ end
19
+
20
+ it "timeline items should been created for followers for new post" do
21
+ @talisman = User.create :nick => "Talisman"
22
+ @morozovm.follow @salkar
23
+ @talisman.follow @salkar
24
+ @salkar_post1 = @salkar.posts.create :body => "salkar_post_test_body"
25
+ ::Inkwell::TimelineItem.where(:user_id => @morozovm.id, :is_comment => false, :item_id => @salkar_post1.id).size.should == 1
26
+ ::Inkwell::TimelineItem.where(:user_id => @talisman.id, :is_comment => false, :item_id => @salkar_post1.id).size.should == 1
27
+ end
28
+
29
+ it "user should have blogline with reblogs and his posts" do
30
+ @salkar_post1 = @salkar.posts.create :body => "salkar_post_test_body_1"
31
+ @salkar_post2 = @salkar.posts.create :body => "salkar_post_test_body_2"
32
+ @salkar_post3 = @salkar.posts.create :body => "salkar_post_test_body_3"
33
+ @morozovm_post = @morozovm.posts.create :body => "morozovm_post_test_body"
34
+ @salkar_post4 = @salkar.posts.create :body => "salkar_post_test_body_4"
35
+ @salkar_post5 = @salkar.posts.create :body => "salkar_post_test_body_5"
36
+ @salkar.reblog @morozovm_post
37
+ @morozovm_post1 = @morozovm.posts.create :body => "morozovm_post_test_body_1"
38
+ @salkar_post6 = @salkar.posts.create :body => "salkar_post_test_body_6"
39
+ @salkar_post7 = @salkar.posts.create :body => "salkar_post_test_body_7"
40
+ @salkar_post8 = @salkar.posts.create :body => "salkar_post_test_body_8"
41
+ @morozovm_post2 = @morozovm.posts.create :body => "morozovm_post_test_body_2"
42
+ @salkar_post9 = @salkar.posts.create :body => "salkar_post_test_body_9"
43
+ @morozovm_post3 = @morozovm.posts.create :body => "morozovm_post_test_body_3"
44
+ @salkar.reblog @morozovm_post1
45
+ @salkar.reblog @morozovm_post2
46
+
47
+ @morozovm.reblog @salkar_post9
48
+ @morozovm.favorite @salkar_post9
49
+
50
+ bline = @salkar.blogline :for_user => @morozovm
51
+ bline.size.should == 10
52
+ bline[0].should == @morozovm_post2
53
+ bline[0].is_reblog_in_blogline.should == true
54
+ bline[1].should == @morozovm_post1
55
+ bline[1].is_reblog_in_blogline.should == true
56
+ bline[2].should == @salkar_post9
57
+ bline[2].is_reblogged.should == true
58
+ bline[2].is_favorited.should == true
59
+ bline[2].is_reblog_in_blogline.should == false
60
+ bline[2].item_id_in_line.should == ::Inkwell::BlogItem.where(:item_id => @salkar_post9.id, :is_comment => false).first.id
61
+ bline[3].should == @salkar_post8
62
+ bline[4].should == @salkar_post7
63
+ bline[5].should == @salkar_post6
64
+ bline[6].should == @morozovm_post
65
+ bline[6].is_reblog_in_blogline.should == true
66
+ bline[7].should == @salkar_post5
67
+ bline[8].should == @salkar_post4
68
+ bline[9].should == @salkar_post3
69
+ end
70
+ end
@@ -0,0 +1,416 @@
1
+ require "spec_helper"
2
+
3
+ describe "Comments" do
4
+
5
+ before(:each) do
6
+ @salkar = User.create :nick => "Salkar"
7
+ @morozovm = User.create :nick => "Morozovm"
8
+ @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
9
+ end
10
+
11
+ it "comments should be available for user and post" do
12
+ @salkar.comments.should == []
13
+ @salkar_post.comments.should == []
14
+ end
15
+
16
+ it "comment should been created" do
17
+ @salkar.comments.size.should == 0
18
+ comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
19
+ @salkar.comments.size.should == 1
20
+ @salkar_post.comments.size.should == 1
21
+ @salkar.comments.should == @salkar_post.comments
22
+ comment.id.should be
23
+ comment.body.should be
24
+ comment.user.should == @salkar
25
+ comment.post.should == @salkar_post
26
+ comment.users_ids_who_favorite_it.should == "[]"
27
+ comment.users_ids_who_comment_it.should == "[]"
28
+ comment.users_ids_who_reblog_it.should == "[]"
29
+
30
+ @salkar_post = Post.find @salkar_post
31
+ ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it).should == [{"user_id"=>@salkar.id, "comment_id"=>comment.id}]
32
+ end
33
+
34
+ it "comment should not been created" do
35
+ post = @salkar.comments.create :post_id => @salkar_post.id
36
+ post.id.should == nil
37
+ post = @salkar.comments.create :body => "salkar_comment_body"
38
+ post.id.should == nil
39
+ post = @salkar_post.comments.create :body => "salkar_comment_body"
40
+ post.id.should == nil
41
+ end
42
+
43
+ it "10 comments for main post should been received" do
44
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
45
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
46
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
47
+ @comment3 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
48
+ @comment4 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
49
+ @comment5 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
50
+ @comment6 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
51
+ @comment7 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
52
+ @comment8 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
53
+ @comment9 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
54
+ @comment10 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
55
+ @comment11 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
56
+
57
+ commentline = @salkar_post.commentline
58
+ commentline.size.should == 10
59
+ commentline[0].id.should == @comment2.id
60
+ commentline[9].id.should == @comment11.id
61
+
62
+ commentline = @salkar_post.commentline :last_shown_comment_id => @comment10.id
63
+ commentline.size.should == 10
64
+ commentline[0].id.should == @comment.id
65
+ commentline[9].id.should == @comment9.id
66
+
67
+ end
68
+
69
+ it "5 comments for main post should been received" do
70
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
71
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
72
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
73
+ @comment3 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment1.id)
74
+ @comment4 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
75
+ @comment5 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
76
+ @comment6 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
77
+ @comment7 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
78
+ @comment8 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
79
+ @comment9 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
80
+ @comment10 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
81
+ @comment11 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
82
+
83
+ commentline = @salkar_post.commentline :limit => 5
84
+ commentline.size.should == 5
85
+ commentline[0].id.should == @comment7.id
86
+ commentline[4].id.should == @comment11.id
87
+
88
+ commentline = @salkar_post.commentline :last_shown_comment_id => @comment10.id, :limit => 5
89
+ commentline.size.should == 5
90
+ commentline[0].id.should == @comment5.id
91
+ commentline[4].id.should == @comment9.id
92
+
93
+ commentline = @salkar_post.commentline :last_shown_comment_id => @comment5.id, :limit => 7
94
+ commentline.size.should == 5
95
+ commentline[0].id.should == @comment.id
96
+ commentline[4].id.should == @comment4.id
97
+ end
98
+
99
+ it "comments should been deleted when parent post destroyed" do
100
+ @salkar_comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
101
+ @morozovm_comment = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
102
+ @salkar_post.comments.size.should == 2
103
+ ::Inkwell::Comment.all.size.should == 2
104
+ @salkar_post.destroy
105
+ ::Inkwell::Comment.all.size.should == 0
106
+ end
107
+
108
+ it "2 comments with parent_id should been created" do
109
+ @salkar_comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
110
+ @morozovm_comment = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @salkar_comment.id)
111
+ @salkar_comment = ::Inkwell::Comment.find @salkar_comment
112
+ @morozovm_comment = ::Inkwell::Comment.find @morozovm_comment
113
+ @salkar_post.reload
114
+ ActiveSupport::JSON.decode(@salkar_comment.users_ids_who_comment_it).should == [{"user_id"=>@morozovm.id, "comment_id"=>@morozovm_comment.id}]
115
+ ActiveSupport::JSON.decode(@morozovm_comment.upper_comments_tree).should == [@salkar_comment.id]
116
+ ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it).should == [{"user_id"=>@salkar.id, "comment_id"=>@salkar_comment.id}, {"user_id"=>@morozovm.id, "comment_id"=>@morozovm_comment.id}]
117
+
118
+
119
+ ActiveSupport::JSON.decode(@morozovm_comment.users_ids_who_comment_it).should == []
120
+ ActiveSupport::JSON.decode(@salkar_comment.upper_comments_tree).should == []
121
+ end
122
+
123
+ it "7 comments should been created" do
124
+ @salkar_comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
125
+ @morozovm_comment = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @salkar_comment.id)
126
+ @salkar_comment1 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
127
+ @morozovm_comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @salkar_comment.id)
128
+ @salkar_comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
129
+ @morozovm_comment2 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @salkar_comment.id)
130
+ @salkar_comment3 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
131
+ @salkar_post.reload
132
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
133
+ users_ids_who_comment_it.size.should == 7
134
+ users_ids_who_comment_it[0].should == {"user_id"=>@salkar.id, "comment_id"=>@salkar_comment.id}
135
+ users_ids_who_comment_it[6].should == {"user_id"=>@salkar.id, "comment_id"=>@salkar_comment3.id}
136
+
137
+ @salkar_comment.reload
138
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_comment.users_ids_who_comment_it)
139
+ users_ids_who_comment_it.size.should == 3
140
+ users_ids_who_comment_it[0].should == {"user_id"=>@morozovm.id, "comment_id"=>@morozovm_comment.id}
141
+ users_ids_who_comment_it[2].should == {"user_id"=>@morozovm.id, "comment_id"=>@morozovm_comment2.id}
142
+
143
+ @salkar_comment1.reload
144
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_comment1.users_ids_who_comment_it)
145
+ users_ids_who_comment_it.size.should == 0
146
+
147
+ @salkar_comment3.reload
148
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_comment3.users_ids_who_comment_it)
149
+ users_ids_who_comment_it.size.should == 0
150
+ end
151
+
152
+ it "1 comments should been deleted from post" do
153
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
154
+ @salkar_post.reload
155
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
156
+ users_ids_who_comment_it.should == [{"user_id"=>@salkar.id, "comment_id"=>@comment.id}]
157
+ ::Inkwell::TimelineItem.create :item_id => @comment.id, :user_id => @morozovm.id, :is_comment => true
158
+ ::Inkwell::FavoriteItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
159
+ ::Inkwell::BlogItem.create :item_id => @comment.id, :user_id => @morozovm.id, :is_comment => true
160
+ ::Inkwell::BlogItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
161
+ ::Inkwell::FavoriteItem.all.size.should == 1
162
+ ::Inkwell::TimelineItem.all.size.should == 1
163
+ ::Inkwell::BlogItem.all.size.should == 3
164
+ ::Inkwell::Comment.all.size.should == 1
165
+
166
+ @comment.destroy
167
+ @salkar_post.reload
168
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
169
+ users_ids_who_comment_it.should == []
170
+ ::Inkwell::FavoriteItem.all.size.should == 0
171
+ ::Inkwell::TimelineItem.all.size.should == 0
172
+ ::Inkwell::BlogItem.all.size.should == 1
173
+ ::Inkwell::Comment.all.size.should == 0
174
+ end
175
+
176
+ it "1 comments should been deleted from post with parent comment" do
177
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
178
+ @comment_to_delete = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
179
+ @salkar_post.reload
180
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
181
+ users_ids_who_comment_it.should == [{"user_id" => @salkar.id, "comment_id" => @comment.id}, {"user_id" => @morozovm.id, "comment_id" => @comment_to_delete.id}]
182
+ ::Inkwell::TimelineItem.create :item_id => @comment_to_delete.id, :user_id => @morozovm.id, :is_comment => true
183
+ ::Inkwell::FavoriteItem.create :item_id => @comment_to_delete.id, :user_id => @salkar.id, :is_comment => true
184
+ ::Inkwell::TimelineItem.create :item_id => @comment.id, :user_id => @morozovm.id, :is_comment => true
185
+ ::Inkwell::FavoriteItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
186
+ ::Inkwell::BlogItem.create :item_id => @comment_to_delete.id, :user_id => @morozovm.id, :is_comment => true
187
+ ::Inkwell::BlogItem.create :item_id => @comment_to_delete.id, :user_id => @salkar.id, :is_comment => true
188
+ ::Inkwell::BlogItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
189
+ ::Inkwell::FavoriteItem.all.size.should == 2
190
+ ::Inkwell::TimelineItem.all.size.should == 2
191
+ ::Inkwell::BlogItem.all.size.should == 4
192
+ ::Inkwell::Comment.all.size.should == 2
193
+
194
+ @comment_to_delete.destroy
195
+ @salkar_post.reload
196
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
197
+ users_ids_who_comment_it.should == [{"user_id" => @salkar.id, "comment_id" => @comment.id}]
198
+ ::Inkwell::FavoriteItem.all.size.should == 1
199
+ ::Inkwell::TimelineItem.all.size.should == 1
200
+ ::Inkwell::BlogItem.all.size.should == 2
201
+ ::Inkwell::Comment.all.size.should == 1
202
+ @comment.reload
203
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@comment.users_ids_who_comment_it)
204
+ users_ids_who_comment_it.should == []
205
+ end
206
+
207
+ it "2 comments should been deleted from post with parent comment" do
208
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
209
+ @comment2 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
210
+ @salkar_post.reload
211
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
212
+ users_ids_who_comment_it.should == [{"user_id" => @salkar.id, "comment_id" => @comment.id}, {"user_id" => @morozovm.id, "comment_id" => @comment2.id}]
213
+ ::Inkwell::TimelineItem.create :item_id => @comment2.id, :user_id => @morozovm.id, :is_comment => true
214
+ ::Inkwell::FavoriteItem.create :item_id => @comment2.id, :user_id => @salkar.id, :is_comment => true
215
+ ::Inkwell::TimelineItem.create :item_id => @comment.id, :user_id => @morozovm.id, :is_comment => true
216
+ ::Inkwell::FavoriteItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
217
+ ::Inkwell::BlogItem.create :item_id => @comment2.id, :user_id => @morozovm.id, :is_comment => true
218
+ ::Inkwell::BlogItem.create :item_id => @comment2.id, :user_id => @salkar.id, :is_comment => true
219
+ ::Inkwell::BlogItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
220
+ ::Inkwell::FavoriteItem.all.size.should == 2
221
+ ::Inkwell::TimelineItem.all.size.should == 2
222
+ ::Inkwell::BlogItem.all.size.should == 4
223
+ ::Inkwell::Comment.all.size.should == 2
224
+ @comment.reload
225
+
226
+ @comment.destroy
227
+ @salkar_post.reload
228
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
229
+ users_ids_who_comment_it.should == []
230
+ ::Inkwell::FavoriteItem.all.size.should == 0
231
+ ::Inkwell::TimelineItem.all.size.should == 0
232
+ ::Inkwell::BlogItem.all.size.should == 1
233
+ ::Inkwell::Comment.all.size.should == 0
234
+ end
235
+
236
+ it "4 comments should been deleted from post with parent comment" do
237
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
238
+ @comment2 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
239
+ @comment2 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment2.id)
240
+ @comment3 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
241
+ @salkar_post.reload
242
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
243
+ users_ids_who_comment_it.size.should == 4
244
+ ::Inkwell::TimelineItem.create :item_id => @comment2.id, :user_id => @morozovm.id, :is_comment => true
245
+ ::Inkwell::FavoriteItem.create :item_id => @comment2.id, :user_id => @salkar.id, :is_comment => true
246
+ ::Inkwell::TimelineItem.create :item_id => @comment.id, :user_id => @morozovm.id, :is_comment => true
247
+ ::Inkwell::FavoriteItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
248
+ ::Inkwell::BlogItem.create :item_id => @comment2.id, :user_id => @morozovm.id, :is_comment => true
249
+ ::Inkwell::BlogItem.create :item_id => @comment2.id, :user_id => @salkar.id, :is_comment => true
250
+ ::Inkwell::BlogItem.create :item_id => @comment.id, :user_id => @salkar.id, :is_comment => true
251
+ ::Inkwell::FavoriteItem.all.size.should == 2
252
+ ::Inkwell::TimelineItem.all.size.should == 2
253
+ ::Inkwell::BlogItem.all.size.should == 4
254
+ ::Inkwell::Comment.all.size.should == 4
255
+ @comment.reload
256
+
257
+ @comment.destroy
258
+ @salkar_post.reload
259
+ users_ids_who_comment_it = ActiveSupport::JSON.decode(@salkar_post.users_ids_who_comment_it)
260
+ users_ids_who_comment_it.should == []
261
+ ::Inkwell::FavoriteItem.all.size.should == 0
262
+ ::Inkwell::TimelineItem.all.size.should == 0
263
+ ::Inkwell::BlogItem.all.size.should == 1
264
+ ::Inkwell::Comment.all.size.should == 0
265
+ end
266
+
267
+ it "commentline for comment should been returned (comments for 1 comment)" do
268
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
269
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
270
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
271
+ @comment3 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
272
+ @comment4 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
273
+ @comment5 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
274
+ @comment6 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
275
+ @comment7 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
276
+ @comment8 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
277
+ @comment9 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
278
+ @comment10 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
279
+ @comment11 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
280
+
281
+ @comment.reload
282
+ commentline = @comment.commentline
283
+ commentline.size.should == 10
284
+ commentline[0].id.should == @comment2.id
285
+ commentline[9].id.should == @comment11.id
286
+
287
+ commentline = @salkar_post.commentline :last_shown_comment_id => @comment10.id
288
+ commentline.size.should == 10
289
+ commentline[0].id.should == @comment.id
290
+ commentline[9].id.should == @comment9.id
291
+ end
292
+
293
+ it "commentline for comment should been returned (comments for several comments)" do
294
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
295
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
296
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
297
+ @comment3 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment1.id)
298
+ @comment4 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment2.id)
299
+ @comment5 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
300
+ @comment6 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment3.id)
301
+ @comment7 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment2.id)
302
+ @comment8 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
303
+ @comment9 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment5.id)
304
+ @comment10 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment4.id)
305
+ @comment11 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
306
+
307
+ @comment.reload
308
+ commentline = @comment.commentline
309
+ commentline.size.should == 10
310
+ commentline[0].id.should == @comment2.id
311
+ commentline[9].id.should == @comment11.id
312
+
313
+ commentline = @salkar_post.commentline :last_shown_comment_id => @comment10.id
314
+ commentline.size.should == 10
315
+ commentline[0].id.should == @comment.id
316
+ commentline[9].id.should == @comment9.id
317
+ end
318
+
319
+ it "5 comments for comment should been received" do
320
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
321
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
322
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
323
+ @comment3 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment1.id)
324
+ @comment4 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment2.id)
325
+ @comment5 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
326
+ @comment6 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment3.id)
327
+ @comment7 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment2.id)
328
+ @comment8 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
329
+ @comment9 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment5.id)
330
+ @comment10 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment4.id)
331
+ @comment11 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
332
+
333
+ @comment.reload
334
+ commentline = @comment.commentline :limit => 5
335
+ commentline.size.should == 5
336
+ commentline[0].id.should == @comment7.id
337
+ commentline[4].id.should == @comment11.id
338
+
339
+ @comment.reload
340
+ commentline = @comment.commentline :last_shown_comment_id => @comment10.id, :limit => 5
341
+ commentline.size.should == 5
342
+ commentline[0].id.should == @comment5.id
343
+ commentline[4].id.should == @comment9.id
344
+
345
+ @comment.reload
346
+ commentline = @comment.commentline :last_shown_comment_id => @comment5.id, :limit => 7
347
+ commentline.size.should == 4
348
+ commentline[0].id.should == @comment1.id
349
+ commentline[3].id.should == @comment4.id
350
+ end
351
+
352
+ it "is_favorited should been returned in commentline for comment for for_user" do
353
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
354
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
355
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
356
+ @salkar.favorite @comment1
357
+ @morozovm.favorite @comment2
358
+
359
+ @comment.reload
360
+ commentline = @comment.commentline :for_user => @salkar
361
+ commentline[0].id.should == @comment1.id
362
+ commentline[0].is_favorited.should == true
363
+ commentline[1].id.should == @comment2.id
364
+ commentline[1].is_favorited.should == false
365
+
366
+ commentline = @comment.commentline :for_user => @morozovm
367
+ commentline[0].id.should == @comment1.id
368
+ commentline[0].is_favorited.should == false
369
+ commentline[1].id.should == @comment2.id
370
+ commentline[1].is_favorited.should == true
371
+ end
372
+
373
+ it "is_favorited should been returned in commentline for post for for_user" do
374
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
375
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
376
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
377
+ @salkar.favorite @comment1
378
+ @morozovm.favorite @comment2
379
+
380
+ @salkar_post.reload
381
+ commentline = @salkar_post.commentline :for_user => @salkar
382
+ commentline[1].id.should == @comment1.id
383
+ commentline[1].is_favorited.should == true
384
+ commentline[2].id.should == @comment2.id
385
+ commentline[2].is_favorited.should == false
386
+
387
+ commentline = @salkar_post.commentline :for_user => @morozovm
388
+ commentline[1].id.should == @comment1.id
389
+ commentline[1].is_favorited.should == false
390
+ commentline[2].id.should == @comment2.id
391
+ commentline[2].is_favorited.should == true
392
+ end
393
+
394
+ it "comment count for post should been received" do
395
+ @salkar_post.comments.size.should == 0
396
+ @salkar_post.comment_count.should == 0
397
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
398
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
399
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
400
+ @salkar_post.reload
401
+ @salkar_post.comments.size.should == 3
402
+ @salkar_post.comment_count.should == 3
403
+ end
404
+
405
+ it "comment count for comment should been received" do
406
+ @comment = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id)
407
+ @comment.reload
408
+ @comment.comment_count.should == 0
409
+ @comment1 = @morozovm.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
410
+ @comment2 = @salkar.comments.create(:body => 'Lets You Party Like a Facebook User', :post_id => @salkar_post.id, :parent_id => @comment.id)
411
+ @comment.reload
412
+ @comment.comment_count.should == 2
413
+ end
414
+
415
+
416
+ end