inkwell 1.0.5 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/app/models/inkwell/blog_item.rb +1 -1
  2. data/app/models/inkwell/comment.rb +22 -24
  3. data/app/models/inkwell/favorite_item.rb +1 -2
  4. data/app/models/inkwell/timeline_item.rb +1 -2
  5. data/db/migrate/20130202130030_change_is_comment_to_item_type.rb +18 -0
  6. data/db/migrate/20130202130040_add_owner_type_to_lines.rb +16 -0
  7. data/db/migrate/20130212130858_refactor_comment_table.rb +7 -0
  8. data/db/migrate/20130212130868_rename_parent_id_to_parent_comment_id_in_comment_table.rb +5 -0
  9. data/lib/acts_as_inkwell_community/base.rb +16 -16
  10. data/lib/acts_as_inkwell_post/base.rb +15 -14
  11. data/lib/acts_as_inkwell_user/base.rb +41 -34
  12. data/lib/common/base.rb +28 -4
  13. data/lib/inkwell/version.rb +1 -1
  14. data/test/dummy/db/development.sqlite3 +0 -0
  15. data/test/dummy/db/migrate/20130210231424_change_is_comment_to_item_type.inkwell.rb +19 -0
  16. data/test/dummy/db/migrate/20130212130848_add_owner_type_to_lines.inkwell.rb +17 -0
  17. data/test/dummy/db/migrate/20130213101736_refactor_comment_table.inkwell.rb +8 -0
  18. data/test/dummy/db/migrate/20130213121414_rename_parent_id_to_parent_comment_id_in_comment_table.inkwell.rb +6 -0
  19. data/test/dummy/db/schema.rb +14 -11
  20. data/test/dummy/db/test.sqlite3 +0 -0
  21. data/test/dummy/log/development.log +699 -0
  22. data/test/dummy/log/test.log +0 -0
  23. data/test/dummy/spec/functional/blogline_spec.rb +7 -7
  24. data/test/dummy/spec/functional/comments_spec.rb +129 -132
  25. data/test/dummy/spec/functional/community_spec.rb +119 -120
  26. data/test/dummy/spec/functional/favorite_spec.rb +27 -27
  27. data/test/dummy/spec/functional/following_spec.rb +26 -26
  28. data/test/dummy/spec/functional/reblog_spec.rb +32 -32
  29. data/test/dummy/spec/functional/timeline_spec.rb +1 -1
  30. data/test/dummy_without_community/db/development.sqlite3 +0 -0
  31. data/test/dummy_without_community/db/migrate/20130213115833_change_is_comment_to_item_type.inkwell.rb +19 -0
  32. data/test/dummy_without_community/db/migrate/20130213115834_add_owner_type_to_lines.inkwell.rb +17 -0
  33. data/test/dummy_without_community/db/migrate/20130213115835_refactor_comment_table.inkwell.rb +8 -0
  34. data/test/dummy_without_community/db/schema.rb +13 -10
  35. data/test/dummy_without_community/db/test.sqlite3 +0 -0
  36. data/test/dummy_without_community/log/development.log +111 -0
  37. data/test/dummy_without_community/log/test.log +11393 -0
  38. data/test/dummy_without_community/spec/functional/blogline_spec.rb +7 -7
  39. data/test/dummy_without_community/spec/functional/comments_spec.rb +128 -131
  40. data/test/dummy_without_community/spec/functional/favorite_spec.rb +27 -27
  41. data/test/dummy_without_community/spec/functional/following_spec.rb +26 -26
  42. data/test/dummy_without_community/spec/functional/reblog_spec.rb +32 -32
  43. data/test/dummy_without_community/spec/functional/timeline_spec.rb +1 -1
  44. metadata +32 -14
@@ -6,7 +6,7 @@ describe "Favorites" do
6
6
  @salkar = User.create :nick => "Salkar"
7
7
  @morozovm = User.create :nick => "Morozovm"
8
8
  @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
9
- @salkar_comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
9
+ @salkar_comment = @salkar.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
10
10
  end
11
11
 
12
12
  it "Post should been favorited" do
@@ -22,7 +22,7 @@ describe "Favorites" do
22
22
  end
23
23
 
24
24
  it "Post should been favorited" do
