gris_accounts 0.0.1 → 0.0.2

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: 3dcdb91930a83ca1949bfb729fa1e1553f1bcced
4
- data.tar.gz: 528643073ce1d2ba690775e7b65a0ba9d14b3c8e
3
+ metadata.gz: f085c9f1964c38a7660ebd4be7cd6d642b36fb1e
4
+ data.tar.gz: 9a8ffd3cabd774027dd0199bd2ca7502214b671c
5
5
  SHA512:
6
- metadata.gz: 0ac42c4d4c033977b86559adadbac5d677bf05891bb4ba4193925609c4e3d03b02b1bace178cbe4c34adff3259b9d3cda61cf40d5511294594c9e4d3d6dfd148
7
- data.tar.gz: 534b1064056979c19209575c24b7664e764aa966d34ac26c102b379183e730d68ad9a1b7efbd814d82fef39d07491634bc45c61c6240b05c6d8fde4a23e239c8
6
+ metadata.gz: ec30a91cc7ff902a671285befb50eb7dc0debaaa6233ac93d88bb481cbbe5c923d6ff4efa5f11ec8382b8ee6bde488a4ca7df6f9a76edbdeb94428d53e00d606
7
+ data.tar.gz: 8c39854c5522e3f4306a49e94602947b225731bdfc339a04daf8ef229ffccbfa75ddb880c3ca6d407b7e3a3155c0da2b731e5e6753064153de0fe1e29f61f629
@@ -1,10 +1,19 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-08-07 21:57:08 -0400 using RuboCop version 0.32.1.
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-10-08 15:58:27 -0400 using RuboCop version 0.34.2.
3
4
  # The point is for the user to remove these configuration records
4
5
  # one by one as the offenses are removed from the code base.
5
6
  # Note that changes in the inspected code, or installation of new
6
7
  # versions of RuboCop, may require this file to be generated again.
7
8
 
8
- # Offense count: 4
9
+ # Offense count: 1
10
+ # Configuration parameters: AllowURI, URISchemes.
11
+ Metrics/LineLength:
12
+ Max: 83
13
+
14
+ # Offense count: 2
15
+ # Configuration parameters: Exclude.
9
16
  Style/Documentation:
10
- Enabled: false
17
+ Exclude:
18
+ - 'lib/gris_accounts/authorization_helpers.rb'
19
+ - 'lib/gris_accounts/version.rb'
@@ -2,13 +2,13 @@ module GrisAccounts
2
2
  module AuthorizationHelpers
3
3
  def require_access_to_account(account_id)
4
4
  @account_ids = payload_content['account_ids'] if payload_content
5
- fail 'Forbidden.' unless @account_ids &&
6
- (@account_ids.include? account_id.to_i)
5
+ gris_error!('Forbidden.', 403) unless @account_ids &&
6
+ (@account_ids.include? account_id.to_i)
7
7
  end
8
8
 
9
9
  def user_id_from_payload
10
10
  @user_id = payload_content['id'] if payload_content
11
- fail 'Forbidden.' unless @user_id
11
+ gris_error!('Forbidden.', 403) unless @user_id
12
12
  end
13
13
 
14
14
  private
@@ -1,3 +1,3 @@
1
1
  module GrisAccounts
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,11 +1,8 @@
1
1
  require 'spec_helper'
2
+ require 'gris/grape_extensions/error_helpers'
2
3
 
3
4
  describe GrisAccounts::AuthorizationHelpers do
4
- class EndpointClass
5
- include GrisAccounts::AuthorizationHelpers
6
- end
7
-
8
- let(:helper) { EndpointClass.new }
5
+ let(:helper) { SpecApiErrorHelper.new }
9
6
 
10
7
  context 'require_access_to_account' do
11
8
  let(:account_id) { 1 }
@@ -37,9 +34,10 @@ describe GrisAccounts::AuthorizationHelpers do
37
34
  end
38
35
 
39
36
  it 'raises Forbidden error' do
40
- expect do
41
- helper.require_access_to_account(account_id)
42
- end.to raise_error(RuntimeError, 'Forbidden.')
37
+ helper.require_access_to_account(account_id)
38
+ expect(helper.message)
39
+ .to eq(message: { message: 'Forbidden.', status: 403 }, status: 403)
40
+ expect(helper.thrown).to eq(:error)
43
41
  end
44
42
  end
45
43
  end
@@ -68,9 +66,10 @@ describe GrisAccounts::AuthorizationHelpers do
68
66
  end
69
67
 
70
68
  it 'raises Forbidden error' do
71
- expect do
72
- helper.user_id_from_payload
73
- end.to raise_error(RuntimeError, 'Forbidden.')
69
+ helper.user_id_from_payload
70
+ expect(helper.message)
71
+ .to eq(message: { message: 'Forbidden.', status: 403 }, status: 403)
72
+ expect(helper.thrown).to eq(:error)
74
73
  end
75
74
  end
76
75
  end
@@ -1,3 +1,5 @@
1
1
  require 'gris'
2
2
  require 'gris_accounts'
3
3
  require 'byebug'
4
+
5
+ Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
@@ -0,0 +1,13 @@
1
+ # Mock API helper
2
+ class SpecApiErrorHelper
3
+ include Gris::ErrorHelpers
4
+ include GrisAccounts::AuthorizationHelpers
5
+
6
+ attr_accessor :message
7
+ attr_accessor :thrown
8
+
9
+ def throw(thrown, message)
10
+ @message = message
11
+ @thrown = thrown
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gris_accounts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Fareed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gris
@@ -116,6 +116,7 @@ files:
116
116
  - lib/gris_accounts/version.rb
117
117
  - spec/authorization_helpers_spec.rb
118
118
  - spec/spec_helper.rb
119
+ - spec/support/spec_api_error_helper.rb
119
120
  homepage: https://github.com/dylanfareed/gris_accounts
120
121
  licenses:
121
122
  - MIT
@@ -136,10 +137,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  requirements: []
138
139
  rubyforge_project:
139
- rubygems_version: 2.4.5
140
+ rubygems_version: 2.4.5.1
140
141
  signing_key:
141
142
  specification_version: 4
142
143
  summary: Gris JWT Account resource authorization helpers.
143
144
  test_files:
144
145
  - spec/authorization_helpers_spec.rb
145
146
  - spec/spec_helper.rb
147
+ - spec/support/spec_api_error_helper.rb