apicasso 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +226 -223
  3. data/Rakefile +23 -23
  4. data/app/controllers/apicasso/apidocs_controller.rb +309 -299
  5. data/app/controllers/apicasso/application_controller.rb +170 -147
  6. data/app/controllers/apicasso/crud_controller.rb +246 -245
  7. data/app/controllers/concerns/orderable.rb +45 -45
  8. data/app/models/apicasso/ability.rb +38 -38
  9. data/app/models/apicasso/application_record.rb +6 -6
  10. data/app/models/apicasso/key.rb +25 -25
  11. data/app/models/apicasso/request.rb +8 -8
  12. data/config/routes.rb +14 -14
  13. data/lib/apicasso/active_record_extension.rb +0 -44
  14. data/lib/apicasso/engine.rb +13 -13
  15. data/lib/apicasso/version.rb +3 -3
  16. data/lib/apicasso.rb +15 -13
  17. data/lib/generators/apicasso/install/install_generator.rb +25 -25
  18. data/lib/generators/apicasso/install/templates/create_apicasso_tables.rb +20 -20
  19. data/spec/dummy/Gemfile +56 -0
  20. data/spec/dummy/Gemfile.lock +237 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  22. data/spec/dummy/app/models/used_model.rb +42 -0
  23. data/spec/dummy/app/serializers/used_model_serializer.rb +3 -0
  24. data/spec/dummy/bin/rails +5 -0
  25. data/spec/dummy/bin/rake +5 -0
  26. data/spec/dummy/bin/setup +0 -3
  27. data/spec/dummy/bin/spring +17 -0
  28. data/spec/dummy/bin/update +0 -3
  29. data/spec/dummy/config/application.rb +14 -10
  30. data/spec/dummy/config/cable.yml +1 -1
  31. data/spec/dummy/config/credentials.yml.enc +1 -0
  32. data/spec/dummy/config/database.yml +5 -14
  33. data/spec/dummy/config/environments/development.rb +6 -10
  34. data/spec/dummy/config/environments/production.rb +1 -10
  35. data/spec/dummy/config/initializers/cors.rb +16 -0
  36. data/spec/dummy/config/locales/en.yml +7 -32
  37. data/spec/dummy/config/routes.rb +1 -1
  38. data/{db/migrate/20180826141433_create_apicasso_tables.rb → spec/dummy/db/migrate/20180918134607_create_apicasso_tables.rb} +1 -0
  39. data/spec/dummy/db/migrate/20180918141254_create_used_models.rb +44 -0
  40. data/spec/dummy/db/migrate/20180919130152_create_active_storage_tables.active_storage.rb +26 -0
  41. data/spec/dummy/db/migrate/20180920133933_change_used_model_to_validates.rb +7 -0
  42. data/spec/dummy/db/schema.rb +98 -0
  43. data/spec/dummy/db/seeds.rb +56 -0
  44. data/spec/factories/used_model.rb +28 -0
  45. data/spec/models/used_model_spec.rb +35 -0
  46. data/spec/rails_helper.rb +66 -0
  47. data/spec/requests/requests_spec.rb +227 -0
  48. data/spec/spec_helper.rb +7 -9
  49. data/spec/support/factory_bot.rb +3 -0
  50. metadata +83 -64
  51. data/spec/controllers/apicasso/aplication_controller_spec.rb +0 -18
  52. data/spec/controllers/apicasso/crud_controller_spec.rb +0 -107
  53. data/spec/dummy/app/assets/config/manifest.js +0 -3
  54. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  55. data/spec/dummy/app/assets/javascripts/cable.js +0 -13
  56. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  57. data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
  58. data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
  59. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  60. data/spec/dummy/app/jobs/application_job.rb +0 -2
  61. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  62. data/spec/dummy/app/views/layouts/application.html.erb +0 -15
  63. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  64. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  65. data/spec/dummy/bin/yarn +0 -11
  66. data/spec/dummy/config/initializers/assets.rb +0 -14
  67. data/spec/dummy/config/initializers/content_security_policy.rb +0 -25
  68. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
  69. data/spec/dummy/log/development.log +0 -0
  70. data/spec/dummy/public/404.html +0 -67
  71. data/spec/dummy/public/422.html +0 -67
  72. data/spec/dummy/public/500.html +0 -66
  73. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  74. data/spec/dummy/public/apple-touch-icon.png +0 -0
  75. data/spec/dummy/public/favicon.ico +0 -0
  76. data/spec/factories/apicasso_key.rb +0 -9
  77. data/spec/factories/object.rb +0 -5
  78. data/spec/models/apicasso/key.rb +0 -5
  79. data/spec/routing/appointments_routing_spec.rb +0 -38
