Skip to content

Commit

Permalink
Upgraded default to Rails 5.2 and use encrypted credentials now
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahW91 committed May 13, 2020
1 parent 1009601 commit 0f7ec3d
Show file tree
Hide file tree
Showing 21 changed files with 585 additions and 576 deletions.
19 changes: 12 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
/coverage
.idea/
.idea
.bundle
tmp/
log/
public/assets/
public/system/

config/database.yml
config/secrets.yml
config/application.yml
log/
# Ignore master key for decrypting credentials and more.
config/master.key

.DS_Store
rails_best_practices_output.html

dump.rdb
latest.dump
specimens.xls
species.xls
public/assets/
public/system/
latest.dump
spec/examples.txt

.rbenv-vars
.env
.env
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ gem 'select2-rails' # Integrate Select2 Javascript library
gem 'ancestry' # Self-related models
gem 'bcrypt', platforms: :ruby
gem 'bio' # BioRuby
gem 'bootsnap'
gem 'bootstrap-sass'
gem 'bootstrap_progressbar'
gem 'builder'
Expand All @@ -56,7 +57,6 @@ gem 'net-ssh'
gem 'roo-xls' # Handle excel files
gem 'rubyzip' # Handle zip files
gem 'simple_form'
gem 'slim' # TODO: Used anywhere?
gem 'sprockets-rails', require: 'sprockets/railtie'
# gem 'turbolinks' # Turbolinks makes navigating your web application faster TODO: Does not work unless first changes to js code, in particular data-tables (see http://guides.rubyonrails.org/working_with_javascript_in_rails.html#turbolinks)
gem 'whenever', require: false # Runs scheduled jobs via cron
Expand All @@ -77,8 +77,7 @@ group :development do
gem 'bullet' # Checks for n+1 queries
gem 'binding_of_caller' # Extends features of better_errors
gem 'meta_request' # Supporting gem for Google Chrome Rails Panel
# gem 'spring' # Spring speeds up development by keeping your application running in the background
# gem 'spring-watcher-listen'
gem 'spring' # Spring speeds up development by keeping your application running in the background
gem 'yard' # Documentation generation tool
end

