Module: PrestaShopAutomation::InstallerActions
- Included in:
- PrestaShop
- Defined in:
- lib/actions/installer.rb
Instance Method Summary collapse
- #add_module_from_repo(repo, branch = nil) ⇒ Object
- #database_exists ⇒ Object
- #drop_database ⇒ Object
- #install(options = {}) ⇒ Object
- #install_module(name) ⇒ Object
- #prepare_database ⇒ Object
- #update_all_modules(strict = false) ⇒ Object
Instance Method Details
#add_module_from_repo(repo, branch = nil) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/actions/installer.rb', line 74 def add_module_from_repo repo, branch=nil b = branch ? ['-b', branch] : [] unless system 'git', 'clone', repo, *b, :chdir => File.join(@filesystem_path, 'modules') throw "Could not clone '#{repo}' into '#{@filesystem_path}'" end end |
#database_exists ⇒ Object
117 118 119 120 121 |
# File 'lib/actions/installer.rb', line 117 def database_exists count = client.query("SHOW DATABASES LIKE '#{client.escape @database_name}'").count expect(count).to be <= 1 count == 1 end |
#drop_database ⇒ Object
113 114 115 |
# File 'lib/actions/installer.rb', line 113 def drop_database client.query("DROP DATABASE IF EXISTS #{safe_database_name}") end |
#install(options = {}) ⇒ Object
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 |
# File 'lib/actions/installer.rb', line 6 def install ={} if [:prepare_database] prepare_database end visit @installer_url select_by_value '#langList', [:language] || 'en' click '#btNext' click_label_for 'set_license' click '#btNext' fill_in 'infosShop', :with => [:shop_name] || @database_name if has_selector? "input[name='db_mode']" find("input[name='db_mode'][value='#{[:no_demo_products] ? 'lite' : 'full'}']").click end select_by_value_jqChosen '#infosCountry', [:country] || 'us' if [:timezone] select_by_value_jqChosen '#infosTimezone', [:timezone] end fill_in 'infosFirstname', :with => [:admin_firstname] || @admin_firstname || 'John' fill_in 'infosName', :with => [:admin_lastname] || @admin_lastname || 'Doe' fill_in 'infosEmail', :with => [:admin_email] || @admin_email || '[email protected]' password = [:admin_password] || @admin_password || '123456789' fill_in 'infosPassword', :with => password fill_in 'infosPasswordRepeat', :with => password if has_selector? "#infosNotification" if [:newsletter] check 'infosNotification' else uncheck 'infosNotification' end end click '#btNext' fill_in 'dbServer', :with => "#{@database_host}:#{@database_port}" fill_in 'dbName', :with => @database_name fill_in 'dbLogin', :with => @database_user fill_in 'dbPassword', :with => @database_password fill_in 'db_prefix', :with => @database_prefix click '#btTestDB' if [:prepare_database] #db should be ok if we used :prepare_database expect_to have_selector '#dbResultCheck.okBlock' else check 'db_clear' if has_selector? 'db_clear' expect_to have_selector '#dbResultCheck.errorBlock' click '#btCreateDB' expect_to have_selector '#dbResultCheck.okBlock' end click '#btNext' wait_until do has_selector? 'a.BO' and has_selector? 'a.FO' end if [:paranoid] login_to_back_office login_to_front_office end end |
#install_module(name) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/actions/installer.rb', line 81 def install_module name goto_admin_tab 'AdminModules' recent = version_gte('1.6.0.7') rescue true if recent link = first("a[data-link*='&install='][data-link*='controller=AdminModules']", :visible => false)['data-link'] randomname = link[/\binstall=([^&?#]+)/, 1] link.gsub! randomname, name link = @back_office_url + link puts link else link = first("a[href*='&install='][href*='controller=AdminModules']", :visible => false)['href'] randomname = link[/\binstall=([^&?#]+)/, 1] link.gsub! randomname, name end visit link #check that the entry was added to the DB expect(client.query("SELECT * FROM #{safe_database_name}.#{@database_prefix}module WHERE name='#{client.escape name}'").count).to be 1 end |
#prepare_database ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/actions/installer.rb', line 123 def prepare_database if !database_exists client.query "CREATE DATABASE #{safe_database_name}" else tables = client.query("SHOW TABLES IN #{safe_database_name} LIKE '#{client.escape @database_prefix}%'") tables.each do |row| table = row.values[0] client.query "DROP TABLE #{safe_database_name}.`#{table}`" end end end |
#update_all_modules(strict = false) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/actions/installer.rb', line 102 def update_all_modules strict=false goto_admin_tab 'AdminModules' if has_selector? '#desc-module-update-all' click '#desc-module-update-all' if strict goto_admin_tab 'AdminModules' expect_to have_selector '#desc-module-check-and-update-all' end end end |