25
- ::Inkwell::FavoriteItem.create :item_id => @salkar_post.id, :user_id => @salkar.id, :is_comment => false
25
+ ::Inkwell::FavoriteItem.create :item_id => @salkar_post.id, :owner_id => @salkar.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_type => ::Inkwell::Constants::OwnerTypes::USER
26
26
  ::Inkwell::FavoriteItem.all.size.should == 1
27
27
  @salkar.favorite?(@salkar_post).should == true
28
28
  end
@@ -33,7 +33,7 @@ describe "Favorites" do
33
33
  end
34
34
 
35
35
  it "Comment should been favorited" do
36
- ::Inkwell::FavoriteItem.create :item_id => @salkar_comment.id, :user_id => @salkar.id, :is_comment => true
36
+ ::Inkwell::FavoriteItem.create :item_id => @salkar_comment.id, :owner_id => @salkar.id, :item_type => ::Inkwell::Constants::ItemTypes::COMMENT, :owner_type => ::Inkwell::Constants::OwnerTypes::USER
37
37
  ::Inkwell::FavoriteItem.all.size.should == 1
38
38
  @salkar.favorite?(@salkar_comment).should == true
39
39
  end
@@ -123,17 +123,17 @@ describe "Favorites" do
123
123
 
124
124
  it "Favoriteline should been return" do
125
125
  @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
126
- @salkar_comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
126
+ @salkar_comment = @salkar.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
127
127
  @morozovm_post = @morozovm.posts.create :body => "salkar_post_test_body"
128
- @morozovm_comment = @morozovm.comments.create :post_id => @morozovm_post.id, :body => "salkar_comment_body"
129
- @salkar_comment1 = @salkar.comments.create :post_id => @morozovm_post.id, :body => "salkar_comment_body"
128
+ @morozovm_comment = @morozovm.create_comment :for_object => @morozovm_post, :body => "salkar_comment_body"
129
+ @salkar_comment1 = @salkar.create_comment :for_object => @morozovm_post, :body => "salkar_comment_body"
130
130
  @morozovm_post1 = @morozovm.posts.create :body => "salkar_post_test_body"
131
131
  @morozovm_post2 = @morozovm.posts.create :body => "salkar_post_test_body"
132
132
  @morozovm_post3 = @morozovm.posts.create :body => "salkar_post_test_body"
133
- @salkar_comment2 = @salkar.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
134
- @salkar_comment3 = @salkar.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
135
- @salkar_comment4 = @salkar.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
136
- @morozovm_comment2 = @morozovm.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
133
+ @salkar_comment2 = @salkar.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
134
+ @salkar_comment3 = @salkar.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
135
+ @salkar_comment4 = @salkar.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
136
+ @morozovm_comment2 = @morozovm.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
137
137
  @salkar_post1 = @salkar.posts.create :body => "salkar_post_test_body"
138
138
 
139
139
  @salkar.favorite @salkar_post
@@ -154,48 +154,48 @@ describe "Favorites" do
154
154
  fline.size.should == 10
155
155
  fline[0].id.should == @salkar_post1.id
156
156
  fline[0].class.to_s.should == 'Post'
157
- fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@salkar_post1.id, false).id
157
+ fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@salkar_post1.id, ::Inkwell::Constants::ItemTypes::POST).id
158
158
  fline[9].id.should == @morozovm_comment.id
159
159
  fline[9].class.to_s.should == 'Inkwell::Comment'
160
- fline[9].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@morozovm_comment.id, true).id
160
+ fline[9].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@morozovm_comment.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
161
161
 
162
162
  fline_same = @salkar.favoriteline :last_shown_obj_id => nil, :limit => 10, :for_user => nil
163
163
  fline_same.should == fline
164
164
 
165
- from_favorite_item_id = ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@morozovm_comment2.id, true).id
165
+ from_favorite_item_id = ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@morozovm_comment2.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
166
166
  fline = @salkar.favoriteline(:last_shown_obj_id => from_favorite_item_id)
167
167
  fline.size.should == 10
168
168
  fline[0].id.should == @salkar_comment4.id
169
169
  fline[0].class.to_s.should == 'Inkwell::Comment'
170
- fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@salkar_comment4.id, true).id
170
+ fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@salkar_comment4.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
171
171
  fline[9].id.should == @salkar_comment.id
172
172
  fline[9].class.to_s.should == 'Inkwell::Comment'
