Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dummy app to current Rails conventions #110

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Next Release

* Your contribution here.
* [#110](https://github.com/ruby-grape/grape-swagger-rails/pull/110): Update dummy app to current rails conventions - [@duffn](https://github.com/duffn).

### 0.4.0 (2023/03/28)

Expand Down
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ end

group :development, :test do
gem 'capybara'
gem 'coffee-rails'
gem 'grape-swagger-ui'
gem 'jquery-rails'
gem 'mime-types'
gem 'nokogiri'
gem 'rack', '< 3.0'
gem 'rack-cors'
gem 'rack-no_animations'
gem 'rake'
gem 'rspec-rails'
gem 'rubocop', '0.77.0'
gem 'rubocop'
gem 'ruby-grape-danger', '~> 0.2.0', require: false
gem 'sass'
gem 'sass-rails'
gem 'selenium-webdriver'
gem 'sprockets'
gem 'sprockets-rails', require: 'sprockets/railtie'
gem 'uglifier'
gem 'webrick'
end
11 changes: 2 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
require 'bundler/setup'

APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks

Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each do |f|
load f
Expand Down
2 changes: 2 additions & 0 deletions app/assets/config/grape_swagger_rails_manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= link_directory ../stylesheets/grape_swagger_rails .css
//= link_directory ../javascripts/grape_swagger_rails .js
7 changes: 4 additions & 3 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require_relative 'config/application'

Dummy::Application.load_tasks
Rails.application.load_tasks
7 changes: 3 additions & 4 deletions spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//= link application.js
//= link application.css
//= link grape_swagger_rails/application.css
//= link grape_swagger_rails/application.js
//= link_directory ../stylesheets .css
//= link_directory ../javascripts .js
//= link grape_swagger_rails_manifest.js
2 changes: 0 additions & 2 deletions spec/dummy/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
//= require jquery
//= require jquery_ujs
//= require_tree .
1 change: 1 addition & 0 deletions spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
</head>
<body>

Expand Down
3 changes: 0 additions & 3 deletions spec/dummy/bin/bundle

This file was deleted.

6 changes: 1 addition & 5 deletions spec/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
4 changes: 0 additions & 4 deletions spec/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
25 changes: 25 additions & 0 deletions spec/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require 'fileutils'

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
18 changes: 0 additions & 18 deletions spec/dummy/bin/spring

This file was deleted.

6 changes: 4 additions & 2 deletions spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Dummy::Application
require_relative 'config/environment'

run Rails.application
Rails.application.load_server
17 changes: 8 additions & 9 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'

require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
require 'jquery-rails'
require 'rack/cors'
require 'rack/no_animations'
require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require 'grape-swagger-rails'

module Dummy
class Application < Rails::Application
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
config.load_defaults Rails::VERSION::STRING.to_f

# For compatibility with applications that use this config
config.action_controller.include_all_helpers = false
config.middleware.use Rack::Cors do
allow do
origins '*'
Expand Down
11 changes: 3 additions & 8 deletions spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
require 'rubygems'

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)

require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require 'sass'
require 'grape'
require 'grape-swagger'
require 'coffee_script'
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
6 changes: 4 additions & 2 deletions spec/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require File.expand_path('../application', __FILE__)
# Load the Rails application.
require_relative 'application'

Dummy::Application.initialize!
# Initialize the Rails application.
Rails.application.initialize!
57 changes: 38 additions & 19 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
require 'active_support/core_ext/integer/time'

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Show full error reports.
config.consider_all_requests_local = true

# Enable server timing
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

# Don't care if the mailer can't send.
# config.action_mailer.raise_delivery_errors = false
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false

config.cache_store = :null_store
end

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise

# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []

# Suppress logger output for asset requests.
config.assets.quiet = true

# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Disable animations
config.middleware.use Rack::NoAnimations
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
end
58 changes: 28 additions & 30 deletions spec/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/core_ext/integer/time'

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -14,16 +16,17 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true

# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_files = false
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
Expand All @@ -32,48 +35,43 @@
# Generate digests for assets URLs.
config.assets.digest = true

# `config.assets.precompile` has moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# Set to :debug to see everything in the log.
# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = :info

# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]

# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )

# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true

# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Don't log any deprecations.
config.active_support.report_deprecations = false

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")

if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
end
Loading