Skip to content
Extraits de code Groupes Projets
misc_spec.rb 1,97 ko
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    #   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    Raphael's avatar
    Raphael a validé
    #   the COPYRIGHT file.
    
    require 'spec_helper'
    
    maxwell's avatar
    maxwell a validé
    describe 'making sure the spec runner works' do
    
    Raphael's avatar
    Raphael a validé
      it 'factory creates a user with a person saved' do
    
    Raphael's avatar
    Raphael a validé
        user = Factory.create(:user)
    
        loaded_user = User.find(user.id)
    
    Raphael's avatar
    Raphael a validé
        loaded_user.person.owner_id.should == user.id
      end
    
    Raphael's avatar
    Raphael a validé
      describe 'fixtures' do
        it 'loads fixtures' do
    
          User.count.should_not == 0
    
    Raphael's avatar
    Raphael a validé
        end
      end
    
    
       describe '#connect_users' do
    
    Raphael's avatar
    Raphael a validé
        before do
    
    Raphael's avatar
    Raphael a validé
          @user1 = User.where(:username => 'alice').first
          @user2 = User.where(:username => 'eve').first
    
          @aspect1 = @user1.aspects.first
          @aspect2 = @user2.aspects.first
    
    
          connect_users(@user1, @aspect1, @user2, @aspect2)
    
    Raphael's avatar
    Raphael a validé
        end
    
        it 'connects the first user to the second' do
    
          contact = @user1.contact_for @user2.person
    
          contact.should_not be_nil
    
          @user1.contacts.reload.include?(contact).should be_true
    
          @aspect1.contacts.include?(contact).should be_true
    
          contact.aspects.include?(@aspect1).should be_true
    
    Raphael's avatar
    Raphael a validé
        end
    
    
        it 'connects the second user to the first' do
    
          contact = @user2.contact_for @user1.person
    
          contact.should_not be_nil
    
          @user2.contacts.reload.include?(contact).should be_true
    
          @aspect2.contacts.include?(contact).should be_true
    
          contact.aspects.include?(@aspect2).should be_true
    
    Raphael's avatar
    Raphael a validé
        end
    
          message = @user1.post(:status_message, :message => "Connection!", :to => @aspect1.id)
    
          @user2.reload.visible_posts.should include message
        end
    
    Raphael's avatar
    Raphael a validé
      end
    
    
      describe '#comment' do
        it "should send a user's comment on a person's post to that person" do
          person = Factory.create(:person)
    
          person_status = Factory.create(:status_message, :author => person)
    
          m = mock()
          m.stub!(:post)
          Postzord::Dispatch.should_receive(:new).and_return(m)
    
          alice.comment "yo", :on => person_status
        end
      end
    
    
    Raphael's avatar
    Raphael a validé
    end