comment_test.rb
1.06 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
require File.dirname(__FILE__) + '/../../../../test/test_helper'
require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
class CommentTest < ActiveSupport::TestCase
include PluginTestHelper
should "validate institution if there an institution_id" do
private_institution = build_private_institution "huehue", "hue", "11.222.333/4444-55"
assert_equal true, private_institution.save
comment = Comment.new :institution_id => 123456, :body => "simple body"
comment.valid?
assert_equal true, comment.errors[:institution].include?("not found")
comment.institution = private_institution
comment.valid?
assert_equal false, comment.errors[:institution].include?("not found")
end
private
def build_private_institution name, corporate_name, cnpj, country="AR"
community = Community.new :name => name
community.country = country
institution = PrivateInstitution.new :name=> name
institution.corporate_name = corporate_name
institution.cnpj = cnpj
institution.community = community
institution
end
end