s3_relay 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/controllers/s3_relay/uploads_controller.rb +8 -2
  4. data/app/models/s3_relay/upload.rb +1 -1
  5. data/lib/s3_relay/private_url.rb +1 -1
  6. data/lib/s3_relay/version.rb +1 -1
  7. data/test/controllers/s3_relay/uploads_controller_test.rb +17 -11
  8. data/test/dummy/{README.rdoc → README.md} +1 -5
  9. data/test/dummy/Rakefile +1 -1
  10. data/test/dummy/app/assets/config/manifest.js +3 -0
  11. data/test/dummy/app/assets/javascripts/application.js +6 -4
  12. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +5 -5
  14. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  15. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  16. data/test/dummy/app/controllers/application_controller.rb +0 -2
  17. data/test/dummy/app/jobs/application_job.rb +2 -0
  18. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  19. data/test/dummy/app/models/application_record.rb +3 -0
  20. data/test/dummy/app/models/product.rb +1 -1
  21. data/test/dummy/app/views/layouts/application.html.erb +9 -9
  22. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  23. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  24. data/test/dummy/bin/rails +6 -1
  25. data/test/dummy/bin/rake +5 -0
  26. data/test/dummy/bin/setup +38 -0
  27. data/test/dummy/bin/spring +17 -0
  28. data/test/dummy/bin/update +29 -0
  29. data/test/dummy/bin/yarn +11 -0
  30. data/test/dummy/config/application.rb +7 -11
  31. data/test/dummy/config/boot.rb +2 -4
  32. data/test/dummy/config/cable.yml +10 -0
  33. data/test/dummy/config/environment.rb +1 -1
  34. data/test/dummy/config/environments/development.rb +24 -7
  35. data/test/dummy/config/environments/production.rb +35 -22
  36. data/test/dummy/config/environments/test.rb +6 -3
  37. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  38. data/test/dummy/config/initializers/assets.rb +8 -2
  39. data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
  40. data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
  41. data/test/dummy/config/locales/en.yml +10 -0
  42. data/test/dummy/config/puma.rb +56 -0
  43. data/test/dummy/config/secrets.yml +15 -5
  44. data/test/dummy/config/spring.rb +6 -0
  45. data/test/dummy/config.ru +2 -1
  46. data/test/dummy/db/seeds.rb +7 -0
  47. data/test/dummy/package.json +5 -0
  48. data/test/dummy/public/404.html +6 -6
  49. data/test/dummy/public/422.html +6 -6
  50. data/test/dummy/public/500.html +6 -6
  51. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  52. data/test/dummy/public/apple-touch-icon.png +0 -0
  53. data/test/dummy/public/robots.txt +1 -0
  54. data/test/dummy/test/application_system_test_case.rb +5 -0
  55. data/test/dummy/test/test_helper.rb +9 -0
  56. data/test/factories/uploads.rb +10 -3
  57. data/test/helpers/s3_relay/uploads_helper_test.rb +3 -3
  58. data/test/models/s3_relay/upload_test.rb +6 -5
  59. data/test/test_helper.rb +1 -0
  60. metadata +89 -33
  61. data/test/dummy/config/initializers/session_store.rb +0 -3
  62. data/test/dummy/log/development.log +0 -26
  63. data/test/dummy/log/test.log +0 -988
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afc5415d8757f11bbbfce2dc39e1e185eee3a2f7
4
- data.tar.gz: f9855a56037d0a2822a2cc888e9e5edd26ace1f1
3
+ metadata.gz: e3e10d8c93c2b0dfb2c30d18dc6f4bd8843951d7
4
+ data.tar.gz: 3306281d165ad4cad71aaffddad4ae7f10593b30
5
5
  SHA512:
