public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
James Smith (author)
Thu May 08 10:50:32 -0700 2008
commit  0ca6f9a34bc9e23cd1f882426d29b887a59b6be9
tree    081d3688967b32533a3e020a7025f8b4ee44e096
parent  9072b487bf45c5e41e33c66b32d94aea84732d1b
mephisto / spec / models / comment_spec.rb
100644 53 lines (43 sloc) 1.701 kb
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
49
50
51
52
53
require File.dirname(__FILE__) + '/../spec_helper'
 
 
describe Comment, "previewing" do
  define_models do
    time 2007, 6, 15
 
    model Site do
      stub :cupcake, :title => "Cupcake", :host => 'cupcake.com'
    end
    model Article do
      stub :welcome, :title => "Welcome!", :body => "Hi there", :filter => "textile_filter", :site => all_stubs(:site), :created_at => current_time - 3.days, :published_at => current_time - 2.days, :comment_age => 0
    end
  end
    
  before do
    @comment = Comment.new :author => "1", :author_ip => "127.0.0.1", :body => "No answer"
    @comment.article = contents(:welcome)
  end
  
  it "should be valid" do
    @comment.should be_valid
  end
  
  it "raises Previewing error when preview accessor is set" do
    @comment.preview = true
    lambda{
      @comment.save!
    }.should raise_error(Comment::Previewing)
  end
 
end
 
describe Comment, "textilizing" do
  define_models do
    model Site do
      stub :cupcake, :title => "Cupcake", :host => 'cupcake.com'
    end
    model Article do
      stub :welcome, :title => "Welcome!", :body => "Hi there", :filter => "textile_filter", :site => all_stubs(:site), :created_at => current_time - 3.days, :published_at => current_time - 2.days, :comment_age => 0
    end
  end
   
  # Copied from tests, in the hope that more people will PDI and convert the test::unit
  # tests to RSpec.
  it "processes comments with textile, if the article is textile-formatted" do
    @comment = Comment.new :author => "1", :author_ip => "127.0.0.1", :body => "*test* comment"
    @comment.article = contents(:welcome)
    @comment.save
    @comment.body_html.should == "<p><strong>test</strong> comment</p>"
  end
 
end