operating_system_helper_test.rb
2.66 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
require 'test_helper'
SoftwareCommunitiesPlugin::OperatingSystemName.create(:name=>"Debina")
SoftwareCommunitiesPlugin::OperatingSystemName.create(:name=>"Fedora")
SoftwareCommunitiesPlugin::OperatingSystemName.create(:name=>"CentOS")
class OperatingSystemHelperTest < ActiveSupport::TestCase
def setup
@operating_system_objects = [
{:operating_system_name_id => SoftwareCommunitiesPlugin::OperatingSystemName.find_by_name("Debina").id.to_s, :version => "2.0"},
{:operating_system_name_id => SoftwareCommunitiesPlugin::OperatingSystemName.find_by_name("Fedora").id.to_s, "version" => "2.1"},
{:operating_system_name_id => SoftwareCommunitiesPlugin::OperatingSystemName.find_by_name("CentOS").id.to_s, "version" => "2.2"}
]
@operating_system_objects
end
should "return an empty list" do
empty_list = []
assert_equal [], SoftwareCommunitiesPlugin::OperatingSystemHelper.list_operating_system(empty_list)
end
should "return a list with current OperatingSystems" do
list_compare = []
list_op = SoftwareCommunitiesPlugin::OperatingSystemHelper.list_operating_system(@operating_system_objects)
assert_equal list_compare.class, list_op.class
end
should "have same information from the list passed as parameter" do
list_compare = SoftwareCommunitiesPlugin::OperatingSystemHelper.list_operating_system(@operating_system_objects)
first_operating = @operating_system_objects.first[:operating_system_name_id]
assert_equal first_operating, list_compare.first.operating_system_name_id.to_s
end
should "return a list with the same size of the parameter" do
list_compare = SoftwareCommunitiesPlugin::OperatingSystemHelper.list_operating_system(@operating_system_objects)
assert_equal @operating_system_objects.count, list_compare.count
end
should "return false if list_operating_system are empty or null" do
list_compare = []
assert_equal false, SoftwareCommunitiesPlugin::OperatingSystemHelper.valid_list_operating_system?(list_compare)
end
should "return a html text with operating system" do
operating_systems = []
operating_system = SoftwareCommunitiesPlugin::OperatingSystemName.new
operating_system.name = "teste"
software_operating_system = SoftwareCommunitiesPlugin::OperatingSystem.new
software_operating_system.version = 2
software_operating_system.operating_system_name = operating_system
operating_systems << software_operating_system
op_table = SoftwareCommunitiesPlugin::OperatingSystemHelper.operating_system_as_tables(operating_systems)
assert_not_nil op_table.first.call.index(SoftwareCommunitiesPlugin::OperatingSystemName.first.name)
end
end