173
- fline[9].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@salkar_comment.id, true).id
173
+ fline[9].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@salkar_comment.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
174
174
 
175
- from_favorite_item_id = ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@morozovm_comment2.id, true).id
175
+ from_favorite_item_id = ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@morozovm_comment2.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
176
176
  fline = @salkar.favoriteline(:last_shown_obj_id => from_favorite_item_id, :limit => 5)
177
177
  fline.size.should == 5
178
178
  fline[0].id.should == @salkar_comment4.id
179
179
  fline[0].class.to_s.should == 'Inkwell::Comment'
180
- fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@salkar_comment4.id, true).id
180
+ fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@salkar_comment4.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
181
181
  fline[4].id.should == @morozovm_post2.id
182
182
  fline[4].class.to_s.should == 'Post'
183
- fline[4].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@morozovm_post2.id, false).id
183
+ fline[4].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@morozovm_post2.id, ::Inkwell::Constants::ItemTypes::POST).id
184
184
  end
185
185
 
186
186
  it "Favoriteline should been return for for_user" do
187
187
  @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
188
- @salkar_comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
188
+ @salkar_comment = @salkar.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
189
189
  @morozovm_post = @morozovm.posts.create :body => "salkar_post_test_body"
190
- @morozovm_comment = @morozovm.comments.create :post_id => @morozovm_post.id, :body => "salkar_comment_body"
191
- @salkar_comment1 = @salkar.comments.create :post_id => @morozovm_post.id, :body => "salkar_comment_body"
190
+ @morozovm_comment = @morozovm.create_comment :for_object => @morozovm_post, :body => "salkar_comment_body"
191
+ @salkar_comment1 = @salkar.create_comment :for_object => @morozovm_post, :body => "salkar_comment_body"
192
192
  @morozovm_post1 = @morozovm.posts.create :body => "salkar_post_test_body"
193
193
  @morozovm_post2 = @morozovm.posts.create :body => "salkar_post_test_body"
194
194
  @morozovm_post3 = @morozovm.posts.create :body => "salkar_post_test_body"
195
- @salkar_comment2 = @salkar.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
196
- @salkar_comment3 = @salkar.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
197
- @salkar_comment4 = @salkar.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
198
- @morozovm_comment2 = @morozovm.comments.create :post_id => @morozovm_post3.id, :body => "salkar_comment_body"
195
+ @salkar_comment2 = @salkar.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
196
+ @salkar_comment3 = @salkar.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
197
+ @salkar_comment4 = @salkar.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
198
+ @morozovm_comment2 = @morozovm.create_comment :for_object => @morozovm_post3, :body => "salkar_comment_body"
199
199
  @salkar_post1 = @salkar.posts.create :body => "salkar_post_test_body"
200
200
 
201
201
  @salkar.favorite @salkar_post
@@ -221,7 +221,7 @@ describe "Favorites" do
221
221
  fline.size.should == 10
222
222
  fline[0].id.should == @salkar_post1.id
223
223
  fline[0].class.to_s.should == 'Post'
224
- fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@salkar_post1.id, false).id
224
+ fline[0].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@salkar_post1.id, ::Inkwell::Constants::ItemTypes::POST).id
225
225
  fline[0].is_favorited.should == true
226
226
  fline[0].is_reblogged.should == true
227
227
  fline[2].id.should == @salkar_comment4.id
@@ -229,7 +229,7 @@ describe "Favorites" do
229
229
  fline[2].is_reblogged.should == true
230
230
  fline[9].id.should == @morozovm_comment.id
231
231
  fline[9].class.to_s.should == 'Inkwell::Comment'
232
- fline[9].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_is_comment(@morozovm_comment.id, true).id
232
+ fline[9].item_id_in_line.should == ::Inkwell::FavoriteItem.find_by_item_id_and_item_type(@morozovm_comment.id, ::Inkwell::Constants::ItemTypes::COMMENT).id
233
233
  fline[9].is_favorited.should == true
234
234
  for i in 1..8
235
235
  fline[i].is_favorited.should == false
@@ -6,7 +6,7 @@ describe "Following" do
6
6
  @salkar = User.create :nick => "Salkar"
7
7
  @morozovm = User.create :nick => "Morozovm"
8
8
  @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
9
- @salkar_comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
9
+ @salkar_comment = @salkar.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
10
10
  @salkar_post1 = @salkar.posts.create :body => "salkar_post_test_body"