@@ -0,0 +1,227 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe 'Used Model requests', type: :request do
6
+ token = Apicasso::Key.create(scope: { manage: { used_model: true } }).token
7
+ access_token = { 'AUTHORIZATION' => "Token token=#{token}" }
8
+ describe 'GET /api/v1/used_model' do
9
+ context 'with default pagination' do
10
+ before(:all) do
11
+ get '/api/v1/used_model', headers: access_token
12
+ end
13
+
14
+ it 'returns status ok' do
15
+ expect(response).to have_http_status(:ok)
16
+ end
17
+ it 'returns all UsedModel' do
18
+ expect(JSON.parse(response.body)['entries'].size).to eq(UsedModel.all.size)
19
+ end
20
+ end
21
+
22
+ context 'with negative pagination' do
23
+ before(:all) do
24
+ get '/api/v1/used_model', params: { per_page: -1 }, headers: access_token
25
+ end
26
+
27
+ it 'returns status ok' do
28
+ expect(response).to have_http_status(:ok)
29
+ end
30
+ it 'returns all UsedModel' do
31
+ expect(JSON.parse(response.body)['entries'].size).to eq(UsedModel.all.size)
32
+ end
33
+ end
34
+
35
+ context 'with pagination' do
36
+ before(:all) do
37
+ get '/api/v1/used_model', params: { per_page: 5, page: 1 }, headers: access_token
38
+ end
39
+
40
+ it 'returns status ok' do
41
+ expect(response).to have_http_status(:ok)
42
+ end
43
+
44
+ it 'returns five records from UsedModel if not last page' do
45
+ expect(JSON.parse(response.body)['entries'].size).to be(5) if JSON.parse(response.body)['last_page'] == false
46
+ end
47
+ end
48
+
49
+ context 'by searching' do
50
+ before(:all) do
51
+ get '/api/v1/used_model', params: { 'q[brand_matches]': 'Audi' }, headers: access_token
52
+ end
53
+
54
+ it 'returns status ok' do
55
+ expect(response).to have_http_status(:ok)
56
+ end
57
+
58
+ it 'returns all records with brand queried' do
59
+ JSON.parse(response.body)['entries'].each do |record|
60
+ expect(record['brand']).to eq('Audi')
61
+ end
62
+ end
63
+ end
64
+
65
+ context 'by grouping' do
66
+ before(:all) do
67
+ get '/api/v1/used_model', params: { 'group[by]': 'brand', 'group[calculate]': 'count', 'group[fields]': 'transmission' }, headers: access_token
68
+ end
69
+
70
+ it 'returns status ok' do
71
+ expect(response).to have_http_status(:ok)
72
+ end
73
+
74
+ it 'returns all records grouped brand queried' do
75
+ expect(JSON.parse(response.body)).to eq(UsedModel.group(:brand).count)
76
+ end
77
+ end
78
+
79
+ context 'with sorting' do
80
+ before(:all) do
81
+ get '/api/v1/used_model', params: { 'per_page': -1, 'sort': '+brand,+model' }, headers: access_token
82
+ end
83
+
84
+ it 'returns status ok' do
85
+ expect(response).to have_http_status(:ok)
86
+ end
87
+
88
+ it 'returns all records sorted queried' do
89
+ used_model_sorted = UsedModel.order(:brand, :model).map(&:id)
90
+ entries = JSON.parse(response.body)['entries'].map { |model| model['id'] }
91
+ expect(entries).to eq(used_model_sorted)
92
+ end
93
+ end
94
+
95
+ context 'with field selecting' do
96
+ before(:all) do
97
+ get '/api/v1/used_model', params: { 'select': 'brand' }, headers: access_token
98
+ end
99
+
100
+ it 'returns status ok' do
101
+ expect(response).to have_http_status(:ok)
102
+ end
103
+
104
+ it 'returns all records that have field queried' do
105
+ JSON.parse(response.body)['entries'].each do |record|
106
+ expect(record.keys).to include('brand')
107
+ end
108
+ end
109
+ end
110
+
111
+ context 'with include associations valid' do
112
+ before(:all) do
113
+ get '/api/v1/used_model', params: { 'include': 'files_blobs,files_url' }, headers: access_token
114
+ end
115
+
116
+ it 'returns status ok' do
117
+ expect(response).to have_http_status(:ok)
118
+ end
119
+
120
+ it 'returns all records with includes queried' do
121
+ JSON.parse(response.body)['entries'].each do |record|
122
+ expect(record.keys).to include('files_blobs', 'files_url')
123
+ end
124
+ end
125
+ end
126
+
127
+ context 'with include associations invalid' do
128
+ before(:all) do
129
+ get '/api/v1/used_model', params: { 'include': 'files,file' }, headers: access_token
130
+ end
131
+
132
+ it 'returns status ok' do
133
+ expect(response).to have_http_status(:ok)
134
+ end
135
+
136
+ it 'returns all records without includes queried' do
137
+ JSON.parse(response.body)['entries'].each do |record|
138
+ expect(record.keys).not_to include('files_blobs', 'files_url')
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ describe 'GET /api/v1/used_model/:id' do
145
+ before(:all) do
146
+ get '/api/v1/used_model/1', headers: access_token
147
+ end
148
+
149
+ it 'returns status ok' do
150
+ expect(response).to have_http_status(:ok)
151
+ end
152
+
153
+ it 'returns a record with attributes' do
154
+ expect(JSON.parse(response.body).keys).to include('id', 'active', 'account_id', 'unit_id', 'brand', 'name', 'slug', 'model', 'version', 'model_year', 'production_year', 'kind', 'new_vehicle', 'old_price', 'price_value', 'price', 'category', 'transmission', 'km_value', 'km', 'plate', 'color', 'doors', 'fuel', 'fuel_text', 'note', 'chassis', 'shielded', 'featured', 'integrator', 'ordination', 'visits', 'bait_id', 'fipe_id', 'identifier', 'synced_at', 'deleted_at', 'created_at', 'updated_at')
155
+ end
156
+ end
157
+
158
+ describe 'GET /api/v1/used_model/:slug' do
159
+ before(:all) do
160
+ get '/api/v1/used_model/cr-v', headers: access_token
161
+ end
162
+
163
+ it 'returns status ok' do
164
+ expect(response).to have_http_status(:ok)
165
+ end
166
+
167
+ it 'returns a record with attributes' do
168
+ expect(JSON.parse(response.body).keys).to include('id', 'active', 'account_id', 'unit_id', 'brand', 'name', 'slug', 'model', 'version', 'model_year', 'production_year', 'kind', 'new_vehicle', 'old_price', 'price_value', 'price', 'category', 'transmission', 'km_value', 'km', 'plate', 'color', 'doors', 'fuel', 'fuel_text', 'note', 'chassis', 'shielded', 'featured', 'integrator', 'ordination', 'visits', 'bait_id', 'fipe_id', 'identifier', 'synced_at', 'deleted_at', 'created_at', 'updated_at')
169
+ end
170
+ end
171
+
172
+ describe 'POST /api/v1/used_model/' do
173
+ context 'with valid params' do
174
+ before(:all) do
175
+ post '/api/v1/used_model/', params: { 'used_model': { 'name': 'test', 'account_id': 1, 'unit_id': 1, 'slug': 'tests' }}, headers: access_token
176
+ end
177
+
178
+ it 'returns status created' do
179
+ expect(response).to have_http_status(:created)
180
+ end
181
+ end
182
+
183
+ context 'with invalid params' do
184
+ it 'return a error' do
185
+ post '/api/v1/used_model/', params: { 'used_model': { 'slug': 'cr-v' }}, headers: access_token
186
+ expect(response).to have_http_status(:unprocessable_entity)
187
+ end
188
+ end
189
+ end
190
+
191
+ describe 'PUT /api/v1/used_model/:id' do
192
+ context 'with valid params' do
193
+ before(:all) do
194
+ patch '/api/v1/used_model/' + UsedModel.last.id.to_s, params: { 'used_model': { 'name': 'updated' }}, headers: access_token
195
+ end
196
+
197
+ it 'returns status ok' do
198
+ expect(response).to have_http_status(:ok)
199
+ end
200
+
201
+ it 'updates requested record' do
202
+ expect(UsedModel.last.name).to eq('updated')
203
+ end
204
+ end
205
+
206
+ context 'with invalid params' do
207
+ it 'return a error' do
208
+ patch '/api/v1/used_model/' + UsedModel.last.id.to_s, params: { 'used_model': { 'slug': 'cr-v' }}, headers: access_token
209
+ expect(response).to have_http_status(:unprocessable_entity)
210
+ end
211
+ end
212
+ end
213
+
214
+ describe 'DELETE /api/v1/used_model/:id' do
215
+ before(:all) do
216
+ delete '/api/v1/used_model/' + UsedModel.last.id.to_s, headers: access_token
217
+ end
218
+
219
+ it 'returns status no content' do
220
+ expect(response).to have_http_status(:no_content)
221
+ end
222
+
223
+ it 'detete a UsedModel record' do
224
+ expect(UsedModel.all.size).to eq(10)
225
+ end
226
+ end
227
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,16 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
2
 
