introspective_grape 0.0.4 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +1164 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +4 -2
  7. data/CHANGELOG.md +58 -0
  8. data/Gemfile +5 -3
  9. data/README.md +70 -17
  10. data/introspective_grape.gemspec +8 -8
  11. data/lib/.DS_Store +0 -0
  12. data/lib/introspective_grape/api.rb +177 -216
  13. data/lib/introspective_grape/camel_snake.rb +28 -59
  14. data/lib/introspective_grape/filters.rb +66 -0
  15. data/lib/introspective_grape/formatter/camel_json.rb +14 -0
  16. data/lib/introspective_grape/helpers.rb +63 -0
  17. data/lib/introspective_grape/traversal.rb +54 -0
  18. data/lib/introspective_grape/version.rb +1 -1
  19. data/lib/introspective_grape.rb +11 -0
  20. data/spec/.DS_Store +0 -0
  21. data/spec/dummy/Gemfile +5 -3
  22. data/spec/dummy/app/api/.DS_Store +0 -0
  23. data/spec/dummy/app/api/api_helpers.rb +5 -6
  24. data/spec/dummy/app/api/dummy/chat_api.rb +1 -2
  25. data/spec/dummy/app/api/dummy/company_api.rb +16 -1
  26. data/spec/dummy/app/api/dummy/location_api.rb +3 -3
  27. data/spec/dummy/app/api/dummy/project_api.rb +1 -0
  28. data/spec/dummy/app/api/dummy/sessions.rb +4 -8
  29. data/spec/dummy/app/api/dummy/user_api.rb +3 -1
  30. data/spec/dummy/app/api/dummy_api.rb +6 -6
  31. data/spec/dummy/app/api/error_handlers.rb +2 -2
  32. data/spec/dummy/app/models/chat_user.rb +1 -1
  33. data/spec/dummy/app/models/image.rb +2 -2
  34. data/spec/dummy/app/models/role.rb +1 -1
  35. data/spec/dummy/app/models/user/chatter.rb +6 -6
  36. data/spec/dummy/app/models/user_project_job.rb +3 -3
  37. data/spec/dummy/config/application.rb +1 -1
  38. data/spec/dummy/db/migrate/20150824215701_create_images.rb +3 -3
  39. data/spec/dummy/db/schema.rb +1 -1
  40. data/spec/models/image_spec.rb +1 -1
  41. data/spec/models/role_spec.rb +5 -5
  42. data/spec/models/user_location_spec.rb +2 -2
  43. data/spec/models/user_project_job_spec.rb +1 -1
  44. data/spec/rails_helper.rb +3 -1
  45. data/spec/requests/company_api_spec.rb +28 -0
  46. data/spec/requests/location_api_spec.rb +19 -2
  47. data/spec/requests/project_api_spec.rb +34 -3
  48. data/spec/requests/sessions_api_spec.rb +1 -1
  49. data/spec/requests/user_api_spec.rb +24 -3
  50. data/spec/support/blueprints.rb +3 -3
  51. data/spec/support/location_helper.rb +26 -21
  52. data/spec/support/request_helpers.rb +1 -3
  53. metadata +58 -28
  54. data/spec/dummy/app/api/active_record_helpers.rb +0 -17
@@ -1,6 +1,34 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe Dummy::CompanyAPI, type: :request do
4
+ context :default_values do
5
+ it "should respect default values" do
6
+ get '/api/v1/companies/special/list'
7
+ response.should be_success
8
+ json.should eq({"boolean_default"=>false, "string_default"=>"foo", "integer_default"=>123})
9
+ end
10
+
11
+ it "should override default values" do
12
+ get '/api/v1/companies/special/list', boolean_default: true, string_default: 'bar', integer_default: 321
13
+ response.should be_success
14
+ json.should eq({"boolean_default"=>true, "string_default"=>"bar", "integer_default"=>321})
15
+ end
16
+ end
17
+
18
+ context :pagination do
19
+ it "should use the default introsepctive grape pagination values" do
20
+ Company.destroy_all
21
+ 30.times { Company.make! }
22
+
23
+ get '/api/v1/companies'
24
+
25
+ response.should be_success
26
+ json.length.should eq 25
27
+ json.first['id'].should eq Company.first.id
28
+ response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["30", "2", "25", "1", "2", "", "0"]
29
+ end
30
+ end
31
+
4
32
  before :all do
5
33
  Company.find_by_name("Sprockets") || Company.make!(name:"Sprockets")
6
34
  end
