Skip to content

Commit

Permalink
Upgrade to Rails 5 and fix tests
Browse files Browse the repository at this point in the history
leaving in a depreciation notice from shoulda matchers that should be fixed
soon per issue thoughtbot/shoulda-matchers#867
  • Loading branch information
melissawahnish committed Aug 17, 2016
1 parent 6523df8 commit 43d9506
Show file tree
Hide file tree
Showing 31 changed files with 291 additions and 154 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

ruby '2.2.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', ' 4.2.5.2'
gem 'rails', ' 5.0.0.1'

gem 'pg'
# Use SCSS for stylesheets
Expand All @@ -25,9 +25,10 @@ gem 'sdoc', '~> 0.4.0', group: :doc

gem 'devise'
gem 'cocoon' #for nested forms
# gem "wysiwyg-rails"
gem "wysiwyg-rails"
gem "font-awesome-rails"
gem "figaro"
gem 'rails-controller-testing' #rails 5 upgrade

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Expand Down
110 changes: 62 additions & 48 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5.2)
actionpack (= 4.2.5.2)
actionview (= 4.2.5.2)
activejob (= 4.2.5.2)
actioncable (5.0.0.1)
actionpack (= 5.0.0.1)
nio4r (~> 1.2)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5.2)
actionview (= 4.2.5.2)
activesupport (= 4.2.5.2)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.0.0.1)
actionview (= 5.0.0.1)
activesupport (= 5.0.0.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5.2)
activesupport (= 4.2.5.2)
actionview (5.0.0.1)
activesupport (= 5.0.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5.2)
activesupport (= 4.2.5.2)
globalid (>= 0.3.0)
activemodel (4.2.5.2)
activesupport (= 4.2.5.2)
builder (~> 3.1)
activerecord (4.2.5.2)
activemodel (= 4.2.5.2)
activesupport (= 4.2.5.2)
arel (~> 6.0)
activesupport (4.2.5.2)
activejob (5.0.0.1)
activesupport (= 5.0.0.1)
globalid (>= 0.3.6)
activemodel (5.0.0.1)
activesupport (= 5.0.0.1)
activerecord (5.0.0.1)
activemodel (= 5.0.0.1)
activesupport (= 5.0.0.1)
arel (~> 7.0)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
arel (7.1.1)
bcrypt (3.1.11)
better_errors (2.1.1)
coderay (>= 1.0.0)
Expand Down Expand Up @@ -132,6 +134,7 @@ GEM
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.2.0)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
Expand All @@ -146,31 +149,34 @@ GEM
pry (>= 0.9.10, < 0.11.0)
pry-rails (0.3.4)
pry (>= 0.9.10)
rack (1.6.4)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5.2)
actionmailer (= 4.2.5.2)
actionpack (= 4.2.5.2)
actionview (= 4.2.5.2)
activejob (= 4.2.5.2)
activemodel (= 4.2.5.2)
activerecord (= 4.2.5.2)
activesupport (= 4.2.5.2)
rails (5.0.0.1)
actioncable (= 5.0.0.1)
actionmailer (= 5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
activemodel (= 5.0.0.1)
activerecord (= 5.0.0.1)
activesupport (= 5.0.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5.2)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
railties (= 5.0.0.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.5.2)
actionpack (= 4.2.5.2)
activesupport (= 4.2.5.2)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
Expand Down Expand Up @@ -236,6 +242,12 @@ GEM
execjs (>= 0.3.0, < 3)
warden (1.2.6)
rack (>= 1.0)
websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
wysiwyg-rails (2.3.4)
font-awesome-rails (~> 4.4, >= 4.4.0.0)
railties (>= 3.2, < 6.0)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand Down Expand Up @@ -265,7 +277,8 @@ DEPENDENCIES
pry
pry-nav
pry-rails (~> 0.3.2)
rails (= 4.2.5.2)
rails (= 5.0.0.1)
rails-controller-testing
rspec-rails
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
Expand All @@ -275,6 +288,7 @@ DEPENDENCIES
therubyracer
turbolinks
uglifier (>= 1.3.0)
wysiwyg-rails

BUNDLED WITH
1.11.2
2 changes: 1 addition & 1 deletion app/models/admin.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin < ActiveRecord::Base
class Admin < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
Expand Down
3 changes: 3 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 1 addition & 1 deletion app/models/crew_member.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CrewMember < ActiveRecord::Base
class CrewMember < ApplicationRecord
belongs_to :starship
accepts_nested_attributes_for :starship,
reject_if: lambda {|attributes| attributes["name"].blank?}
Expand Down
2 changes: 1 addition & 1 deletion app/models/hacker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Hacker < ActiveRecord::Base
class Hacker < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
Expand Down
2 changes: 1 addition & 1 deletion app/models/holodeck_program.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class HolodeckProgram < ActiveRecord::Base
class HolodeckProgram < ApplicationRecord
belongs_to :starship
belongs_to :crew_member
end
2 changes: 1 addition & 1 deletion app/models/starship.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Starship < ActiveRecord::Base
class Starship < ApplicationRecord
has_many :crew_members
accepts_nested_attributes_for :crew_members,
reject_if: lambda {|attributes| attributes["name"].blank?},
Expand Down
6 changes: 1 addition & 5 deletions 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 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
29 changes: 17 additions & 12 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

Dir.chdir APP_ROOT do
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
# Add necessary setup steps to this file.

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

# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end

puts "\n== Preparing database =="
system "bin/rake db:setup"
system! 'bin/rails db:setup'

puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
system! 'bin/rails restart'
end
29 changes: 29 additions & 0 deletions bin/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

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

chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.

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

puts "\n== Updating database =="
system! 'bin/rails db:migrate'

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

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
27 changes: 3 additions & 24 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand All @@ -20,18 +11,6 @@ class Application < Rails::Application
# 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.

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true

config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib)
end
end
2 changes: 1 addition & 1 deletion config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
9 changes: 9 additions & 0 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
development:
adapter: async

test:
adapter: async

production:
adapter: redis
url: redis://localhost:6379/1
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!
Loading

0 comments on commit 43d9506

Please sign in to comment.