sandboxy 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/pull_request_template.md +2 -2
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/DEPRECATIONS.md +3 -1
- data/Gemfile +1 -1
- data/INSTALL.md +1 -1
- data/LICENSE +1 -1
- data/README.md +68 -38
- data/Rakefile +0 -1
- data/examples/rails_example/Gemfile +1 -0
- data/examples/rails_example/app/api/books/api.rb +33 -0
- data/examples/rails_example/app/assets/javascripts/{bars.coffee → applications.coffee} +0 -0
- data/examples/rails_example/app/assets/javascripts/{foos.coffee → authors.coffee} +0 -0
- data/examples/rails_example/app/assets/javascripts/books.coffee +3 -0
- data/examples/rails_example/app/assets/javascripts/libraries.coffee +3 -0
- data/examples/rails_example/app/assets/javascripts/sandbox.coffee +3 -0
- data/examples/rails_example/app/assets/stylesheets/applications.scss +3 -0
- data/examples/rails_example/app/assets/stylesheets/{foos.scss → authors.scss} +1 -1
- data/examples/rails_example/app/assets/stylesheets/{bars.scss → books.scss} +1 -1
- data/examples/rails_example/app/assets/stylesheets/libraries.scss +3 -0
- data/examples/rails_example/app/assets/stylesheets/sandbox.scss +3 -0
- data/examples/rails_example/app/controllers/application_controller.rb +5 -1
- data/examples/rails_example/app/controllers/applications_controller.rb +74 -0
- data/examples/rails_example/app/controllers/authors_controller.rb +77 -0
- data/examples/rails_example/app/controllers/books_controller.rb +77 -0
- data/examples/rails_example/app/controllers/libraries_controller.rb +77 -0
- data/examples/rails_example/app/controllers/sandbox_controller.rb +6 -0
- data/examples/rails_example/app/helpers/applications_helper.rb +2 -0
- data/examples/rails_example/app/helpers/authors_helper.rb +2 -0
- data/examples/rails_example/app/helpers/books_helper.rb +2 -0
- data/examples/rails_example/app/helpers/libraries_helper.rb +2 -0
- data/examples/rails_example/app/helpers/sandbox_helper.rb +2 -0
- data/examples/rails_example/app/models/application.rb +14 -0
- data/examples/rails_example/app/models/author.rb +2 -0
- data/examples/rails_example/app/models/book.rb +2 -0
- data/examples/rails_example/app/models/library.rb +2 -0
- data/examples/rails_example/app/views/applications/_application.json.jbuilder +2 -0
- data/examples/rails_example/app/views/applications/_form.html.erb +19 -0
- data/examples/rails_example/app/views/applications/edit.html.erb +6 -0
- data/examples/rails_example/app/views/applications/index.html.erb +25 -0
- data/examples/rails_example/app/views/applications/index.json.jbuilder +1 -0
- data/examples/rails_example/app/views/applications/new.html.erb +5 -0
- data/examples/rails_example/app/views/applications/show.html.erb +7 -0
- data/examples/rails_example/app/views/applications/show.json.jbuilder +1 -0
- data/examples/rails_example/app/views/authors/_author.json.jbuilder +2 -0
- data/examples/rails_example/app/views/authors/_form.html.erb +19 -0
- data/examples/rails_example/app/views/authors/edit.html.erb +6 -0
- data/examples/rails_example/app/views/authors/index.html.erb +25 -0
- data/examples/rails_example/app/views/authors/index.json.jbuilder +1 -0
- data/examples/rails_example/app/views/authors/new.html.erb +5 -0
- data/examples/rails_example/app/views/authors/show.html.erb +4 -0
- data/examples/rails_example/app/views/authors/show.json.jbuilder +1 -0
- data/examples/rails_example/app/views/books/_book.json.jbuilder +2 -0
- data/examples/rails_example/app/views/books/_form.html.erb +19 -0
- data/examples/rails_example/app/views/books/edit.html.erb +6 -0
- data/examples/rails_example/app/views/books/index.html.erb +25 -0
- data/examples/rails_example/app/views/books/index.json.jbuilder +1 -0
- data/examples/rails_example/app/views/books/new.html.erb +5 -0
- data/examples/rails_example/app/views/books/show.html.erb +4 -0
- data/examples/rails_example/app/views/books/show.json.jbuilder +1 -0
- data/examples/rails_example/app/views/libraries/_form.html.erb +19 -0
- data/examples/rails_example/app/views/libraries/_library.json.jbuilder +2 -0
- data/examples/rails_example/app/views/libraries/edit.html.erb +6 -0
- data/examples/rails_example/app/views/libraries/index.html.erb +25 -0
- data/examples/rails_example/app/views/libraries/index.json.jbuilder +1 -0
- data/examples/rails_example/app/views/libraries/new.html.erb +5 -0
- data/examples/rails_example/app/views/libraries/show.html.erb +4 -0
- data/examples/rails_example/app/views/libraries/show.json.jbuilder +1 -0
- data/examples/rails_example/config/initializers/grape.rb +2 -0
- data/examples/rails_example/config/initializers/sandboxy.rb +13 -0
- data/examples/rails_example/config/routes.rb +9 -3
- data/examples/rails_example/config/secrets.yml +2 -2
- data/examples/rails_example/db/migrate/20170827184048_create_books.rb +9 -0
- data/examples/rails_example/db/migrate/20170827184054_create_authors.rb +9 -0
- data/examples/rails_example/db/migrate/20170827184106_create_libraries.rb +9 -0
- data/examples/rails_example/db/migrate/20170827184304_create_applications.rb +11 -0
- data/examples/rails_example/db/migrate/{20170827105828_sandboxy_migration.rb → 20170827190815_sandboxy_migration.rb} +0 -0
- data/examples/rails_example/db/schema.rb +19 -3
- data/examples/rails_example/test/controllers/applications_controller_test.rb +48 -0
- data/examples/rails_example/test/controllers/authors_controller_test.rb +48 -0
- data/examples/rails_example/test/controllers/books_controller_test.rb +48 -0
- data/examples/rails_example/test/controllers/libraries_controller_test.rb +48 -0
- data/examples/rails_example/test/controllers/sandbox_controller_test.rb +7 -0
- data/examples/rails_example/test/fixtures/{bars.yml → applications.yml} +0 -0
- data/examples/rails_example/test/fixtures/{foos.yml → authors.yml} +0 -0
- data/examples/rails_example/test/fixtures/books.yml +11 -0
- data/examples/rails_example/test/fixtures/libraries.yml +11 -0
- data/examples/rails_example/test/models/application_test.rb +7 -0
- data/examples/rails_example/test/models/{bar_test.rb → author_test.rb} +1 -1
- data/examples/rails_example/test/models/{foo_test.rb → book_test.rb} +1 -1
- data/examples/rails_example/test/models/library_test.rb +7 -0
- data/examples/rails_example/test/system/applications_test.rb +9 -0
- data/examples/rails_example/test/system/authors_test.rb +9 -0
- data/examples/rails_example/test/system/books_test.rb +9 -0
- data/examples/rails_example/test/system/libraries_test.rb +9 -0
- data/lib/generators/sandboxy_generator.rb +4 -6
- data/lib/generators/templates/initializer.rb +13 -0
- data/lib/sandboxy/configuration.rb +11 -34
- data/lib/sandboxy/middleware.rb +3 -3
- data/lib/sandboxy/railtie.rb +3 -3
- data/lib/sandboxy/version.rb +1 -1
- data/lib/sandboxy.rb +12 -3
- data/sandboxy.gemspec +4 -6
- data/test/dummy30/config/initializers/sandboxy.rb +13 -0
- data/test/test_helper.rb +0 -2
- metadata +93 -78
- data/examples/rails_example/app/controllers/bars_controller.rb +0 -74
- data/examples/rails_example/app/controllers/foos_controller.rb +0 -74
- data/examples/rails_example/app/helpers/bars_helper.rb +0 -2
- data/examples/rails_example/app/helpers/foos_helper.rb +0 -2
- data/examples/rails_example/app/models/bar.rb +0 -2
- data/examples/rails_example/app/models/foo.rb +0 -2
- data/examples/rails_example/app/models/shared_sandbox.rb +0 -3
- data/examples/rails_example/app/views/bars/_bar.json.jbuilder +0 -2
- data/examples/rails_example/app/views/bars/_form.html.erb +0 -17
- data/examples/rails_example/app/views/bars/edit.html.erb +0 -6
- data/examples/rails_example/app/views/bars/index.html.erb +0 -25
- data/examples/rails_example/app/views/bars/index.json.jbuilder +0 -1
- data/examples/rails_example/app/views/bars/new.html.erb +0 -5
- data/examples/rails_example/app/views/bars/show.html.erb +0 -4
- data/examples/rails_example/app/views/bars/show.json.jbuilder +0 -1
- data/examples/rails_example/app/views/foos/_foo.json.jbuilder +0 -2
- data/examples/rails_example/app/views/foos/_form.html.erb +0 -17
- data/examples/rails_example/app/views/foos/edit.html.erb +0 -6
- data/examples/rails_example/app/views/foos/index.html.erb +0 -25
- data/examples/rails_example/app/views/foos/index.json.jbuilder +0 -1
- data/examples/rails_example/app/views/foos/new.html.erb +0 -5
- data/examples/rails_example/app/views/foos/show.html.erb +0 -4
- data/examples/rails_example/app/views/foos/show.json.jbuilder +0 -1
- data/examples/rails_example/config/sandboxy.yml +0 -13
- data/examples/rails_example/db/migrate/20170826223227_create_foos.rb +0 -8
- data/examples/rails_example/db/migrate/20170826223243_create_bars.rb +0 -8
- data/examples/rails_example/test/controllers/bars_controller_test.rb +0 -48
- data/examples/rails_example/test/controllers/foos_controller_test.rb +0 -48
- data/examples/rails_example/test/system/bars_test.rb +0 -9
- data/examples/rails_example/test/system/foos_test.rb +0 -9
- data/lib/generators/templates/configuration.yml.erb +0 -13
@@ -0,0 +1,77 @@
|
|
1
|
+
class LibrariesController < ApplicationController
|
2
|
+
before_action :set_library, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
# GET /libraries
|
5
|
+
# GET /libraries.json
|
6
|
+
def index
|
7
|
+
$sandbox = session[:sandbox]
|
8
|
+
@libraries = Library.all
|
9
|
+
end
|
10
|
+
|
11
|
+
# GET /libraries/1
|
12
|
+
# GET /libraries/1.json
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /libraries/new
|
17
|
+
def new
|
18
|
+
$sandbox = session[:sandbox]
|
19
|
+
@library = Library.new
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /libraries/1/edit
|
23
|
+
def edit
|
24
|
+
end
|
25
|
+
|
26
|
+
# POST /libraries
|
27
|
+
# POST /libraries.json
|
28
|
+
def create
|
29
|
+
$sandbox = session[:sandbox]
|
30
|
+
@library = Library.new(library_params)
|
31
|
+
|
32
|
+
respond_to do |format|
|
33
|
+
if @library.save
|
34
|
+
format.html { redirect_to @library, notice: 'Library was successfully created.' }
|
35
|
+
format.json { render :show, status: :created, location: @library }
|
36
|
+
else
|
37
|
+
format.html { render :new }
|
38
|
+
format.json { render json: @library.errors, status: :unprocessable_entity }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# PATCH/PUT /libraries/1
|
44
|
+
# PATCH/PUT /libraries/1.json
|
45
|
+
def update
|
46
|
+
respond_to do |format|
|
47
|
+
if @library.update(library_params)
|
48
|
+
format.html { redirect_to @library, notice: 'Library was successfully updated.' }
|
49
|
+
format.json { render :show, status: :ok, location: @library }
|
50
|
+
else
|
51
|
+
format.html { render :edit }
|
52
|
+
format.json { render json: @library.errors, status: :unprocessable_entity }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# DELETE /libraries/1
|
58
|
+
# DELETE /libraries/1.json
|
59
|
+
def destroy
|
60
|
+
@library.destroy
|
61
|
+
respond_to do |format|
|
62
|
+
format.html { redirect_to libraries_url, notice: 'Library was successfully destroyed.' }
|
63
|
+
format.json { head :no_content }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
# Use callbacks to share common setup or constraints between actions.
|
69
|
+
def set_library
|
70
|
+
@library = Library.find(params[:id])
|
71
|
+
end
|
72
|
+
|
73
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
74
|
+
def library_params
|
75
|
+
params.fetch(:library, {})
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Application < ApplicationRecord
|
2
|
+
before_create :create_access_tokens
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def create_access_tokens
|
7
|
+
begin
|
8
|
+
self.access_token = SecureRandom.hex(32)
|
9
|
+
end while self.class.where(access_token: self.access_token, sandbox_access_token: self.access_token).exists?
|
10
|
+
begin
|
11
|
+
self.sandbox_access_token = SecureRandom.hex(32)
|
12
|
+
end while self.class.where(sandbox_access_token: self.sandbox_access_token, access_token: self.sandbox_access_token).exists?
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= form_with(model: application, local: true) do |form| %>
|
2
|
+
<% if application.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(application.errors.count, "error") %> prohibited this application from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% application.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= form.input :name %>
|
15
|
+
|
16
|
+
<div class="actions">
|
17
|
+
<%= form.submit %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Applications</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th colspan="3"></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
|
12
|
+
<tbody>
|
13
|
+
<% @applications.each do |application| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= link_to 'Show', application %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_application_path(application) %></td>
|
17
|
+
<td><%= link_to 'Destroy', application, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<%= link_to 'New Application', new_application_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @applications, partial: 'applications/application', as: :application
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "applications/application", application: @application
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= form_with(model: author, local: true) do |form| %>
|
2
|
+
<% if author.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(author.errors.count, "error") %> prohibited this author from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% author.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= form.input :name %>
|
15
|
+
|
16
|
+
<div class="actions">
|
17
|
+
<%= form.submit %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Authors</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th colspan="3"></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
|
12
|
+
<tbody>
|
13
|
+
<% @authors.each do |author| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= link_to 'Show', author %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_author_path(author) %></td>
|
17
|
+
<td><%= link_to 'Destroy', author, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<%= link_to 'New Author', new_author_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @authors, partial: 'authors/author', as: :author
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "authors/author", author: @author
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= form_with(model: book, local: true) do |form| %>
|
2
|
+
<% if book.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(book.errors.count, "error") %> prohibited this book from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% book.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= form.input :name %>
|
15
|
+
|
16
|
+
<div class="actions">
|
17
|
+
<%= form.submit %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Books</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th colspan="3"></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
|
12
|
+
<tbody>
|
13
|
+
<% @books.each do |book| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= link_to 'Show', book %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_book_path(book) %></td>
|
17
|
+
<td><%= link_to 'Destroy', book, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<%= link_to 'New Book', new_book_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @books, partial: 'books/book', as: :book
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "books/book", book: @book
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= form_with(model: library, local: true) do |form| %>
|
2
|
+
<% if library.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(library.errors.count, "error") %> prohibited this library from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% library.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= form.input :name %>
|
15
|
+
|
16
|
+
<div class="actions">
|
17
|
+
<%= form.submit %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Libraries</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th colspan="3"></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
|
12
|
+
<tbody>
|
13
|
+
<% @libraries.each do |library| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= link_to 'Show', library %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_library_path(library) %></td>
|
17
|
+
<td><%= link_to 'Destroy', library, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<%= link_to 'New Library', new_library_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @libraries, partial: 'libraries/library', as: :library
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "libraries/library", library: @library
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Sandboxy.configure do |config|
|
2
|
+
|
3
|
+
# Set your environment default: Must be either `live` or `sandbox`.
|
4
|
+
# This is the environment that your app boots with.
|
5
|
+
# By default it gets refreshed with every new request to your server.
|
6
|
+
# config.environment = 'live'
|
7
|
+
|
8
|
+
# Specify whether to retain your current app environment on new requests.
|
9
|
+
# If set to true, your app will only load your environment default when starting.
|
10
|
+
# Every additional switch of your environment at runtime will then not be automatically resolved to your environment default on a new request.
|
11
|
+
# config.retain_environment = false
|
12
|
+
|
13
|
+
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
resources :foos
|
2
|
+
mount Books::API => '/api'
|
4
3
|
|
5
|
-
|
4
|
+
resources :applications
|
5
|
+
resources :libraries
|
6
|
+
resources :authors
|
7
|
+
resources :books
|
8
|
+
|
9
|
+
root 'libraries#index'
|
10
|
+
|
11
|
+
get 'switch-environments', to: 'sandbox#edit'
|
6
12
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
7
13
|
end
|
@@ -18,10 +18,10 @@
|
|
18
18
|
# Environmental secrets are only available for that specific environment.
|
19
19
|
|
20
20
|
development:
|
21
|
-
secret_key_base:
|
21
|
+
secret_key_base: def380439341bd8d1fe444db27e4faa1626b39097220af40dd6fb6e99fff10cec00d782dda094b4ebda0f45fa9578d42110534d2e35b2240f418586e44aa12bf
|
22
22
|
|
23
23
|
test:
|
24
|
-
secret_key_base:
|
24
|
+
secret_key_base: 269bf1f079ced783a42ff334f462b938b9d704748377e180023443a761c513437c06b6c7958cb6d19bc1826ee9ced849f295cb47a6c586a85be13a67a3d9101a
|
25
25
|
|
26
26
|
# Do not keep production secrets in the unencrypted secrets file.
|
27
27
|
# Instead, either read values from the environment.
|
File without changes
|
@@ -10,14 +10,30 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20170827190815) do
|
14
14
|
|
15
|
-
create_table "
|
15
|
+
create_table "applications", force: :cascade do |t|
|
16
|
+
t.string "name", null: false
|
17
|
+
t.string "access_token", null: false
|
18
|
+
t.string "sandbox_access_token", null: false
|
16
19
|
t.datetime "created_at", null: false
|
17
20
|
t.datetime "updated_at", null: false
|
18
21
|
end
|
19
22
|
|
20
|
-
create_table "
|
23
|
+
create_table "authors", force: :cascade do |t|
|
24
|
+
t.string "name", null: false
|
25
|
+
t.datetime "created_at", null: false
|
26
|
+
t.datetime "updated_at", null: false
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table "books", force: :cascade do |t|
|
30
|
+
t.string "name", null: false
|
31
|
+
t.datetime "created_at", null: false
|
32
|
+
t.datetime "updated_at", null: false
|
33
|
+
end
|
34
|
+
|
35
|
+
create_table "libraries", force: :cascade do |t|
|
36
|
+
t.string "name", null: false
|
21
37
|
t.datetime "created_at", null: false
|
22
38
|
t.datetime "updated_at", null: false
|
23
39
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ApplicationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@application = applications(:one)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get index" do
|
9
|
+
get applications_url
|
10
|
+
assert_response :success
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should get new" do
|
14
|
+
get new_application_url
|
15
|
+
assert_response :success
|
16
|
+
end
|
17
|
+
|
18
|
+
test "should create application" do
|
19
|
+
assert_difference('Application.count') do
|
20
|
+
post applications_url, params: { application: { } }
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_redirected_to application_url(Application.last)
|
24
|
+
end
|
25
|
+
|
26
|
+
test "should show application" do
|
27
|
+
get application_url(@application)
|
28
|
+
assert_response :success
|
29
|
+
end
|
30
|
+
|
31
|
+
test "should get edit" do
|
32
|
+
get edit_application_url(@application)
|
33
|
+
assert_response :success
|
34
|
+
end
|
35
|
+
|
36
|
+
test "should update application" do
|
37
|
+
patch application_url(@application), params: { application: { } }
|
38
|
+
assert_redirected_to application_url(@application)
|
39
|
+
end
|
40
|
+
|
41
|
+
test "should destroy application" do
|
42
|
+
assert_difference('Application.count', -1) do
|
43
|
+
delete application_url(@application)
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_redirected_to applications_url
|
47
|
+
end
|
48
|
+
end
|