prestashop-automation 0.6 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,9 @@ module PrestaShopAutomation
15
15
  click '#btNext'
16
16
 
17
17
  fill_in 'infosShop', :with => options[:shop_name] || @database_name
18
- find("input[name='db_mode'][value='#{options[:no_demo_products] ? 'lite' : 'full'}']").click
18
+ if has_selector? "input[name='db_mode']"
19
+ find("input[name='db_mode'][value='#{options[:no_demo_products] ? 'lite' : 'full'}']").click
20
+ end
19
21
  select_by_value_jqChosen '#infosCountry', options[:country] || 'us'
20
22
 
21
23
  if options[:timezone]
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  module PrestaShopAutomation
2
4
  module OrdersActions
3
5
 
@@ -52,7 +54,7 @@ module PrestaShopAutomation
52
54
  pdf_url = find('a[href*="generateInvoicePDF"]')['href']
53
55
 
54
56
  if options[:dump_pdf_to]
55
- all_cookies = page.driver.browser.manage.all_cookies
57
+ all_cookies = driver.browser.manage.all_cookies
56
58
  cookies = all_cookies.map do |c| "#{c[:name]}=#{c[:value]}" end.join ";"
57
59
  cmd = "curl --url #{Shellwords.shellescape pdf_url} -b \"#{cookies}\" -o #{Shellwords.shellescape options[:dump_pdf_to]} 2>/dev/null"
58
60
  `#{cmd}` #download the PDF
@@ -1,6 +1,20 @@
1
1
  module PrestaShopAutomation
2
2
  module SettingsActions
3
3
 
4
+ def set_rounding_rule option
5
+ goto_admin_tab 'AdminTaxes'
6
+
7
+ value = {:item => 1, :line => 2, :total => 3}[option.to_sym]
8
+
9
+ if value
10
+ select_by_value '#PS_TAX_ROUND_TYPE', value
11
+ click_button_named 'submitOptionstax', :first => true
12
+ standard_success_check
13
+ else
14
+ throw "Unsupported option: #{option}"
15
+ end
16
+ end
17
+
4
18
  def set_friendly_urls on
5
19
  goto_admin_tab 'AdminMeta'
6
20
  if on
data/lib/actions/taxes.rb CHANGED
@@ -32,10 +32,10 @@ module PrestaShopAutomation
32
32
  return current_url[/\bid_tax_rules_group=(\d+)/, 1].to_i
33
33
  end
34
34
 
35
- def create_tax_group_from_rate rate
35
+ def create_tax_group_from_rate rate, taxes_pool={}
36
36
  if /^(?:\d+(?:.\d+)?)$/ =~ rate.to_s
37
37
  tax_id = create_tax :name => "#{rate}% Tax (Rate)", :rate => rate
38
- create_tax_group :name => "#{rate}% Tax (Group)", :taxes => [{:tax_id => tax_id}]
38
+ taxes_pool[rate] ||= create_tax_group :name => "#{rate}% Tax (Group)", :taxes => [{:tax_id => tax_id}]
39
39
  elsif /(?:\d+(?:.\d+)?)(?:\s*(?:\+|\*)\s*(?:\d+(?:.\d+)?))+/ =~ rate
40
40
  taxes = []
41
41
  combine = {'+' => :sum, '*' => :multiply}[rate[/(\+|\*)/, 1]] || :no
@@ -45,7 +45,7 @@ module PrestaShopAutomation
45
45
  elsif token == '*'
46
46
  combine = :multiply
47
47
  else
