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 to Rails 5 #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ AllCops:
Exclude:
- db/**/*
- spec/dummy/db/**/*
- bin/rspec
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: ruby
rvm:
- 2.2.3
before_install: gem install bundler -v 1.10.6
- 2.3.0
before_install: gem install bundler -v 1.11.2
cache:
- bundler
addons:
Expand Down
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in primegap-core.gemspec
gemspec

gem 'codeclimate-test-reporter', group: :test, require: nil
group :test do
gem 'codeclimate-test-reporter', require: nil
gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: 'master'
gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: 'master'
gem 'rspec-support', github: 'rspec/rspec-support', branch: 'master'
gem 'rspec-core', github: 'rspec/rspec-core', branch: 'master'
gem 'rspec-rails', github: 'rspec/rspec-rails', branch: 'master'
end
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
4 changes: 1 addition & 3 deletions app/models/authentication_token.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'has_secure_token'

class AuthenticationToken < ActiveRecord::Base
class AuthenticationToken < ApplicationRecord
include AuthenticationTokens::Associations

has_secure_token :body
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion app/models/company.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Company < ActiveRecord::Base
class Company < ApplicationRecord
include Companies::Associations
include Companies::Validations
end
2 changes: 1 addition & 1 deletion app/models/customer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Customer < ActiveRecord::Base
class Customer < ApplicationRecord
include Customers::Associations
include Customers::Validations

Expand Down
6 changes: 3 additions & 3 deletions app/models/token_issuer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def find_token(resource, token_from_headers)

def purge_old_tokens(resource)
resource.authentication_tokens
.order(last_used_at: :desc)
.offset(maximum_tokens_per_user)
.destroy_all
.order(last_used_at: :desc)
.offset(maximum_tokens_per_user)
.destroy_all
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class User < ActiveRecord::Base
class User < ApplicationRecord
include Users::Associations
include Users::Validations

Expand Down
3 changes: 3 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
10 changes: 4 additions & 6 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
# This command will automatically be run when you run "rails" with Rails 5 gems installed from the root of your application.

APP_PATH = File.expand_path('../../spec/dummy/config/application', __FILE__)
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/primegap/core/engine', __FILE__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require_relative '../spec/dummy/config/boot'
require 'rails/all'
require 'rails/commands'
require 'rails/engine/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 '../spec/dummy/config/boot'
require 'rake'
Rake.application.run
3 changes: 2 additions & 1 deletion bin/rspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError
rescue LoadError => e
raise unless e.message.include?('spring')
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
3 changes: 2 additions & 1 deletion lib/primegap/core/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
module Primegap
module Core
VERSION = '0.1.0'
VERSION = '0.1.0'.freeze
end
end
11 changes: 5 additions & 6 deletions primegap-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ Gem::Specification.new do |spec|
spec.test_files = Dir['spec/**/*']

# Rails dependencies
spec.add_dependency 'activerecord', '~> 4.2.4'
spec.add_dependency 'actionmailer', '~> 4.2.4'
spec.add_dependency 'railties', '5.0.0.beta1.1'
spec.add_dependency 'activerecord', '5.0.0.beta1.1'
spec.add_dependency 'actionmailer', '5.0.0.beta1.1'

# Other dependecies
spec.add_dependency 'bcrypt', '~> 3.1.7'
spec.add_dependency 'has_secure_token'

# Development/Test dependencies
spec.add_development_dependency 'sqlite3'

spec.add_development_dependency 'bundler', '~> 1.10'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'rake', '~> 10.5'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec-rails', '~> 3.3'
spec.add_development_dependency 'shoulda-matchers', '~> 3.0'
end
13 changes: 2 additions & 11 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require 'active_record/railtie'
require 'action_mailer/railtie'

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

Expand All @@ -12,16 +14,5 @@ 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
end
end
3 changes: 1 addition & 2 deletions spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)

require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' # Set up gems listed in the Gemfile.
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
27 changes: 21 additions & 6 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@
# 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/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
Expand All @@ -25,17 +36,21 @@
# 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
# config.assets.debug = true

# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# config.assets.digest = 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
# config.assets.raise_runtime_errors = true

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
25 changes: 14 additions & 11 deletions spec/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
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

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
Expand All @@ -37,10 +31,17 @@

# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.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

# Action Cable endpoint configuration
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]

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

Expand All @@ -49,16 +50,18 @@
config.log_level = :debug

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

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

# 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'
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "primegap_#{Rails.env}"

# 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.
Expand Down
8 changes: 5 additions & 3 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false

# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.

# Require `belongs_to` associations by default. This is a new Rails 5.0 default,
# so introduced as a config to ensure apps made with earlier versions of Rails aren't affected when upgrading.
Rails.application.config.active_record.belongs_to_required_by_default = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Be sure to restart your server when you modify this file.

# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
Expand Down
5 changes: 5 additions & 0 deletions spec/dummy/config/initializers/callback_terminator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.

# Do not halt callback chains when a callback returns false. This is a new Rails 5.0 default,
# so introduced as a config to ensure apps made with earlier versions of Rails aren't affected when upgrading.
ActiveSupport.halt_callback_chains_on_return_false = false
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Be sure to restart your server when you modify this file.

# This is a new Rails 5.0 default, so introduced as a config to ensure apps made with earlier versions of Rails aren't affected when upgrading.
Rails.application.config.action_dispatch.cookies_serializer = :json
16 changes: 16 additions & 0 deletions spec/dummy/config/initializers/cors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.

# Avoid CORS issues when API is called from the frontend app.
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.

# Read more: https://github.com/cyu/rack-cors

# Rails.application.config.middleware.insert_before 0, Rack::Cors do
# allow do
# origins 'example.com'
#
# resource '*',
# headers: :any,
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
# end
# end
4 changes: 4 additions & 0 deletions spec/dummy/config/initializers/request_forgery_protection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.

# Enable origin-checking CSRF mitigation.
Rails.application.config.action_controller.forgery_protection_origin_check = true
4 changes: 2 additions & 2 deletions spec/dummy/config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end

# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# self.include_root_in_json = true
# end
Loading