3
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
4
  require 'rspec/rails'
5
- require 'rspec/autorun'
6
- require 'factory_girl_rails'
5
+ require 'factory_bot_rails'
6
+ require 'faker'
7
+ require 'simplecov'
8
+ SimpleCov.start
9
+ require 'codecov'
10
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
7
11
 
8
12
  Rails.backtrace_cleaner.remove_silencers!
9
13
 
10
14
  # Load support files
11
15
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
16
 
13
- RSpec.configure do |config|
14
- config.mock_with :rspec
15
- config.use_transactional_fixtures = true
16
- config.infer_base_class_for_anonymous_controllers = false
17
- config.order = 'random'
18
- end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryBot::Syntax::Methods
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apicasso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Bellincanta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-09 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: sqlite3
28
+ name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -81,7 +81,35 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: factory_girl_rails
84
+ name: factory_bot_rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faker
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - ">="
@@ -164,6 +192,20 @@ dependencies:
164
192
  - - "~>"
165
193
  - !ruby/object:Gem::Version
166
194
  version: 3.1.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: friendly_id
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 5.2.0
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 5.2.0
167
209
  description: 'JSON API development can get boring and time consuming. If you think
168
210
  it through, every time you make one you use almost the same route structure pointing
169
211
  the same controller actions, with the same features: ordering, filtering and pagination.