@@ -7,18 +7,34 @@ describe Dummy::LocationAPI, type: :request do
7
7
 
8
8
  before :all do
9
9
  create_test_airport
10
+ Location.make!(name: "TEST2", kind: "airport")
10
11
  end
11
12
 
12
13
  it "should return a list of top level locations and their children" do
13
14
  get '/api/v1/locations'
14
15
  response.should be_success
15
- json.length.should > 0
16
+ json.length.should eq 2
16
17
  json.map{|l| l['id'].to_i }.include?(location.id).should == true
17
18
 
18
19
  json.first['child_locations'].size.should > 0
19
20
  json.first['child_locations'].map{|l| l['id'].to_i}.sort.should == location.child_locations.map(&:id).sort
20
21
  end
21
22
 
23
+ it "should generate basic filters on the whitelisted model attributes" do
24
+ get '/api/v1/locations', { name: "TEST" }
25
+ response.should be_success
26
+ json.length.should eq 1
27
+ json.first['name'].should eq "TEST"
28
+ end
29
+
30
+ it "should parse more advanced JSON filters" do
31
+ get '/api/v1/locations', filter: "{\"child_locations_locations\":{\"name\":\"Terminal A\"}}"
32
+ response.should be_success
33
+ json.length.should eq 1
34
+ json.first['child_locations'].length.should eq 1
35
+ json.first['child_locations'].first['name'].should eq "Terminal A"
36
+ end
37
+
22
38
  it "should return the specified location" do
23
39
  get "/api/v1/locations/#{location.id}"
24
40
  response.should be_success
@@ -43,7 +59,7 @@ describe Dummy::LocationAPI, type: :request do
43
59
  json['name'].should == "Test 123"
44
60
  l = Location.find(json['id'])
45
61
  created = l.beacons.first
46
- created.uuid.should == b.uuid.gsub(/-/,'').upcase
62
+ created.uuid.should == b.uuid.delete('-').upcase
47
63
  created.minor.should == b.minor
48
64
  created.major.should == b.major
49
65
  end
@@ -93,4 +109,5 @@ describe Dummy::LocationAPI, type: :request do
93
109
  Location.where(id: child_locations).size.should == 0
94
110
  end
95
111
 
112
+
96
113
  end
@@ -24,7 +24,7 @@ describe Dummy::ProjectAPI, type: :request do
24
24
 
25
25
  context "As a super admin" do
26
26
  it "should return a list of all projects" do
27
- get '/api/v1/projects'
27
+ get '/api/v1/projects', per_page: 10, offset: 0
28
28
  response.should be_success
29
29
  json.length.should == Project.count
30
30
  json.map{|c| c['id'].to_i}.include?(project.id).should == true
@@ -118,7 +118,7 @@ describe Dummy::ProjectAPI, type: :request do
118
118
  end
119
119
 
120
120
  it "should return a list of all the company's projects" do
121
- get '/api/v1/projects'
121
+ get '/api/v1/projects', offset: 0
122
122
  response.should be_success
123
123
  json.length.should == 2
124
124
  json.map{|c| c['name']}.include?("Manufacture Sprockets").should == true
@@ -140,7 +140,7 @@ describe Dummy::ProjectAPI, type: :request do
140
140
  end
141
141
 
142
142
  it "should return a list of all the project admin's projects" do
143
- get '/api/v1/projects'
143
+ get '/api/v1/projects', offset: 0
144
144
  response.should be_success
145
145
  json.length.should == 1
146
146
  json.map{|c| c['name']}.include?("Manufacture Sprockets").should == true
@@ -148,4 +148,35 @@ describe Dummy::ProjectAPI, type: :request do
148
148
  end
149
149
  end
150
150
 
151
+ context :pagination do
152
+ before(:all) do
153
+ Project.destroy_all
154
+ 20.times { Project.make! }
155
+ end
156
+
157
+ it "should return the project API's declared default paginated results" do
158
+ get '/api/v1/projects'
159
+ response.should be_success
160
+ json.length.should == 2
161
+ json.first['id'].should eq Project.all[2].id
162
+ json.second['id'].should eq Project.all[3].id
163
+ response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["20", "9", "2", "1", "2", "", "2"]
164
+ end
165
+
166
+ it "should return the request number of results" do
167
+ get '/api/v1/projects', per_page: 9, offset: 9
168
+ response.should be_success
169
+ json.size.should == 9
170
+ json.map {|j| j['id']}.should eq Project.all[9..17].map(&:id)
171
+ response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["20", "2", "9", "1", "2", "", "9"]
172
+ end
173
+
174
+ it "should respect the maximum number of results" do
175
+ get '/api/v1/projects', per_page: 20, offset: 0
176
+ response.code.should eq "400"
177
+ json['error'].should eq "per_page must be less than 10"
178
+ end
179
+ end
180
+
181
+
151
182
  end
