approve_article_test.rb
1.87 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__) + '/../test_helper'
class ApproveArticleTest < ActiveSupport::TestCase
should 'have name, reference article and profile' do
profile = create_user('test_user').person
article = profile.articles.create!(:name => 'test article')
a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
assert_equal 'test name', a.name
assert_equal article, a.article
assert_equal profile, a.target
end
should 'create published article when finished' do
profile = create_user('test_user').person
article = profile.articles.create!(:name => 'test article')
a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
assert_difference PublishedArticle, :count do
a.finish
end
end
should 'override target notification message method from Task' do
p1 = create_user('testuser1').person
p2 = create_user('testuser2').person
task = AddFriend.new(:person => p1, :friend => p2)
assert_nothing_raised NotImplementedError do
task.target_notification_message
end
end
should 'have parent if defined' do
profile = create_user('test_user').person
article = profile.articles.create!(:name => 'test article')
folder = profile.articles.create!(:name => 'test folder', :type => 'Folder')
a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile, :article_parent_id => folder.id)
assert_equal folder, a.article_parent
end
should 'not have parent if not defined' do
profile = create_user('test_user').person
article = profile.articles.create!(:name => 'test article')
a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
assert_nil a.article_parent
end
end