@@ -190,7 +232,6 @@ files:
190
232
  - app/models/apicasso/key.rb
191
233
  - app/models/apicasso/request.rb
192
234
  - config/routes.rb
193
- - db/migrate/20180826141433_create_apicasso_tables.rb
194
235
  - lib/apicasso.rb
195
236
  - lib/apicasso/active_record_extension.rb
196
237
  - lib/apicasso/engine.rb
@@ -198,43 +239,32 @@ files:
198
239
  - lib/generators/apicasso/install/install_generator.rb
199
240
  - lib/generators/apicasso/install/templates/create_apicasso_tables.rb
200
241
  - spec/apicasso_spec.rb
201
- - spec/controllers/apicasso/aplication_controller_spec.rb
202
- - spec/controllers/apicasso/crud_controller_spec.rb
242
+ - spec/dummy/Gemfile
243
+ - spec/dummy/Gemfile.lock
203
244
  - spec/dummy/Rakefile
204
- - spec/dummy/app/assets/config/manifest.js
205
- - spec/dummy/app/assets/javascripts/application.js
206
- - spec/dummy/app/assets/javascripts/cable.js
207
- - spec/dummy/app/assets/stylesheets/application.css
208
- - spec/dummy/app/channels/application_cable/channel.rb
209
- - spec/dummy/app/channels/application_cable/connection.rb
210
245
  - spec/dummy/app/controllers/application_controller.rb
211
- - spec/dummy/app/helpers/application_helper.rb
212
- - spec/dummy/app/jobs/application_job.rb
213
- - spec/dummy/app/mailers/application_mailer.rb
214
246
  - spec/dummy/app/models/application_record.rb
