Sha256: c92570b02df0456b4e51f93314a7ad3ab2ff72e0a1418c3d7b2684c90f48ad0f

Contents?: true

Size: 1.89 KB

Versions: 24

Compression:

Stored size: 1.89 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ContactsController do

  render_views

  before(:all) do
    @tie = Factory(:friend)
    @user = @tie.sender_subject
  end

  it "should be successful" do
    sign_in @user

    get 'index'
    response.should be_success
  end

  it "should render edit" do
    sign_in @user

    get :edit, :id => @tie.contact_id

    assert_response :success
  end

  it "should render update" do
    sign_in @user

    put :update, :id => @tie.contact_id,
                 :contact => { "relation_ids" => [ "gotcha", @user.relations.last.id ] }

    response.should redirect_to(@tie.receiver_subject)
    @user.reload.
      sent_ties.
      merge(Contact.received_by(@tie.receiver)).
      first.relation.
      should == @user.relations.last
  end

  it "should create contact" do
    sign_in @user

    group = Factory(:group)
    contact = @user.contact_to!(group)
    

    put :update, :id => contact.id,
                 :contact => { :relation_ids => [ "gotcha", @user.relations.last.id ],
                               :message => "Testing" }

    response.should redirect_to(contact.receiver_subject)
    contact.reload.
      ties.
      first.relation.
      should == @user.relations.last
  end

  it "should create contact with several relations" do
    sign_in @user

    group = Factory(:group)
    contact = @user.contact_to!(group)
    # Initialize inverse contact
    contact.inverse!
    relations = [ @user.relation_custom('friend'), @user.relation_custom('colleague') ]
    

    put :update, :id => contact.id,
                 :contact => { :relation_ids => [ "gotcha", relations.map(&:id) ].flatten,
                               :message => "Testing" }

    response.should redirect_to(contact.receiver_subject)

    contact.reload.
      ties.
      map(&:relation).
      map(&:id).sort.
      should == relations.map(&:id).sort
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
social_stream-base-0.9.5 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.9.4 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.9.3 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.9.2 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.9.1 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.9.0 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.8.2 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.8.1 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.8.0 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.11 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.10 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.9 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.8 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.7 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.6 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.5 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.4 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.3 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.2 spec/controllers/contacts_controller_spec.rb
social_stream-base-0.7.1 spec/controllers/contacts_controller_spec.rb