Commit 7e2d4d40698c26777839ffd8879ace1d0766bcdf

Authored by Gabriela Navarro
Committed by Fabio Teixeira
1 parent cf48d248

Tests for edit software

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
test/functional/mpog_software_plugin_myprofile_controller_test.rb
@@ -63,13 +63,28 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase @@ -63,13 +63,28 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
63 63
64 should 'create a new software with all fields filled in' do 64 should 'create a new software with all fields filled in' do
65 fields = software_fields 65 fields = software_fields
66 - post :new_software, :profile => person.identifier, :community => fields[6], :license_info => fields[5],  
67 - :software_info => fields[0], :library => fields[1], :database => fields[3],  
68 - :language => fields[2], :operating_system=> fields[4],:software_categories => fields[7] 66 + post :new_software, :profile => person.identifier, :community => fields[1], :license_info => fields[0],
  67 + :software_info => fields[2]
69 assert_equal SoftwareInfo.last.community.name, "Debian" 68 assert_equal SoftwareInfo.last.community.name, "Debian"
70 end 69 end
71 70
  71 + should 'edit a new software adding basic information' do
  72 + fields_software = software_fields
  73 + fields = software_edit_basic_fields
72 74
  75 + software = create_software fields_software
  76 + post :edit_software, :profile => software.community.identifier, :license => fields[1], :software => fields[0], :library => {}, :operating_system => {}, :language => {}, :database => {}
  77 + assert_equal SoftwareInfo.last.repository_link, "www.github.com/test"
  78 + end
  79 +
  80 + should 'edit a new software adding specific information' do
  81 + fields_software = software_fields
  82 + fields = software_edit_specific_fields
73 83
  84 + software = create_software fields_software
  85 + post :edit_software, :profile => software.community.identifier, :library => fields[0], :language => fields[1],
  86 + :database => fields[2], :operating_system => fields[3], :software => fields[4], :software_categories => fields[5], :license => fields[6]
  87 + assert_equal SoftwareInfo.last.acronym, "test"
  88 + end
74 89
75 end 90 end
test/functional/software_test_helper.rb
@@ -66,14 +66,14 @@ module SoftwareTestHelper @@ -66,14 +66,14 @@ module SoftwareTestHelper
66 66
67 software = SoftwareInfo.new 67 software = SoftwareInfo.new
68 community = Community.new 68 community = Community.new
69 - software_hash = fields[0]  
70 - library_hash = fields[1]  
71 - language_hash = fields[2]  
72 - database_hash = fields[3]  
73 - operating_system_hash = fields[4]  
74 - license_system_hash = fields[5]  
75 - community_hash = fields[6]  
76 - categories_hash = fields[7] 69 + software_hash = fields[2]
  70 + #library_hash = fields[1]
  71 + #language_hash = fields[2]
  72 + #database_hash = fields[3]
  73 + #operating_system_hash = fields[4]
  74 + license_system_hash = fields[0]
  75 + community_hash = fields[1]
  76 + #categories_hash = fields[7]
77 77
78 software_hash.each do |k,v| 78 software_hash.each do |k,v|
79 software[k] = v 79 software[k] = v
@@ -85,25 +85,43 @@ module SoftwareTestHelper @@ -85,25 +85,43 @@ module SoftwareTestHelper
85 85
86 community.save! 86 community.save!
87 software.community = community 87 software.community = community
88 - software.software_databases << create_database(database_hash)  
89 - software.software_languages << create_language(language_hash)  
90 - software.operating_systems << create_operating_system(operating_system_hash) 88 + #software.software_databases << create_database(database_hash)
  89 + #software.software_languages << create_language(language_hash)
  90 + #software.operating_systems << create_operating_system(operating_system_hash)
91 software.license_info_id = license_system_hash 91 software.license_info_id = license_system_hash
92 - software.libraries << create_library(library_hash)  
93 - software.software_categories = create_categories(categories_hash) 92 + #software.libraries << create_library(library_hash)
  93 + #software.software_categories = create_categories(categories_hash)
94 94
  95 + software.save
95 software 96 software
96 end 97 end
97 98
98 - def software_fields  
99 - 99 + def software_edit_basic_fields
100 fields = Hash.new 100 fields = Hash.new
  101 + fields_license = Hash.new
  102 + hash_list = []
  103 +
  104 + fields['repository_link'] = 'www.github.com/test'
  105 + fields['finality'] = 'This is the new finality of the software'
  106 + hash_list << fields
  107 +
  108 + #Fields for license info
  109 + fields_license['license_infos_id'] = LicenseInfo.last.id
  110 + hash_list << fields_license
  111 +
  112 + hash_list
  113 + end
  114 +
  115 + def software_edit_specific_fields
101 fields_library = Hash.new 116 fields_library = Hash.new
102 fields_language = Hash.new 117 fields_language = Hash.new
103 fields_database = Hash.new 118 fields_database = Hash.new
104 fields_operating_system = Hash.new 119 fields_operating_system = Hash.new
105 - fields_community = Hash.new 120 + fields_software = Hash.new
  121 + fields_categories = Hash.new