48
- tax_id = create_tax :name => "#{token}% Tax (Rate)", :rate => token
48
+ tax_id = taxes_pool[rate] ||= (create_tax :name => "#{token}% Tax (Rate)", :rate => token)
49
49
  taxes << {
50
50
  :tax_id => tax_id,
51
51
  :combine => combine
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prestashop-automation
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,17 +20,16 @@ executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
- - lib/prestashop-automation.rb
24
- - lib/helpers/general.rb
25
- - lib/actions/products.rb
26
- - lib/actions/installer.rb
27
- - lib/actions/cart_rules.rb
28
23
  - lib/actions/carriers.rb
24
+ - lib/actions/cart_rules.rb
25
+ - lib/actions/general.rb
26
+ - lib/actions/installer.rb
29
27
  - lib/actions/orders.rb
28
+ - lib/actions/products.rb
30
29
  - lib/actions/settings.rb
31
- - lib/actions/general.rb
32
30
  - lib/actions/taxes.rb
33
- - test/all.rb
31
+ - lib/helpers/general.rb
32
+ - lib/prestashop-automation.rb
34
33
  homepage: https://github.com/djfm/prestashop-automation
35
34
  licenses:
36
35
  - OSL
data/test/all.rb DELETED
@@ -1,130 +0,0 @@
1
- require_relative '../lib/prestashop-automation.rb'
2
-
3
- ps = PrestaShopAutomation::PrestaShop.new({
4
- :back_office_url => 'http://localhost/1.6/admin-dev/',
5
- :front_office_url => 'http://localhost/1.6/',
6
- :installer_url => 'http://localhost/1.6/install-dev',
7
- :admin_email => 'pub@prestashop.com',
8
- :admin_password => '123456789',
9
- :database_name => '1.6'
10
- })
11
-
12
- describe 'Installing' do
13
- it 'should use the UI to prepare the database' do
14
- ps.drop_database
15
- ps.install
16
- ps.reset!
17
- end
18
-
19
- it 'should prepare the database externally' do
20
- ps.drop_database
21
- ps.install :prepare_database => true
22
- ps.reset!
23
- end
24
- end
25
-
26
- describe 'Front Office Primitives' do
27
-
28
- before :all do
29
- ps.login_to_front_office
30
- ps.login_to_back_office
31
- ps.set_friendly_urls false
32
- end
33
-
34
- after :all do
35
- ps.logout_of_front_office
36
- ps.logout_of_back_office
37
- end
38
-
39
- it 'should add product 1 to cart and make an order in OPC' do
40
- ps.goto_back_office
41
- ps.set_order_process_type :opc
42
- ps.goto_front_office
43
- ps.add_product_to_cart 1
44
- order_id = ps.order_current_cart_opc :carrier => 'My carrier'
45
- ps.goto_back_office
46
- ps.validate_order id: order_id
47
- end
48
-
49
- it 'should add product 1 to cart and make an order in 5 steps checkout' do
50
- ps.goto_back_office
51
- ps.set_order_process_type :five_steps
52
- ps.goto_front_office
53
- ps.add_product_to_cart 1
54
- order_id = ps.order_current_cart_5_steps :carrier => 'My carrier'
55
- ps.goto_back_office
56
- ps.validate_order id: order_id
57
- end
58
- end
59
-
60
- describe 'Back Office Primitives' do
61
-
62
- before :all do
63
- ps.login_to_back_office
64
- end
65
-
66
- after :all do
67
- ps.logout_of_back_office
68
- end
69
-
70
- describe 'Creating And Deleting a Cart Rule' do
71
- it 'should work with one product' do
72
- id = ps.create_cart_rule :name => 'YiiHaaa', :product_id => 1, :amount => '10%'
73
- ps.delete_cart_rule id
74
- end
75
- end
76
-
77
- describe 'Creating carriers' do
78
- it 'should work in the simplest case' do
79
- ps.create_carrier :name => 'Turtle Bob'
80
- end
81
- end
82
-
83
- describe 'Creating taxes' do
84
-
85
- it 'should create a complicated tax group' do
86
- ps.create_tax_group_from_rate '10 + 9.6'
87
- end
88
-
89
- it 'should create a tax and a tax group' do
90
- tax_id = ps.create_tax :name => 'Some Tax', :rate => '20'
91
- ps.create_tax_group :name => 'Test Tax Group', :taxes => [{:tax_id => tax_id}]
92
- end
93
- end
94
-
95
- describe 'Creating products' do
96
-
97
- it 'should work with a specific price' do
98
- ps.create_product :name => 'Petit Sachet de Vis Cruciformes Pas Cher', :price => '1.92', :specific_price => 'minus 1 tax included'
99
- end
100
-
101
- it 'should work with just a price and a name' do
102
- ps.create_product :name => 'Petit Sachet de Vis Cruciformes', :price => '1.85'
103
- end
104
- end
105
-
106
- describe 'Changing a few settings' do
107
- it 'should enable OPC' do
108
- ps.set_order_process_type :opc
109
- end
110
-
111
- it 'should disable OPC' do
112
- ps.set_order_process_type :five_steps
113
- end
114
-
115
- it 'shoud enable Gift Wrapping' do
116
- ps.set_gift_wrapping_option true, :price => 2
117
- end
118
-
119
- it 'shoud enable Friendly URLs' do
120
- ps.set_friendly_urls true
121
- end
122
- end
123
-
124
- describe 'Navigating the back office' do
125
- it 'should go to AdminOrders' do
126
- ps.goto_admin_tab 'AdminOrders'
127
- end
128
- end
129
-
130
- end