@@ -23,7 +23,7 @@ describe Dummy::Sessions, type: :request do
23
23
  post '/api/v1/sessions', { login: user.email, password: 'bad password', token: true }
24
24
  response.should_not be_success
25
25
  json['error'].should be_truthy
26
- json['error']['type'].should == 'unauthorized'
26
+ json['error']['type'].should == 'unauthenticated'
27
27
  user.authentication_token.should be_nil
28
28
  end
29
29
  end
@@ -26,6 +26,27 @@ describe Dummy::UserAPI, type: :request do
26
26
  json.first['roles_attributes'].first['ownable_id'].should == company.id
27
27
  end
28
28
 
29
+ it "should constrain the index by a time range" do
30
+ 6.times { User.make! }
31
+ u = User.last
32
+ u.update_column(:created_at, 1.day.ago)
33
+ get '/api/v1/users', { created_at_start: 2.day.ago, created_at_end: 8.hours.ago }
34
+ response.should be_success
35
+ json.length.should eq 1
36
+ json.first['id'].to_i.should eq u.id
37
+ json.first['first_name'].should eq u.first_name
38
+ end
39
+
40
+ it "should accept a comma separated list of ids" do
41
+ 4.times { User.make! }
42
+ user_ids = [User.first,User.second,User.third].map(&:id)
43
+ get '/api/v1/users', { id: user_ids.join(',') }
44
+ response.should be_success
45
+ json.length.should eq 3
46
+ json.map {|j| j['id'] }.should eq user_ids
47
+
48
+ end
49
+
29
50
  it "should not expose users' encrypted_passwords" do
30
51
  get "/api/v1/users"
31
52
  response.should be_success
@@ -131,7 +152,7 @@ describe Dummy::UserAPI, type: :request do
131
152
  user.avatar.should == Image.last
132
153
  user.avatar_url.should == Image.last.file.url(:medium)
133
154
  end
134
-
155
+
135
156
  it "should upload a user avatar via the nested route, to test the restful api's handling of has_one associations" do
136
157
  params = { file: Rack::Test::UploadedFile.new(Rails.root+'../fixtures/images/avatar.jpeg', 'image/jpeg', true) }
137
158
 
@@ -142,7 +163,7 @@ describe Dummy::UserAPI, type: :request do
142
163
  user.avatar_url.should == Image.last.file.url(:medium)
143
164
  user.avatar_url
144
165
  end
145
-
166
+
146
167
  it "should require a devise re-confirmation email to update a user's email address" do
147
168
  new_email = 'new.email@test.com'
148
169
  old_email = user.email
@@ -167,7 +188,7 @@ describe Dummy::UserAPI, type: :request do
167
188
  put "/api/v1/users/#{user.id}", { roles_attributes: [{ownable_type: 'Company', ownable_id: company.id}] }
168
189
  response.should_not be_success
169
190
  json['error'].should =~ /user has already been assigned that role/
170
- user.admin?(company).should be_truthy
191
+ user.admin?(company).should be_truthy
171
192
  end
172
193
 
173
194
  it "should update a user to be company admin" do
@@ -12,11 +12,11 @@ def syllable(length=-1)
12
12
  end
13
13
 
14
14
  def word(max_syl=3)
15
- (1+rand(max_syl)).times.collect { syllable }.join
15
+ Array.new(1+rand(max_syl)).map { syllable }.join
16
16
  end
17
17
 
18
18
  def words(n=3)
19
- n.times.collect { word }.join
19
+ Array.new(n).collect { word }.join
20
20
  end
21
21
 
22
22
  def paragraph(n=25)
@@ -29,7 +29,7 @@ Company.blueprint do
29
29
  end
30
30
 
31
31
  User.blueprint do
32
- email { "test-"+syllable+'@springshot.com' }
32
+ email { "test-"+word(5)+'@springshot.com' }
33
33
  first_name { word(4) }
34
34
  last_name { word(5) }
35
35
  password { 'abc12345' }
@@ -6,6 +6,7 @@ module LocationHelper
6
6
  end
7
7
 
8
8
  def create_test_airport
9
+ return unless Rails.env.test?
9
10
  ### build an airport with 8 terminals each with 3 gates along each cardinal and ordinal
10
11
  ### axis, for two companies each with their own set of bluetooth beacons at every gate:
11
12
  ###
@@ -14,43 +15,47 @@ module LocationHelper
14
15
  ### (8)H-*-D e.g.->(Terminal D with gates D1, D2, and D3)
15
16
  ### /|\
16
17
  ### G F E
18
+ @sprocketCo, @widgetCo = test_companies
17
19
 
18
- @sprocketCo = Company.find_by_name("Sprockets") || Company.make(name:'Sprockets')
19
- @widgetCo = Company.find_by_name("Widgets") || Company.make(name:'Widgets')
20
- if @airport = Location.find_by_name("TEST")
21
- return @airport
22
- end
23
-
24
- @airport = Location.new(name:'TEST',kind:'airport')
25
- @airport.companies.push @sprocketCo
26
- @airport.companies.push @widgetCo
20
+ @airport = Location.find_by_name("TEST") || Location.new(name:'TEST',kind:'airport')
21
+ return @airport if @airport.persisted?
22
+ @airport.companies.push @sprocketCo, @widgetCo
27
23
  @airport.gps = LocationGps.new(lat: 37.615223, lng: -122.389977 )
24
+
25
+ @airport = generate_terminals(@airport)
26
+ @airport.save!
27
+ @airport
28
+ end
29
+
30
+ def generate_terminals(airport)
28
31
  (1..8).each do |terminal|
29
32
  gate = (64+terminal).chr # A-H
30
33
  t = Location.new(name:"Terminal #{gate}",kind:'terminal')
31
34
 
32
- @airport.child_locations.push t
33
-
34
35
  (1..3).each do |number|
35
-
36
- lat, lng = [@airport.gps.lat, @airport.gps.lng]
36
+ lat, lng = [airport.gps.lat, airport.gps.lng]
37
37
  adj = 0.003*number # push successive gates ~0.21 miles out
38
38
 
39
- lat += (1..3).include?(terminal) ? adj : 0
40
- lat -= (5..7).include?(terminal) ? adj : 0
39
+ lat += (1..3).cover?(terminal) ? adj : 0
40
+ lat -= (5..7).cover?(terminal) ? adj : 0
41
41
 
42
42
  adj *= Math.cos(37.615223*Math::PI/180)
43
- lng += (3..5).include?( terminal) ? adj : 0
43
+ lng += (3..5).cover?( terminal) ? adj : 0
44
44
  lng -= [1,7,8].include?(terminal) ? adj : 0
45
45
 
46
- g = Location.new(name:"Gate #{gate}#{number}", kind:'gate')
46
+ g = Location.new(name:"Gate #{gate}#{number}", kind:'gate')
47
47
  g.gps = LocationGps.make(location: g, lat: lat, lng: lng)
48
- g.beacons.push LocationBeacon.make(company: @sprocketCo, location: g)
49
- g.beacons.push LocationBeacon.make(company: @widgetCo, location: g)
48
+ g.beacons.push LocationBeacon.make(company: airport.companies.first, location: g)
49
+ g.beacons.push LocationBeacon.make(company: airport.companies.second, location: g)
50
50
  t.child_locations.push g
51
51
  end
52
+ airport.child_locations.push t
52
53
  end
53
- @airport.save!
54
- @airport
54
+ airport
55
+ end
56
+
57
+ def test_companies
58
+ [Company.find_by_name("Sprockets") || Company.make(name:'Sprockets'),
59
+ Company.find_by_name("Widgets") || Company.make(name:'Widgets')]
55
60
  end
56
61
  end
@@ -1,9 +1,7 @@
1
1
  require 'introspective_grape/camel_snake'
2
2
  module RequestHelpers
3
- include IntrospectiveGrape::CamelSnake
4
-
5
3
  def json
6
- @json ||= snake_keys(JSON.parse(response.body))
4
+ @json ||= JSON.parse(response.body).with_snake_keys(true)
7
5
  end
8
6
 
9
7
  def with_authentication(role=:superuser)
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.0.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-25 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,70 +16,76 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 3.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 3.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0
27
33
  - !ruby/object:Gem::Dependency
28
- name: activerecord
34
+ name: grape
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ">="
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: 0.16.2
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ">="
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: 0.16.2
41
47
  - !ruby/object:Gem::Dependency
42
- name: grape
48
+ name: grape-entity
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ">="
51
+ - - "<"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: 0.5.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ">="
58
+ - - "<"
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
60
+ version: 0.5.0
55
61
  - !ruby/object:Gem::Dependency
