Sha256: 9c301f66a38be59e2fef99dae5363c08a0868055cfa568e9f68841cc5c69ad5e

Contents?: true

Size: 1.62 KB

Versions: 83

Compression:

Stored size: 1.62 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",
                      :author_id => tie.receiver.id,
                      :owner_id => tie.sender.id,
                      :user_author_id => tie.receiver.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",
                      :author_id => tie.receiver.id,
                      :owner_id => tie.sender.id,
                      :user_author_id => tie.receiver.id

      post.save!

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

Version data entries

83 entries across 83 versions & 4 rubygems

Version Path
social_stream-0.25.0 base/spec/models/post_spec.rb
social_stream-base-0.19.0 spec/models/post_spec.rb
social_stream-0.24.1 base/spec/models/post_spec.rb
social_stream-base-0.18.1 spec/models/post_spec.rb
social_stream-0.24.0 base/spec/models/post_spec.rb
social_stream-base-0.18.0 spec/models/post_spec.rb
social_stream-0.23.4 base/spec/models/post_spec.rb
social_stream-base-0.17.3 spec/models/post_spec.rb
social_stream-0.23.3 base/spec/models/post_spec.rb
social_stream-base-0.17.2 spec/models/post_spec.rb
social_stream-0.23.2 base/spec/models/post_spec.rb
social_stream-base-0.17.1 spec/models/post_spec.rb
social_stream-0.23.1 base/spec/models/post_spec.rb
social_stream-base-0.17.0 spec/models/post_spec.rb
social_stream-0.22.1 base/spec/models/post_spec.rb
social_stream-base-0.16.4 spec/models/post_spec.rb
social_stream-0.22.0 base/spec/models/post_spec.rb
social_stream-base-0.16.3 spec/models/post_spec.rb
social_stream-0.21.4 base/spec/models/post_spec.rb
social_stream-base-0.16.2 spec/models/post_spec.rb