Sha256: 1fce710b46bd5dca48d4e9f5cfbf5ef377feef9b2ef392ef5bd90ef6723d1903

Contents?: true

Size: 1.43 KB

Versions: 65

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Post do
  before do
    @post = Factory(:post)
    @post_activity_object = @post.activity_object
    @post_activity = @post.post_activity
  end 

  describe "with like activity" do
    before do
      @like_activity = Factory(:like_activity, :parent => @post_activity)
    end

    describe "when destroying" do
      before do
        @post.try(:destroy)
      end

      it "should also destroy its activity_object" do
        assert_nil ActivityObject.find_by_id(@post_activity_object.id)
      end

      it "should also destroy its post_activity" do
        assert_nil Activity.find_by_id(@post_activity.id)
      end

      it "should also destroy its children like activity" do
        assert_nil Activity.find_by_id(@like_activity.id)
      end
    end
  end

  context "without relations" do
    it "should allow create to friend" do
      tie = Factory(:friend)

      post = Post.new :text => "testing",
                      :_contact_id => tie.contact.inverse!.id

      assert post.build_post_activity.allow? tie.receiver_subject, 'create'

      ability = Ability.new(tie.receiver_subject)

      ability.should be_able_to(:create, post)
    end

    it "should fill relation" do
      tie = Factory(:friend)

      post = Post.new :text => "testing",
                      :_contact_id => tie.contact.inverse!.id

      post.save!

      post.post_activity.relations.should include(tie.relation)
    end
  end
end

Version data entries

65 entries across 65 versions & 2 rubygems

Version Path
social_stream-0.12.14 base/spec/models/post_spec.rb
social_stream-base-0.9.36 spec/models/post_spec.rb
social_stream-0.12.13 base/spec/models/post_spec.rb
social_stream-base-0.9.35 spec/models/post_spec.rb
social_stream-0.12.12 base/spec/models/post_spec.rb
social_stream-base-0.9.34 spec/models/post_spec.rb
social_stream-0.12.11 base/spec/models/post_spec.rb
social_stream-base-0.9.33 spec/models/post_spec.rb
social_stream-0.12.10 base/spec/models/post_spec.rb
social_stream-base-0.9.32 spec/models/post_spec.rb
social_stream-0.12.9 base/spec/models/post_spec.rb
social_stream-base-0.9.31 spec/models/post_spec.rb
social_stream-0.12.8 base/spec/models/post_spec.rb
social_stream-base-0.9.30 spec/models/post_spec.rb
social_stream-0.12.7 base/spec/models/post_spec.rb
social_stream-base-0.9.29 spec/models/post_spec.rb
social_stream-0.12.6 base/spec/models/post_spec.rb
social_stream-0.12.5 base/spec/models/post_spec.rb
social_stream-base-0.9.28 spec/models/post_spec.rb
social_stream-0.12.4 base/spec/models/post_spec.rb