11
11
  @salkar_post2 = @salkar.posts.create :body => "salkar_post_test_body"
12
12
  @salkar_post3 = @salkar.posts.create :body => "salkar_post_test_body"
@@ -14,7 +14,7 @@ describe "Following" do
14
14
  @morozovm_post1 = @morozovm.posts.create :body => "salkar_post_test_body"
15
15
  @morozovm_post2 = @morozovm.posts.create :body => "salkar_post_test_body"
16
16
  @morozovm_post3 = @morozovm.posts.create :body => "salkar_post_test_body"
17
- @morozovm_comment = @morozovm.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
17
+ @morozovm_comment = @morozovm.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
18
18
  end
19
19
 
20
20
  it "user should follow another user" do
@@ -26,18 +26,18 @@ describe "Following" do
26
26
  @salkar.followers_ids.should == "[]"
27
27
  @salkar.followers_row.should == []
28
28
 
29
- @salkar.timeline_items.size.should == 4
30
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post.id, false).should be
31
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post1.id, false).should be
32
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post2.id, false).should be
33
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post3.id, false).should be
34
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_comment.id, true).should == nil
35
- @salkar.timeline_items.each do |item|
29
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 4
30
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post.id, ::Inkwell::Constants::ItemTypes::POST).should be
31
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post1.id, ::Inkwell::Constants::ItemTypes::POST).should be
32
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post2.id, ::Inkwell::Constants::ItemTypes::POST).should be
33
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post3.id, ::Inkwell::Constants::ItemTypes::POST).should be
34
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_comment.id, ::Inkwell::Constants::ItemTypes::COMMENT).should == nil
35
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).each do |item|
36
36
  item.has_many_sources.should == false
37
37
  ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @morozovm.id, 'type' => 'following']]
38
38
  end
39
39
 
40
- @morozovm.timeline_items.size.should == 0
40
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
41
41
  @morozovm.followers_ids.should == "[#{@salkar.id}]"
42
42
  @morozovm.followers_row.should == [@salkar.id]
43
43
  @morozovm.followings_ids.should == "[]"
@@ -46,10 +46,10 @@ describe "Following" do
46
46
 
47
47
  it "created_at from blog_item should transferred to timeline_item for follower when he follow this user" do
48
48
  @salkar.follow @morozovm
49
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post.id, false).created_at.to_s.should == @morozovm_post.created_at.to_s
50
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post1.id, false).created_at.to_s.should == @morozovm_post1.created_at.to_s
51
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post2.id, false).created_at.to_s.should == @morozovm_post2.created_at.to_s
52
- @salkar.timeline_items.find_by_item_id_and_is_comment(@morozovm_post3.id, false).created_at.to_s.should == @morozovm_post3.created_at.to_s
49
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post.id, ::Inkwell::Constants::ItemTypes::POST).created_at.to_s.should == @morozovm_post.created_at.to_s
50
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post1.id, ::Inkwell::Constants::ItemTypes::POST).created_at.to_s.should == @morozovm_post1.created_at.to_s
51
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post2.id, ::Inkwell::Constants::ItemTypes::POST).created_at.to_s.should == @morozovm_post2.created_at.to_s
52
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).find_by_item_id_and_item_type(@morozovm_post3.id, ::Inkwell::Constants::ItemTypes::POST).created_at.to_s.should == @morozovm_post3.created_at.to_s
53
53
  end
54
54
 
55
55
  it "user should follow another user (follow?)" do
@@ -70,10 +70,10 @@ describe "Following" do
70
70
  it "user should unfollow another user" do
71
71
  @salkar.follow @morozovm
72
72
  @salkar.reload
73
- @salkar.timeline_items.size.should == 4
73
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 4
74
74
  @salkar.unfollow @morozovm
75
75
  @salkar.reload
76
- @salkar.timeline_items.size.should == 0
76
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
77
77
 
78
78
  end
79
79
 
@@ -81,11 +81,11 @@ describe "Following" do
81
81
  @talisman = User.create :nick => "Talisman"
82
82
  @talisman.reblog @salkar_post
83
83
  @morozovm.follow @talisman
84
- @morozovm.timeline_items.size.should == 1
85
- item = @morozovm.timeline_items.first
84
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
85
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
86
86
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @talisman.id, 'type' => 'reblog'}])
87
87
  item.item_id.should == @salkar_post.id