6
- metadata.gz: ed0dd8dd182bc57118b2e8e7828b4894fda0350c81bbbf5e1889548faad285d80c263e6bd9ab6cee51869210277cc1993c5c5f3e06b0dc76dd44fa4bc8662b8f
7
- data.tar.gz: 7ee20e055833c5eb99528b6874c16a441f552ea9dcfce3cd07e2c30191650d72f4e2dace956741eeb60377224bf92309960c7af389534ca5eb95c82eb9a89a54
6
+ metadata.gz: 3b4db0505eb9f8b6b47530634ffc7d7dd8a497c49f86c4a1025b91de9a06ef35e504a70e62e5686800cc6a297b97ce0a9b0956fdee42ed9256e567c6cacc6bb7
7
+ data.tar.gz: e36d26eb9e0d782bded5badef70b270f4127f26a6171b81f8345d217fd774722cb6492fa3ccd24bdc5df8e57c0e83f7cf360b5ac91bbf9fd988dacb2200d0e76
data/README.md CHANGED
@@ -52,8 +52,8 @@ adhering to for a couple of major versions now. Even IE, wuh?
52
52
  The latest versions of all of the following are ideal, but here are the gem's
53
53
  minimum requirements:
54
54
 
55
- * Ruby 1.9.3+
56
- * Rails 3.1+
55
+ * For rails 5.1+, use version 0.6.x+ and ruby 2.3+
56
+ * For rails 3.1 to 5.0, use version 0.5.x and ruby 1.9.3+
57
57
  * Modern versions of Chrome, Safari, FireFox or IE 10+
58
58
  * Note: Progress bars are currently disabled in IE
59
59
  * Note: IE <= 9 users will be instructed to upgrade their browser upon
@@ -11,7 +11,13 @@ class S3Relay::UploadsController < ApplicationController
11
11
  @upload = S3Relay::Upload.new(upload_attrs)
12
12
 
13
13
  if @upload.save
14
- render json: { private_url: @upload.private_url }, status: 201
14
+ data = {
15
+ private_url: @upload.private_url,
16
+ parent_type: @upload.parent_type,
17
+ parent_id: @upload.parent_id,
18
+ user_id: user_attrs[:user_id]
19
+ }
20
+ render json: data, status: 201
15
21
  else
16
22
  render json: { errors: @upload.errors }, status: 422
17
23
  end
@@ -55,7 +61,7 @@ class S3Relay::UploadsController < ApplicationController
55
61
  end
56
62
 
57
63
  def user_attrs
58
- if respond_to?(:current_user) && (id = current_user.try(:id))
64
+ if respond_to?(:current_user) && (id = current_user&.id)
59
65
  { user_id: id }
60
66
  else
61
67
  {}
@@ -1,7 +1,7 @@
1
1
  module S3Relay
2
2
  class Upload < ActiveRecord::Base
3
3
 
4
- belongs_to :parent, polymorphic: true
4
+ belongs_to :parent, polymorphic: true, optional: true
5
5
 
6
6
  validates :uuid, presence: true, uniqueness: true
7
7
  validates :upload_type, presence: true
@@ -4,7 +4,7 @@ module S3Relay
4
4
  attr_reader :expires, :path
5
5
 
6
6
  def initialize(uuid, file, options={})
7
- filename = URI.encode(file).gsub("+", "%2B")
7
+ filename = Addressable::URI.escape(file).gsub("+", "%2B")
8
8
  @path = [uuid, filename].join("/")
9
9
  @expires = (options[:expires] || 10.minutes.from_now).to_i
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module S3Relay
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -22,7 +22,7 @@ module S3Relay
22
22
  S3Relay::UploadPresigner.any_instance.stubs(:uuid).returns(uuid)
23
23
  S3Relay::UploadPresigner.any_instance.stubs(:expires).returns(time)
24
24
 
25
- get :new
25
+ get new_s3_relay_upload_url
26
26
  assert_response 200
27
27
 
28
28
  data = JSON.parse(response.body)
@@ -44,11 +44,12 @@ module S3Relay
44
44
  describe "success" do
45
45
  it do
46
46
  assert_difference "S3Relay::Upload.count", 1 do
