textile_article_test.rb
1.64 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
54
55
56
57
58
require File.dirname(__FILE__) + '/../test_helper'
class TextileArticleTest < Test::Unit::TestCase
def setup
@profile = create_user('testing').person
end
attr_reader :profile
should 'provide a proper short description' do
assert_kind_of String, TextileArticle.short_description
end
should 'provide a proper description' do
assert_kind_of String, TextileArticle.description
end
should 'convert Textile to HTML' do
assert_equal '<p><strong>my text</strong></p>', TextileArticle.new(:body => '*my text*').to_html
end
should 'accept empty body' do
a = TextileArticle.new
a.expects(:body).returns(nil)
assert_nothing_raised do
assert_equal '', a.to_html
end
end
should 'notifiable be true' do
a = fast_create(TextileArticle)
assert a.notifiable?
end
should 'notify activity on create' do
ActionTracker::Record.delete_all
TextileArticle.create! :name => 'test', :profile_id => fast_create(Profile).id, :published => true
assert_equal 1, ActionTracker::Record.count
end
should 'notify activity on update' do
ActionTracker::Record.delete_all
a = TextileArticle.create! :name => 'bar', :profile_id => fast_create(Profile).id, :published => true
assert_equal 1, ActionTracker::Record.count
a.name = 'foo'
a.save!
assert_equal 2, ActionTracker::Record.count
end
should 'notify activity on destroy' do
ActionTracker::Record.delete_all
a = TextileArticle.create! :name => 'bar', :profile_id => fast_create(Profile).id, :published => true
assert_equal 1, ActionTracker::Record.count
a.destroy
assert_equal 2, ActionTracker::Record.count
end
end