software_info_test.rb
2.56 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
59
60
61
62
63
64
65
66
67
require 'test_helper'
require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
class SoftwareInfoValidationTest < ActiveSupport::TestCase
include PluginTestHelper
should "Return original license_info when license is not 'Another'" do
@software_info = create_software_info("software_test")
@license_info = create_license_info("license_test")
@software_info.license_info = @license_info
@software_info.save!
assert_equal @software_info.license_info, @license_info
end
should "Return license_info with nil id when license is 'Another'" do
@software_info = create_software_info("software_test")
@license_another = create_license_info("Another")
@software_info.license_info = @license_another
@software_info.save!
assert_equal @software_info.license_info_id, @license_another.id
assert_equal @software_info.license_info.id, nil
end
should "Return fake license_info when call method another_license" do
@software_info = create_software_info("software_test")
@license_another = create_license_info("Another")
another_license_version = "Another Version"
another_license_link = "#another_link"
@software_info.another_license(another_license_version, another_license_link)
assert_equal @software_info.license_info_id, @license_another.id
assert_equal @software_info.license_info.version, another_license_version
assert_equal @software_info.license_info.link, another_license_link
end
should "search softwares on the correct environment when multi environments available" do
software_info = create_software_info("soft1")
another_software_info = create_software_info("soft2")
other_env = Environment.create!(name: "sisp")
another_soft_profile = another_software_info.community
another_soft_profile.environment_id = other_env.id
another_soft_profile.save
assert_equal 2, SoftwareInfo.count
assert_equal 1, SoftwareInfo.search_by_query("", Environment.default).count
assert_equal software_info, SoftwareInfo.search_by_query("", Environment.default).first
assert_equal 1, SoftwareInfo.search_by_query("", other_env).count
assert_equal true, SoftwareInfo.search_by_query("", other_env).include?(another_software_info)
end
should "start another license with default values" do
software_info = create_software_info("software_test")
license_another = create_license_info("Another")
software_info.license_info_id = license_another.id
assert_equal software_info.license_info.version, "Another"
assert_equal software_info.license_info.link, "#"
end
end