magento 0.24.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ RSpec.describe Magento::Order do
2
+ let(:magento_client) { request = Magento::Request.new }
3
+
4
+ before do
5
+ allow(Magento::Order).to receive(:request).and_return(magento_client)
6
+ end
7
+
8
+ describe 'send_email' do
9
+ let(:order_id) { 11735 }
10
+ let(:response) { double('Response', parse: true, status: 200) }
11
+
12
+ describe 'class method' do
13
+ it 'should request POST /orders/:id/emails' do
14
+ expect(magento_client).to receive(:post)
15
+ .with("orders/#{order_id}/emails")
16
+ .and_return(response)
17
+
18
+ result = Magento::Order.send_email(order_id)
19
+ end
20
+
21
+ it 'should return true' do
22
+ VCR.use_cassette('order/send_email') do
23
+ expect(Magento::Order.send_email(order_id)).to be(true).or be(false)
24
+ end
25
+ end
26
+ end
27
+
28
+ describe 'instance method' do
29
+ it 'shuld call the class method with order_id' do
30
+ expect(Magento::Order).to receive(:send_email).with(order_id)
31
+
32
+ order = Magento::Order.build(id: order_id)
33
+ result = order.send_email
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,4 +1,25 @@
1
1
  RSpec.describe Magento::Product do
2
+ let(:magento_client) { Magento::Request.new }
3
+
4
+ before { allow(Magento::Product).to receive(:request).and_return(magento_client) }
5
+
6
+ describe '.find' do
7
+ it 'request to /prducts/:sku' do
8
+ response = double('HTTP::Response', parse: {})
9
+
10
+ expect(magento_client).to receive(:get).with('products/1243').and_return(response)
11
+
12
+ Magento::Product.find('1243')
13
+ end
14
+
15
+ it 'returns a Magento::Product instance' do
16
+ VCR.use_cassette('product/find') do
17
+ product = Magento::Product.find('1243')
18
+ expect(product).to be_an_instance_of(Magento::Product)
19
+ end
20
+ end
21
+ end
22
+
2
23
  describe '#set_custom_attribute' do