215
- - spec/dummy/app/views/layouts/application.html.erb
216
- - spec/dummy/app/views/layouts/mailer.html.erb
217
- - spec/dummy/app/views/layouts/mailer.text.erb
247
+ - spec/dummy/app/models/used_model.rb
248
+ - spec/dummy/app/serializers/used_model_serializer.rb
218
249
  - spec/dummy/bin/bundle
219
250
  - spec/dummy/bin/rails
220
251
  - spec/dummy/bin/rake
221
252
  - spec/dummy/bin/setup
253
+ - spec/dummy/bin/spring
222
254
  - spec/dummy/bin/update
223
- - spec/dummy/bin/yarn
224
255
  - spec/dummy/config.ru
225
256
  - spec/dummy/config/application.rb
226
257
  - spec/dummy/config/boot.rb
227
258
  - spec/dummy/config/cable.yml
259
+ - spec/dummy/config/credentials.yml.enc
228
260
  - spec/dummy/config/database.yml
229
261
  - spec/dummy/config/environment.rb
230
262
  - spec/dummy/config/environments/development.rb
231
263
  - spec/dummy/config/environments/production.rb
232
264
  - spec/dummy/config/environments/test.rb
233
265
  - spec/dummy/config/initializers/application_controller_renderer.rb
234
- - spec/dummy/config/initializers/assets.rb
235
266
  - spec/dummy/config/initializers/backtrace_silencers.rb
236
- - spec/dummy/config/initializers/content_security_policy.rb
237
- - spec/dummy/config/initializers/cookies_serializer.rb
267
+ - spec/dummy/config/initializers/cors.rb
238
268
  - spec/dummy/config/initializers/filter_parameter_logging.rb
239
269
  - spec/dummy/config/initializers/inflections.rb
240
270
  - spec/dummy/config/initializers/mime_types.rb
@@ -244,19 +274,19 @@ files:
244
274
  - spec/dummy/config/routes.rb
245
275
  - spec/dummy/config/spring.rb
246
276
  - spec/dummy/config/storage.yml
247
- - spec/dummy/log/development.log
277
+ - spec/dummy/db/migrate/20180918134607_create_apicasso_tables.rb
278
+ - spec/dummy/db/migrate/20180918141254_create_used_models.rb
279
+ - spec/dummy/db/migrate/20180919130152_create_active_storage_tables.active_storage.rb
280
+ - spec/dummy/db/migrate/20180920133933_change_used_model_to_validates.rb
281
+ - spec/dummy/db/schema.rb
282
+ - spec/dummy/db/seeds.rb
248
283
  - spec/dummy/package.json
249
- - spec/dummy/public/404.html
250
- - spec/dummy/public/422.html
251
- - spec/dummy/public/500.html
252
- - spec/dummy/public/apple-touch-icon-precomposed.png
253
- - spec/dummy/public/apple-touch-icon.png
254
- - spec/dummy/public/favicon.ico
255
- - spec/factories/apicasso_key.rb
256
- - spec/factories/object.rb
257
- - spec/models/apicasso/key.rb
258
- - spec/routing/appointments_routing_spec.rb
284
+ - spec/factories/used_model.rb
285
+ - spec/models/used_model_spec.rb
286
+ - spec/rails_helper.rb
287
+ - spec/requests/requests_spec.rb
259
288
  - spec/spec_helper.rb
289
+ - spec/support/factory_bot.rb
260
290
  homepage: https://github.com/ErvalhouS/APIcasso
261
291
  licenses:
262
292
  - MIT
@@ -277,47 +307,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
307
  version: '0'
278
308
  requirements: []
279
309
  rubyforge_project:
280
- rubygems_version: 2.6.14
310
+ rubygems_version: 2.7.6
281
311
  signing_key:
282
312
  specification_version: 4
283
313
  summary: An abstract API design as a mountable engine
284
314
  test_files:
285
315
  - spec/apicasso_spec.rb
286
- - spec/controllers/apicasso/aplication_controller_spec.rb
287
- - spec/controllers/apicasso/crud_controller_spec.rb
288
- - spec/dummy/app/assets/config/manifest.js
289
- - spec/dummy/app/assets/javascripts/application.js
290
- - spec/dummy/app/assets/javascripts/cable.js
291
- - spec/dummy/app/assets/stylesheets/application.css
292
- - spec/dummy/app/channels/application_cable/channel.rb
293
- - spec/dummy/app/channels/application_cable/connection.rb
294
316
  - spec/dummy/app/controllers/application_controller.rb
