apicasso 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/Rakefile +11 -20
- data/app/controllers/apicasso/crud_controller.rb +36 -2
- data/app/models/apicasso/ability.rb +2 -2
- data/db/migrate/20180826141433_create_apicasso_tables.rb +3 -0
- data/lib/apicasso/engine.rb +7 -0
- data/lib/apicasso/version.rb +1 -1
- data/lib/apicasso.rb +4 -0
- data/spec/apicasso_spec.rb +5 -0
- data/spec/controllers/apicasso/aplication_controller_spec.rb +18 -0
- data/spec/controllers/apicasso/crud_controller_spec.rb +107 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config/application.rb +19 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +94 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/apicasso_key.rb +9 -0
- data/spec/factories/object.rb +5 -0
- data/spec/models/apicasso/key.rb +5 -0
- data/spec/routing/appointments_routing_spec.rb +38 -0
- data/spec/spec_helper.rb +18 -0
- metadata +218 -15
- data/lib/tasks/apicasso_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1bf6652d93e5464765b0c05924a1a948efa9337
|
4
|
+
data.tar.gz: 0f599b807751c7151fd2ca943e0dbb840d33d810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7db2ffa761b81b282cf62d33b40f0a884fdbbd35d71ff0915a1050c74c60203eb7c7ed5b51e9393fa9711ff547f5c3525168b631987e208960a35fdb539811eb
|
7
|
+
data.tar.gz: 0aaec104200af5337d282d93e00711b4e4f6be38033620d2e7f8295d6a175529ccb21f92c03fed79f448c58fef5b3f52bddb013a48d5eeae1111c61877da5cbd
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ And then execute this to generate the required migrations:
|
|
19
19
|
$ bundle install && rails g apicasso:install
|
20
20
|
```
|
21
21
|
|
22
|
-
You will
|
22
|
+
### You will must have PostgreSQL as database to be able to use this gem.
|
23
23
|
|
24
24
|
# Usage
|
25
25
|
|
@@ -176,7 +176,7 @@ If there is any method or relation that you want to be inserted on the payload,
|
|
176
176
|
?include=pictures,suggestions
|
177
177
|
```
|
178
178
|
|
179
|
-
This will insert the contents of `.pictures` and `.suggestions` on the payload, along with the records' data. **This method can be used both on index and show actions**
|
179
|
+
This will insert the contents of `.pictures` and `.suggestions` on the payload, along with the records' data. This means you can populate the payload both with methods or relations contents. **This method can be used both on index and show actions**
|
180
180
|
|
181
181
|
### Grouping operations
|
182
182
|
|
@@ -206,9 +206,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Ervalh
|
|
206
206
|
|
207
207
|
### TODO
|
208
208
|
|
209
|
-
-
|
209
|
+
- Add support to other databases
|
210
|
+
- Abstract a configurable CORS approach, maybe using middleware
|
210
211
|
- Add gem options like: Token rotation, Alternative authentication methods
|
211
|
-
-
|
212
|
+
- Refine and document auto-documentation feature
|
212
213
|
- Rate limiting
|
213
214
|
- Testing suite
|
214
215
|
- Travis CI
|
data/Rakefile
CHANGED
@@ -1,32 +1,23 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
begin
|
2
3
|
require 'bundler/setup'
|
3
4
|
rescue LoadError
|
4
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
6
|
end
|
7
|
+
require 'bundler/gem_tasks'
|
8
|
+
require 'rspec/core/rake_task'
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'Apicasso'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.md')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
10
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
11
|
load 'rails/tasks/engine.rake'
|
19
12
|
|
20
|
-
|
13
|
+
Bundler::GemHelper.install_tasks
|
21
14
|
|
22
|
-
|
15
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
23
16
|
|
24
|
-
require '
|
17
|
+
require 'rspec/core'
|
18
|
+
require 'rspec/core/rake_task'
|
25
19
|
|
26
|
-
|
27
|
-
|
28
|
-
t.pattern = 'test/**/*_test.rb'
|
29
|
-
t.verbose = false
|
30
|
-
end
|
20
|
+
desc 'Run all specs in spec directory (excluding plugin specs)'
|
21
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
31
22
|
|
32
|
-
task default: :
|
23
|
+
task default: :spec
|
@@ -67,7 +67,7 @@ module Apicasso
|
|
67
67
|
resource: resource.name.underscore.to_sym,
|
68
68
|
object: @object)
|
69
69
|
if @object.save
|
70
|
-
render json: @object, status: :created
|
70
|
+
render json: @object, status: :created
|
71
71
|
else
|
72
72
|
render json: @object.errors, status: :unprocessable_entity
|
73
73
|
end
|
@@ -205,7 +205,41 @@ module Apicasso
|
|
205
205
|
# Only allow a trusted parameter "white list" through,
|
206
206
|
# based on resource's schema.
|
207
207
|
def object_params
|
208
|
-
params.
|
208
|
+
params.require(resource.name.underscore.to_sym)
|
209
|
+
.permit(resource_params)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Resource params mapping, with a twist:
|
213
|
+
# Including relations as they are needed
|
214
|
+
def resource_params
|
215
|
+
built = resource_schema.keys
|
216
|
+
built += has_one_params if has_one_params.present?
|
217
|
+
built += has_many_params if has_many_params.present?
|
218
|
+
built
|
219
|
+
end
|
220
|
+
|
221
|
+
# A wrapper to has_one relations parameter building
|
222
|
+
def has_one_params
|
223
|
+
resource.reflect_on_all_associations(:has_one).map do |one|
|
224
|
+
if one.class_name.starts_with?('ActiveStorage')
|
225
|
+
next if one.class_name.ends_with?('Blob')
|
226
|
+
one.name.to_s.gsub(/(_attachment)$/, '').to_sym
|
227
|
+
else
|
228
|
+
one.name
|
229
|
+
end
|
230
|
+
end.compact
|
231
|
+
end
|
232
|
+
|
233
|
+
# A wrapper to has_many parameter building
|
234
|
+
def has_many_params
|
235
|
+
resource.reflect_on_all_associations(:has_many).map do |many|
|
236
|
+
if many.class_name.starts_with?('ActiveStorage')
|
237
|
+
next if many.class_name.ends_with?('Blob')
|
238
|
+
{ many.name.to_s.gsub(/(_attachments)$/, '').to_sym => [] }
|
239
|
+
else
|
240
|
+
{ many.name.to_sym => [] }
|
241
|
+
end
|
242
|
+
end.compact
|
209
243
|
end
|
210
244
|
end
|
211
245
|
end
|
@@ -16,7 +16,7 @@ module Apicasso
|
|
16
16
|
# To have a key reading all channels and all accouts
|
17
17
|
# you would have a scope:
|
18
18
|
# => `{read: {channel: true, accout: true}}`
|
19
|
-
can permission.to_sym, klass.underscore.to_sym
|
19
|
+
can permission.to_sym, klass.underscore.singularize.to_sym
|
20
20
|
can permission.to_sym, klass.classify.constantize
|
21
21
|
elsif clearance.class == Hash
|
22
22
|
# Usage:
|
@@ -24,7 +24,7 @@ module Apicasso
|
|
24
24
|
# you would have a scope:
|
25
25
|
# => `{read: {banner: {owner_id: [999]}}}`
|
26
26
|
can permission.to_sym,
|
27
|
-
klass.underscore.to_sym
|
27
|
+
klass.underscore.singularize.to_sym
|
28
28
|
clearance.each do |by_field, values|
|
29
29
|
can permission.to_sym,
|
30
30
|
klass.classify.constantize,
|
data/lib/apicasso/engine.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Apicasso
|
4
|
+
# Behavior control for the Apicasso::Engine
|
4
5
|
class Engine < ::Rails::Engine
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec, fixture: false
|
8
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
9
|
+
g.assets false
|
10
|
+
g.helper false
|
11
|
+
end
|
5
12
|
end
|
6
13
|
end
|
data/lib/apicasso/version.rb
CHANGED
data/lib/apicasso.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
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
|
@@ -0,0 +1,107 @@
|
|
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
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
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 .
|
@@ -0,0 +1,13 @@
|
|
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);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
9
|
+
<%= javascript_include_tag 'application' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a starting point to setup your application.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
# puts "\n== Copying sample files =="
|
24
|
+
# unless File.exist?('config/database.yml')
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
26
|
+
# end
|
27
|
+
|
28
|
+
puts "\n== Preparing database =="
|
29
|
+
system! 'bin/rails db:setup'
|
30
|
+
|
31
|
+
puts "\n== Removing old logs and tempfiles =="
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
33
|
+
|
34
|
+
puts "\n== Restarting application server =="
|
35
|
+
system! 'bin/rails restart'
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a way to update your development environment automatically.
|
14
|
+
# Add necessary update steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
puts "\n== Updating database =="
|
24
|
+
system! 'bin/rails db:migrate'
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
28
|
+
|
29
|
+
puts "\n== Restarting application server =="
|
30
|
+
system! 'bin/rails restart'
|
31
|
+
end
|
data/spec/dummy/bin/yarn
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(APP_ROOT) do
|
4
|
+
begin
|
5
|
+
exec "yarnpkg", *ARGV
|
6
|
+
rescue Errno::ENOENT
|
7
|
+
$stderr.puts "Yarn executable was not detected in the system."
|
8
|
+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require 'apicasso'
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Initialize configuration defaults for originally generated Rails version.
|
11
|
+
config.load_defaults 5.2
|
12
|
+
|
13
|
+
# Settings in config/environments/* take precedence over those specified here.
|
14
|
+
# Application configuration can go into files in config/initializers
|
15
|
+
# -- all .rb files in that directory are automatically loaded after loading
|
16
|
+
# the framework and any gems in your application.
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: db/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: db/test.sqlite3
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *default
|
25
|
+
database: db/production.sqlite3
|