diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index 852a56c..7c03ffd 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -20,10 +20,10 @@ class MpogSoftwarePluginMyprofileController < MyProfileController @community.environment = environment @software_info = SoftwareInfo.new(params[:software_info]) - @license_info = if params[:license_info].nil? + @license_info = if params[:license].blank? or params[:license][:license_infos_id].blank? LicenseInfo.new else - LicenseInfo.find(params[:license_info][:id]) + LicenseInfo.find(params[:license][:license_infos_id]) end control_software_creation diff --git a/features/software_registration.feature b/features/software_registration.feature index 71ab290..8499143 100644 --- a/features/software_registration.feature +++ b/features/software_registration.feature @@ -14,6 +14,7 @@ Feature: edit public software information And I follow "Create a new software" And I fill in "community_name" with "basic software" And I fill in "software_info_finality" with "basic software finality" + And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-2" And I press "Create" @selenium @@ -41,7 +42,7 @@ Feature: edit public software information Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software When I follow "Specifications" And I follow "New Database" - And I type in "my" into autocomplete list "database_autocomplete" and I choose "MySQL" + And I type in "my" in autocomplete list ".database_autocomplete" and I choose "MySQL" Then selector ".database_autocomplete" should have any "MySQL" @selenium @@ -49,7 +50,7 @@ Feature: edit public software information Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software When I follow "Specifications" And I follow "New language" - And I type in "py" into autocomplete list "language_autocomplete" and I choose "Python" + And I type in "py" in autocomplete list ".language_autocomplete" and I choose "Python" Then selector ".database_autocomplete" should have any "Python" @selenium @@ -57,10 +58,10 @@ Feature: edit public software information Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software When I follow "Specifications" And I follow "New language" - And I type in "py" into autocomplete list "language_autocomplete" and I choose "Python" + And I type in "py" in autocomplete list ".language_autocomplete" and I choose "Python" And I fill in "language__version" with "1.2.3" And I follow "New Database" - And I type in "my" into autocomplete list "database_autocomplete" and I choose "MySQL" + And I type in "my" in autocomplete list ".database_autocomplete" and I choose "MySQL" And I fill in "database__version" with "4.5.6" Then I press "Save" And I follow "Software Info" @@ -86,10 +87,10 @@ Feature: edit public software information And I follow "Create a new software" And I fill in "community_name" with "another software" And I fill in "software_info_finality" with "another software finality" - And I select "GPL-2" from "license_info_id" - And I should see "www.gpl2.com" within "#version_link" + And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-2" + And I should see "Read license" within "#version_link" And I press "Create" And I go to another-software's control panel And I follow "Software Info" - And I select "GPL-3" from "license_info_id" - Then I should see "www.gpl3.com" within "#version_link" \ No newline at end of file + And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-3" + Then I should see "Read license" within "#version_link" \ No newline at end of file diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb index e23ad0b..2fbb304 100644 --- a/features/step_definitions/mpog_steps.rb +++ b/features/step_definitions/mpog_steps.rb @@ -41,12 +41,27 @@ Given /^Institutions has initial default values on database$/ do national_region.save end -Given /^I type in "([^"]*)" into autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_institution, should_select| - page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("focus") } - fill_in("#{input_institution}",:with => typed) - page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("keydown") } - sleep 1 - page.driver.browser.execute_script %Q{ jQuery('.ui-menu-item a:contains("#{should_select}")').trigger("mouseenter").trigger("click"); } +Given /^I type in "([^"]*)" in autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_field_selector, should_select| + # Wait the page javascript load + sleep 1 + # Basicaly it, search for the input field, type something, wait for ajax end select an item + page.driver.browser.execute_script %Q{ + var search_query = "#{input_field_selector}.ui-autocomplete-input"; + var input = jQuery(search_query).first(); + + input.trigger('click'); + input.val('#{typed}'); + input.trigger('keydown'); + + window.setTimeout(function(){ + search_query = ".ui-menu-item a:contains('#{should_select}')"; + var typed = jQuery(search_query).first(); + + typed.trigger('mouseenter').trigger('click'); + console.log(jQuery('#license_info_id')); + }, 1000); + } + sleep 1 end Given /^the following public institutions?$/ do |table| -- libgit2 0.21.2