47
- post :create,
47
+ post s3_relay_uploads_url, params: {
48
48
  association: "photo_uploads",
49
49
  uuid: SecureRandom.uuid,
50
50
  filename: "cat.png",
51
51
  content_type: "image/png"
52
+ }
52
53
  end
53
54
 
54
55
  assert_response 201
@@ -60,13 +61,14 @@ module S3Relay
60
61
 
61
62
  it do
62
63
  assert_difference "@product.photo_uploads.count", 1 do
63
- post :create,
64
+ post s3_relay_uploads_url, params: {
64
65
  association: "photo_uploads",
65
66
  uuid: SecureRandom.uuid,
66
67
  filename: "cat.png",
67
68
  content_type: "image/png",
68
69
  parent_type: @product.class.to_s,
69
70
  parent_id: @product.id.to_s
71
+ }
70
72
  end
71
73
 
72
74
  assert_response 201
@@ -76,40 +78,43 @@ module S3Relay
76
78
  describe "not matching an object" do
77
79
  it do
78
80
  assert_difference "S3Relay::Upload.count" do
79
- post :create,
81
+ post s3_relay_uploads_url, params: {
80
82
  association: "photo_uploads",
81
83
  uuid: SecureRandom.uuid,
82
84
  filename: "cat.png",
83
85
  content_type: "image/png",
84
86
  parent_type: "Product",
85
87
  parent_id: "10000000"
88
+ }
86
89
  end
87
90
 
88
91
  assert_response 201
92
+ body = JSON.parse(response.body)
89
93
 
90
- assigns[:upload].parent_type.must_equal nil
91
- assigns[:upload].parent_id.must_equal nil
94
+ assert body["parent_type"] == nil
95
+ assert body["parent_id"] == nil
92
96
  end
93
97
  end
94
98
 
95
99
  describe "with a current_user" do
96
100
  before do
97
101
  @user = OpenStruct.new(id: 123)
98
- @controller.stubs(:current_user).returns(@user)
102
+ UploadsController.any_instance.stubs(:current_user).returns(@user)
99
103
  end
100
104
 
101
105
  it "associates the upload with the user" do
102
106
  assert_difference "S3Relay::Upload.count", 1 do
103
- post :create,
107
+ post s3_relay_uploads_url, params: {
104
108
  association: "photo_uploads",
105
109
  uuid: SecureRandom.uuid,
106
110
  filename: "cat.png",
107
111
  content_type: "image/png"
112
+ }
108
113
  end
109
114
 
110
115
  assert_response 201
111
-
112
- assigns[:upload].user_id.must_equal @user.id
116
+ body = JSON.parse(response.body)
117
+ body["user_id"].must_equal @user.id
113
118
  end
114
119
  end
115
120
 
@@ -119,10 +124,11 @@ module S3Relay
119
124
  describe "error" do
120
125
  it do
121
126
  assert_no_difference "S3Relay::Upload.count" do
122
- post :create,
127
+ post s3_relay_uploads_url, params: {
123
128
  uuid: SecureRandom.uuid,
124
129
  filename: "cat.png",
125
130
  content_type: "image/png"
131
+ }
126
132
  end
127
133
 
128
134
  assert_response 422
@@ -1,4 +1,4 @@
1
- == README
1
+ # README
2
2
 
3
3
  This README would normally document whatever steps are necessary to get the
4
4
  application up and running.
@@ -22,7 +22,3 @@ Things you may want to cover:
22
22
  * Deployment instructions
23
23
 
24
24
  * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
data/test/dummy/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
5
5
 
6
6
  Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -1,13 +1,15 @@
1
1
  // This is a manifest file that'll be compiled into application.js, which will include all the files
2
2
  // listed below.
3
3
  //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
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.
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
9
  //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require rails-ujs
14
+ //= require turbolinks
13
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);
@@ -2,13 +2,13 @@
2
2
  * This is a manifest file that'll be compiled into application.css, which will include all the files
