human_error 1.2.0 → 1.3.0

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: b0ba5cd0b3771844ca8a0d3b4811467b639eb10b
4
- data.tar.gz: 33ebdd2f1294a257e15a0797e940027c72e53b15
3
+ metadata.gz: 8b87c5a22db771619d2acebf4366be06025cf2fa
4
+ data.tar.gz: 9264a39f94e6c6b054b608564ada1347418c907f
5
5
  SHA512:
6
- metadata.gz: 2bb40250f8a0da4e325ed1c03d8a8b15908515835bf0a5c351e65f7dcda0ec10387d108ac986cfee9e9a43bba89b8be20b0cac8f12d13eb2aa39bac858c063f7
7
- data.tar.gz: 802c6a60c38c83858f9c272cc7aee9ba93244b1b8ed3d1cf4a7755476ddb9ee63745c96586e8ec79efcbd4efdcae3b3835550e8c2e492d11ee2380afd62e3ffe
6
+ metadata.gz: d2cf3e74bda9aca504b2f17aef58a0533d29df07f91974ca94d43a81427b408fd255acbc88b6de1c71d26c470a6c8f0dd28a92130417975530b3eba8e1205315
7
+ data.tar.gz: f14a129a5374268528578006185a1851168be6c7ef99c2d04da8337ffe83b1ff153ae3d8cca8964bf04bc1334b79e4b9076e858f0b32cb0b26de2b53976bdb7b
@@ -13,6 +13,7 @@ class ErrorCodeDirectory
13
13
  'HumanError::Errors::ResourceNotFoundError' => 1005,
14
14
  'HumanError::Errors::ResourcePersistenceError' => 1006,
15
15
  'Apill::Errors::InvalidApiRequestError' => 1007,
16
+ 'HumanError::Errors::DuplicateAuthenticationError' => 1008,
16
17
  }
17
18
  end
18
19
  end
@@ -0,0 +1,34 @@
1
+ require 'human_error/errors/request_error'
2
+ require 'human_error/errors/authentication_error'
3
+
4
+ module HumanError
5
+ module Errors
6
+ class DuplicateAuthenticationError < RequestError
7
+ include AuthenticationError
8
+
9
+ attr_accessor :provider,
10
+ :provider_user_id,
11
+ :user_id
12
+
13
+ def http_status
14
+ 409
15
+ end
16
+
17
+ def developer_message
18
+ 'The authentication you attempted to register has already been registered by another user. We do not currently support allowing multiple users to be connected to the same authentication.'
19
+ end
20
+
21
+ def developer_details
22
+ {
23
+ 'provider' => provider,
24
+ 'provider_user_id' => provider_user_id,
25
+ 'user_id' => user_id,
26
+ }
27
+ end
28
+
29
+ def friendly_message
30
+ "Sorry! Someone else has already registered this #{provider} login."
31
+ end
32
+ end
33
+ end
34
+ end
@@ -8,12 +8,6 @@ class InvalidTokenError < RequestError
8
8
 
9
9
  attr_accessor :authentication_token
10
10
 
11
- def initialize(authentication_token: nil, **args)
12
- self.authentication_token = authentication_token
13
-
14
- super **args
15
- end
16
-
17
11
  def http_status
18
12
  401
19
13
  end
@@ -8,12 +8,6 @@ class InvalidUsernameOrPasswordError < RequestError
8
8
 
9
9
  attr_accessor :username
10
10
 
11
- def initialize(username: nil, **args)
12
- self.username = username
13
-
14
- super **args
15
- end
16
-
17
11
  def http_status
18
12
  401
19
13
  end
@@ -9,13 +9,6 @@ class ResourcePersistenceError < RequestError
9
9
  attr_accessor :errors,
10
10
  :attributes
11
11
 
12
- def initialize(errors: nil, attributes: nil, **args)
13
- self.errors = errors
14
- self.attributes = attributes
15
-
16
- super **args
17
- end
18
-
19
12
  def http_status
