Skip to content
Extraits de code Groupes Projets
status_message_spec.rb 1,78 ko
Newer Older
  • Learn to ignore specific revisions
  • #    Copyright 2010 Diaspora Inc.
    #
    #    This file is part of Diaspora.
    #
    #    Diaspora is free software: you can redistribute it and/or modify
    #    it under the terms of the GNU Affero General Public License as published by
    #    the Free Software Foundation, either version 3 of the License, or
    #    (at your option) any later version.
    #
    #    Diaspora is distributed in the hope that it will be useful,
    #    but WITHOUT ANY WARRANTY; without even the implied warranty of
    #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #    GNU Affero General Public License for more details.
    #
    #    You should have received a copy of the GNU Affero General Public License
    #    along with Diaspora.  If not, see <http://www.gnu.org/licenses/>.
    #
    
    
    
    
    maxwell's avatar
    maxwell a validé
    require File.dirname(__FILE__) + '/../spec_helper'
    
    describe StatusMessage do
    
    ilya's avatar
    ilya a validé
      before do
    
    maxwell's avatar
    maxwell a validé
          @user = Factory.create(:user, :email => "bob@aol.com")
    
    Raphael's avatar
    Raphael a validé
          @aspect = @user.aspect(:name => "losers")
    
    ilya's avatar
    ilya a validé
      end
    
      it "should have a message" do    
    
    ilya's avatar
    ilya a validé
        n = Factory.build(:status_message, :message => nil)
    
    maxwell's avatar
    maxwell a validé
        n.valid?.should be false
        n.message = "wales"
        n.valid?.should be true
      end
    
      
      it 'should be postable through the user' do
    
    Raphael's avatar
    Raphael a validé
        status = @user.post(:status_message, :message => "Users do things", :to => @aspect.id)
    
      describe "XML" do
        it 'should serialize to XML' do
    
    maxwell's avatar
    maxwell a validé
          message = Factory.create(:status_message, :message => "I hate WALRUSES!", :person => @user.person)
    
          message.to_xml.to_s.should include "<message>I hate WALRUSES!</message>"
    
        end
      
        it 'should marshal serialized XML to object' do       
    
          xml = "<statusmessage><message>I hate WALRUSES!</message></statusmessage>" 
    
          parsed.message.should == "I hate WALRUSES!"
    
          parsed.valid?.should be_true
        end
      end