295
- - spec/dummy/app/helpers/application_helper.rb
296
- - spec/dummy/app/jobs/application_job.rb
297
- - spec/dummy/app/mailers/application_mailer.rb
298
317
  - spec/dummy/app/models/application_record.rb
299
- - spec/dummy/app/views/layouts/application.html.erb
300
- - spec/dummy/app/views/layouts/mailer.html.erb
301
- - spec/dummy/app/views/layouts/mailer.text.erb
318
+ - spec/dummy/app/models/used_model.rb
319
+ - spec/dummy/app/serializers/used_model_serializer.rb
302
320
  - spec/dummy/bin/bundle
303
321
  - spec/dummy/bin/rails
304
322
  - spec/dummy/bin/rake
305
323
  - spec/dummy/bin/setup
324
+ - spec/dummy/bin/spring
306
325
  - spec/dummy/bin/update
307
- - spec/dummy/bin/yarn
308
326
  - spec/dummy/config/application.rb
309
327
  - spec/dummy/config/boot.rb
310
328
  - spec/dummy/config/cable.yml
329
+ - spec/dummy/config/credentials.yml.enc
311
330
  - spec/dummy/config/database.yml
312
331
  - spec/dummy/config/environment.rb
313
332
  - spec/dummy/config/environments/development.rb
314
333
  - spec/dummy/config/environments/production.rb
315
334
  - spec/dummy/config/environments/test.rb
316
335
  - spec/dummy/config/initializers/application_controller_renderer.rb
317
- - spec/dummy/config/initializers/assets.rb
318
336
  - spec/dummy/config/initializers/backtrace_silencers.rb
319
- - spec/dummy/config/initializers/content_security_policy.rb
320
- - spec/dummy/config/initializers/cookies_serializer.rb
337
+ - spec/dummy/config/initializers/cors.rb
321
338
  - spec/dummy/config/initializers/filter_parameter_logging.rb
322
339
  - spec/dummy/config/initializers/inflections.rb
323
340
  - spec/dummy/config/initializers/mime_types.rb
@@ -328,17 +345,19 @@ test_files:
328
345
  - spec/dummy/config/spring.rb
329
346
  - spec/dummy/config/storage.yml
330
347
  - spec/dummy/config.ru
331
- - spec/dummy/log/development.log
348
+ - spec/dummy/db/migrate/20180918134607_create_apicasso_tables.rb
349
+ - spec/dummy/db/migrate/20180918141254_create_used_models.rb
350
+ - spec/dummy/db/migrate/20180919130152_create_active_storage_tables.active_storage.rb
351
+ - spec/dummy/db/migrate/20180920133933_change_used_model_to_validates.rb
352
+ - spec/dummy/db/schema.rb
353
+ - spec/dummy/db/seeds.rb
354
+ - spec/dummy/Gemfile
355
+ - spec/dummy/Gemfile.lock
332
356
  - spec/dummy/package.json
333
- - spec/dummy/public/404.html
334
- - spec/dummy/public/422.html
335
- - spec/dummy/public/500.html
336
- - spec/dummy/public/apple-touch-icon-precomposed.png
337
- - spec/dummy/public/apple-touch-icon.png
338
- - spec/dummy/public/favicon.ico
339
357
  - spec/dummy/Rakefile
340
- - spec/factories/apicasso_key.rb
341
- - spec/factories/object.rb
342
- - spec/models/apicasso/key.rb
343
- - spec/routing/appointments_routing_spec.rb
358
+ - spec/factories/used_model.rb
359
+ - spec/models/used_model_spec.rb
360
+ - spec/rails_helper.rb
361
+ - spec/requests/requests_spec.rb
344
362
  - spec/spec_helper.rb