20
13
  422
21
14
  end
@@ -2,6 +2,7 @@ require 'human_error/errors/request_error'
2
2
  require 'human_error/errors/authentication_error'
3
3
  require 'human_error/errors/authentication_errors/invalid_token_error'
4
4
  require 'human_error/errors/authentication_errors/invalid_username_or_password_error'
5
+ require 'human_error/errors/authentication_errors/duplicate_authentication_error'
5
6
  require 'human_error/errors/crud_error'
6
7
  require 'human_error/errors/crud_errors/resource_not_found_error'
7
8
  require 'human_error/errors/crud_errors/resource_persistence_error'
@@ -13,6 +13,7 @@ class KnowledgebaseIdDirectory
13
13
  'HumanError::Errors::ResourceNotFoundError' => '1234567890',
14
14
  'HumanError::Errors::ResourcePersistenceError' => '1234567890',
15
15
  'Apill::Errors::InvalidApiRequestError' => '1234567890',
16
+ 'HumanError::Errors::DuplicateAuthenticationError' => '1234567890',
16
17
  }
17
18
  end
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module HumanError
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -0,0 +1,42 @@
1
+ require 'rspectacular'
2
+ require 'human_error/errors/authentication_errors/duplicate_authentication_error'
3
+
4
+ module HumanError
5
+ module Errors
6
+ describe DuplicateAuthenticationError do
7
+ let(:error) { DuplicateAuthenticationError.new(provider: 'flibbity',
8
+ provider_user_id: '12345',
9
+ user_id: '54321',) }
10
+
11
+ it 'has a status of 409' do
12
+ expect(error.http_status).to eql 409
13
+ end
14
+
15
+ it 'has a code of 1008' do
16
+ expect(error.code).to eql 1008
17
+ end
18
+
19
+ it 'has a knowledgebase article ID of 1234567890' do
20
+ expect(error.knowledgebase_article_id).to eql '1234567890'
21
+ end
22
+
23
+ it 'can output the developer message' do
24
+ expect(error.developer_message).to eql 'The authentication you attempted to register has already been registered by another user. We do not currently support allowing multiple users to be connected to the same authentication.'
25
+ end
26
+
27
+ it 'can output the developer details' do
28
+ expect(error.developer_details).to eql(
29
+ {
30
+ 'provider' => 'flibbity',
31
+ 'provider_user_id' => '12345',
32
+ 'user_id' => '54321',
33
+ }
34
+ )
35
+ end
36
+
37
+ it 'can output the friendly message' do
38
+ expect(error.friendly_message).to eql 'Sorry! Someone else has already registered this flibbity login.'
39
+ end
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_error
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -67,6 +67,7 @@ files:
67
67
  - lib/human_error/error_code_directory.rb
68
68
  - lib/human_error/errors.rb
69
69
  - lib/human_error/errors/authentication_error.rb
70
+ - lib/human_error/errors/authentication_errors/duplicate_authentication_error.rb
70
71
  - lib/human_error/errors/authentication_errors/invalid_token_error.rb
71
72
  - lib/human_error/errors/authentication_errors/invalid_username_or_password_error.rb
72
73
  - lib/human_error/errors/crud_error.rb
@@ -78,6 +79,7 @@ files:
78
79
  - lib/human_error/version.rb
79
80
  - spec/lib/human_error/configuration_spec.rb
80
81
  - spec/lib/human_error/error_spec.rb
82
+ - spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
81
83
  - spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb
82
84
  - spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
83
85
  - spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
@@ -110,6 +112,7 @@ summary: Common Error Extensions and Helpers
110
112
  test_files:
111
113
  - spec/lib/human_error/configuration_spec.rb
112
114
  - spec/lib/human_error/error_spec.rb
115
+ - spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
113
116
  - spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb
114
117
  - spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
115
118
  - spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb