Welcome to mirror list, hosted at ThFree Co, Russian Federation.

status_message_spec.rb « models « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 086d66e80464c151b9839b77354582b34f2b8926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

require 'spec_helper'

describe StatusMessage do
  before do
      @user = Factory.create(:user)
      @aspect = @user.aspect(:name => "losers")
  end

  it "should have a message" do
    n = Factory.build(:status_message, :message => nil)
    n.valid?.should be false
    n.message = "wales"
    n.valid?.should be true
  end

  it 'should be postable through the user' do
    status = @user.post(:status_message, :message => "Users do things", :to => @aspect.id)
  end

  it 'should require status messages to be less than 1000 characters' do
    message = ''
    1001.times do message = message +'1';end
    status = Factory.build(:status_message, :message => message)

    status.should_not be_valid
    
  end

  describe "XML" do
    it 'should serialize to XML' do
      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 = StatusMessage.from_xml(xml)
      parsed.message.should == "I hate WALRUSES!"
      parsed.valid?.should be_true
    end
  end

end