cadun 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cadun/user.rb CHANGED
@@ -52,8 +52,8 @@ module Cadun
52
52
  estado['sigla']
53
53
  end
54
54
 
55
- def to_hash
56
- %w(address birthday cadun_id city complement country cpf email gender login mobile name neighborhood phone state status user_type zipcode).inject(Hash.new(0)) { |hash, method| hash[method.to_sym] = send(method); hash }
55
+ def to_hash
56
+ %w(address birthday cadun_id city complement country cpf email gender login mobile name neighborhood phone state status user_type zipcode).inject(Hash.new(0)) { |hash, method| hash[method.to_sym] = (send(method) rescue nil); hash }
57
57
  end
58
58
 
59
59
  def provision_to_service(service_id)
data/lib/cadun/version.rb CHANGED
@@ -2,7 +2,7 @@ module Cadun
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- PATCH = 5
5
+ PATCH = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH] * '.'
8
8
  end
data/lib/cadun.rb CHANGED
@@ -3,6 +3,7 @@ require 'yaml'
3
3
  require 'rest_client'
4
4
  require 'json'
5
5
  require 'active_support/core_ext/hash'
6
+ require 'active_support/core_ext/object'
6
7
  require "#{File.dirname(__FILE__)}/cadun/gateway"
7
8
  require "#{File.dirname(__FILE__)}/cadun/user"
8
9
  require "#{File.dirname(__FILE__)}/cadun/config"
@@ -51,26 +51,33 @@ describe Cadun::User do
51
51
  end
52
52
 
53
53
  describe "#to_hash" do
54
- subject { Cadun::User.new(:cadun_id => "10001000").to_hash }
54
+ context "when the user has all data" do
55
+ subject { Cadun::User.new(:cadun_id => "10001000").to_hash }
56
+
57
+ specify { should include(:cadun_id => "10001000") }
58
+ specify { should include(:name => "Guilherme Chico") }
59
+ specify { should include(:email => "fab1@spam.la") }
60
+ specify { should include(:user_type => "NAO_ASSINANTE") }
61
+ specify { should include(:gender => "MASCULINO") }
62
+ specify { should include(:neighborhood => "Andaraí") }
63
+ specify { should include(:city => "Rio de Janeiro") }
64
+ specify { should include(:state => "RJ") }
65
+ specify { should include(:country => "Brasil") }
66
+ specify { should include(:address => "Rua Uruguai, 59") }
67
+ specify { should include(:birthday => Date.new(1983, 02, 22)) }
68
+ specify { should include(:phone => "21 22881060") }
69
+ specify { should include(:mobile => "21 99999999") }
70
+ specify { should include(:login => "fabricio_fab1") }
71
+ specify { should include(:cpf => "09532034765") }
72
+ specify { should include(:zipcode => "20510060") }
73
+ specify { should include(:status => "ATIVO") }
74
+ specify { should include(:complement => "807") }
75
+ end
55
76
 
56
- specify { should include(:cadun_id => "10001000") }
57
- specify { should include(:name => "Guilherme Chico") }
58
- specify { should include(:email => "fab1@spam.la") }
59
- specify { should include(:user_type => "NAO_ASSINANTE") }
60
- specify { should include(:gender => "MASCULINO") }
61
- specify { should include(:neighborhood => "Andaraí") }
62
- specify { should include(:city => "Rio de Janeiro") }
63
- specify { should include(:state => "RJ") }
64
- specify { should include(:country => "Brasil") }
65
- specify { should include(:address => "Rua Uruguai, 59") }
66
- specify { should include(:birthday => Date.new(1983, 02, 22)) }
67
- specify { should include(:phone => "21 22881060") }
68
- specify { should include(:mobile => "21 99999999") }
69
- specify { should include(:login => "fabricio_fab1") }
70
- specify { should include(:cpf => "09532034765") }
71
- specify { should include(:zipcode => "20510060") }
72
- specify { should include(:status => "ATIVO") }
73
- specify { should include(:complement => "807") }
77
+ context "when the user has minimal data" do
78
+ subject { Cadun::User.find_by_email("fulano_adm_campanha@globomail.com").to_hash }
79
+ specify { should include(:cadun_id => "23370159") }
80
+ end
74
81
  end
75
82
 
76
83
  describe ".find_by_email" do
data/spec/spec_helper.rb CHANGED
@@ -24,6 +24,8 @@ def stub_requests
24
24
  :body => "#{File.dirname(__FILE__)}/support/fixtures/email.xml")
25
25
  FakeWeb.register_uri(:get, "http://isp-authenticator.qa01.globoi.com:8280/cadunii/ws/resources/pessoa/email/silvano@corp.globo.com",
26
26
  :body => "#{File.dirname(__FILE__)}/support/fixtures/email.xml")
