introspective_grape 0.3.2 → 0.3.3

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +16 -3
  4. data/CHANGELOG.md +16 -8
  5. data/README.md +6 -6
  6. data/gemfiles/2.0.0-Gemfile +1 -1
  7. data/gemfiles/Gemfile.rails.3.2.22 +1 -1
  8. data/gemfiles/Gemfile.rails.4.1.13 +1 -1
  9. data/gemfiles/Gemfile.rails.4.2.7.1 +1 -1
  10. data/gemfiles/Gemfile.rails.4.2.7.1.new.swagger +1 -1
  11. data/gemfiles/Gemfile.rails.4.2.8 +1 -1
  12. data/gemfiles/Gemfile.rails.5.0.1 +1 -1
  13. data/gemfiles/Gemfile.rails.master +1 -1
  14. data/introspective_grape.gemspec +2 -2
  15. data/lib/introspective_grape/api.rb +16 -16
  16. data/lib/introspective_grape/camel_snake.rb +5 -4
  17. data/lib/introspective_grape/filters.rb +2 -2
  18. data/lib/introspective_grape/formatter/camel_json.rb +12 -9
  19. data/lib/introspective_grape/helpers.rb +3 -3
  20. data/lib/introspective_grape/snake_params.rb +2 -1
  21. data/lib/introspective_grape/traversal.rb +5 -5
  22. data/lib/introspective_grape/validators.rb +1 -1
  23. data/lib/introspective_grape/version.rb +1 -1
  24. data/spec/dummy/app/api/dummy/chat_api.rb +4 -4
  25. data/spec/dummy/app/api/dummy/company_api.rb +1 -1
  26. data/spec/dummy/app/api/dummy/location_api.rb +2 -2
  27. data/spec/dummy/app/api/dummy/project_api.rb +1 -1
  28. data/spec/dummy/app/api/dummy/sessions.rb +3 -3
  29. data/spec/dummy/app/api/dummy/user_api.rb +1 -1
  30. data/spec/dummy/app/api/dummy_api.rb +0 -3
  31. data/spec/dummy/app/api/error_handlers.rb +2 -2
  32. data/spec/dummy/app/models/admin_user.rb +1 -1
  33. data/spec/dummy/app/models/chat.rb +1 -1
  34. data/spec/dummy/app/models/chat_message.rb +1 -1
  35. data/spec/dummy/app/models/chat_user.rb +1 -1
  36. data/spec/dummy/app/models/company.rb +1 -1
  37. data/spec/dummy/app/models/image.rb +1 -1
  38. data/spec/dummy/app/models/project.rb +1 -1
  39. data/spec/dummy/app/models/user.rb +1 -1
  40. data/spec/dummy/app/models/user/chatter.rb +4 -4
  41. data/spec/dummy/app/models/user_location.rb +4 -4
  42. data/spec/dummy/app/policies/location_policy.rb +1 -1
  43. data/spec/dummy/app/policies/project_policy.rb +5 -5
  44. data/spec/dummy/app/policies/role_policy.rb +2 -2
  45. data/spec/dummy/app/policies/user_policy.rb +1 -1
  46. data/spec/dummy/db/migrate/20150414213154_add_user_authentication_token.rb +1 -1
  47. data/spec/dummy/db/migrate/20150601212924_create_location_beacons.rb +1 -1
  48. data/spec/dummy/db/migrate/20150616205336_add_role_user_constraint.rb +1 -1
  49. data/spec/dummy/db/migrate/20150727214950_add_confirmable_to_devise.rb +1 -1
  50. data/spec/dummy/db/migrate/20150820190524_add_user_names.rb +2 -2
  51. data/spec/models/project_spec.rb +3 -3
  52. data/spec/models/role_spec.rb +6 -6
  53. data/spec/models/team_spec.rb +2 -2
  54. data/spec/models/team_user_spec.rb +4 -4
  55. data/spec/models/user_location_spec.rb +1 -1
  56. data/spec/models/user_project_job_spec.rb +2 -2
  57. data/spec/models/user_spec.rb +10 -10
  58. data/spec/requests/chat_api_spec.rb +7 -7
  59. data/spec/requests/company_api_spec.rb +4 -4
  60. data/spec/requests/location_api_spec.rb +10 -10
  61. data/spec/requests/project_api_spec.rb +18 -18
  62. data/spec/requests/role_api_spec.rb +1 -1
  63. data/spec/requests/sessions_api_spec.rb +3 -3
  64. data/spec/requests/swagger_spec.rb +1 -1
  65. data/spec/requests/user_api_spec.rb +13 -13
  66. data/spec/support/blueprints.rb +10 -10
  67. data/spec/support/location_helper.rb +6 -6
  68. data/spec/support/request_helpers.rb +4 -3
  69. metadata +6 -10
  70. data/lib/.DS_Store +0 -0
  71. data/spec/.DS_Store +0 -0
  72. data/spec/dummy/app/api/.DS_Store +0 -0