363
+ - spec/support/factory_bot.rb
@@ -1,18 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe Apicasso::ApplicationController, type: :controller do
4
-
5
- describe "#current_ability" do
6
- it "instantiates a @current_ability object" do
7
- Apicasso::ApplicationController.current_ability
8
- expect(@current_ability).not_to be nil
9
- end
10
- end
11
-
12
- describe "#restrict_access" do
13
- it "instantiates an @api_key object" do
14
- Apicasso::ApplicationController.current_ability
15
- expect(@api_key).not_to be nil
16
- end
17
- end
18
- end
@@ -1,107 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe Apicasso::ApplicationController, type: :controller do
4
-
5
- # This should return the minimal set of values that should be in the session
6
- # in order to pass any filters (e.g. authentication) defined in
7
- # AppointmentsController. Be sure to keep this updated too.
8
- let(:valid_session) { {} }
9
-
10
- describe "GET #index" do
11
- it "returns a success response" do
12
- Appointment.create! valid_attributes
13
- get :index, params: {}, session: valid_session
14
- expect(response).to be_successful
15
- end
16
- end
17
-
18
- describe "GET #show" do
19
- it "returns a success response" do
20
- appointment = Appointment.create! valid_attributes
21
- get :show, params: {id: appointment.to_param}, session: valid_session
22
- expect(response).to be_successful
23
- end
24
- end
25
-
26
- describe "GET #new" do
27
- it "returns a success response" do
28
- get :new, params: {}, session: valid_session
29
- expect(response).to be_successful
30
- end
31
- end
32
-
33
- describe "GET #edit" do
34
- it "returns a success response" do
35
- appointment = Appointment.create! valid_attributes
36
- get :edit, params: {id: appointment.to_param}, session: valid_session
37
- expect(response).to be_successful
38
- end
39
- end
40
-
41
- describe "POST #create" do
42
- context "with valid params" do
43
- it "creates a new Appointment" do
44
- expect {
45
- post :create, params: {appointment: valid_attributes}, session: valid_session
46
- }.to change(Appointment, :count).by(1)
47
- end
48
-
49
- it "redirects to the created appointment" do
50
- post :create, params: {appointment: valid_attributes}, session: valid_session
51
- expect(response).to redirect_to(Appointment.last)
52
- end
53
- end
54
-
55
- context "with invalid params" do
56
- it "returns a success response (i.e. to display the 'new' template)" do
57
- post :create, params: {appointment: invalid_attributes}, session: valid_session
58
- expect(response).to be_successful
59
- end
60
- end
61
- end
62
-
63
- describe "PUT #update" do
64
- context "with valid params" do
65
- let(:new_attributes) {
66
- skip("Add a hash of attributes valid for your model")
67
- }
68
-
69
- it "updates the requested appointment" do
70
- appointment = Appointment.create! valid_attributes
71
- put :update, params: {id: appointment.to_param, appointment: new_attributes}, session: valid_session
72
- appointment.reload
73
- skip("Add assertions for updated state")
74
- end
75
-
76
- it "redirects to the appointment" do
77
- appointment = Appointment.create! valid_attributes
78
- put :update, params: {id: appointment.to_param, appointment: valid_attributes}, session: valid_session
79
- expect(response).to redirect_to(appointment)
80
- end
81
- end
82
-
83
- context "with invalid params" do
84
- it "returns a success response (i.e. to display the 'edit' template)" do
85
- appointment = Appointment.create! valid_attributes
86
- put :update, params: {id: appointment.to_param, appointment: invalid_attributes}, session: valid_session
87
- expect(response).to be_successful
88
- end
89
- end
90
- end
91
-
92
- describe "DELETE #destroy" do
93
- it "destroys the requested appointment" do
94
- appointment = Appointment.create! valid_attributes
95
- expect {
96
- delete :destroy, params: {id: appointment.to_param}, session: valid_session
97
- }.to change(Appointment, :count).by(-1)
98
- end
99
-
100
- it "redirects to the appointments list" do
101
- appointment = Appointment.create! valid_attributes
102
- delete :destroy, params: {id: appointment.to_param}, session: valid_session
103
- expect(response).to redirect_to(appointments_url)
104
- end
105
- end
106
-
107
- end
@@ -1,3 +0,0 @@
1
- //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
- //= link_directory ../stylesheets .css
@@ -1,15 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require rails-ujs
14
- //= require activestorage
15
- //= require_tree .
@@ -1,13 +0,0 @@
1
- // Action Cable provides the framework to deal with WebSockets in Rails.
2
- // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
- //
4
- //= require action_cable
5
- //= require_self
6
- //= require_tree ./channels
7
-
8
- (function() {
9
- this.App || (this.App = {});
10
-
11
- App.cable = ActionCable.createConsumer();
12
-
13
- }).call(this);