27
+ FakeWeb.register_uri(:get, "http://isp-authenticator.qa01.globoi.com:8280/cadunii/ws/resources/pessoa/email/fulano_adm_campanha@globomail.com",
28
+ :body => "#{File.dirname(__FILE__)}/support/fixtures/email2.xml")
27
29
  FakeWeb.register_uri(:put, "http://cadun-rest.qa01.globoi.com/service/provisionamento",
28
30
  :body => "#{File.dirname(__FILE__)}/support/fixtures/provisionamento.json", :status => 200)
29
31
  end
@@ -0,0 +1,32 @@
1
+ <pessoa>
2
+ <id>23370159</id>
3
+ <cookie>000009Xa0RCfmEXFknsHiyaPnp2eOY8x</cookie>
4
+ <criacao>2011-08-02T00:00:00-03:00</criacao>
5
+ <dataNascimento>1969-12-18T00:00:00-03:00</dataNascimento>
6
+ <emailAlternativo>edusteiner2@gmail.com</emailAlternativo>
7
+ <ipCadastro>127.0.0.1</ipCadastro>
8
+ <login>fulano_adm_campanha</login>
9
+ <modulos>
10
+ <criacao>2011-08-02T19:17:08-03:00</criacao>
11
+ <moduloID>1</moduloID>
12
+ <pessoaID>23370159</pessoaID>
13
+ </modulos>
14
+ <modulos>
15
+ <criacao>2011-08-02T19:17:08-03:00</criacao>
16
+ <moduloID>4</moduloID>
17
+ <pessoaID>23370159</pessoaID>
18
+ </modulos>
19
+ <nome>Fulano Adm Campanha</nome>
20
+ <optinCelular>false</optinCelular>
21
+ <optinGlobo>false</optinGlobo>
22
+ <optinParceiros>false</optinParceiros>
23
+ <origemId>101</origemId>
24
+ <perguntaId>2</perguntaId>
25
+ <resposta>peixe</resposta>
26
+ <servicoOrigemId>3755</servicoOrigemId>
27
+ <sexo>MASCULINO</sexo>
28
+ <status>ATIVO</status>
29
+ <telefoneResidencial>22334455</telefoneResidencial>
30
+ <telefoneResidencialDdd>21</telefoneResidencialDdd>
31
+ <tipoUsuario>NAO_ASSINANTE</tipoUsuario>
32
+ </pessoa>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cadun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-07-28 00:00:00.000000000Z
14
+ date: 2011-08-03 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &2156848880 !ruby/object:Gem::Requirement
18
+ requirement: &2168462760 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 3.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2156848880
26
+ version_requirements: *2168462760
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
- requirement: &2156848380 !ruby/object:Gem::Requirement
29
+ requirement: &2168462260 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 2.1.2
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2156848380
37
+ version_requirements: *2168462260
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rest-client
40
- requirement: &2156848000 !ruby/object:Gem::Requirement
40
+ requirement: &2168461880 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2156848000
48
+ version_requirements: *2168461880
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: json
51
- requirement: &2156847540 !ruby/object:Gem::Requirement
51
+ requirement: &2168461420 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *2156847540
59
+ version_requirements: *2168461420
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: i18n
62
- requirement: &2156847120 !ruby/object:Gem::Requirement
62
+ requirement: &2168461000 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *2156847120
70
+ version_requirements: *2168461000
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rake
73
- requirement: &2156846700 !ruby/object:Gem::Requirement
73
+ requirement: &2168460580 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *2156846700
81
+ version_requirements: *2168460580
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rspec
84
- requirement: &2156846280 !ruby/object:Gem::Requirement
84
+ requirement: &2168460160 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *2156846280
92
+ version_requirements: *2168460160
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rr
95
- requirement: &2156845860 !ruby/object:Gem::Requirement
95
+ requirement: &2168459740 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *2156845860
103
+ version_requirements: *2168459740
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: fakeweb
106
- requirement: &2156845440 !ruby/object:Gem::Requirement
106
+ requirement: &2168459320 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,7 +111,7 @@ dependencies:
111
111
  version: '0'
112
112
  type: :development
113
113
  prerelease: false
114
- version_requirements: *2156845440
114
+ version_requirements: *2168459320
115
115
  description: A wrapper for the Globo.com's authentication/authorization API
116
116
  email:
117
117
  - bruno@azisaka.com.br
@@ -139,6 +139,7 @@ files:
139
139
  - spec/support/fixtures/autorizacao.xml
140
140
  - spec/support/fixtures/config.yml
141
141
  - spec/support/fixtures/email.xml
142
+ - spec/support/fixtures/email2.xml
142
143
  - spec/support/fixtures/pessoa.xml
143
144
  - spec/support/fixtures/pessoa_2.xml
144
145
  - spec/support/fixtures/provisionamento.json