@@ -34,7 +34,7 @@ describe Dummy::RoleAPI, type: :request do
34
34
  response.code.should == '400'
35
35
  json['error'].should =~ /user has already been assigned that role/
36
36
  end
37
-
37
+
38
38
  it 'validates ownable type value specified in grape_validations' do
39
39
  post '/api/v1/roles', { user_id: user.id, ownable_type: 'NotCompany' }
40
40
  response.code.should == '400'
@@ -9,7 +9,7 @@ describe Dummy::Sessions, type: :request do
9
9
 
10
10
  let(:user) { User.last }
11
11
 
12
- context :sign_in do
12
+ context :sign_in do
13
13
 
14
14
  it "should set a user token on login" do
15
15
  post '/api/v1/sessions', { login: user.email, password: 'abc12345', token: true }
@@ -29,7 +29,7 @@ describe Dummy::Sessions, type: :request do
29
29
  end
30
30
 
31
31
  context :sign_out do
32
- it "should reset a user's auth token" do
32
+ it "should reset a user's auth token" do
33
33
  user.authentication_token = "1234567890"
34
34
  user.save!
35
35
  delete "/api/v1/sessions", { api_key: "1234567890" }
@@ -38,7 +38,7 @@ describe Dummy::Sessions, type: :request do
38
38
  user.authentication_token.should be_nil
39
39
  end
40
40
 
41
- it "signing out an already signed-out user should look fine, right?" do
41
+ it "signing out an already signed-out user should look fine, right?" do
42
42
  user.authentication_token = "1234567890"
43
43
  user.save!
44
44
  delete "/api/v1/sessions", { api_key: "1234567890" }
@@ -3,7 +3,7 @@ describe GrapeSwagger, type: :request do
3
3
 
4
4
  context :swagger_doc do
5
5
 
6
- it "should render swagger docs for the api" do
6
+ it "should render swagger docs for the api" do
7
7
  get '/api/v1/swagger_doc'
8
8
  response.should be_success
9
9
  json = JSON.parse( response.body )
@@ -12,7 +12,7 @@ describe Dummy::UserAPI, type: :request do
12
12
  u.save
13
13
  end
14
14
 
15
- context :index do
15
+ context :index do
16
16
 
17
17
  it "should return a list of users" do
18
18
  get '/api/v1/users'
@@ -100,7 +100,7 @@ describe Dummy::UserAPI, type: :request do
100
100
 
101
101
  it "should return only the records that were created at a nested endpoint" do
102
102
  new_company = Company.make!
103
- post "/api/v1/users/#{user.id}/roles", {ownable_type: 'Company', ownable_id: new_company.id}
103
+ post "/api/v1/users/#{user.id}/roles", {ownable_type: 'Company', ownable_id: new_company.id}
104
104
  response.should be_success
105
105
  json.size.should eq 1
106
106
  json.first['ownable_id'].should eq new_company.id
@@ -115,7 +115,7 @@ describe Dummy::UserAPI, type: :request do
115
115
  { ownable_id: company.id, ownable_type: 'Company' }
116
116
  end
117
117
 
118
- it "should create a company admin" do
118
+ it "should create a company admin" do
119
119
  params[:roles_attributes].push(role)
120
120
  post "/api/v1/users", params
121
121
  response.should be_success
@@ -123,19 +123,19 @@ describe Dummy::UserAPI, type: :request do
123
123
  end
124
124
 
125
125
 
126
- context "Project default passwords for new users" do
126
+ context "Project default passwords for new users" do
127
127
  let(:job) { Job.make! }
128
128
  let(:project) { Project.make!(jobs: [job], default_password: "super secret") }
129
- let(:params) do
129
+ let(:params) do
130
130
  {
131
131
  email: 'test@test.com', password: '',
132
132
  user_project_jobs_attributes: [ job_id: project.jobs.first.id, project_id: project.id ]
133
- }
133
+ }
134
134
  end
135
135
 
136
136
  it "should set an empty password to an assigned project's default password" do
137
137
  post "/api/v1/users", params
138
- response.should be_success
138
+ response.should be_success
139
139
  json['user_project_jobs_attributes'][0]['name'].should == project.name
140
140
  json['user_project_jobs_attributes'][0]['title'].should == job.title
141
141
  end