56
- name: grape-entity
62
+ name: grape-swagger
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ">="
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
67
+ version: 0.11.0
62
68
  type: :runtime
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ">="
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '0'
74
+ version: 0.11.0
69
75
  - !ruby/object:Gem::Dependency
70
- name: grape-swagger
76
+ name: grape-kaminari
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: 0.10.4
81
+ version: 0.1.9
76
82
  type: :runtime
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: 0.10.4
88
+ version: 0.1.9
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: pundit
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +100,20 @@ dependencies:
94
100
  - - ">="
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: camel_snake_keys
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 0.0.2
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 0.0.2
97
117
  - !ruby/object:Gem::Dependency
98
118
  name: sqlite3
99
119
  requirement: !ruby/object:Gem::Requirement
@@ -154,16 +174,16 @@ dependencies:
154
174
  name: paperclip
155
175
  requirement: !ruby/object:Gem::Requirement
156
176
  requirements:
157
- - - ">="
177
+ - - "<"
158
178
  - !ruby/object:Gem::Version
159
- version: '0'
179
+ version: '5.0'
160
180
  type: :development
161
181
  prerelease: false
162
182
  version_requirements: !ruby/object:Gem::Requirement
163
183
  requirements:
164
- - - ">="
184
+ - - "<"
165
185
  - !ruby/object:Gem::Version
166
- version: '0'
186
+ version: '5.0'
167
187
  - !ruby/object:Gem::Dependency
168
188
  name: machinist
169
189
  requirement: !ruby/object:Gem::Requirement
@@ -228,8 +248,12 @@ executables: []
228
248
  extensions: []
229
249
  extra_rdoc_files: []
230
250
  files:
251
+ - ".coveralls.yml"
231
252
  - ".gitignore"
253
+ - ".rubocop.yml"
254
+ - ".ruby-version"
232
255
  - ".travis.yml"
256
+ - CHANGELOG.md
233
257
  - Gemfile
234
258
  - MIT-LICENSE
235
259
  - README.md
@@ -243,15 +267,21 @@ files:
243
267
  - app/views/.keep
244
268
  - bin/rails
245
269
  - introspective_grape.gemspec
270
+ - lib/.DS_Store
246
271
  - lib/introspective_grape.rb
247
272
  - lib/introspective_grape/api.rb
248
273
  - lib/introspective_grape/camel_snake.rb
274
+ - lib/introspective_grape/filters.rb
275
+ - lib/introspective_grape/formatter/camel_json.rb
276
+ - lib/introspective_grape/helpers.rb
277
+ - lib/introspective_grape/traversal.rb
249
278
  - lib/introspective_grape/version.rb
250
279
  - lib/tasks/introspective_grape_tasks.rake
280
+ - spec/.DS_Store
251
281
  - spec/dummy/Gemfile
252
282
  - spec/dummy/README.rdoc
253
283
  - spec/dummy/Rakefile
254
- - spec/dummy/app/api/active_record_helpers.rb
284
+ - spec/dummy/app/api/.DS_Store
255
285
  - spec/dummy/app/api/api_helpers.rb
256
286
  - spec/dummy/app/api/dummy/chat_api.rb
257
287
  - spec/dummy/app/api/dummy/company_api.rb
@@ -421,7 +451,7 @@ test_files:
421
451
  - spec/dummy/Gemfile
422
452
  - spec/dummy/README.rdoc
423
453
  - spec/dummy/Rakefile
424
- - spec/dummy/app/api/active_record_helpers.rb
454
+ - spec/dummy/app/api/.DS_Store
425
455
  - spec/dummy/app/api/api_helpers.rb
426
456
  - spec/dummy/app/api/dummy/chat_api.rb
427
457
  - spec/dummy/app/api/dummy/company_api.rb
@@ -1,17 +0,0 @@
1
- # Duck-type some helper class methods into our ActiveRecord models to
2
- # allow us to configure API behaviors granularly, at the model level.
3
- class ActiveRecord::Base
4
- class << self
5
- @@api_actions ||= [:index,:show,:create,:update,:destroy,nil]
6
- def api_actions; @@api_actions; end
7
-
8
- def exclude_actions(*args) # Do not define endpoints for these actions
9
- raise "#{self.name} defines invalid exclude_actions: #{args-@@api_actions}" if (args.flatten-@@api_actions).present?
10
- @exclude_actions = args.present? ? args.flatten : @exclude_actions || []
11
- end
12
-
13
- def default_includes(*args) # Eager load these associations.
14
- @default_includes = args.present? ? args.flatten : @default_includes || []
15
- end
16
- end
17
- end