rents 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba844c2f33282b0f62eb32737e641fb0f76e2057
4
- data.tar.gz: 7c9a893f91276ff429344bebda00947690c97005
3
+ metadata.gz: eb3d382ab4fdcd3697a03a3724921c95520cf3d6
4
+ data.tar.gz: 127b3ba19687b1efffce1bb1984acbf73570b68a
5
5
  SHA512:
6
- metadata.gz: 09825367acc551a0f2e12e6a289737563a4b4b9a230b2f5ffbd913e9e747c00df89d89d1654b473d84b8173f282a23a27c044010250cf2aff7236b0f2b544739
7
- data.tar.gz: f0c9f052506ee89272d9da97b8570a72e3f861fa213a9034a25d2b3cc8e3f35535858f702a2dad12b0c125c7e123cbc76e9247f4ac3638b65ea3ef3eabaa766e
6
+ metadata.gz: c68fe14936da92b876cc5a8b929ffe50d7aabe6447b294f76ac63f6bb94b9dc4c0538ce90a67ef500933f6a60824f7ea434aa8fcea4f705214eb1c62917a3c63
7
+ data.tar.gz: 25519da4d3791086a14ad62d423e41a223281324e19554aeaa746b35c0165c5cead31df697b8d315ed471224b963132b9db3cc4e69810f7900c0c96289047a7b
@@ -28,7 +28,7 @@ module Rents
28
28
  self.domain = 'localhost:7000'
29
29
  else
30
30
  self.protocol = 'https'
31
- self.domain = 'apprents.herokuapp.com'
31
+ self.domain = 'rents-app.herokuapp.com'
32
32
  end
33
33
 
34
34
  self.api_version = 'v1'
data/lib/rents/status.rb CHANGED
@@ -4,6 +4,7 @@ module Rents
4
4
  attr_accessor :message # API response message
5
5
  attr_accessor :http_code # HTTP Code for the request
6
6
  attr_accessor :api_code # Internal system response code
7
+ attr_accessor :response # the JSON retrieved
7
8
 
8
9
  # Constructor
9
10
  def initialize(params = {})
@@ -21,6 +22,7 @@ module Rents
21
22
  self.message = "EndPoint not response(connection error): #{self.url_requested}" if self.http_code != 200
22
23
  self.message = hash_resp[:message] if self.http_code == 200
23
24
  self.api_code = hash_resp[:api_code]
25
+ self.response = hash_resp
24
26
 
25
27
  return self
26
28
  end
data/lib/rents/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rents
2
2
  MAJOR = 1
3
3
  MINOR = 0
4
- PATCH = 3
4
+ PATCH = 4
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
  end
data/spec/helpers.rb CHANGED
@@ -34,4 +34,20 @@ module Helpers
34
34
  resp = RestClient.get url
35
35
  JSON.parse(resp).it_keys_to_sym
36
36
  end
37
+
38
+ def page_transaction_mock(card_brand, amount, redir_link)
39
+ page = {}
40
+ page[:transaction] = Rents::Transaction.new({
41
+ card:{brand: card_brand},
42
+ amount: amount, # The last 2 numbers are the cents
43
+ redirect_link: redir_link # (* optional) used only for CieloPage
44
+ })
45
+
46
+ # Fake SoldItems added
47
+ page[:transaction].sold_items = fake_sold_items
48
+
49
+ # Perform BuyPage
50
+ page[:resp] = page[:transaction].charge_page
51
+ page
52
+ end
37
53
  end
@@ -11,75 +11,156 @@ describe Rents::Transaction do
11
11
  context 'BuyOperatorPage' do
12
12
  # OK Operator Page tests
13
13
  describe '(SUCCESS REQUEST)' do
14
- # ================ SetUp/Config ================
15
- before(:all) do
16
- Rents.debug=true
17
- Rents.test_env=true
14
+ context 'amount with cents' do
15
+ # ================ SetUp/Config ================
16
+ before(:all) do
17
+ Rents.debug=true
18
+ Rents.test_env=true
18
19
 
19
- @api_status = Rents::Status.new
20
- @page_transaction = Rents::Transaction.new({
21
- card:{brand:'visa'},
22
- amount: Random.rand(99999), # The last 2 numbers are the cents
23
- redirect_link: "#{@base_url}/api/redirect_receiver" # (* optional) used only for CieloPage
24
- })
20
+ # "Int" amount, with cents
21
+ amount = (BigDecimal Random.rand(99999))/100
22
+ card_brand = 'elo'
25
23
 
26
- # Fake SoldItems added
27
- @page_transaction.sold_items = fake_sold_items
24
+ # (* optional) used only for CieloPage
25
+ redir_link = "#{@base_url}/api/redirect_receiver"
28
26
 
