rents 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require 'colorize'
1
2
  module Rents
2
3
  module Generators
3
4
  class InstallGenerator < Rails::Generators::Base
@@ -42,17 +42,22 @@ module Rents
42
42
  # using json_request because need only the answer (do not use something like it HTTP Code)
43
43
  self.resp = self.post_json_request unless full_resp
44
44
  self.resp = self.post_request if full_resp
45
- return self.resp
45
+ self.resp
46
46
  end
47
47
 
48
48
  # TODO create charge works like a buy_store
49
- =begin
50
49
  # POST /api/transactions
51
- def charge_store
52
- self.path = "transactions"
53
- self.status = self.post_request
50
+ def charge_store full_resp=false
51
+ custom_http_params
52
+
53
+ # dynamic path (it is written when a specific method use it)
54
+ self.path = "transactions/store"
55
+
56
+ # using json_request because need only the answer (do not use something like it HTTP Code)
57
+ self.resp = self.post_json_request unless full_resp
58
+ self.resp = self.post_request if full_resp
59
+ self.resp
54
60
  end
55
- =end
56
61
 
57
62
  # ================ STATICs ================
58
63
  # GET /api/transactions/:rid by the rid passed
data/lib/rents/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rents
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- PATCH = 10
4
+ PATCH = 11
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
  end
data/spec/helpers.rb CHANGED
@@ -12,9 +12,11 @@ module Helpers
12
12
 
13
13
  until count == items_amount do
14
14
  count = count+1
15
+ rand_count_departments = Random.new.rand(1..10)
15
16
  sold_items.push({
16
17
  remote_id: Faker::Number.number(count),
17
- name: Faker::Commerce.product_name
18
+ name: Faker::Commerce.product_name,
19
+ description: Faker::Commerce.department(rand_count_departments, rand_count_departments==2)
18
20
  })
19
21
  end
20
22
 
@@ -99,4 +99,139 @@ describe Rents::Transaction do
99
99
  expect(error).to_not be_nil
100
100
  end
101
101
  end
102
+
103
+ # OK StorePage tests
104
+ describe '(SUCCESS REQUEST) Store - BuyPage' do
105
+ # ================ SetUp/Config ================
106
+ before(:all) do
107
+ Rents.test_env=true
108
+ Rents.debugger=true
109
+
110
+ # To test it as CAPTURED it mustn't have cents or invalid credit card number!?
111
+ amount = Random.rand(99999).to_s
112
+ amount = "#{amount}00" if amount[amount.length-2, amount.length] != '00'
113
+
114
+ @store_transaction = Rents::Transaction.new({
115
+ card:{
116
+ flag: 'visa',
117
+ cvv: '123',
118
+ expiration_month: '05',
119
+ expiration_year: '2018',
120
+ number: '4012001037141112',
121
+ holder: Faker::Name.name,
122
+ },
123
+
124
+ amount: amount
125
+ })
126
+
127
+ # Fake SoldItems added
128
+ @store_transaction.sold_items = fake_sold_items
129
+
130
+ # Send StoreCharge
131
+ @resp = @store_transaction.charge_store
132
+ end
133
+
134
+ # ================ Tests/Expects/Should ================
135
+ it 'resp should not be null' do
136
+ expect(@resp).to_not be_nil
137
+ end
138
+ end
139
+
140
+ # TRANSACTION DENIED example
141
+ describe '(SUCCESS REQUEST, but denied on the Operator) Store - BuyPage' do
142
+ # ================ SetUp/Config ================
143
+ before(:all) do
144
+ Rents.test_env=true
145
+ Rents.debugger=true
146
+
147
+ # To test it as DENIED it must have cents or invalid credit card number!?
148
+ amount = Random.rand(99999).to_s
149
+ amount = "#{amount}71" if amount[amount.length-2, amount.length] == '00'
150
+
151
+ @store_transaction = Rents::Transaction.new({
152
+ card:{
153
+ flag: 'visa',
154
+ cvv: '123',
155
+ expiration_month: '05',
156
+ expiration_year: '2018',
157
+ number: '9999999999999999',
158
+ holder: Faker::Name.name,
159
+ },
160
+
161
+ amount: amount
162
+ })
163
+
164
+ # Fake SoldItems added
165
+ @store_transaction.sold_items = fake_sold_items
166
+
167
+ # Send StoreCharge
168
+ @resp = @store_transaction.charge_store
169
+ end
170
+
171
+ # ================ Tests/Expects/Should ================
172
+ it 'resp should not be null' do
173
+ expect(@resp).to_not be_nil
174
+ end
175
+
176
+ it 'should setup the rid accessible method' do
177
+ expect(@resp[:rid]).to_not be_nil
178
+ end
179
+
180
+ it 'should setup the purchase_url accessible method' do
181
+ expect(@resp.purchase_url).to_not be_nil
182
+ end
183
+
184
+ it 'resp should not have any error' do
185
+ error = @resp[:error]
186
+ error = @resp['error'] if error.nil?
187
+ expect(error).to be_nil
188
+ end
189
+
190
+ it 'resp should be an accessible Operator URL' do
191
+ url = @page_transaction.purchase_url
192
+
193
+ expect(url).to_not be_nil
194
+ expect(accessible?(url)).to be_truthy
195
+ end
196
+
197
+ it 'must be verifiable' do
198
+ # SetUps
199
+ verify_resp = @page_transaction.verify
200
+ error = verify_resp[:error]
201
+ error = verify_resp['error'] if error.nil?
202
+
203
+ # Validations
204
+ expect(verify_resp).to_not be_nil
205
+ expect(error).to be_nil
206
+ end
207
+
208
+ it 'must have a get accessible URL request' do
209
+ url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
210
+ expect(be_accessible(url)).to be_truthy
211
+ end
212
+ end
213
+
214
+ # NOT_OK on the authentication Store Page tests
215
+ describe '(BAD REQUEST) Store - BuyPage' do
216
+ # SetUp/Config
217
+ before(:each) do
218
+ Rents.test_env = false
219
+ Rents.debugger = false
220
+ Rents.app_id = 1
221
+ Rents.secret_key = '12312321312$2a$10$NmV9EysKVLe8ItBdl9CHN.LF05bOuDdoOkmfptdbJs7cuaDWksuUu'
222
+ base_url = 'http://localhost:7000'
223
+
224
+ # Not using test_env (so using a app passed not the global app)
225
+ @page_transaction = Rents::Transaction.new({
226
+ card:{flag:'visa'},
227
+ amount: Random.rand(99999), # TODO: no error por rand menor que 99 (* mandatory) Amount in cents (1000 = R$ 10,00)
228
+ redirect_link: "#{base_url}/api/redirect_receiver" # (* optional) used only for CieloPage
229
+ })
230
+
231
+ # Send BuyPage
232
+ @page_resp = @page_transaction.charge_page(full_resp=true)
233
+ end
234
+
235
+ # ================ Tests/Expects/Should ================
236
+ end
102
237
  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: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilton Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -216,6 +216,7 @@ files:
216
216
  - LICENSE.txt
217
217
  - README.md
218
218
  - Rakefile
219
+ - lib/ca-bundle.crt
219
220
  - lib/generators/rents/install_generator.rb
220
221
  - lib/generators/templates/rents.rb
221
222
  - lib/rents.rb