passaporteweb-client 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.hound.yml +1063 -0
- data/.travis.yml +2 -3
- data/Gemfile.lock +70 -48
- data/README.rdoc +5 -0
- data/lib/passaporte_web/service_account.rb +16 -0
- data/lib/passaporte_web/version.rb +1 -1
- data/passaporteweb-client.gemspec +12 -12
- data/spec/passaporte_web/http_spec.rb +1 -1
- data/spec/passaporte_web/identity_service_account_spec.rb +2 -2
- data/spec/passaporte_web/identity_service_spec.rb +7 -7
- data/spec/passaporte_web/identity_spec.rb +17 -17
- data/spec/passaporte_web/notification_spec.rb +14 -14
- data/spec/passaporte_web/service_account_member_spec.rb +10 -10
- data/spec/passaporte_web/service_account_spec.rb +35 -3
- data/spec/spec_helper.rb +1 -0
- metadata +35 -33
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,54 +1,76 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
passaporteweb-client (0.0
|
4
|
+
passaporteweb-client (0.2.0)
|
5
5
|
multi_json (~> 1.9.0)
|
6
|
-
rest-client (~> 1.
|
6
|
+
rest-client (~> 1.8.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
addressable (2.3.3)
|
12
|
-
awesome_print (1.1
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
awesome_print (1.6.1)
|
13
|
+
byebug (4.0.5)
|
14
|
+
columnize (= 0.9.0)
|
15
|
+
coderay (1.1.0)
|
16
|
+
columnize (0.9.0)
|
17
|
+
coveralls (0.8.1)
|
18
|
+
json (~> 1.8)
|
19
|
+
rest-client (>= 1.6.8, < 2)
|
20
|
+
simplecov (~> 0.10.0)
|
21
|
+
term-ansicolor (~> 1.3)
|
22
|
+
thor (~> 0.19.1)
|
21
23
|
crack (0.3.2)
|
22
|
-
diff-lcs (1.2.
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
diff-lcs (1.2.5)
|
25
|
+
docile (1.1.5)
|
26
|
+
domain_name (0.5.24)
|
27
|
+
unf (>= 0.0.5, < 1.0.0)
|
28
|
+
http-cookie (1.0.2)
|
29
|
+
domain_name (~> 0.5)
|
30
|
+
json (1.8.3)
|
31
|
+
method_source (0.8.2)
|
32
|
+
mime-types (2.6.1)
|
26
33
|
multi_json (1.9.2)
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
netrc (0.10.3)
|
35
|
+
pry (0.10.1)
|
36
|
+
coderay (~> 1.1.0)
|
37
|
+
method_source (~> 0.8.1)
|
30
38
|
slop (~> 3.4)
|
31
|
-
pry-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
rest-client (1.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
rspec-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
pry-byebug (3.1.0)
|
40
|
+
byebug (~> 4.0)
|
41
|
+
pry (~> 0.10)
|
42
|
+
rake (10.4.2)
|
43
|
+
rdoc (4.2.0)
|
44
|
+
rest-client (1.8.0)
|
45
|
+
http-cookie (>= 1.0.2, < 2.0)
|
46
|
+
mime-types (>= 1.16, < 3.0)
|
47
|
+
netrc (~> 0.7)
|
48
|
+
rspec (3.3.0)
|
49
|
+
rspec-core (~> 3.3.0)
|
50
|
+
rspec-expectations (~> 3.3.0)
|
51
|
+
rspec-mocks (~> 3.3.0)
|
52
|
+
rspec-core (3.3.0)
|
53
|
+
rspec-support (~> 3.3.0)
|
54
|
+
rspec-expectations (3.3.0)
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
+
rspec-support (~> 3.3.0)
|
57
|
+
rspec-mocks (3.3.0)
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
+
rspec-support (~> 3.3.0)
|
60
|
+
rspec-support (3.3.0)
|
61
|
+
simplecov (0.10.0)
|
62
|
+
docile (~> 1.1.0)
|
63
|
+
json (~> 1.8)
|
64
|
+
simplecov-html (~> 0.10.0)
|
65
|
+
simplecov-html (0.10.0)
|
66
|
+
slop (3.6.0)
|
67
|
+
term-ansicolor (1.3.0)
|
68
|
+
tins (~> 1.0)
|
69
|
+
thor (0.19.1)
|
70
|
+
tins (1.5.2)
|
71
|
+
unf (0.1.4)
|
72
|
+
unf_ext
|
73
|
+
unf_ext (0.0.7.1)
|
52
74
|
vcr (2.4.0)
|
53
75
|
webmock (1.9.3)
|
54
76
|
addressable (>= 2.2.7)
|
@@ -58,15 +80,15 @@ PLATFORMS
|
|
58
80
|
ruby
|
59
81
|
|
60
82
|
DEPENDENCIES
|
61
|
-
awesome_print (~> 1.
|
62
|
-
bundler (~> 1.
|
63
|
-
coveralls (~> 0.
|
83
|
+
awesome_print (~> 1.6)
|
84
|
+
bundler (~> 1.9)
|
85
|
+
coveralls (~> 0.8)
|
86
|
+
json (= 1.8.3)
|
64
87
|
passaporteweb-client!
|
65
|
-
pry (~>
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
simplecov (~> 0.7)
|
88
|
+
pry-byebug (~> 3.1)
|
89
|
+
rake (~> 10.4)
|
90
|
+
rdoc (~> 4.2)
|
91
|
+
rspec (~> 3.3.0)
|
92
|
+
simplecov (~> 0.10)
|
71
93
|
vcr (~> 2.4)
|
72
94
|
webmock (~> 1.9.3)
|
data/README.rdoc
CHANGED
@@ -6,6 +6,7 @@ A Ruby client for the PassaporteWeb REST API
|
|
6
6
|
{<img src="https://travis-ci.org/myfreecomm/passaporteweb-client-ruby.png?branch=master" alt="Build Status" />}[https://travis-ci.org/myfreecomm/passaporteweb-client-ruby]
|
7
7
|
{<img src="https://coveralls.io/repos/myfreecomm/passaporteweb-client-ruby/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/myfreecomm/passaporteweb-client-ruby]
|
8
8
|
{<img src="https://codeclimate.com/github/myfreecomm/passaporteweb-client-ruby.png" alt="Code Climate Status" />}[https://codeclimate.com/github/myfreecomm/passaporteweb-client-ruby]
|
9
|
+
{<img src="http://inch-ci.org/github/myfreecomm/passaporteweb-client-ruby.svg" alt="Inline docs" />}[http://inch-ci.org/github/myfreecomm/passaporteweb-client-ruby]
|
9
10
|
|
10
11
|
PassaporteWeb API docs: https://app.passaporteweb.com.br/static/docs/
|
11
12
|
|
@@ -29,6 +30,10 @@ Or install it yourself as:
|
|
29
30
|
|
30
31
|
$ gem install passaporteweb-client
|
31
32
|
|
33
|
+
== Support
|
34
|
+
|
35
|
+
This gem supports Ruby 2.1 and Ruby 2.2.
|
36
|
+
|
32
37
|
== Usage
|
33
38
|
|
34
39
|
=== Mapping of API endpoints to this client
|
@@ -97,6 +97,22 @@ module PassaporteWeb
|
|
97
97
|
@persisted == true
|
98
98
|
end
|
99
99
|
|
100
|
+
# Activates an existing ServiceAccount. Returns true if successfull or false if not. In case of failure,
|
101
|
+
# it will fill the <tt>errors</tt> attribute with the reason for the failure to save the object.
|
102
|
+
#
|
103
|
+
# API method: <tt>PUT /organizations/api/activate/</tt>
|
104
|
+
#
|
105
|
+
# API documentation: http://myfreecomm.github.io/passaporte-web/pweb/api/account_manager.html#put-organizations-api-activate
|
106
|
+
def activate(identity)
|
107
|
+
response = Http.put("/organizations/api/activate/", {slug: self.plan_slug, identity: identity, global_account: self.uuid})
|
108
|
+
raise "unexpected response: #{response.code} - #{response.body}" unless response.code == 200
|
109
|
+
@errors = {}
|
110
|
+
true
|
111
|
+
rescue *[RestClient::Conflict, RestClient::BadRequest] => e
|
112
|
+
@errors = MultiJson.decode(e.response.body)
|
113
|
+
false
|
114
|
+
end
|
115
|
+
|
100
116
|
private
|
101
117
|
|
102
118
|
def update
|
@@ -8,8 +8,8 @@ require File.join([File.dirname(__FILE__),'lib','passaporte_web','version.rb'])
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = "passaporteweb-client"
|
10
10
|
spec.version = PassaporteWeb::VERSION
|
11
|
-
spec.authors = ["Rodrigo Tassinari de Oliveira", "
|
12
|
-
spec.email = ["rodrigo@pittlandia.net", "rodrigo.tassinari@myfreecomm.com.br", "
|
11
|
+
spec.authors = ["Rodrigo Tassinari de Oliveira", "Eduardo Hertz", "Rafael B. Tauil"]
|
12
|
+
spec.email = ["rodrigo@pittlandia.net", "rodrigo.tassinari@myfreecomm.com.br", "eduardo.hertz@myfreecomm.com.br", "rafael@tauil.com.br"]
|
13
13
|
spec.description = %q{A Ruby client for the PassaporteWeb REST API}
|
14
14
|
spec.summary = %q{A Ruby client for the PassaporteWeb REST API: https://app.passaporteweb.com.br/static/docs/}
|
15
15
|
spec.homepage = "https://github.com/myfreecomm/passaporteweb-client-ruby"
|
@@ -23,18 +23,18 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_dependency "rest-client", "~> 1.
|
26
|
+
spec.add_dependency "rest-client", "~> 1.8.0"
|
27
27
|
spec.add_dependency "multi_json", "~> 1.9.0"
|
28
28
|
|
29
|
-
spec.add_development_dependency "bundler", "~> 1.
|
30
|
-
spec.add_development_dependency "rake", "~> 10.
|
31
|
-
spec.add_development_dependency 'rdoc', '~> 4.
|
32
|
-
spec.add_development_dependency "rspec", "~>
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
31
|
+
spec.add_development_dependency 'rdoc', '~> 4.2'
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.3.0"
|
33
33
|
spec.add_development_dependency "vcr", "~> 2.4"
|
34
34
|
spec.add_development_dependency "webmock", "~> 1.9.3"
|
35
|
-
spec.add_development_dependency "pry", "~>
|
36
|
-
spec.add_development_dependency "
|
37
|
-
spec.add_development_dependency "
|
38
|
-
spec.add_development_dependency "
|
39
|
-
spec.add_development_dependency "
|
35
|
+
spec.add_development_dependency "pry-byebug", "~> 3.1"
|
36
|
+
spec.add_development_dependency "awesome_print", "~> 1.6"
|
37
|
+
spec.add_development_dependency "simplecov", "~> 0.10"
|
38
|
+
spec.add_development_dependency "coveralls", "~> 0.8"
|
39
|
+
spec.add_development_dependency "json", "1.8.3"
|
40
40
|
end
|
@@ -13,7 +13,7 @@ describe PassaporteWeb::Http do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
let(:mock_response) {
|
16
|
+
let(:mock_response) { 'restclient http response' }
|
17
17
|
|
18
18
|
describe ".get" do
|
19
19
|
it "should use RestClient.get with the supplied params and common options" do
|
@@ -87,7 +87,7 @@ describe PassaporteWeb::IdentityServiceAccount do
|
|
87
87
|
name: 'Conta Nova em Folha'
|
88
88
|
}
|
89
89
|
account = described_class.new(identity, attributes)
|
90
|
-
account.save.
|
90
|
+
expect(account.save).to be_truthy
|
91
91
|
account.should be_persisted
|
92
92
|
|
93
93
|
account.plan_slug.should == 'basic'
|
@@ -135,7 +135,7 @@ describe PassaporteWeb::IdentityServiceAccount do
|
|
135
135
|
name: 'Conta Nova em Folha 2: A missão'
|
136
136
|
}
|
137
137
|
account = described_class.new(identity, attributes)
|
138
|
-
account.save.
|
138
|
+
expect(account.save).to be_falsy
|
139
139
|
account.should_not be_persisted
|
140
140
|
account.errors.should == {"field_errors"=>{"expiration"=>["Cannot set the expiration to the past."]}}
|
141
141
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe PassaporteWeb::IdentityService do
|
5
5
|
let(:identity) { PassaporteWeb::Identity.find('5e32f927-c4ab-404e-a91c-b2abc05afb56') }
|
6
|
-
let(:mock_identity) {
|
6
|
+
let(:mock_identity) { double('Identity', uuid: 'identity-uuid') }
|
7
7
|
let(:identity_service_data_hash) { {:foo => 'bar', 'spam' => :eggs, 'integer' => 2, :float => 3.456, :array => [1, 2.0, 'three', :four], :hash => {oba: 'eba'}} }
|
8
8
|
let(:identity_service_data_hash_as_strings) { {"foo"=>"bar", "hash"=>{"oba"=>"eba"}, "spam"=>"eggs", "integer"=>2, "array"=>[1, 2.0, "three", "four"], "float"=>3.456} }
|
9
9
|
|
@@ -14,7 +14,7 @@ describe PassaporteWeb::IdentityService do
|
|
14
14
|
identity_service.identity.should == mock_identity
|
15
15
|
identity_service.slug.should be_nil
|
16
16
|
identity_service.is_active.should be_nil
|
17
|
-
identity_service.is_active
|
17
|
+
expect(identity_service.is_active?).to be_falsy
|
18
18
|
identity_service.service_data.should be_nil
|
19
19
|
identity_service.errors.should be_empty
|
20
20
|
identity_service.should_not be_persisted
|
@@ -31,7 +31,7 @@ describe PassaporteWeb::IdentityService do
|
|
31
31
|
identity_service.identity.should == mock_identity
|
32
32
|
identity_service.slug.should == 'identity_client'
|
33
33
|
identity_service.is_active.should == true
|
34
|
-
identity_service.is_active
|
34
|
+
expect(identity_service.is_active?).to be_truthy
|
35
35
|
identity_service.service_data.should == identity_service_data_hash
|
36
36
|
identity_service.errors.should be_empty
|
37
37
|
identity_service.should_not be_persisted
|
@@ -44,8 +44,8 @@ describe PassaporteWeb::IdentityService do
|
|
44
44
|
identity_service.should be_instance_of(described_class)
|
45
45
|
identity_service.identity.should == identity
|
46
46
|
identity_service.slug.should == 'identity_client'
|
47
|
-
identity_service.is_active.
|
48
|
-
identity_service.is_active
|
47
|
+
expect(identity_service.is_active).to be_truthy
|
48
|
+
expect(identity_service.is_active?).to be_truthy
|
49
49
|
identity_service.service_data.should be_nil
|
50
50
|
identity_service.errors.should be_empty
|
51
51
|
identity_service.should be_persisted
|
@@ -65,7 +65,7 @@ describe PassaporteWeb::IdentityService do
|
|
65
65
|
'service_data' => identity_service_data_hash
|
66
66
|
}
|
67
67
|
identity_service = described_class.new(other_identity, attributes)
|
68
|
-
identity_service.save.
|
68
|
+
expect(identity_service.save).to be_truthy
|
69
69
|
identity_service.service_data.should == identity_service_data_hash_as_strings
|
70
70
|
|
71
71
|
identity_service = described_class.find(other_identity, 'identity_client')
|
@@ -75,7 +75,7 @@ describe PassaporteWeb::IdentityService do
|
|
75
75
|
identity_service = described_class.find(identity, 'identity_client')
|
76
76
|
identity_service.service_data.should be_empty
|
77
77
|
identity_service.service_data = identity_service_data_hash
|
78
|
-
identity_service.save.
|
78
|
+
expect(identity_service.save).to be_truthy
|
79
79
|
identity_service.service_data.should == identity_service_data_hash_as_strings
|
80
80
|
|
81
81
|
identity_service = described_class.find(identity, 'identity_client')
|
@@ -128,7 +128,7 @@ describe PassaporteWeb::Identity do
|
|
128
128
|
# REGRSSION
|
129
129
|
it "should return the is_active and id_token fields" do
|
130
130
|
identity = described_class.find('13b972ab-0946-4a5b-8217-60255a9cbee7', true, true)
|
131
|
-
identity.is_active.
|
131
|
+
expect(identity.is_active).to be_truthy
|
132
132
|
identity.id_token.should be_nil # não mostra token pois não foi autenticado com a senha do usuário
|
133
133
|
end
|
134
134
|
it "should raise an error if no profiles exist with that uuid" do
|
@@ -175,7 +175,7 @@ describe PassaporteWeb::Identity do
|
|
175
175
|
# REGRSSION
|
176
176
|
it "should return the is_active and id_token fields" do
|
177
177
|
identity = described_class.find_by_email('mobileteste269@mailinator.com', true, true)
|
178
|
-
identity.is_active.
|
178
|
+
expect(identity.is_active).to be_truthy
|
179
179
|
identity.id_token.should be_nil # não mostra token pois não foi autenticado com a senha do usuário
|
180
180
|
end
|
181
181
|
it "should raise an error if no profiles exist with that email" do
|
@@ -205,12 +205,12 @@ describe PassaporteWeb::Identity do
|
|
205
205
|
identity.email_list.count.should == 2
|
206
206
|
# Primary e-mail
|
207
207
|
identity.email_list[0]['address'].should == 'jaime.lannister@mailinator.com'
|
208
|
-
identity.email_list[0]['is_primary'].
|
209
|
-
identity.email_list[0]['is_active'].
|
208
|
+
expect(identity.email_list[0]['is_primary']).to be_truthy
|
209
|
+
expect(identity.email_list[0]['is_active']).to be_truthy
|
210
210
|
# Secondary email
|
211
211
|
identity.email_list[1]['address'].should == 'kingslayer@mailinator.com'
|
212
|
-
identity.email_list[1]['is_primary'].
|
213
|
-
identity.email_list[1]['is_active'].
|
212
|
+
expect(identity.email_list[1]['is_primary']).to be_falsy
|
213
|
+
expect(identity.email_list[1]['is_active']).to be_truthy
|
214
214
|
end
|
215
215
|
it "should raise an error if no profiles exist with that email" do
|
216
216
|
expect {
|
@@ -231,11 +231,11 @@ describe PassaporteWeb::Identity do
|
|
231
231
|
# REGRSSION
|
232
232
|
it "should return the is_active and id_token fields" do
|
233
233
|
identity = described_class.authenticate('mobileteste269@mailinator.com', 'vivalasvegas')
|
234
|
-
identity.is_active.
|
234
|
+
expect(identity.is_active).to be_truthy
|
235
235
|
identity.id_token.should == '9864ec27fb4fd866f6fad5bc041d0363d0bc0fd2945858a1'
|
236
236
|
end
|
237
237
|
it "should return false if the password is wrong for the given email" do
|
238
|
-
described_class.authenticate('teste@teste.com', 'wrong password').
|
238
|
+
expect(described_class.authenticate('teste@teste.com', 'wrong password')).to be_falsy
|
239
239
|
end
|
240
240
|
it "should return false if no Identity exists on PassaporteWeb with that email" do
|
241
241
|
described_class.authenticate('non_existing_email@teste.com', 'some password')
|
@@ -245,10 +245,10 @@ describe PassaporteWeb::Identity do
|
|
245
245
|
describe "#authenticate", vcr: true do
|
246
246
|
let(:identity) { described_class.find("5e32f927-c4ab-404e-a91c-b2abc05afb56") }
|
247
247
|
it "should return true if the password is correct" do
|
248
|
-
identity.authenticate('123456').
|
248
|
+
expect(identity.authenticate('123456')).to be_truthy
|
249
249
|
end
|
250
250
|
it "should return false if the password is wrong" do
|
251
|
-
identity.authenticate('wrong password').
|
251
|
+
expect(identity.authenticate('wrong password')).to be_falsy
|
252
252
|
end
|
253
253
|
it "should raise an error if the email is not set" do
|
254
254
|
identity.instance_variable_set(:@email, nil)
|
@@ -266,7 +266,7 @@ describe PassaporteWeb::Identity do
|
|
266
266
|
identity.first_name.should == 'Testador'
|
267
267
|
identity.should be_persisted
|
268
268
|
identity.first_name = 'Testador 2'
|
269
|
-
identity.save.
|
269
|
+
expect(identity.save).to be_truthy
|
270
270
|
identity.should be_persisted
|
271
271
|
identity.first_name.should == 'Testador 2'
|
272
272
|
|
@@ -278,7 +278,7 @@ describe PassaporteWeb::Identity do
|
|
278
278
|
it "should return false and set the errors hash" do
|
279
279
|
identity.cpf = 42
|
280
280
|
identity.should be_persisted
|
281
|
-
identity.save.
|
281
|
+
expect(identity.save).to be_falsy
|
282
282
|
identity.should be_persisted
|
283
283
|
identity.errors.should == {"cpf" => ["Certifique-se de que o valor tenha no mínimo 11 caracteres (ele possui 2)."]}
|
284
284
|
end
|
@@ -298,7 +298,7 @@ describe PassaporteWeb::Identity do
|
|
298
298
|
}
|
299
299
|
identity = described_class.new(attributes)
|
300
300
|
identity.should_not be_persisted
|
301
|
-
identity.save.
|
301
|
+
expect(identity.save).to be_truthy
|
302
302
|
identity.should be_persisted
|
303
303
|
end
|
304
304
|
it "should save with all params" do
|
@@ -317,7 +317,7 @@ describe PassaporteWeb::Identity do
|
|
317
317
|
}
|
318
318
|
identity = described_class.new(attributes)
|
319
319
|
identity.should_not be_persisted
|
320
|
-
identity.save.
|
320
|
+
expect(identity.save).to be_truthy
|
321
321
|
identity.should be_persisted
|
322
322
|
end
|
323
323
|
# REGRESSION
|
@@ -332,9 +332,9 @@ describe PassaporteWeb::Identity do
|
|
332
332
|
send_myfreecomm_news: true
|
333
333
|
}
|
334
334
|
identity = described_class.new(attributes)
|
335
|
-
mock_response =
|
335
|
+
mock_response = double('response', code: 201, body: MultiJson.encode(attributes))
|
336
336
|
PassaporteWeb::Http.should_receive(:post).with("/accounts/api/create/", attributes).and_return(mock_response)
|
337
|
-
identity.save.
|
337
|
+
expect(identity.save).to be_truthy
|
338
338
|
end
|
339
339
|
end
|
340
340
|
context "on failure" do
|
@@ -347,7 +347,7 @@ describe PassaporteWeb::Identity do
|
|
347
347
|
}
|
348
348
|
identity = described_class.new(attributes)
|
349
349
|
identity.should_not be_persisted
|
350
|
-
identity.save.
|
350
|
+
expect(identity.save).to_not be_truthy
|
351
351
|
identity.should_not be_persisted
|
352
352
|
identity.errors.should == {"password2"=>["Este campo é obrigatório."], "password"=>["Este campo é obrigatório."]}
|
353
353
|
end
|
@@ -55,7 +55,7 @@ describe PassaporteWeb::Notification do
|
|
55
55
|
|
56
56
|
notifications = data.notifications
|
57
57
|
notifications.size.should == 2
|
58
|
-
notifications.map { |n| n.instance_of?(described_class) }.uniq.
|
58
|
+
expect(notifications.map { |n| n.instance_of?(described_class) }.uniq).to be_truthy
|
59
59
|
n1, n2 = notifications
|
60
60
|
n1.body.should == '"oioioi"' # TODO why? was it created like this?
|
61
61
|
n2.body.should == '"oioioisss"'
|
@@ -74,7 +74,7 @@ describe PassaporteWeb::Notification do
|
|
74
74
|
|
75
75
|
notifications = data.notifications
|
76
76
|
notifications.size.should == 1
|
77
|
-
notifications.map { |n| n.instance_of?(described_class) }.uniq.
|
77
|
+
expect(notifications.map { |n| n.instance_of?(described_class) }.uniq). to be_truthy
|
78
78
|
n1 = notifications.first
|
79
79
|
n1.body.should == '"oioioi"' # TODO why? was it created like this?
|
80
80
|
n1.uuid.should == "2ca046be-0178-418d-80ac-3a334c264009"
|
@@ -125,7 +125,7 @@ describe PassaporteWeb::Notification do
|
|
125
125
|
it "should create the Notification on PassaporteWeb, authenticated as the user" do
|
126
126
|
PassaporteWeb.configuration.user_token = "f01d30c0a2e878fecc838735560253f9e9395932f5337f40"
|
127
127
|
notification.should_not be_persisted
|
128
|
-
notification.save.
|
128
|
+
expect(notification.save).to be_truthy # by default authenticates as the user
|
129
129
|
notification.should be_persisted
|
130
130
|
notification.uuid.should_not be_nil
|
131
131
|
notification.absolute_url.should_not be_nil
|
@@ -139,7 +139,7 @@ describe PassaporteWeb::Notification do
|
|
139
139
|
end
|
140
140
|
it "should create the Notification on PassaporteWeb, authenticated as the application" do
|
141
141
|
notification.should_not be_persisted
|
142
|
-
notification.save('application').
|
142
|
+
expect(notification.save('application')).to be_truthy
|
143
143
|
notification.should be_persisted
|
144
144
|
notification.uuid.should_not be_nil
|
145
145
|
notification.absolute_url.should_not be_nil
|
@@ -156,13 +156,13 @@ describe PassaporteWeb::Notification do
|
|
156
156
|
it "should return false an do nothing if the Notification is already persisted" do
|
157
157
|
PassaporteWeb.configuration.user_token = "f01d30c0a2e878fecc838735560253f9e9395932f5337f40"
|
158
158
|
notification = described_class.find_all(1,20,nil,true).notifications.last
|
159
|
-
notification.save.
|
159
|
+
expect(notification.save).to be_falsy
|
160
160
|
end
|
161
161
|
it "should return false and set the errors with the reason for the failure, authenticated as the user" do
|
162
162
|
PassaporteWeb.configuration.user_token = "f01d30c0a2e878fecc838735560253f9e9395932f5337f40"
|
163
163
|
notification.target_url = 'lalalala'
|
164
164
|
notification.should_not be_persisted
|
165
|
-
notification.save('user').
|
165
|
+
expect(notification.save('user')).to be_falsy
|
166
166
|
notification.should_not be_persisted
|
167
167
|
notification.uuid.should be_nil
|
168
168
|
notification.errors.should == {"field_errors"=>{"target_url"=>["Informe uma URL válida."]}}
|
@@ -170,7 +170,7 @@ describe PassaporteWeb::Notification do
|
|
170
170
|
it "should return false and set the errors with the reason for the failure, authenticated as the application" do
|
171
171
|
notification.destination = nil # required field
|
172
172
|
notification.should_not be_persisted
|
173
|
-
notification.save('application').
|
173
|
+
expect(notification.save('application')).to be_falsy
|
174
174
|
notification.should_not be_persisted
|
175
175
|
notification.uuid.should be_nil
|
176
176
|
notification.errors.should == {"field_errors"=>{"destination"=>["Este campo é obrigatório."]}}
|
@@ -187,7 +187,7 @@ describe PassaporteWeb::Notification do
|
|
187
187
|
context "on success" do
|
188
188
|
it "should mark the Notification as read" do
|
189
189
|
notification.read_at.should be_nil
|
190
|
-
notification.read
|
190
|
+
expect(notification.read!).to be_truthy
|
191
191
|
notification.read_at.should_not be_nil
|
192
192
|
end
|
193
193
|
end
|
@@ -195,7 +195,7 @@ describe PassaporteWeb::Notification do
|
|
195
195
|
it "should return false if the notification is already read" do
|
196
196
|
read_notification = described_class.find_all(1,20,nil,true).notifications.detect { |n| !n.read_at.nil? }
|
197
197
|
read_notification.read_at.should_not be_nil
|
198
|
-
read_notification.read
|
198
|
+
expect(read_notification.read!).to be_falsy
|
199
199
|
read_notification.errors.should == {message: 'notification already read'}
|
200
200
|
end
|
201
201
|
end
|
@@ -204,19 +204,19 @@ describe PassaporteWeb::Notification do
|
|
204
204
|
describe "#destroy" do
|
205
205
|
let(:notification) { described_class.new(body: 'novinha', destination: 'a5868d14-6529-477a-9c6b-a09dd42a7cd2', scheduled_to: '2013-04-06') } # 2.days.from_now
|
206
206
|
it "should return false if the record is not persisted" do
|
207
|
-
notification.destroy.
|
207
|
+
expect(notification.destroy).to be_falsy
|
208
208
|
notification.errors.should == {message: 'notification not persisted yet'}
|
209
209
|
end
|
210
210
|
it "should destroy the notification on PassaporteWeb if the notification has not been read and is scheduled", vcr: true do
|
211
|
-
notification.save('application').
|
211
|
+
expect(notification.save('application')).to be_truthy
|
212
212
|
notification.read_at.should be_nil
|
213
213
|
notification.scheduled_to.should == "2013-04-06 00:00:00"
|
214
|
-
notification.destroy.
|
214
|
+
expect(notification.destroy).to be_truthy
|
215
215
|
end
|
216
216
|
it "should not exclude non-scheduled notification", vcr: true do
|
217
217
|
notification.scheduled_to = nil
|
218
|
-
notification.save('application').
|
219
|
-
notification.destroy.
|
218
|
+
expect(notification.save('application')).to be_truthy
|
219
|
+
expect(notification.destroy).to be_falsy
|
220
220
|
notification.errors.should == "Only scheduled notifications can be deleted via API"
|
221
221
|
end
|
222
222
|
end
|