29
- # Send BuyPage
30
- @page_resp = @page_transaction.charge_page
31
- end
27
+ # With cents
28
+ aux = page_transaction_mock(card_brand, amount, redir_link)
29
+ @page_resp = aux[:resp]
30
+ @page_transaction = aux[:transaction]
31
+ end
32
32
 
33
- # ================ Tests/Expects/Should ================
34
- it 'resp should not be null' do
35
- expect(@page_resp).to_not be_nil
36
- end
33
+ # ================ Tests/Expects/Should ================
34
+ it 'resp should not be null' do
35
+ expect(@page_resp).to_not be_nil
36
+ end
37
37
 
38
- it 'resp should contain the RequestID' do
39
- request_id = @page_resp[:request_id]
40
- expect(request_id).to_not be_nil
41
- expect(request_id).to be_a Integer
42
- end
38
+ it 'resp should contain the RequestID' do
39
+ request_id = @page_resp[:request_id]
40
+ expect(request_id).to_not be_nil
41
+ expect(request_id).to be_a Integer
42
+ end
43
43
 
44
- it 'should setup the rid accessible method' do
45
- expect(@page_transaction.rid).to_not be_nil
46
- end
44
+ it 'should setup the rid accessible method' do
45
+ expect(@page_transaction.rid).to_not be_nil
46
+ end
47
47
 
48
- it 'should setup the purchase_url accessible method' do
49
- expect(@page_transaction.purchase_url).to_not be_nil
50
- end
48
+ it 'should setup the purchase_url accessible method' do
49
+ expect(@page_transaction.purchase_url).to_not be_nil
50
+ end
51
51
 
52
- it 'resp should not have any error' do
53
- error = @page_resp[:error]
54
- error = @page_resp['error'] if error.nil?
55
- expect(error).to be_nil
56
- end
52
+ it 'resp should not have any error' do
53
+ error = @page_resp[:error]
54
+ error = @page_resp['error'] if error.nil?
55
+ expect(error).to be_nil
56
+ end
57
57
 
58
- it 'resp should be an accessible Operator URL' do
59
- url = @page_transaction.purchase_url
58
+ it 'resp should be an accessible Operator URL' do
59
+ url = @page_transaction.purchase_url
60
60
 
61
- expect(url).to_not be_nil
62
- expect(accessible?(url)).to be_truthy
63
- end
61
+ expect(url).to_not be_nil
62
+ expect(accessible?(url)).to be_truthy
63
+ end
64
+
65
+ it 'must be verifiable' do
66
+ # SetUps
67
+ verify_resp = @page_transaction.verify
68
+ error = verify_resp[:error]
69
+ error = verify_resp['error'] if error.nil?
64
70
 
65
- it 'must be verifiable' do
66
- # SetUps
67
- verify_resp = @page_transaction.verify
68
- error = verify_resp[:error]
69
- error = verify_resp['error'] if error.nil?
71
+ # Validations
72
+ expect(error).to be_nil
73
+ expect(verify_resp).to_not be_nil
70
74
 
71
- # Validations
72
- expect(error).to be_nil
73
- expect(verify_resp).to_not be_nil
75
+ # It is just created status
76
+ expect(0..1).to cover(verify_resp[:status][:code])
77
+ expect(verify_resp[:status][:name]).to eq('pending')
78
+ end
79
+
80
+ it 'must have a get accessible URL request' do
81
+ url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
82
+ expect(be_accessible(url)).to be_truthy
83
+ end
74
84
 
75
- # It is just created status
76
- expect(0..1).to cover(verify_resp[:status][:code])
77
- expect(verify_resp[:status][:name]).to eq('pending')
85
+ it 'amount must be the same as send' do
86
+ expect(@page_transaction.amount.to_i).to be == @page_resp[:transaction][:amount]
87
+ end
78
88
  end
79
89
 
