test/dummy/spec/functional/community_spec.rb in inkwell-1.0.5 vs test/dummy/spec/functional/community_spec.rb in inkwell-1.1.1
- old
+ new
@@ -1,9 +1,8 @@
require "spec_helper"
describe "Community" do
-
before(:each) do
@salkar = User.create :nick => "Salkar"
@morozovm = User.create :nick => "Morozovm"
@talisman = User.create :nick => "Talisman"
@community_1 = Community.create :name => "Community_1", :owner_id => @talisman.id
@@ -36,32 +35,32 @@
@salkar_post7 = @salkar.posts.create :body => "salkar_post_test_body"
@salkar_post8 = @salkar.posts.create :body => "salkar_post_test_body"
@morozovm_post = @morozovm.posts.create :body => "morozovm_post_test_body"
@morozovm_post1 = @morozovm.posts.create :body => "morozovm_post_test_body1"
@morozovm_post2 = @morozovm.posts.create :body => "morozovm_post_test_body2"
- ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
+ ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
@talisman = User.create :nick => "Talisman"
@community_1.add_user :user => @talisman
@talisman.reload
- tline = @talisman.timeline_items
+ tline = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER)
tline.size.should == 10
tline[0].item_id.should == @morozovm_post2.id
- tline[0].is_comment.should == false
+ tline[0].item_type.should == ::Inkwell::Constants::ItemTypes::POST
ActiveSupport::JSON.decode(tline[0].from_source).should == [Hash['community_id' => @community_1.id]]
tline[9].item_id.should == @salkar_post2.id
- tline[9].is_comment.should == false
+ tline[9].item_type.should == ::Inkwell::Constants::ItemTypes::POST
ActiveSupport::JSON.decode(tline[9].from_source).should == [Hash['community_id' => @community_1.id]]
end
it "community's posts should been transferred to user timeline (if some timeline items exist)" do
@talisman = User.create :nick => "Talisman"
@@ -75,30 +74,30 @@
@salkar_post7 = @salkar.posts.create :body => "salkar_post_test_body"
@salkar_post8 = @salkar.posts.create :body => "salkar_post_test_body"
@morozovm_post = @morozovm.posts.create :body => "morozovm_post_test_body"
@morozovm_post1 = @morozovm.posts.create :body => "morozovm_post_test_body1"
@morozovm_post2 = @morozovm.posts.create :body => "morozovm_post_test_body2"
- ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
+ ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
@community_1.add_user :user => @talisman
@talisman.reload
- tline = @talisman.timeline_items
+ tline = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER)
tline.size.should == 12
- item = tline.where(:item_id => @morozovm_post2.id, :is_comment => false).first
+ item = tline.where(:item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
item.should be
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
- item = tline.where(:item_id => @salkar_post2.id, :is_comment => false).first
+ item = tline.where(:item_id => @salkar_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
item.should be
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following'], Hash['community_id' => @community_1.id]]
end
it "community's posts should not been transferred to user timeline (posts with authorship of user)" do
@@ -113,30 +112,30 @@
@salkar_post7 = @salkar.posts.create :body => "salkar_post_test_body"
@salkar_post8 = @salkar.posts.create :body => "salkar_post_test_body"
@morozovm_post = @morozovm.posts.create :body => "morozovm_post_test_body"
@morozovm_post1 = @morozovm.posts.create :body => "morozovm_post_test_body1"
@morozovm_post2 = @morozovm.posts.create :body => "morozovm_post_test_body2"
- ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
+ ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
@community_1.add_user :user => @salkar
@salkar.reload
- tline = @salkar.timeline_items
+ tline = ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER)
tline.size.should == 3
- item = tline.where(:item_id => @morozovm_post2.id, :is_comment => false).first
+ item = tline.where(:item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
item.should be
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
- item = tline.where(:item_id => @salkar_post2.id, :is_comment => false).first
+ item = tline.where(:item_id => @salkar_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first
item.should == nil
end
it "error should occure on tries to pass incorrect params into add_user" do
expect { @community_1.add_user :user => "@salkar" }.to raise_error
@@ -215,36 +214,36 @@
@salkar_post7 = @salkar.posts.create :body => "salkar_post_test_body"
@salkar_post8 = @salkar.posts.create :body => "salkar_post_test_body"
@morozovm_post = @morozovm.posts.create :body => "morozovm_post_test_body"
@morozovm_post1 = @morozovm.posts.create :body => "morozovm_post_test_body1"
@morozovm_post2 = @morozovm.posts.create :body => "morozovm_post_test_body2"
- ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
- ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :is_comment => false, :owner_id => @community_1.id, :is_owner_user => false
+ ::Inkwell::BlogItem.create :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post3.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post4.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post5.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post6.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post7.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @salkar_post8.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
+ ::Inkwell::BlogItem.create :item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST, :owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY
@community_1.add_user :user => @talisman
@talisman.reload
@community_1.reload
- tline = @talisman.timeline_items
+ tline = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER)
tline.size.should == 12
@community_1.include_user?(@talisman).should == true
@community_1.remove_user :user => @talisman
@talisman.reload
- tline = @talisman.timeline_items
+ tline = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER)
tline.size.should == 9
- tline.where(:item_id => @morozovm_post.id, :is_comment => false).first.should == nil
- tline.where(:item_id => @morozovm_post1.id, :is_comment => false).first.should == nil
- tline.where(:item_id => @morozovm_post2.id, :is_comment => false).first.should == nil
- ActiveSupport::JSON.decode(tline.where(:item_id => @salkar_post8.id, :is_comment => false).first.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following']]
+ tline.where(:item_id => @morozovm_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first.should == nil
+ tline.where(:item_id => @morozovm_post1.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first.should == nil
+ tline.where(:item_id => @morozovm_post2.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first.should == nil
+ ActiveSupport::JSON.decode(tline.where(:item_id => @salkar_post8.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).first.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following']]
end
it "admin level of user should be returned" do
@salkar.admin_of = ActiveSupport::JSON.encode [{:community_id => @community_1.id, :admin_level => 3}]
@salkar.save
@@ -385,27 +384,27 @@
@community_1.add_post :post => @morozovm_post1, :user => @morozovm
@community_1.add_post :post => @morozovm_post2, :user => @morozovm
@talisman.follow @morozovm
@salkar.follow @morozovm
::Inkwell::BlogItem.all.size.should == 24
- @salkar.timeline_items.size.should == 3
- @talisman.timeline_items.size.should == 12
- @morozovm.timeline_items.size.should == 9
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 3
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 12
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 9
id = @community_1.id
@community_1.reload
@community_1.destroy
::Inkwell::BlogItem.all.size.should == 12
- ::Inkwell::BlogItem.where(:owner_id => id, :is_owner_user => false).size.should == 0
- @salkar.timeline_items.size.should == 3
- @talisman.timeline_items.size.should == 3
- @morozovm.timeline_items.size.should == 0
- @salkar.timeline_items.each do |item|
+ ::Inkwell::BlogItem.where(:owner_id => id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY).size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 3
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 3
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).each do |item|
item.has_many_sources.should == false
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @morozovm.id, 'type' => 'following']]
end
- @talisman.timeline_items.each do |item|
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).each do |item|
item.has_many_sources.should == false
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @morozovm.id, 'type' => 'following']]
end
@salkar.reload
@talisman.reload
@@ -416,17 +415,17 @@
ActiveSupport::JSON.decode(@talisman.admin_of).size.should == 0
end
it "post should be added to community blogline and user's timeline" do
@community_1.add_user :user => @salkar
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 0
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 0
@community_1.add_post :post => @salkar_post, :user => @salkar
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 1
- @salkar.timeline_items.size.should == 0
- @talisman.timeline_items.size.should == 1
- @talisman.timeline_items.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
item.has_many_sources.should == false
@salkar_post.reload
ActiveSupport::JSON.decode(@salkar_post.communities_ids).should == [@community_1.id]
@@ -436,28 +435,28 @@
@community_1.add_user :user => @salkar
@community_1.add_user :user => @morozovm
@community_1.reload
@morozovm.reload
@talisman.follow @salkar
- @talisman.timeline_items.size.should == 1
- @talisman.timeline_items.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 1
- @morozovm.timeline_items.size.should == 0
- @salkar.timeline_items.size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
@community_1.add_post :post => @salkar_post, :user => @salkar
- @talisman.timeline_items.size.should == 1
- @talisman.timeline_items.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following'], Hash['community_id' => @community_1.id]]
item.has_many_sources.should == true
- @salkar.timeline_items.size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
@morozovm.reload
- @morozovm.timeline_items.size.should == 1
- @morozovm.timeline_items.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 1
- item = @morozovm.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
item.has_many_sources.should == false
end
it "post should not be added to community blogline and user's timeline" do
@@ -477,62 +476,62 @@
@community_1.add_user :user => @salkar
@community_1.add_user :user => @morozovm
@community_1.add_post :post => @salkar_post, :user => @salkar
@talisman.follow @salkar
@talisman.reload
- @talisman.timeline_items.size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id], Hash['user_id' => @salkar.id, 'type' => 'following']]
item.has_many_sources.should == true
- @morozovm.timeline_items.size.should == 1
- item = @morozovm.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
item.has_many_sources.should == false
@community_1.remove_post :post => @salkar_post, :user => @salkar
@talisman.reload
- @talisman.timeline_items.size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following']]
item.has_many_sources.should == false
@morozovm.reload
- @morozovm.timeline_items.size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 0
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 0
@salkar_post.reload
ActiveSupport::JSON.decode(@salkar_post.communities_ids).size.should == 0
end
it "post should be removed by admin from community" do
@community_1.add_user :user => @salkar
@community_1.add_user :user => @morozovm
@community_1.add_post :post => @salkar_post, :user => @salkar
@talisman.follow @salkar
@talisman.reload
- @talisman.timeline_items.size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id], Hash['user_id' => @salkar.id, 'type' => 'following']]
item.has_many_sources.should == true
- @morozovm.timeline_items.size.should == 1
- item = @morozovm.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
item.has_many_sources.should == false
@salkar.reload
@talisman.reload
@community_1.remove_post :post => @salkar_post, :user => @talisman
@talisman.reload
- @talisman.timeline_items.size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following']]
item.has_many_sources.should == false
@morozovm.reload
- @morozovm.timeline_items.size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 0
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 0
@salkar_post.reload
ActiveSupport::JSON.decode(@salkar_post.communities_ids).size.should == 0
end
it "post should not be removed from community" do
@@ -601,17 +600,17 @@
ActiveSupport::JSON.decode(@salkar.admin_of).size.should == 0
end
it "post should be sended to community" do
@community_1.add_user :user => @salkar
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 0
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 0
@salkar.send_post_to_community :post => @salkar_post, :to_community => @community_1
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 1
- @salkar.timeline_items.size.should == 0
- @talisman.timeline_items.size.should == 1
- @talisman.timeline_items.where(:item_id => @salkar_post.id, :is_comment => false).size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @salkar.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).where(:item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
item.has_many_sources.should == false
@salkar_post.reload
ActiveSupport::JSON.decode(@salkar_post.communities_ids).should == [@community_1.id]
@@ -621,29 +620,29 @@
@community_1.add_user :user => @salkar
@community_1.add_user :user => @morozovm
@community_1.add_post :post => @salkar_post, :user => @salkar
@talisman.follow @salkar
@talisman.reload
- @talisman.timeline_items.size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id], Hash['user_id' => @salkar.id, 'type' => 'following']]
item.has_many_sources.should == true
- @morozovm.timeline_items.size.should == 1
- item = @morozovm.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['community_id' => @community_1.id]]
item.has_many_sources.should == false
@salkar.remove_post_from_community :post => @salkar_post, :from_community => @community_1
@talisman.reload
- @talisman.timeline_items.size.should == 1
- item = @talisman.timeline_items.first
+ ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 1
+ item = ::Inkwell::TimelineItem.where(:owner_id => @talisman.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).first
ActiveSupport::JSON.decode(item.from_source).should == [Hash['user_id' => @salkar.id, 'type' => 'following']]
item.has_many_sources.should == false
@morozovm.reload
- @morozovm.timeline_items.size.should == 0
+ ::Inkwell::TimelineItem.where(:owner_id => @morozovm.id, :owner_type => ::Inkwell::Constants::OwnerTypes::USER).size.should == 0
- ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :is_owner_user => false, :item_id => @salkar_post.id, :is_comment => false).size.should == 0
+ ::Inkwell::BlogItem.where(:owner_id => @community_1.id, :owner_type => ::Inkwell::Constants::OwnerTypes::COMMUNITY, :item_id => @salkar_post.id, :item_type => ::Inkwell::Constants::ItemTypes::POST).size.should == 0
@salkar_post.reload
ActiveSupport::JSON.decode(@salkar_post.communities_ids).size.should == 0
end
it "admin permissions should be granted" do
\ No newline at end of file