Sha256: ed94e5ebba73a0cba1007b80904a1b88bba072641715efb8abf5ef75cabcf1e4

Contents?: true

Size: 1.92 KB

Versions: 37

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe CommentsController do
  include SocialStream::TestHelpers::Controllers

  render_views

  describe "authorizing" do
    before do
      @user = Factory(:user)
      sign_in @user
    end

    describe "comment from user" do
      before do
        activity = Factory(:self_activity, :contact => Factory(:self_contact, :sender => @user.actor))

        model_attributes[:author_id] = @user.actor_id
        model_attributes[:owner_id]  = @user.actor_id
        model_attributes[:user_author_id] = @user.actor_id
        model_attributes[:_activity_parent_id] = activity.id
      end

      it_should_behave_like "Allow Creating"

      it "should create with js" do
        count = model_count
        post :create, attributes.merge(:format => :js)

        resource = assigns(model_sym)

        model_count.should eq(count + 1)
        resource.should be_valid
        response.should be_success
      end
    end

    describe "comment to friend" do
      before do
        f = Factory(:friend, :contact => Factory(:contact, :receiver => @user.actor)).sender
        activity = Factory(:self_activity, :contact => f.contact_to!(f))

        model_attributes[:author_id] = @user.actor_id
        model_attributes[:owner_id]  = f.id
        model_attributes[:user_author_id] = @user.actor_id
        model_attributes[:_activity_parent_id] = activity.id
      end

      it_should_behave_like "Allow Creating"
    end

    describe "post to acquaintance" do
      before do
        a = Factory(:acquaintance, :contact => Factory(:contact, :receiver => @user.actor)).sender
        activity = Factory(:self_activity, :contact => a.contact_to!(a))

        model_attributes[:author_id] = @user.actor_id
        model_attributes[:owner_id]  = a.id
        model_attributes[:user_author_id] = @user.actor_id
        model_attributes[:_activity_parent_id] = activity.id
      end

      it_should_behave_like "Deny Creating"
    end
  end
end

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
vkhater-social_stream-0.16.3.3 base/spec/controllers/comments_controller_spec.rb
vkhater-social_stream-base-0.11.2 spec/controllers/comments_controller_spec.rb
social_stream-0.17.1 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.12.1 spec/controllers/comments_controller_spec.rb
social_stream-0.17.0 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.12.0 spec/controllers/comments_controller_spec.rb
social_stream-0.16.3 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.11.2 spec/controllers/comments_controller_spec.rb
social_stream-0.16.2 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.11.1 spec/controllers/comments_controller_spec.rb
social_stream-0.16.1 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.11.0 spec/controllers/comments_controller_spec.rb
social_stream-0.15.8 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.10.11 spec/controllers/comments_controller_spec.rb
social_stream-0.15.7 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.10.10 spec/controllers/comments_controller_spec.rb
social_stream-0.15.6 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.10.9 spec/controllers/comments_controller_spec.rb
social_stream-0.15.5 base/spec/controllers/comments_controller_spec.rb
social_stream-base-0.10.8 spec/controllers/comments_controller_spec.rb