@@ -176,7 +176,7 @@ describe Dummy::UserAPI, type: :request do
176
176
  it "should require a devise re-confirmation email to update a user's email address" do
177
177
  new_email = 'new.email@test.com'
178
178
  old_email = user.email
179
- put "/api/v1/users/#{user.id}", { email: new_email }
179
+ put "/api/v1/users/#{user.id}", { email: new_email }
180
180
  response.should be_success
181
181
  user.reload
182
182
  user.email.should == old_email
@@ -186,30 +186,30 @@ describe Dummy::UserAPI, type: :request do
186
186
 
187
187
  it "should skip the confirmation and update a user's email address" do
188
188
  new_email = 'new.email@test.com'
189
- put "/api/v1/users/#{user.id}", { email: new_email, skip_confirmation_email: true }
189
+ put "/api/v1/users/#{user.id}", { email: new_email, skip_confirmation_email: true }
190
190
  response.should be_success
191
191
  json['email'].should == new_email
192
192
  user.reload
193
193
  user.email.should == new_email
194
194
  end
195
195
 
196
- it "should validate the uniqueness of a user role" do
196
+ it "should validate the uniqueness of a user role" do
197
197
  put "/api/v1/users/#{user.id}", { roles_attributes: [{ownable_type: 'Company', ownable_id: company.id}] }
198
198
  response.should_not be_success
199
199
  json['error'].should =~ /user has already been assigned that role/
200
200
  user.admin?(company).should be_truthy
201
201
  end
202
202
 
203
- it "should update a user to be company admin" do
203
+ it "should update a user to be company admin" do
204
204
  c = Company.make
205
205
  c.save!
206
- put "/api/v1/users/#{user.id}", { roles_attributes: [{ownable_type: 'Company', ownable_id: c.id}] }
206
+ put "/api/v1/users/#{user.id}", { roles_attributes: [{ownable_type: 'Company', ownable_id: c.id}] }
207
207
  response.should be_success
208
208
  user.reload
209
209
  user.admin?(c).should be_truthy
210
210
  end
211
211
 
212
- it "should destroy a user's company admin role" do
212
+ it "should destroy a user's company admin role" do
213
213
  user.admin?(company).should be_truthy
214
214
  put "/api/v1/users/#{user.id}", { roles_attributes: [{id: user.roles.last.id, _destroy: '1'}] }
215
215
  response.should be_success
@@ -24,8 +24,8 @@ def paragraph(n=25)
24
24
  end
25
25
 
26
26
  Company.blueprint do
27
- name { words }
28
- short_name { syllable(10) }
27
+ name { words }
28
+ short_name { syllable(10) }
29
29
  end
30
30
 
31
31
  User.blueprint do
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  Role.blueprint {
40
40
  user_id { User.first||User.make }
41
- ownable_id { Company.first||Company.make }
41
+ ownable_id { Company.first||Company.make }
42
42
  ownable_type { 'Company' }
43
43
  }
44
44
 
@@ -47,7 +47,7 @@ Locatable.blueprint {
47
47
  locatable { Company.make }
48
48
  }
49
49
  Location.blueprint {
50
- name { (65+rand(8)).chr+"1"}
50
+ name { (65+rand(8)).chr+"1"}
51
51
  kind { 'gate' }
52
52
  gps { LocationGps.new(lat: 37.615223, lng: -122.389977 ) }
53
53
  }
@@ -65,12 +65,12 @@ LocationGps.blueprint {
65
65
  # place the point randomly within about a mile radius of the TEST airport (LocationHelper)
66
66
  lat { 37.615223 + 0.01609*rand(0.1) * (rand(2) > 0 ? 1 : -1) }
67
67
  lng { -122.389977 + 0.01609*rand(0.1)*Math.cos(37.615223*Math::PI/180) * (rand(2) > 0 ? 1 : -1) }
68
- alt { 0 }
68
+ alt { 0 }
69
69
  }
70
70
 
71
71
  Project.blueprint {
72
72
  name { words(2) }
73
- owner { Company.make }
73
+ owner { Company.make }
74
74
  jobs { [Job.make, Job.make] }
75
75
  admins { [User.make] }
76
76
  }
@@ -78,7 +78,7 @@ Job.blueprint {
78
78
  title { words(2) }
79
79
  }
80
80
  UserProjectJob.blueprint {
81
- user { User.make }
81
+ user { User.make }
82
82
  project { Project.make }
83
83
  job { Job.make }
84
84
  }
@@ -88,9 +88,9 @@ ProjectJob.blueprint {
88
88
  }
89
89
 
90
90
 