106 fields_license = Hash.new 122 fields_license = Hash.new
  123 +
  124 + hash_list = []
107 list_database = [] 125 list_database = []
108 list_language = [] 126 list_language = []
109 list_operating_system = [] 127 list_operating_system = []
@@ -115,36 +133,39 @@ module SoftwareTestHelper @@ -115,36 +133,39 @@ module SoftwareTestHelper
115 fields_library['license'] = 'test' 133 fields_library['license'] = 'test'
116 list_library << fields_library 134 list_library << fields_library
117 list_library << {} 135 list_library << {}
  136 + hash_list << list_library
  137 +
118 #Fields for software language 138 #Fields for software language
119 fields_language['version'] = 'test' 139 fields_language['version'] = 'test'
120 fields_language['programming_language_id'] = ProgrammingLanguage.last.id 140 fields_language['programming_language_id'] = ProgrammingLanguage.last.id
121 fields_language['operating_system'] = 'test' 141 fields_language['operating_system'] = 'test'
122 list_language << fields_language 142 list_language << fields_language
123 list_language << {} 143 list_language << {}
  144 + hash_list << list_language
  145 +
124 #Fields for database 146 #Fields for database
125 fields_database['version'] = 'test' 147 fields_database['version'] = 'test'
126 fields_database['database_description_id'] = DatabaseDescription.last.id 148 fields_database['database_description_id'] = DatabaseDescription.last.id
127 fields_database['operating_system'] = 'test' 149 fields_database['operating_system'] = 'test'
128 list_database << fields_database 150 list_database << fields_database
129 list_database << {} 151 list_database << {}
130 - #Fields for license info  
131 - fields_license['version'] = LicenseInfo.last.version 152 + hash_list << list_database
  153 +
132 #Fields for operating system 154 #Fields for operating system
133 fields_operating_system['version'] = 'version' 155 fields_operating_system['version'] = 'version'
134 fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id 156 fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id
135 list_operating_system << fields_operating_system 157 list_operating_system << fields_operating_system
136 list_operating_system << {} 158 list_operating_system << {}
137 - #Fields for community  
138 - fields_community['name'] = 'Debian'  
139 - fields_community['identifier'] = 'debian' 159 + hash_list << list_operating_system
140 160
141 - fields['acronym'] = 'test'  
142 - fields['objectives'] = 'test'  
143 - fields['features'] = 'test'  
144 - fields['operating_platform'] = 'operating_platform_test'  
145 - fields['demonstration_url'] = 'test' 161 + #software fields
  162 + fields_software['acronym'] = 'test'
  163 + fields_software['operating_platform'] = 'Linux'
  164 + fields_software['objectives'] = 'This is the objective of the software'
  165 + fields_software['features'] = 'This software does nothing'
  166 + hash_list << fields_software
146 167
147 - fields_categories = {} 168 + #Fields for software categories
148 fields_categories["administration"] = true 169 fields_categories["administration"] = true
149 fields_categories["agriculture"] = "1" 170 fields_categories["agriculture"] = "1"
150 fields_categories["business_and_services"] = "1" 171 fields_categories["business_and_services"] = "1"
@@ -167,16 +188,34 @@ module SoftwareTestHelper @@ -167,16 +188,34 @@ module SoftwareTestHelper
167 fields_categories["work"] = "1" 188 fields_categories["work"] = "1"
168 fields_categories["transportation"] = "1" 189 fields_categories["transportation"] = "1"
169 fields_categories["urbanism"] = "1" 190 fields_categories["urbanism"] = "1"
  191 + hash_list << fields_categories
  192 +
  193 + #Fields for license
  194 + fields_license['license_infos_id'] = LicenseInfo.last.id
  195 + hash_list << fields_license
  196 +
  197 + hash_list
  198 + end
170 199
  200 + def software_fields
  201 + fields = Hash.new
  202 + fields_community = Hash.new
  203 + fields_license = Hash.new
171 hash_list = [] 204 hash_list = []
172 - hash_list << fields  
173 - hash_list << list_library  
174 - hash_list << list_language  
175 - hash_list << list_database  
176 - hash_list << list_operating_system 205 +
  206 + #Fields for license info
  207 + fields_license['version'] = LicenseInfo.last.version
177 hash_list << fields_license 208 hash_list << fields_license
  209 +
  210 + #Fields for community
  211 + fields_community['name'] = 'Debian'
  212 + fields_community['identifier'] = 'debian'
178 hash_list << fields_community 213 hash_list << fields_community
179 - hash_list << fields_categories 214 +
  215 + #Fields for basic information
  216 + fields['finality'] = 'This is the finality of the software'
  217 + hash_list << fields
  218 +
180 hash_list 219 hash_list
181 end 220 end
182 end 221 end