88
- item.is_comment.should == false
88
+ item.item_type.should == ::Inkwell::Constants::ItemTypes::POST
89
89
  end
90
90
 
91
91
  it "timeline item should not delete if has many sources when unfollow" do
@@ -93,25 +93,25 @@ describe "Following" do
93
93
  @talisman.reblog @salkar_post
94
94
  @morozovm.follow @talisman
95
95
  @morozovm.follow @salkar
96
- @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
97
- item = @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
96
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
97
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
98
98
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @talisman.id, 'type' => 'reblog'},{'user_id' => @salkar.id, 'type' => 'following'}])
99
99
  item.has_many_sources.should == true
100
100
 
101
101
  @morozovm.unfollow @salkar
102
- @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
103
- item = @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
102
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
103
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
104
104
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @talisman.id, 'type' => 'reblog'}])
105
105
  item.has_many_sources.should == false
106
106
 
107
107
  @morozovm.follow @salkar
108
- item = @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
108
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
109
109
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @talisman.id, 'type' => 'reblog'},{'user_id' => @salkar.id, 'type' => 'following'}])
110
110
  item.has_many_sources.should == true
111
111
 
112
112
  @morozovm.unfollow @talisman
113
- @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
114
- item = @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
113
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
114
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
115
115
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @salkar.id, 'type' => 'following'}])
116
116
  item.has_many_sources.should == false
117
117
  end
@@ -7,20 +7,20 @@ describe "Reblog" do
7
7
  @morozovm = User.create :nick => "Morozovm"
8
8
  @talisman = User.create :nick => "Talisman"
9
9
  @salkar_post = @salkar.posts.create :body => "salkar_post_test_body"
10
- @salkar_comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
10
+ @salkar_comment = @salkar.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
11
11
  end
12
12
 
13
13
  it "user should reblog post" do
14
14
  @morozovm.reblog @salkar_post
15
- ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 2
16
- ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :is_comment => false, :owner_id => @morozovm.id, :is_owner_user => true, :is_reblog => true).size.should == 1
15
+ ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 2
16
+ ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER, :is_reblog => true).size.should == 1
17
17
  @salkar_post.reload
18
18
  @salkar_post.users_ids_who_reblog_it.should == "[#{@morozovm.id}]"
19
19
  end
20
20
 
21
21
  it "user should reblog comment" do
22
22
  @morozovm.reblog @salkar_comment
23
- ::Inkwell::BlogItem.where(:item_id => @salkar_comment.id, :is_comment => true, :owner_id => @morozovm.id, :is_owner_user => true, :is_reblog => true).size.should == 1
23
+ ::Inkwell::BlogItem.where(:item_id => @salkar_comment.id, :item_type => ::Inkwell::Constants::ItemTypes::COMMENT, :owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER, :is_reblog => true).size.should == 1
24
24
  @salkar_comment.reload
25
25
  @salkar_comment.users_ids_who_reblog_it.should == "[#{@morozovm.id}]"
26
26
  end
@@ -28,38 +28,38 @@ describe "Reblog" do
28
28
  it "timeline item should been created for followers when user reblog post" do
29
29
  @talisman.follow @morozovm
30
30
  @morozovm.reblog @salkar_post
31
- @talisman.timeline_items.size.should == 1
32
- item = @talisman.timeline_items.first
31
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
32
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
33
33
  item.item_id.should == @salkar_post.id
34
34
  item.created_at.to_i.should == @salkar_post.created_at.to_i
35
35
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @morozovm.id, 'type' => 'reblog'}])
36
- item.is_comment.should == false
36
+ item.item_type.should == ::Inkwell::Constants::ItemTypes::POST
37
37
  end
38
38
 
39
39
  it "timeline item should been created for followers when user reblog comment" do
40
40
  @talisman.follow @morozovm
41
41
  @morozovm.reblog @salkar_comment
42
- @talisman.timeline_items.size.should == 1
43
- item = @talisman.timeline_items.first
42
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
43
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
44
44
  item.item_id.should == @salkar_comment.id
45
45
  item.created_at.to_i.should == @salkar_comment.created_at.to_i
46
46
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @morozovm.id, 'type' => 'reblog'}])
47
- item.is_comment.should == true
47
+ item.item_type.should == ::Inkwell::Constants::ItemTypes::COMMENT
48
48
  end