3
3
  * listed below.
4
4
  *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
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 styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
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
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -1,5 +1,3 @@
1
1
  class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
2
  protect_from_forgery with: :exception
5
3
  end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,4 +1,4 @@
1
- class Product < ActiveRecord::Base
1
+ class Product < ApplicationRecord
2
2
 
3
3
  s3_relay :icon_upload
4
4
  s3_relay :photo_uploads, has_many: true
@@ -1,14 +1,14 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
10
6
 
11
- <%= yield %>
7
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9
+ </head>
12
10
 
13
- </body>
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
14
  </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
data/test/dummy/bin/rails CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
8
  require_relative '../config/boot'
4
9
  require 'rails/commands'
data/test/dummy/bin/rake CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
2
7
  require_relative '../config/boot'
3
8
  require 'rake'
4
9
  Rake.application.run
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # Install JavaScript dependencies if using Yarn
22
+ # system('bin/yarn')
23
+
24
+
25
+ # puts "\n== Copying sample files =="
26
+ # unless File.exist?('config/database.yml')
27
+ # cp 'config/database.yml.sample', 'config/database.yml'
28
+ # end
29
+
30
+ puts "\n== Preparing database =="
31
+ system! 'bin/rails db:setup'
32
+
33
+ puts "\n== Removing old logs and tempfiles =="
34
+ system! 'bin/rails log:clear tmp:clear'
35
+
36
+ puts "\n== Restarting application server =="
37
+ system! 'bin/rails restart'
38
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11
+ spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12
+ if spring
13
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14
+ gem 'spring', spring.version
15
+ require 'spring/binstub'
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(" ")}"
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
@@ -1,23 +1,19 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative 'boot'
2
2
 
3
3
  require 'rails/all'
4
+ require 's3_relay'
4
5
 
6
+ # Require the gems listed in Gemfile, including any gems
7
+ # you've limited to :test, :development, or :production.
5
8
  Bundler.require(*Rails.groups)
6
- require "s3_relay"
7
9
 
8
10
  module Dummy
9
11
  class Application < Rails::Application
12
+ # Initialize configuration defaults for originally generated Rails version.
13
+ config.load_defaults 5.1
14
+
10
15
  # Settings in config/environments/* take precedence over those specified here.
11
16
  # Application configuration should go into files in config/initializers
12
17
  # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
18
  end
22
19
  end
23
-
@@ -1,5 +1,3 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
2
 
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
10
+ channel_prefix: dummy_production
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require_relative 'application'
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -9,13 +9,28 @@ Rails.application.configure do
9
9
  # Do not eager load code on boot.
10
10
  config.eager_load = false
11
11
 
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
18
+
19
+ config.cache_store = :memory_store
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22
+ }
23
+ else
24
+ config.action_controller.perform_caching = false
25
+
26
+ config.cache_store = :null_store
27
+ end
15
28
 
16
29
  # Don't care if the mailer can't send.
17
30
  config.action_mailer.raise_delivery_errors = false
18
31
 
32
+ config.action_mailer.perform_caching = false
33
+
19
34
  # Print deprecation notices to the Rails logger.
20
35
  config.active_support.deprecation = :log
21
36
 
@@ -27,11 +42,13 @@ Rails.application.configure do
27
42
  # number of complex assets.
28
43
  config.assets.debug = true
29
44
 
30
- # Adds additional error checking when serving assets at runtime.
31
- # Checks for improperly declared sprockets dependencies.
32
- # Raises helpful error messages.
33
- config.assets.raise_runtime_errors = true
45
+ # Suppress logger output for asset requests.
46
+ config.assets.quiet = true
34
47
 
35
48
  # Raises error for missing translations
36
49
  # config.action_view.raise_on_missing_translations = true
50
+
51
+ # Use an evented file watcher to asynchronously detect changes in source code,
52
+ # routes, locales, etc. This feature depends on the listen gem.
53
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
37
54
  end