80
- it 'must have a get accessible URL request' do
81
- url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
82
- expect(be_accessible(url)).to be_truthy
90
+ context 'full amount (without any cent)' do
91
+ # ================ SetUp/Config ================
92
+ before(:all) do
93
+ Rents.debug=true
94
+ Rents.test_env=true
95
+
96
+ # "Int" amount, no cents
97
+ amount = BigDecimal Random.rand(99999)
98
+ card_brand = 'visa'
99
+
100
+ # (* optional) used only for CieloPage
101
+ redir_link = "#{@base_url}/api/redirect_receiver"
102
+
103
+ # Without cents ,00
104
+ aux = page_transaction_mock(card_brand, amount, redir_link)
105
+ @page_resp = aux[:resp]
106
+ @page_transaction = aux[:transaction]
107
+ end
108
+
109
+ # ================ Tests/Expects/Should ================
110
+ it 'resp should not be null' do
111
+ expect(@page_resp).to_not be_nil
112
+ end
113
+
114
+ it 'resp should contain the RequestID' do
115
+ request_id = @page_resp[:request_id]
116
+ expect(request_id).to_not be_nil
117
+ expect(request_id).to be_a Integer
118
+ end
119
+
120
+ it 'should setup the rid accessible method' do
121
+ expect(@page_transaction.rid).to_not be_nil
122
+ end
123
+
124
+ it 'should setup the purchase_url accessible method' do
125
+ expect(@page_transaction.purchase_url).to_not be_nil
126
+ end
127
+
128
+ it 'resp should not have any error' do
129
+ error = @page_resp[:error]
130
+ error = @page_resp['error'] if error.nil?
131
+ expect(error).to be_nil
132
+ end
133
+
134
+ it 'resp should be an accessible Operator URL' do
135
+ url = @page_transaction.purchase_url
136
+
137
+ expect(url).to_not be_nil
138
+ expect(accessible?(url)).to be_truthy
139
+ end
140
+
141
+ it 'must be verifiable' do
142
+ # SetUps
143
+ verify_resp = @page_transaction.verify
144
+ error = verify_resp[:error]
145
+ error = verify_resp['error'] if error.nil?
146
+
147
+ # Validations
148
+ expect(error).to be_nil
149
+ expect(verify_resp).to_not be_nil
150
+
151
+ # It is just created status
152
+ expect(0..1).to cover(verify_resp[:status][:code])
153
+ expect(verify_resp[:status][:name]).to eq('pending')
154
+ end
155
+
156
+ it 'must have a get accessible URL request' do
157
+ url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
158
+ expect(be_accessible(url)).to be_truthy
159
+ end
160
+
161
+ it 'amount must be the same as send' do
162
+ expect(@page_transaction.amount.to_i).to be == @page_resp[:transaction][:amount]
163
+ end
83
164
  end
84
165
  end
85
166
 
@@ -358,7 +439,7 @@ describe Rents::Transaction do
358
439
  # SetUpVars
359
440
  empty_subscription_resp = @empty_transaction_resp[:subscription]
360
441
  resp_amount = empty_subscription_resp[:amount]
361
- resp_recurrence_period = empty_subscription_resp[:recurrence_period_id]
442
+ resp_recurrence_period = empty_subscription_resp[:recurrence_period]
362
443
 
363
444
  # test those attrs
364
445
  expect(resp_amount).to eq(@amount)
@@ -367,7 +448,7 @@ describe Rents::Transaction do
367
448
  # SetUpVars
368
449
  rid_subscription_resp = @rid_transaction_resp[:subscription]
369
450
  resp_amount = rid_subscription_resp[:amount]
370
- resp_recurrence_period = rid_subscription_resp[:recurrence_period_id]
451
+ resp_recurrence_period = rid_subscription_resp[:recurrence_period]
371
452
 
372
453
  # test those attrs
373
454
  expect(resp_amount).to eq(@amount)
@@ -547,7 +628,7 @@ describe Rents::Transaction do
547
628
  describe 'Update recurrent subscription DENIED' do
548
629
  # ================ SetUp/Config ================
549
630
  before(:all) do
550
- Rents.debug=false
631
+ Rents.debug=true
551
632
  Rents.test_env=false
552
633
 
553
634
  Rents.app_id = 1
@@ -585,7 +666,7 @@ describe Rents::Transaction do
585
666
  describe 'Unsubscribe denied' do
586
667
  # ================ SetUp/Config ================
587
668
  before(:all) do
588
- Rents.debug=false
669
+ Rents.debug=true
589
670
  Rents.test_env=false
590
671
 
591
672
  Rents.app_id = 1
@@ -677,4 +758,24 @@ describe Rents::Transaction do
677
758
  comment_proxy_yml
678
759
  end
679
760
  end
761
+
762
+ context 'Remote sample connection test' do
763
+ before(:all) do
764
+ Rents.debug=false
765
+ Rents.test_env=false
766
+ @remote = Rents::Status.new
767
+ end
768
+
769
+ it 'must have a response JSON' do
770
+ expect(@remote.response).to be_a Hash
771
+ end
772
+
773
+ it 'must have a message' do
774
+ expect(@remote.message).to be_a String
775
+ end
776
+
777
+ it 'must have an API code' do
778
+ expect(@remote.api_code).to be_a Integer
779
+ end
780
+ end
680
781
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rents
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilton Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler