software_test_helper.rb
4.47 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
module SoftwareTestHelper
def create_language language_fields
language = SoftwareLanguage.new
language_fields[0].each do |k,v|
language[k] = v
end
language.save!
language
end
def create_database database_fields
database = SoftwareDatabase.new
database_fields[0].each do |k,v|
database[k] = v
end
database.save!
database
end
def create_library library_fields
library = Library.new
library_fields[0].each do |k,v|
library[k] = v
end
library.save!
library
end
def create_operating_system operating_system_hash
operating_system = OperatingSystem.new
operating_system_hash[0].each do |k,v|
operating_system[k] = v
end
operating_system.save
operating_system
end
def create_license license_hash
license_info = LicenseInfo.new
license_hash.each do |k,v|
license_info[k] = v
end
license_info.save
license_info
end
def create_categories categories_hash
software_categories = SoftwareCategories.new
categories_hash.each do |k,v|
software_categories[k] = v
end
software_categories.save
software_categories
end
def create_software fields
software = SoftwareInfo.new
community = Community.new
software_hash = fields[2]
license_system_hash = fields[0]
community_hash = fields[1]
software_hash.each do |k,v|
software[k] = v
end
community_hash.each do |k,v|
community[k] = v
end
community.save!
software.community = community
software.license_info_id = license_system_hash[:license_infos_id]
software.save!
software
end
def software_edit_basic_fields
fields = Hash.new
fields_license = Hash.new
hash_list = []
fields['repository_link'] = 'www.github.com/test'
fields['finality'] = 'This is the new finality of the software'
hash_list << fields
#Fields for license info
fields_license['license_infos_id'] = LicenseInfo.last.id
hash_list << fields_license
hash_list
end
def software_edit_specific_fields
fields_library = Hash.new
fields_language = Hash.new
fields_database = Hash.new
fields_operating_system = Hash.new
fields_software = Hash.new
fields_categories = Hash.new
fields_license = Hash.new
hash_list = []
list_database = []
list_language = []
list_operating_system = []
list_library = []
#Fields for library
fields_library['version'] = 'test'
fields_library['name'] = 'test'
fields_library['license'] = 'test'
list_library << fields_library
list_library << {}
hash_list << list_library
#Fields for software language
fields_language['version'] = 'test'
fields_language['programming_language_id'] = ProgrammingLanguage.last.id
fields_language['operating_system'] = 'test'
list_language << fields_language
list_language << {}
hash_list << list_language
#Fields for database
fields_database['version'] = 'test'
fields_database['database_description_id'] = DatabaseDescription.last.id
fields_database['operating_system'] = 'test'
list_database << fields_database
list_database << {}
hash_list << list_database
#Fields for operating system
fields_operating_system['version'] = 'version'
fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id
list_operating_system << fields_operating_system
list_operating_system << {}
hash_list << list_operating_system
#software fields
fields_software['acronym'] = 'test'
fields_software['operating_platform'] = 'Linux'
fields_software['objectives'] = 'This is the objective of the software'
fields_software['features'] = 'This software does nothing'
fields_software['demonstration_url'] = 'www.test.com'
hash_list << fields_software
#Fields for license
fields_license['license_infos_id'] = LicenseInfo.last.id
hash_list << fields_license
hash_list
end
def software_fields
hash_list = []
#Fields for license info
fields_license = {
license_infos_id: LicenseInfo.last.id
}
hash_list << fields_license
#Fields for community
fields_community = {
name: 'Debian',
identifier: 'debian'
}
hash_list << fields_community
#Fields for basic information
fields = {
finality: 'This is the finality of the software'
}
hash_list << fields
hash_list
end
end
#version: LicenseInfo.last.version,
#id: LicenseInfo.last.id