certifier_test.rb
1.21 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
require File.dirname(__FILE__) + '/../test_helper'
class CertifierTest < Test::Unit::TestCase
  should 'have link' do
    certifier = Certifier.new
    assert_equal '', certifier.link
    certifier.link = 'http://noosfero.org'
    assert_equal 'http://noosfero.org', certifier.link
  end
  should 'environment is mandatory' do
    certifier = Certifier.new(:name => 'Certifier without environment')
    assert !certifier.valid?
    certifier.environment = fast_create(Environment)
    assert certifier.valid?
  end
  should 'belongs to environment' do
    env_one = fast_create(Environment)
    certifier_from_env_one = Certifier.create(:name => 'Certifier from environment one', :environment => env_one)
    env_two = fast_create(Environment)
    certifier_from_env_two = Certifier.create(:name => 'Certifier from environment two', :environment => env_two)
    assert_includes env_one.certifiers, certifier_from_env_one
    assert_not_includes env_one.certifiers, certifier_from_env_two
  end
  should 'name is mandatory' do
    env_one = fast_create(Environment)
    certifier = Certifier.new(:environment => env_one)
    assert !certifier.valid?
    certifier.name = 'Certifier name'
    assert certifier.valid?
  end
end