3
24
  let(:product) { Magento::Product.build(
4
25
  sku: 25,
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,11 @@
1
- require "bundler/setup"
1
+ require 'bundler/setup'
2
2
  require 'byebug'
3
- require "magento"
3
+ require 'magento'
4
+ require 'vcr'
4
5
 
5
6
  RSpec.configure do |config|
6
7
  # Enable flags like --only-failures and --next-failure
7
- config.example_status_persistence_file_path = ".rspec_status"
8
+ config.example_status_persistence_file_path = '.rspec_status'
8
9
 
9
10
  # Disable RSpec exposing methods globally on `Module` and `main`
10
11
  config.disable_monkey_patching!
@@ -13,3 +14,16 @@ RSpec.configure do |config|
13
14
  c.syntax = :expect
14
15
  end
15
16
  end
17
+
18
+ Magento.configure do |config|
19
+ config.url = 'https://dev.superbomemcasa.com.br'
20
+ end
21
+
22
+ VCR.configure do |c|
23
+ c.cassette_library_dir = 'spec/vcr_cassettes'
24
+ c.hook_into :webmock
25
+ c.configure_rspec_metadata!
26
+ c.filter_sensitive_data('<MAGENTO_URL>') { Magento.configuration.url }
27
+ c.filter_sensitive_data('<MAGENTO_DOMAIN>') { Magento.configuration.url.sub(/^http(s)?:\/\//, '') }
28
+ c.filter_sensitive_data('<MAGENTO_TOKEN>') { Magento.configuration.token }
29
+ end
@@ -0,0 +1,65 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<MAGENTO_URL>/rest/all/V1/orders/11735/emails"
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Bearer <MAGENTO_TOKEN>
12
+ Connection:
13
+ - close
14
+ Host:
15
+ - "<MAGENTO_DOMAIN>"
16
+ User-Agent:
17
+ - http.rb/4.4.1
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 28 Jan 2021 02:19:28 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - close
31
+ Set-Cookie:
32
+ - PHPSESSID=2smb8fbfrh89ov5l6dsaog9ol3; expires=Thu, 28-Jan-2021 03:19:28 GMT;
33
+ Max-Age=3600; path=/; domain=<MAGENTO_DOMAIN>; secure; HttpOnly
34
+ - __cfduid=d6599c746d9235e60e31314f2c23603101611800368; expires=Sat, 27-Feb-21
35
+ 02:19:28 GMT; path=/; domain=.superbomemcasa.com.br; HttpOnly; SameSite=Lax;
36
+ Secure
37
+ Vary:
38
+ - Accept-Encoding
39
+ Expires:
40
+ - Thu, 19 Nov 1981 08:52:00 GMT
41
+ Cache-Control:
42
+ - no-store, no-cache, must-revalidate
43
+ Pragma:
44
+ - no-cache
45
+ X-Frame-Options:
46
+ - SAMEORIGIN
47
+ Cf-Cache-Status:
48
+ - DYNAMIC
49
+ Cf-Request-Id:
50
+ - 07e862ec7d0000f603b22c5000000001
51
+ Expect-Ct:
52
+ - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
53
+ Report-To:
54
+ - '{"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=LcpIGCN14P04w%2B12%2BJip%2BoqrTEEJHVD5vP3%2FqWTDV843xCQbwKwwisiq23jbvZ0fOkDmTOxTTgA804Jq1CCnW9d3I14x%2BUGjfoosFZuRXzpxNONKefOyryVm4KckyBHTJSF1EtaW"}]}'
55
+ Nel:
56
+ - '{"max_age":604800,"report_to":"cf-nel"}'
57
+ Server:
58
+ - cloudflare
59
+ Cf-Ray:
60
+ - 61873a8d9b69f603-GRU
61
+ body:
62
+ encoding: UTF-8
63
+ string: 'false'
64
+ recorded_at: Thu, 28 Jan 2021 02:19:28 GMT
65
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: "<MAGENTO_URL>/rest/all/V1/products/1243"
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Bearer <MAGENTO_TOKEN>
12
+ Connection:
13
+ - close
14
+ Host:
15
+ - "<MAGENTO_DOMAIN>"
16
+ User-Agent:
17
+ - http.rb/4.4.1
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Tue, 26 Jan 2021 12:14:13 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - close
31
+ Set-Cookie:
32
+ - PHPSESSID=ja838407a6que0872jcavh6nnn; expires=Tue, 26-Jan-2021 13:14:13 GMT;
33
+ Max-Age=3600; path=/; domain=<MAGENTO_DOMAIN>; secure; HttpOnly
34
+ - __cfduid=d55e21b42ee59161b6b98cd672c3aed2e1611663253; expires=Thu, 25-Feb-21
35
+ 12:14:13 GMT; path=/; domain=.superbomemcasa.com.br; HttpOnly; SameSite=Lax;
36
+ Secure
37
+ Vary:
38
+ - Accept-Encoding
39
+ Expires:
40
+ - Thu, 19 Nov 1981 08:52:00 GMT
41
+ Cache-Control:
42
+ - no-store, no-cache, must-revalidate
43
+ Pragma:
44
+ - no-cache
45
+ X-Frame-Options:
46
+ - SAMEORIGIN
47
+ Cf-Cache-Status:
48
+ - DYNAMIC
49
+ Cf-Request-Id:
50
+ - 07e036b79f0000f633d7210000000001
51
+ Expect-Ct:
52
+ - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
53
+ Report-To:
54
+ - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=ojIkem%2BboVf6LDGgK2JdO7t9VzPZ4pDxSmPkBKJMXK%2FTZPZQJMXgM4dLSxKcYOfxbXUWorkR0un78o%2BvbskH1pvLHaYY1ynWz9nSQNNSLAltK%2BPoysRl0aKNwHrsnpZPJ%2FETaTj3"}],"max_age":604800,"group":"cf-nel"}'
55
+ Nel:
56
+ - '{"max_age":604800,"report_to":"cf-nel"}'
57
+ Server:
58
+ - cloudflare
59
+ Cf-Ray:
60
+ - 617a2705cd1ff633-GRU
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"id":2455,"sku":"1243","name":"Ketchup Hellmann''s Tradicional 380
64
+ G ","attribute_set_id":4,"price":9.09,"status":1,"visibility":4,"type_id":"simple","created_at":"2020-03-28
65
+ 23:53:11","updated_at":"2020-08-29 00:22:59","weight":0.3,"extension_attributes":{"website_ids":[1,2],"category_links":[{"position":0,"category_id":"2451"},{"position":0,"category_id":"2452"}],"stock_item":{"item_id":2452,"product_id":2455,"stock_id":1,"qty":30,"is_in_stock":true,"is_qty_decimal":false,"show_default_notification_message":false,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":0,"min_sale_qty":1,"use_config_max_sale_qty":true,"max_sale_qty":10000,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":1,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":false,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":null,"is_decimal_divided":false,"stock_status_changed_auto":0}},"product_links":[],"options":[],"media_gallery_entries":[{"id":7913,"media_type":"image","label":"KETCHUP
66
+ HELLMANN''S 380G TRADICIONAL","position":0,"disabled":false,"types":["image","small_image","thumbnail","swatch_image"],"file":"\/7\/8\/7891150027848_1_1_1200_72_RGB_1.png"}],"tier_prices":[],"custom_attributes":[{"attribute_code":"description","value":"Ketchup
67
+ Tradicional Hellmann''s Squeeze 380g"},{"attribute_code":"image","value":"\/7\/8\/7891150027848_1_1_1200_72_RGB_1.png"},{"attribute_code":"url_key","value":"ketchup-hellmann-s-380g-tradicional"},{"attribute_code":"gift_message_available","value":"0"},{"attribute_code":"mostrar","value":"0"},{"attribute_code":"small_image","value":"\/7\/8\/7891150027848_1_1_1200_72_RGB_1.png"},{"attribute_code":"options_container","value":"container2"},{"attribute_code":"thumbnail","value":"\/7\/8\/7891150027848_1_1_1200_72_RGB_1.png"},{"attribute_code":"swatch_image","value":"\/7\/8\/7891150027848_1_1_1200_72_RGB_1.png"},{"attribute_code":"msrp_display_actual_price_type","value":"0"},{"attribute_code":"tax_class_id","value":"2"},{"attribute_code":"timershow","value":"1"},{"attribute_code":"gtin","value":"7891150027848,97623"},{"attribute_code":"required_options","value":"0"},{"attribute_code":"has_options","value":"0"},{"attribute_code":"image_label","value":"KETCHUP
68
+ HELLMANN''S 380G TRADICIONAL"},{"attribute_code":"category_ids","value":["2451","2452"]},{"attribute_code":"small_image_label","value":"KETCHUP
69
+ HELLMANN''S 380G TRADICIONAL"},{"attribute_code":"bebida_alcoolica","value":"0"},{"attribute_code":"thumbnail_label","value":"KETCHUP
70
+ HELLMANN''S 380G TRADICIONAL"},{"attribute_code":"featured","value":"1"}]}'
71
+ recorded_at: Tue, 26 Jan 2021 12:14:13 GMT
72
+ recorded_with: VCR 6.0.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magento
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria
@@ -89,13 +89,13 @@ files:
89
89
  - ".github/workflows/gem-push.yml"
90
90
  - ".gitignore"
91
91
  - ".rspec"
92
- - ".rspec_status"
93
92
  - Gemfile
94
93
  - README.md
95
94
  - Rakefile
96
95
  - bin/console
97
96
  - bin/setup
98
97
  - lib/magento.rb
98
+ - lib/magento/cart.rb
99
99
  - lib/magento/category.rb
100
100
  - lib/magento/configuration.rb
101
101
  - lib/magento/country.rb
@@ -118,6 +118,7 @@ files:
118
118
  - lib/magento/params/create_custom_attribute.rb
119
119
  - lib/magento/params/create_image.rb
120
120
  - lib/magento/params/create_product.rb
121
+ - lib/magento/params/create_product_link.rb
121
122
  - lib/magento/polymorphic_model.rb
122
123
  - lib/magento/product.rb
123
124
  - lib/magento/query.rb
@@ -156,9 +157,17 @@ files:
156
157
  - lib/magento/shared/value.rb
157
158
  - lib/magento/version.rb
158
159
  - magento.gemspec
160
+ - spec/magento/core/model_mapper_spec.rb
161
+ - spec/magento/core/model_spec.rb
162
+ - spec/magento/core/query_spec.rb
163
+ - spec/magento/core/record_collection_spec.rb
164
+ - spec/magento/core/request_spec.rb
165
+ - spec/magento/order_spec.rb
166
+ - spec/magento/product_spec.rb
159
167
  - spec/magento_spec.rb
160
- - spec/product_spec.rb
161
168
  - spec/spec_helper.rb
169
+ - spec/vcr_cassettes/order/send_email.yml
170
+ - spec/vcr_cassettes/product/find.yml
162
171
  homepage: https://github.com/WallasFaria/magento-ruby
163
172
  licenses: []
164
173
  metadata: {}
@@ -177,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
186
  - !ruby/object:Gem::Version
178
187
  version: '0'
179
188
  requirements: []
180
- rubygems_version: 3.0.3
189
+ rubygems_version: 3.0.3.1
181
190
  signing_key:
182
191
  specification_version: 4
183
192
  summary: Magento Ruby library
data/.rspec_status DELETED
@@ -1,5 +0,0 @@
1
- example_id | status | run_time |
2
- ------------------------------- | ------ | --------------- |
3
- ./spec/magento_spec.rb[1:1] | passed | 0.00057 seconds |
4
- ./spec/product_spec.rb[1:1:1:1] | passed | 0.00102 seconds |
5
- ./spec/product_spec.rb[1:1:2:1] | passed | 0.00111 seconds |