human_error 1.5.0 → 1.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0893133a37cc53ee88bd4707062f00d421195351
4
- data.tar.gz: dd2a17883a04d8ac05602d2917164820c58e7ca8
3
+ metadata.gz: 233105511c18274a9f7d45688aa2f653e2752d6b
4
+ data.tar.gz: 754c7919eee3ed9ed509d0ee6352fcca69c8e8d1
5
5
  SHA512:
6
- metadata.gz: f8567ff0577847aa5c5a53b5b1c70b256d1d446ea000c96c0adbd84165569479cc0e016ff428e62a23c89b2f8a38dcee8a98e24a45b11498a908c1272959fc92
7
- data.tar.gz: f9a5302081b1a47efc8dba8f42b61a9572dfd621270987545b6bcf09851f6060f9aff4d9129b7338f03b902880bda687d88453e2bc7d5c15f771e6913ffa9974
6
+ metadata.gz: d41c765a7c3ddeb2970e6c4cf50bedaad4370bcb19f13a28160800dcb5cd2540a90013bc1284af0b8108e04ebf3b499e7bf2057ab4598f9934abfb56ad4a29a5
7
+ data.tar.gz: 82eca3b690cdec516671458e72fa2a9dc8ce35c99b5de39be1d49e4a41ea1c56a70d16667f3c34d504181a67dd52bb2e81a70044028ca553996c51daab78402b
@@ -14,6 +14,7 @@ class ErrorCodeDirectory
14
14
  'HumanError::Errors::ResourcePersistenceError' => 1006,
15
15
  'Apill::Errors::InvalidApiRequestError' => 1007,
16
16
  'HumanError::Errors::DuplicateAuthenticationError' => 1008,
17
+ 'HumanError::Errors::AssociationError' => 1009,
17
18
  }
18
19
  end
19
20
  end
@@ -6,3 +6,4 @@ require 'human_error/errors/authentication_errors/duplicate_authentication_error
6
6
  require 'human_error/errors/crud_error'
7
7
  require 'human_error/errors/crud_errors/resource_not_found_error'
8
8
  require 'human_error/errors/crud_errors/resource_persistence_error'
9
+ require 'human_error/errors/crud_errors/association_error'
@@ -0,0 +1,33 @@
1
+ require 'human_error/errors/crud_error'
2
+ require 'human_error/errors/request_error'
3
+
4
+ class HumanError
5
+ module Errors
6
+ class AssociationError < RequestError
7
+ include CrudError
8
+
9
+ attr_accessor :association_name,
10
+ :association_id,
11
+ :attributes
12
+
13
+ def http_status
14
+ 422
15
+ end
16
+
17
+ def developer_message
18
+ "The #{association_name} that you attempted to associate with the #{resource_name} was not valid."
19
+ end
20
+
21
+ def developer_details
22
+ {
23
+ resource_name => attributes,
24
+ "#{association_name} id" => association_id
25
+ }
26
+ end
27
+
28
+ def friendly_message
29
+ "Sorry! There was a problem when we tried to set the #{association_name} on that #{resource_name}."
30
+ end
31
+ end
32
+ end
33
+ end
@@ -13,10 +13,6 @@ class ResourcePersistenceError < RequestError
13
13
  422
14
14
  end
15
15
 
16
- def knowledgebase_article_id
17
- '1234567890'
18
- end
19
-
20
16
  def developer_message
21
17
  "One or more of the attributes on the #{resource_name} you attempted to #{action} is invalid."
22
18
  end
@@ -14,6 +14,7 @@ class KnowledgebaseIdDirectory
14
14
  'HumanError::Errors::ResourcePersistenceError' => '1234567890',
15
15
  'Apill::Errors::InvalidApiRequestError' => '1234567890',
16
16
  'HumanError::Errors::DuplicateAuthenticationError' => '1234567890',
17
+ 'HumanError::Errors::AssociationError' => '1234567890',
17
18
  }
18
19
  end
19
20
  end
@@ -1,3 +1,3 @@
1
1
  class HumanError
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.1'
3
3
  end
@@ -0,0 +1,48 @@
1
+ require 'rspectacular'
2
+ require 'human_error/errors/crud_errors/association_error'
3
+
4
+ class HumanError
5
+ module Errors
6
+ describe AssociationError do
7
+ let(:error) { AssociationError.new }
8
+
9
+ it 'has a status of 422' do
10
+ expect(error.http_status).to eql 422
11
+ end
12
+
13
+ it 'has a code of 1009' do
14
+ expect(error.code).to eql 1009
15
+ end
16
+
17
+ it 'has a knowledgebase article ID of 1234567890' do
18
+ expect(error.knowledgebase_article_id).to eql '1234567890'
19
+ end
20
+
21
+ it 'includes the resource name and action in the developer message' do
22
+ error = AssociationError.new association_name: 'black leather trenchcoat',
23
+ resource_name: 'Neo'
24
+
25
+ expect(error.developer_message).to eql "The black leather trenchcoat that you attempted to associate with the Neo was not valid."
26
+ end
27
+
28
+ it 'includes the resource name and action in the developer details' do
29
+ error = AssociationError.new association_name: 'black leather trenchcoat',
30
+ resource_name: 'Neo',
31
+ attributes: 'what is the matrix',
32
+ association_id: '123'
33
+
34
+ expect(error.developer_details).to eql(
35
+ 'Neo' => 'what is the matrix',
36
+ 'black leather trenchcoat id' => '123',
37
+ )
38
+ end
39
+
40
+ it 'includes the resource name and action in the friendly message' do
41
+ error = AssociationError.new association_name: 'black leather trenchcoat',
42
+ resource_name: 'Neo'
43
+
44
+ expect(error.friendly_message).to eql "Sorry! There was a problem when we tried to set the black leather trenchcoat on that Neo."
45
+ end
46
+ end
47
+ end
48
+ 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.5.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -71,6 +71,7 @@ files:
71
71
  - lib/human_error/errors/authentication_errors/invalid_token_error.rb
72
72
  - lib/human_error/errors/authentication_errors/invalid_username_or_password_error.rb
73
73
  - lib/human_error/errors/crud_error.rb
74
+ - lib/human_error/errors/crud_errors/association_error.rb
74
75
  - lib/human_error/errors/crud_errors/resource_not_found_error.rb
75
76
  - lib/human_error/errors/crud_errors/resource_persistence_error.rb
76
77
  - lib/human_error/errors/request_error.rb
@@ -82,6 +83,7 @@ files:
82
83
  - spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
83
84
  - spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb
84
85
  - spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
86
+ - spec/lib/human_error/errors/crud_errors/association_error_spec.rb
85
87
  - spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
86
88
  - spec/lib/human_error/errors/crud_errors/resource_persistence_error_spec.rb
87
89
  - spec/lib/human_error/errors/request_error_spec.rb
@@ -116,6 +118,7 @@ test_files:
116
118
  - spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
117
119
  - spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb
118
120
  - spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
121
+ - spec/lib/human_error/errors/crud_errors/association_error_spec.rb
119
122
  - spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
120
123
  - spec/lib/human_error/errors/crud_errors/resource_persistence_error_spec.rb
121
124
  - spec/lib/human_error/errors/request_error_spec.rb