49
49
 
50
50
  it "timeline item should not been created for follower's post/comment" do
51
51
  @salkar.follow @morozovm
52
52
  @morozovm.reblog @salkar_post
53
53
  @morozovm.reblog @salkar_comment
54
- @salkar.timeline_items.size.should == 0
54
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
55
55
  end
56
56
 
57
57
  it "one timeline item should created for one post with two sources" do
58
58
  @talisman.follow @morozovm
59
59
  @morozovm.reblog @salkar_post
60
60
  @talisman.follow @salkar
61
- @talisman.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
62
- item = @talisman.timeline_items.first
61
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
62
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
63
63
  item.has_many_sources.should == true
64
64
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @morozovm.id, 'type' => 'reblog'},{'user_id' => @salkar.id, 'type' => 'following'}])
65
65
  end
@@ -68,8 +68,8 @@ describe "Reblog" do
68
68
  @talisman.follow @morozovm
69
69
  @talisman.follow @salkar
70
70
  @morozovm.reblog @salkar_post
71
- @talisman.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
72
- item = @talisman.timeline_items.first
71
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
72
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
73
73
  item.has_many_sources.should == true
74
74
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @salkar.id, 'type' => 'following'}, {'user_id' => @morozovm.id, 'type' => 'reblog'}])
75
75
  end
@@ -91,8 +91,8 @@ describe "Reblog" do
91
91
  it "user should unreblog post" do
92
92
  @morozovm.reblog @salkar_post
93
93
  @morozovm.unreblog @salkar_post
94
- ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 1
95
- ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :is_comment => false, :owner_id => @morozovm.id, :is_owner_user => true, :is_reblog => true).size.should == 0
94
+ ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
95
+ ::Inkwell::BlogItem.where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER, :is_reblog => true).size.should == 0
96
96
  @salkar_post.reload
97
97
  @salkar_post.users_ids_who_reblog_it.should == "[]"
98
98
  end
@@ -100,7 +100,7 @@ describe "Reblog" do
100
100
  it "user should unreblog comment" do
101
101
  @morozovm.reblog @salkar_comment
102
102
  @morozovm.unreblog @salkar_comment
103
- ::Inkwell::BlogItem.where(:item_id => @salkar_comment.id, :is_comment => true, :owner_id => @morozovm.id, :is_owner_user => true, :is_reblog => true).size.should == 0
103
+ ::Inkwell::BlogItem.where(:item_id => @salkar_comment.id, :item_type => ::Inkwell::Constants::ItemTypes::COMMENT, :owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER, :is_reblog => true).size.should == 0
104
104
  @salkar_comment.reload
105
105
  @salkar_comment.users_ids_who_reblog_it.should == "[]"
106
106
  end
@@ -111,15 +111,15 @@ describe "Reblog" do
111
111
  @morozovm_post = @morozovm.posts.create :body => "morozovm_post_test_body"
112
112
  @morozovm.reblog @salkar_post
113
113
 
114
- @talisman.timeline_items.size.should == 2
115
- @talisman.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
116
- item = @talisman.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
114
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 2
115
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
116
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
117
117
  item.has_many_sources.should == false
118
118
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @morozovm.id, 'type' => 'reblog'}])
119
119
 
120
120
  @morozovm.unreblog @salkar_post
121
- @talisman.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 0
122
- @talisman.timeline_items.size.should == 1
121
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 0
122
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
123
123
  end
124
124
 
125
125
  it "timeline items should delete for followers when user unreblog comment" do
@@ -127,13 +127,13 @@ describe "Reblog" do
127
127
  @talisman.follow @morozovm
128
128
  @morozovm.reblog @salkar_comment
129
129
 
130
- @talisman.timeline_items.where(:item_id => @salkar_comment, :is_comment => true).size.should == 1
131
- item = @talisman.timeline_items.first
130
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_comment, :item_type => ::Inkwell::Constants::ItemTypes::COMMENT).size.should == 1
131
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
132
132
  item.has_many_sources.should == false
133
133
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @morozovm.id, 'type' => 'reblog'}])
134
134
 
135
135
  @morozovm.unreblog @salkar_comment
136
- @talisman.timeline_items.where(:item_id => @salkar_comment, :is_comment => true).size.should == 0
136
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_comment, :item_type => ::Inkwell::Constants::ItemTypes::COMMENT).size.should == 0
137
137
  end
138
138
 
139
139
  it "timeline item should not been delete if post has many sources and unreblogged by following" do
@@ -142,18 +142,18 @@ describe "Reblog" do
142
142
  @morozovm.follow @talisman
143
143
  @morozovm.follow @salkar
144
144
  @talisman_post = @talisman.posts.create :body => "talisman_post_test_body"
145
- @morozovm.timeline_items.size == 2
146
- @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
147
- item = @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
145
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size == 2
146
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
147
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
148
148
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @talisman.id, 'type' => 'reblog'}, {'user_id' => @salkar.id, 'type' => 'following'}])
149
149
  item.has_many_sources.should == true
150
150
 
151
151
  @talisman.unreblog @salkar_post
152
- @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).size.should == 1
153
- item = @morozovm.timeline_items.where(:item_id => @salkar_post, :is_comment => false).first
152
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
153
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
154
154
  item.from_source.should == ActiveSupport::JSON.encode([{'user_id' => @salkar.id, 'type' => 'following'}])
155
155
  item.has_many_sources.should == false
156
- @morozovm.timeline_items.size == 2
156
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size == 2
157
157
  end
158
158
 
159
159
  it "reblog count should been received for post" do
@@ -53,7 +53,7 @@ describe "Timeline" do
53
53
  end
54
54
 
55
55
  it "comment should been in timeline" do
56
- @salkar_comment = @salkar.comments.create :post_id => @salkar_post.id, :body => "salkar_comment_body"
56
+ @salkar_comment = @salkar.create_comment :for_object => @salkar_post, :body => "salkar_comment_body"
57
57
  @talisman.follow @morozovm
58
58
  @morozovm.reblog @salkar_comment
59
59
  @morozovm.favorite @salkar_comment
@@ -0,0 +1,19 @@
1
+ # This migration comes from inkwell (originally 20130202130030)
2
+ class ChangeIsCommentToItemType < ActiveRecord::Migration
3
+ def change
4
+ add_column :inkwell_blog_items, :item_type, :string
5
+ ::Inkwell::BlogItem.where(:is_comment => true).update_all(:item_type => 'c')
6
+ ::Inkwell::BlogItem.where(:is_comment => false).update_all(:item_type => 'p')
7
+ remove_column :inkwell_blog_items, :is_comment
8
+
9
+ add_column :inkwell_favorite_items, :item_type, :string
10
+ ::Inkwell::FavoriteItem.where(:is_comment => true).update_all(:item_type => 'c')
11
+ ::Inkwell::FavoriteItem.where(:is_comment => false).update_all(:item_type => 'p')
12
+ remove_column :inkwell_favorite_items, :is_comment
13
+
14
+ add_column :inkwell_timeline_items, :item_type, :string
15
+ ::Inkwell::TimelineItem.where(:is_comment => true).update_all(:item_type => 'c')
16
+ ::Inkwell::TimelineItem.where(:is_comment => false).update_all(:item_type => 'p')
17
+ remove_column :inkwell_timeline_items, :is_comment
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # This migration comes from inkwell (originally 20130202130040)
2
+ class AddOwnerTypeToLines < ActiveRecord::Migration
3
+ def change
4
+ add_column :inkwell_blog_items, :owner_type, :string
5
+ ::Inkwell::BlogItem.where(:is_owner_user => true).update_all(:owner_type => 'u')
6
+ ::Inkwell::BlogItem.where(:is_owner_user => false).update_all(:owner_type => 'c')
7
+ remove_column :inkwell_blog_items, :is_owner_user
8
+
9
+ add_column :inkwell_favorite_items, :owner_type, :string
10
+ ::Inkwell::FavoriteItem.update_all(:owner_type => 'u')
11
+ rename_column :inkwell_favorite_items, "#{::Inkwell::Engine::config.user_table.to_s.singularize}_id", :owner_id
12
+
13
+ add_column :inkwell_timeline_items, :owner_type, :string
14
+ ::Inkwell::TimelineItem.update_all(:owner_type => 'u')
15
+ rename_column :inkwell_timeline_items, "#{::Inkwell::Engine::config.user_table.to_s.singularize}_id", :owner_id
16
+ end
17
+ end