91
- Team.blueprint {
91
+ Team.blueprint {
92
92
  p = Project.make
93
- project { p }
93
+ project { p }
94
94
  creator { p.admins.first }
95
95
  name { words(2) }
96
96
  }
@@ -98,6 +98,6 @@ TeamUser.blueprint {
98
98
  t = Team.make
99
99
  t.project.users.push User.make(projects: [t.project])
100
100
  team { t }
101
- user { t.project.users.first }
101
+ user { t.project.users.first }
102
102
  }
103
103
 
@@ -10,11 +10,11 @@ module LocationHelper
10
10
  ### build an airport with 8 terminals each with 3 gates along each cardinal and ordinal
11
11
  ### axis, for two companies each with their own set of bluetooth beacons at every gate:
12
12
  ###
13
- ### (1)A B C
14
- ### \|/
15
- ### (8)H-*-D e.g.->(Terminal D with gates D1, D2, and D3)
16
- ### /|\
17
- ### G F E
13
+ ### (1)A B C
14
+ ### \|/
15
+ ### (8)H-*-D e.g.->(Terminal D with gates D1, D2, and D3)
16
+ ### /|\
17
+ ### G F E
18
18
  @sprocketCo, @widgetCo = test_companies
19
19
 
20
20
  @airport = Location.find_by_name("TEST") || Location.new(name:'TEST',kind:'airport')
@@ -39,7 +39,7 @@ module LocationHelper
39
39
  lat += (1..3).cover?(terminal) ? adj : 0
40
40
  lat -= (5..7).cover?(terminal) ? adj : 0
41
41
 
42
- adj *= Math.cos(37.615223*Math::PI/180)
42
+ adj *= Math.cos(37.615223*Math::PI/180)
43
43
  lng += (3..5).cover?( terminal) ? adj : 0
44
44
  lng -= [1,7,8].include?(terminal) ? adj : 0
45
45
 
@@ -1,18 +1,19 @@
1
1
  require 'introspective_grape/camel_snake'
2
2
  module RequestHelpers
3
+
3
4
  def json
4
- @json ||= JSON.parse(response.body).with_snake_keys(true)
5
+ @json ||= CamelSnakeKeys.snake_keys(JSON.parse(response.body), true)
5
6
  end
6
7
 
7
8
  def with_authentication(role=:superuser)
8
9
  return if @without_authentication
9
10
  current_user = User.new #double('User')
10
- allow(current_user).to receive(:admin?) { true } if role == :superuser
11
+ allow(current_user).to receive(:admin?) { true } if role == :superuser
11
12
  allow(current_user).to receive(:superuser?) { true } if role == :superuser
12
13
 
13
14
  # Stubbing API helper methods requires this very nearly undocumented invokation
14
15
  Grape::Endpoint.before_each do |endpoint|
15
- allow(endpoint).to receive(:current_user) { current_user }
16
+ allow(endpoint).to receive(:current_user) { current_user }
16
17
  end
17
18
  end
18
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: introspective_grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: camel_snake_keys
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - ">"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 0.0.4
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - ">"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 0.0.4
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: sqlite3
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -256,7 +256,6 @@ files:
256
256
  - gemfiles/Gemfile.rails.5.0.1
257
257
  - gemfiles/Gemfile.rails.master
258
258
  - introspective_grape.gemspec
259
- - lib/.DS_Store
260
259
  - lib/introspective_grape.rb
261
260
  - lib/introspective_grape/api.rb
262
261
  - lib/introspective_grape/camel_snake.rb
@@ -270,11 +269,9 @@ files:
270
269
  - lib/introspective_grape/validators.rb
271
270
  - lib/introspective_grape/version.rb
272
271
  - lib/tasks/introspective_grape_tasks.rake
273
- - spec/.DS_Store
274
272
  - spec/dummy/Gemfile
275
273
  - spec/dummy/README.rdoc
276
274
  - spec/dummy/Rakefile
277
- - spec/dummy/app/api/.DS_Store
278
275
  - spec/dummy/app/api/api_helpers.rb
279
276
  - spec/dummy/app/api/dummy/chat_api.rb
280
277
  - spec/dummy/app/api/dummy/company_api.rb
@@ -443,7 +440,6 @@ test_files:
443
440
  - spec/dummy/Gemfile
444
441
  - spec/dummy/README.rdoc
445
442
  - spec/dummy/Rakefile
446
- - spec/dummy/app/api/.DS_Store
447
443
  - spec/dummy/app/api/api_helpers.rb
448
444
  - spec/dummy/app/api/dummy/chat_api.rb
449
445
  - spec/dummy/app/api/dummy/company_api.rb
data/lib/.DS_Store DELETED
Binary file
data/spec/.DS_Store DELETED
Binary file
Binary file