standardapi 6.0.0.12 → 6.0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/standard_api.rb +1 -0
  3. data/lib/standard_api/controller.rb +44 -8
  4. data/lib/standard_api/errors.rb +13 -0
  5. data/lib/standard_api/helpers.rb +5 -5
  6. data/lib/standard_api/includes.rb +22 -12
  7. data/lib/standard_api/orders.rb +4 -6
  8. data/lib/standard_api/railtie.rb +1 -1
  9. data/lib/standard_api/route_helpers.rb +4 -0
  10. data/lib/standard_api/test_case/calculate_tests.rb +31 -14
  11. data/lib/standard_api/version.rb +1 -1
  12. data/lib/standard_api/views/application/_record.json.jbuilder +11 -10
  13. data/lib/standard_api/views/application/_record.streamer +11 -10
  14. data/lib/standard_api/views/application/index.json.jbuilder +9 -16
  15. data/lib/standard_api/views/application/index.streamer +9 -16
  16. data/lib/standard_api/views/application/show.json.jbuilder +8 -1
  17. data/lib/standard_api/views/application/show.streamer +8 -1
  18. data/test/standard_api/test_app.rb +54 -0
  19. data/test/standard_api/test_app/config/database.yml +4 -0
  20. data/test/standard_api/test_app/controllers.rb +107 -0
  21. data/test/standard_api/test_app/log/test.log +129516 -0
  22. data/test/standard_api/test_app/models.rb +89 -0
  23. data/test/standard_api/test_app/test/factories.rb +50 -0
  24. data/test/standard_api/test_app/test/fixtures/photo.png +0 -0
  25. data/test/standard_api/test_app/views/photos/_photo.json.jbuilder +15 -0
  26. data/test/standard_api/test_app/views/photos/schema.json.jbuilder +1 -0
  27. data/test/standard_api/test_app/views/properties/edit.html.erb +1 -0
  28. data/test/standard_api/test_app/views/sessions/new.html.erb +0 -0
  29. metadata +21 -8