Expand Down
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ GEM
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bio (2.0.1)
bootsnap (1.4.6)
msgpack (~> 1.0)
bootstrap-multiselect_rails (0.9.5)
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
Expand Down Expand Up @@ -1117,6 +1119,8 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
msgpack (1.3.3)
msgpack (1.3.3-x86-mingw32)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nenv (0.3.0)
Expand Down Expand Up @@ -1268,11 +1272,9 @@ GEM
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
slim (4.1.0)
temple (>= 0.7.6, < 0.9)
tilt (>= 2.0.6, < 2.1)
spreadsheet (1.2.6)
ruby-ole (>= 1.0)
spring (2.1.0)
sprockets (4.0.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -1283,7 +1285,6 @@ GEM
sshkit (1.21.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
temple (0.8.2)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
thor (0.20.3)
Expand Down Expand Up @@ -1328,6 +1329,7 @@ DEPENDENCIES
better_errors
binding_of_caller
bio
bootsnap
bootstrap-multiselect_rails
bootstrap-sass
bootstrap_progressbar
Expand Down Expand Up @@ -1381,7 +1383,7 @@ DEPENDENCIES
simple_form
simplecov
sinatra
slim
spring
sprockets-rails
tzinfo-data
uglifier
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/contigs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ContigsController < ApplicationController

load_and_authorize_resource

http_basic_authenticate_with name: ENV['API_USER_NAME'], password: ENV['API_PASSWORD'], only: [:as_fasq, :change_via_script, :compare_contigs]
http_basic_authenticate_with name: ENV['API_USER_NAME'], password: Rails.application.credentials.api_password, only: [:as_fasq, :change_via_script, :compare_contigs]

skip_before_action :verify_authenticity_token, only: [:as_fasq, :change_via_script, :compare_contigs]

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/mislabel_analyses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MislabelAnalysesController < ApplicationController

before_action :set_mislabel_analysis, only: %i[show destroy import download_results]

http_basic_authenticate_with name: ENV['API_USER_NAME'], password: ENV['API_PASSWORD'], only: :download_results
http_basic_authenticate_with name: ENV['API_USER_NAME'], password: Rails.application.credentials.api_password, only: :download_results
skip_before_action :verify_authenticity_token, only: :download_results

def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ngs_runs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class NgsRunsController < ApplicationController

load_and_authorize_resource

http_basic_authenticate_with name: ENV['API_USER_NAME'], password: ENV['API_PASSWORD'], only: [:import, :revised_tpm]
http_basic_authenticate_with name: ENV['API_USER_NAME'], password: Rails.application.credentials.api_password, only: [:import, :revised_tpm]
skip_before_action :verify_authenticity_token, only: [:import, :revised_tpm]

before_action :set_ngs_run, only: [:show, :edit, :update, :destroy, :import, :analysis_results]
Expand Down
2 changes: 1 addition & 1 deletion app/models/contig_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ContigSearch < ApplicationRecord
validates_attachment_content_type :search_result_archive, :content_type => /\Aapplication\/zip/

# Validate filename
validates_attachment_file_name :search_result_archive, :matches => [/zip\Z/]
validates_attachment_file_name :search_result_archive, :matches => %r{\.zip\Z}i

def contigs
@contigs ||= find_contigs
Expand Down
5 changes: 5 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
5 changes: 5 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
16 changes: 7 additions & 9 deletions bin/spring
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This file loads spring without using Bundler, in order to be fast
# It gets overwritten when you run the `spring binstub` command
# This file loads Spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.

unless defined?(Spring)
require 'rubygems'
require 'bundler'

if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
ENV['GEM_PATH'] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV['GEM_HOME'] = ''
Gem.paths = ENV

gem 'spring', match[1]
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
require 'spring/binstub'
end
end
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module GBOLapp
class Application < Rails::Application
config.load_defaults 5.2

# Keep old default of not requiring belongs to associations
Rails.application.config.active_record.belongs_to_required_by_default = false

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand Down
1 change: 1 addition & 0 deletions config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FpGkY0LW7ey6HabKQfScvjeFu80bDbK01OSB640VyknAcI38vxLUjIstdN8mOWFfEjpn02PwM3LF4baybErS4CJEGPHwbK8GPXzMEaaAPNnkyTCTacjIx+MCCHDnV5EHABS8NvwtgFaDxDmrjBdRAB6NQm1cHAeDoAiUnVRawfrQykGNtRgAt8CHMV6lo9nDARj51z/cvz87cCNGBcqEvYZ4xLgsjV4nT4bYWkeJivaBhHfgT3e1Q2GZhixtxN93IKzTputLY1lZJj7zuT9UatjQyB7LvgFLWlYhxcvsPBKhyA3icFg5nL31wt8UpDEIwlwrdPq0QZj464QyunQuKlbDseV3qhJsSVSUoqv2E9apYDLJtIS8Z7RtEskYi/amyygFqmnS6OMh4Ilzp+guqzsbSZNqKLmA+ItYIbjkdSdzUZ27QQjveI5YONZ8Gx/H1mCll4e6CVkPXlbw86/rLh+WPlsJIcxbPwYSnVHtS8MMcl5GDPcPkYR+JPuBaC1kLSs6Jj0=--sRwDJlZGIJ0mrctd--ivcbdsXY8cEXtCuu0fssZA==
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
Expand Down
8 changes: 4 additions & 4 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# 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
config.require_master_key = true

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
Expand All @@ -39,7 +39,7 @@
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# config.active_storage.service = :local

# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
Expand Down Expand Up @@ -109,8 +109,8 @@
path: '/:class/:attachment/:id_partition/:style/:filename',
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
access_key_id: Rails.application.credentials.aws[:access_key_id],
secret_access_key: Rails.application.credentials.aws[:secret_access_key],
s3_region: ENV['S3_REGION'],
preserve_files: true
}
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
config.action_controller.allow_forgery_protection = false

# Store uploaded files on the local file system in a temporary directory
config.active_storage.service = :test
# config.active_storage.service = :test

config.action_mailer.perform_caching = false

Expand Down
4 changes: 2 additions & 2 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

config.assets.paths << "#{Rails}/app/assets/fonts"
config.assets.paths << "#{Rails}/vendor/assets/fonts"
Rails.application.config.assets.paths << Rails.root.join('/app/assets/fonts')
Rails.application.config.assets.paths << Rails.root.join('/vendor/assets/fonts')
4 changes: 2 additions & 2 deletions config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%w(
%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
].each { |path| Spring.watch(path) }
Loading

0 comments on commit 0f7ec3d

Please sign in to comment.