magento 0.23.0 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,52 @@
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
+
23
+ describe '#set_custom_attribute' do
24
+ let(:product) { Magento::Product.build(
25
+ sku: 25,
26
+ custom_attributes: [
27
+ { attribute_code: 'description', value: 'Some description' }
28
+ ]
29
+ ) }
30
+
31
+ context 'when the custom attribute already exists' do
32
+ it 'must change the attribute value' do
33
+ expect(product.description).to eql('Some description')
34
+ product.set_custom_attribute(:description, 'description updated')
35
+ expect(product.attr(:description)).to eql('description updated')
36
+ end
37
+ end
38
+
39
+ context 'when the custom attribute does not exists' do
40
+ it 'must add a new attribute' do
41
+ expect(product.attr(:new_attribute)).to be_nil
42
+ expect(product.attr(:other_new_attribute)).to be_nil
43
+
44
+ product.set_custom_attribute(:new_attribute, 'value')
45
+ product.set_custom_attribute('other_new_attribute', [1, 2])
46
+
47
+ expect(product.attr(:new_attribute)).to eql('value')
48
+ expect(product.attr(:other_new_attribute)).to eql([1, 2])
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.describe Magento do
2
+ it "has a version number" do
3
+ expect(Magento::VERSION).not_to be nil
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ require 'bundler/setup'
2
+ require 'byebug'
3
+ require 'magento'
4
+ require 'vcr'
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = '.rspec_status'
9
+
10
+ # Disable RSpec exposing methods globally on `Module` and `main`
11
+ config.disable_monkey_patching!
12
+
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = :expect
15
+ end
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.23.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria
@@ -88,8 +88,12 @@ extra_rdoc_files: []
88
88
  files:
89
89
  - ".github/workflows/gem-push.yml"
90
90
  - ".gitignore"
91
+ - ".rspec"
91
92
  - Gemfile
92
93
  - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
93
97
  - lib/magento.rb
94
98
  - lib/magento/category.rb
95
99
  - lib/magento/configuration.rb
@@ -113,6 +117,7 @@ files:
113
117
  - lib/magento/params/create_custom_attribute.rb
114
118
  - lib/magento/params/create_image.rb
115
119
  - lib/magento/params/create_product.rb
120
+ - lib/magento/params/create_product_link.rb
116
121
  - lib/magento/polymorphic_model.rb
117
122
  - lib/magento/product.rb
118
123
  - lib/magento/query.rb
@@ -150,8 +155,18 @@ files:
150
155
  - lib/magento/shared/total.rb
151
156
  - lib/magento/shared/value.rb
152
157
  - lib/magento/version.rb
153
- - magento-ruby.gemspec
154
158
  - magento.gemspec
159
+ - spec/magento/core/model_mapper_spec.rb
160
+ - spec/magento/core/model_spec.rb
161
+ - spec/magento/core/query_spec.rb
162
+ - spec/magento/core/record_collection_spec.rb
163
+ - spec/magento/core/request_spec.rb
164
+ - spec/magento/order_spec.rb
165
+ - spec/magento/product_spec.rb
166
+ - spec/magento_spec.rb
167
+ - spec/spec_helper.rb
168
+ - spec/vcr_cassettes/order/send_email.yml
169
+ - spec/vcr_cassettes/product/find.yml
155
170
  homepage: https://github.com/WallasFaria/magento-ruby
156
171
  licenses: []
157
172
  metadata: {}
data/magento-ruby.gemspec DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require 'magento/version'
7
-
8
- Gem::Specification.new do |s|
9
- s.name = 'magento-ruby'
10
- s.version = Magento::VERSION
11
- s.date = '2020-07-31'
12
- s.summary = 'Magento Ruby library'
13
- s.description = 'Magento Ruby library'
14
- s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
- s.authors = ['Wallas Faria']
16
- s.email = 'wallasfaria@hotmail.com'
17
- s.homepage = 'https://github.com/WallasFaria/magento-ruby'
18
- s.require_paths = ['lib']
19
-
20
- s.add_dependency 'dry-inflector', '~> 0.2.0'
21
- s.add_dependency 'http', '~> 4.4'
22
- s.add_dependency 'dry-struct'
23
- s.add_dependency 'activesupport'
24
- s.add_dependency 'mini_magick'
25
- end