@@ -0,0 +1,89 @@
1
+ # = Models
2
+
3
+ class Account < ActiveRecord::Base
4
+ has_many :photos
5
+ belongs_to :property
6
+ end
7
+
8
+ class Photo < ActiveRecord::Base
9
+ belongs_to :account, :counter_cache => true
10
+ has_and_belongs_to_many :properties
11
+ end
12
+
13
+ class Document < ActiveRecord::Base
14
+ attr_accessor :file
15
+ end
16
+
17
+ class Pdf < Document
18
+ end
19
+
20
+ class Property < ActiveRecord::Base
21
+ has_and_belongs_to_many :photos
22
+ has_many :accounts
23
+ has_one :landlord, class_name: 'Account'
24
+
25
+ validates :name, presence: true
26
+ accepts_nested_attributes_for :photos
27
+
28
+ def english_name
29
+ 'A Name'
30
+ end
31
+ end
32
+
33
+ class Reference < ActiveRecord::Base
34
+ belongs_to :subject, polymorphic: true
35
+ end
36
+
37
+ # = Migration
38
+
39
+ class CreateModelTables < ActiveRecord::Migration[5.2]
40
+
41
+ def self.up
42
+
43
+ create_table "accounts", force: :cascade do |t|
44
+ t.string 'name', limit: 255
45
+ t.integer 'property_id'
46
+ t.integer 'photos_count', null: false, default: 0
47
+ end
48
+
49
+ create_table "photos", force: :cascade do |t|
50
+ t.integer "account_id"
51
+ t.integer "property_id"
52
+ t.string "format", limit: 255
53
+ end
54
+
55
+ create_table "properties", force: :cascade do |t|
56
+ t.string "name", limit: 255
57
+ t.string "aliases", default: [], array: true
58
+ t.text "description"
59
+ t.integer "constructed"
60
+ t.decimal "size"
61
+ t.datetime "created_at", null: false
62
+ t.boolean "active", default: false
63
+ end
64
+
65
+ create_table "references", force: :cascade do |t|
66
+ t.integer "subject_id"
67
+ t.string "subject_type", limit: 255
68
+ t.string "key"
69
+ t.string "value"
70
+ end
71
+
72
+ create_table "photos_properties", force: :cascade do |t|
73
+ t.integer "photo_id"
74
+ t.integer "property_id"
75
+ end
76
+
77
+ create_table "landlords_properties", force: :cascade do |t|
78
+ t.integer "landlord_id"
79
+ t.integer "property_id"
80
+ end
81
+
82
+ create_table "documents", force: :cascade do |t|
83
+ t.string 'type'
84
+ end
85
+ end
86
+
87
+ end
88
+ ActiveRecord::Migration.verbose = false
89
+ CreateModelTables.up
@@ -0,0 +1,50 @@
1
+ FactoryBot.define do
2
+ factory :account do
3
+ name { Faker::Name.name }
4
+
5
+ trait(:nested) { }
6
+ trait(:invalid) do
7
+ name { nil }
8
+ end
9
+ end
10
+
11
+ factory :landlord do
12
+ name { Faker::Name.name }
13
+ end
14
+
15
+ factory :photo do
16
+ format { ['jpg', 'png', 'tiff'].sample }
17
+ end
18
+
19
+ factory :document do
20
+ file { fixture_file_upload(Rails.root + 'test/fixtures/photo.png', 'image/png') }
21
+ end
22
+
23
+ factory :pdf do
24
+ type { 'Pdf' }
25
+ file { fixture_file_upload(Rails.root + 'test/fixtures/photo.png', 'image/png') }
26
+ end
27
+
28
+ factory :reference do
29
+ subject_type { 'Photo' }
30
+ subject_id { create(:photo).id }
31
+ end
32
+
33
+ factory :property do
34
+ name { Faker::Lorem.words(number: Kernel.rand(1..4)).join(' ') }
35
+ description { Faker::Lorem.paragraphs.join("\n\n") }
36
+ constructed { Kernel.rand(1800..(Time.now.year - 2)) }
37
+ size { Kernel.rand(1000..10000000).to_f / 100 }
38
+ active { [true, false].sample }
39
+ photos { [create(:photo)] }
40
+
41
+ trait(:nested) do
42
+ photos_attributes { [attributes_for(:photo)] }
43
+ end
44
+
45
+ trait(:invalid) do
46
+ name { nil }
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,15 @@
1
+ json.set! :id, photo.id
2
+ json.set! :account_id, photo.account_id
3
+ json.set! :property_id, photo.property_id
4
+ json.set! :format, photo.format
5
+ json.set! :template, 'photos/_photo'
6
+
7
+ if includes[:account]
8
+ json.set! :account do
9
+ if photo.account
10
+ json.partial! 'application/record', record: photo.account, includes: includes[:account]
11
+ else
12
+ json.null!
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ json.set! 'template', 'photos/schema'
@@ -0,0 +1 @@
1
+ properties#edit.html
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standardapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.12
4
+ version: 6.0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: minitest-reporters
154
+ name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: simplecov
168
+ name: factory_bot_rails
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,7 +179,7 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: factory_bot_rails
182
+ name: faker
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
@@ -193,7 +193,7 @@ dependencies:
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
- name: faker
196
+ name: byebug
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ">="
@@ -207,7 +207,7 @@ dependencies:
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
- name: byebug
210
+ name: mocha
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - ">="
@@ -221,7 +221,7 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
- name: mocha
224
+ name: benchmark-ips
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="
@@ -246,6 +246,7 @@ files:
246
246
  - README.md
247
247
  - lib/standard_api.rb
248
248
  - lib/standard_api/controller.rb
249
+ - lib/standard_api/errors.rb
249
250
  - lib/standard_api/helpers.rb
250
251
  - lib/standard_api/includes.rb
251
252
  - lib/standard_api/middleware/query_encoding.rb
@@ -272,6 +273,17 @@ files:
272
273
  - lib/standard_api/views/application/schema.streamer
273
274
  - lib/standard_api/views/application/show.json.jbuilder
274
275
  - lib/standard_api/views/application/show.streamer
276
+ - test/standard_api/test_app.rb
277
+ - test/standard_api/test_app/config/database.yml
278
+ - test/standard_api/test_app/controllers.rb
279
+ - test/standard_api/test_app/log/test.log
280
+ - test/standard_api/test_app/models.rb
281
+ - test/standard_api/test_app/test/factories.rb
282
+ - test/standard_api/test_app/test/fixtures/photo.png
283
+ - test/standard_api/test_app/views/photos/_photo.json.jbuilder
284
+ - test/standard_api/test_app/views/photos/schema.json.jbuilder
285
+ - test/standard_api/test_app/views/properties/edit.html.erb
286
+ - test/standard_api/test_app/views/sessions/new.html.erb
275
287
  homepage: https://github.com/waratuman/standardapi
276
288
  licenses:
277
289
  - MIT
@@ -282,6 +294,7 @@ rdoc_options:
282
294
  - README.md
283
295
  require_paths:
284
296
  - lib
297
+ - test
285
298
  required_ruby_version: !ruby/object:Gem::Requirement
286
299
  requirements:
287
300
  - - ">="