rnsap 0.4.5 → 0.4.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rnsap.rb +29 -0
  3. data/lib/rnsap_spec.rb +93 -0
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6caaea338a33ed4b7636f96d2b4e85fa9c8c1437c7ca472aa6be56998d4c8bef
4
- data.tar.gz: 72a6791919a49cdcd6ff0a8a7cea274bdd60c38cd4057680d332f24e4dbdf1e6
3
+ metadata.gz: 7a17557c7181bcd65a32fb58814b567f43744c17915ece180710bb3b4ebecfcb
4
+ data.tar.gz: 185a5c0b02c274c44f47794345ac5b2509463c47a55a68249728568d12175d9d
5
5
  SHA512:
6
- metadata.gz: 6fc660ac491245dde346f49d63059f525234c2e391ffcae8331a3219ead07032f40d341dcaaca03ee75547e602ca71071f0113089849785c7b7e74261de182f8
7
- data.tar.gz: 982047ae5d4236955c87b8c86b94d75d6a69043bff548ff460e6654e5e8ec7bd3eb0a33cfc944e108053f6015462636d1777d9953d5a9c694b0d515978528f50
6
+ metadata.gz: a45fa39484dae3cd8ae6a95215cd3de1b820285706df7b2cb7ba11f8537814b4c1e01e6a45d82d9e66511519c2da96f040f9061a2993bb6e5a9cc00f76043d45
7
+ data.tar.gz: b4bf0e054498ad13c5de3e28efb0e4dd12046f4bec1c8dd6d08cde8baa8d3af0623f3c97c7d283e6f5361ea06bac396495f488bd6c59ad6d3abb3fef35267872
data/lib/rnsap.rb CHANGED
@@ -291,6 +291,35 @@ module RnSap
291
291
  []
292
292
  end
293
293
 
294
+ def authority_check(user, auth_object, field, value)
295
+ #-- Execute AUTHORITY_CHECK
296
+ function = @conn.get_function('AUTHORITY_CHECK')
297
+ fun_call = function.get_function_call
298
+
299
+ fun_call[:USER] = user
300
+ fun_call[:OBJECT] = auth_object
301
+ fun_call[:FIELD1] = field
302
+ fun_call[:VALUE1] = value
303
+
304
+ begin
305
+ fun_call.invoke
306
+ rescue Exception => ex
307
+ if ex.to_s.include?('USER_IS_AUTHORIZED')
308
+ {
309
+ rc: 0,
310
+ message: 'Authorized.'
311
+ }
312
+ else
313
+ {
314
+ rc: 10,
315
+ message: 'User is not authorized.',
316
+ exception: ex
317
+ }
318
+ end
319
+ end
320
+
321
+ end
322
+
294
323
  private
295
324
 
296
325
  attr_writer :conn
data/lib/rnsap_spec.rb ADDED
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'yaml'
5
+ require_relative '../lib/rnsap'
6
+ require_relative '../lib/preq_detail/preq_item'
7
+
8
+ describe RnSap::Sap do
9
+ let(:params) do
10
+ file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'secrets.yml'))
11
+ YAML.safe_load(File.read(file))
12
+ end
13
+
14
+ let(:logon_info) do
15
+ { 'user' => params['user'],
16
+ 'passwd' => params['password'],
17
+ 'trace' => params['trace'],
18
+ 'client' => params['client'],
19
+ 'ashost' => params['ashost'],
20
+ 'sysnr' => params['sysnr'] }
21
+ end
22
+
23
+ let(:test_data) do
24
+ file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_data.yml'))
25
+ YAML.safe_load(File.read(file))
26
+ end
27
+
28
+ let(:conn) do
29
+ RnSap::Sap.new(logon_info)
30
+ end
31
+
32
+ context 'Based on connection available parameters' do
33
+ it 'connects to SAP' do
34
+ expect(conn).not_to be_nil
35
+ end
36
+ end
37
+
38
+ context 'Reads table information from SAP' do
39
+ it 'gets at least one vendor' do
40
+ list = conn.read_table('lfa1', %w[NAME1 LIFNR LAND1])
41
+ expect(list.count).to be > 0
42
+ end
43
+ it 'gets at least one Raw material' do
44
+ list = conn.read_table('mara', %w[matnr ernam], ["MTART = 'ROH'"])
45
+ expect(list.count).to be > 0
46
+ end
47
+
48
+ it 'gets a two Raw materials skipping the first in the database' do
49
+ list = conn.read_table({ name: 'mara', fields: %w[matnr ernam], clauses: ["MTART = 'ROH'"], row_skip: 1, row_count: 2 })
50
+ expect(list.count).to eq(2)
51
+ end
52
+ end
53
+
54
+ context 'Gets information from a Purchase Requisition' do
55
+ it 'Obtains details from purchase requisition' do
56
+ pr = test_data['preqs']['number']
57
+ puts " -> Pesquisando P.Req: #{pr}"
58
+ details = conn.preq_detail(pr)
59
+
60
+ expect(details).not_to be_nil
61
+ expect(details.class).to be(Hash)
62
+ end
63
+
64
+ it 'gets purchase requisition Release Strategy info' do
65
+ pr = test_data['preqs']['number']
66
+ details = conn.preq_release_strategy_info(pr)
67
+
68
+ expect(details).not_to be_nil
69
+ expect(details.class).to be(Hash)
70
+ end
71
+ end
72
+
73
+ context 'Gets information from a Purchase Order' do
74
+ it 'Obtains details from purchase requisition' do
75
+ po = test_data['po']['number']
76
+ puts " -> Pesquisando P.Order: #{po}"
77
+ details = conn.po_detail(po)
78
+
79
+ expect(details).not_to be_nil
80
+ expect(details.class).to be(Array)
81
+ end
82
+
83
+ it 'gets purchase requisition Release Strategy info' do
84
+ po = test_data['po']['number']
85
+ details = conn.po_release_strategy_info(po)
86
+
87
+ expect(details).not_to be_nil
88
+ expect(details.class).to be(Array)
89
+ end
90
+ end
91
+
92
+
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnsap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rogerio Nascimento
@@ -61,6 +61,7 @@ files:
61
61
  - lib/read_table/table_column.rb
62
62
  - lib/return.rb
63
63
  - lib/rnsap.rb
64
+ - lib/rnsap_spec.rb
64
65
  homepage: https://github.com/rnasc/rnsap
65
66
  licenses:
66
67
  - MIT