signinable 2.0.10 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +6 -4
  3. data/app/models/signin.rb +24 -5
  4. data/config/routes.rb +2 -0
  5. data/db/migrate/20140103165607_create_signins.rb +7 -5
  6. data/db/migrate/20180530131006_add_custom_data_to_sigins.rb +5 -5
  7. data/lib/signinable/engine.rb +6 -9
  8. data/lib/signinable/model_additions.rb +117 -51
  9. data/lib/signinable/version.rb +3 -1
  10. data/lib/signinable.rb +3 -1
  11. data/spec/dummy/Rakefile +3 -1
  12. data/spec/dummy/app/models/user.rb +3 -1
  13. data/spec/dummy/bin/bundle +3 -1
  14. data/spec/dummy/bin/rails +3 -1
  15. data/spec/dummy/bin/rake +2 -0
  16. data/spec/dummy/config/application.rb +5 -20
  17. data/spec/dummy/config/boot.rb +5 -3
  18. data/spec/dummy/config/environment.rb +3 -1
  19. data/spec/dummy/config/environments/development.rb +4 -2
  20. data/spec/dummy/config/environments/production.rb +2 -0
  21. data/spec/dummy/config/environments/test.rb +4 -2
  22. data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
  23. data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  24. data/spec/dummy/config/initializers/inflections.rb +1 -0
  25. data/spec/dummy/config/initializers/mime_types.rb +1 -0
  26. data/spec/dummy/config/initializers/secret_token.rb +2 -0
  27. data/spec/dummy/config/initializers/session_store.rb +2 -0
  28. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  29. data/spec/dummy/config/routes.rb +2 -0
  30. data/spec/dummy/config.ru +3 -1
  31. data/spec/dummy/db/development.sqlite3 +0 -0
  32. data/spec/dummy/db/migrate/20140103165606_create_users.rb +3 -1
  33. data/spec/dummy/db/schema.rb +23 -24
  34. data/spec/dummy/db/test.sqlite3 +0 -0
  35. data/spec/dummy/log/development.log +427 -0
  36. data/spec/dummy/log/test.log +20023 -0
  37. data/spec/factories/signins.rb +8 -0
  38. data/spec/factories/users.rb +7 -0
  39. data/spec/models/signin_spec.rb +85 -33
  40. data/spec/models/user_spec.rb +204 -84
  41. data/spec/rails_helper.rb +20 -0
  42. data/spec/spec_helper.rb +11 -12
  43. data/spec/support/utilities.rb +3 -2
  44. metadata +76 -38
  45. data/spec/factories/signin.rb +0 -8
  46. data/spec/factories/user.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 613fce3b113d51ec3af31824c31ef3c61b90178cc96064974e28bfca260d53a1
4
- data.tar.gz: 30b3a5aa8f20d9440c468f861a668a0fb343efa775089dd01c340f6b03fa3e87
3
+ metadata.gz: e090b91cbbcbbfe860ca07984e3a19a965cc96bf2909f4e469e5d0ed48794dbe
4
+ data.tar.gz: c84bacb35618b62991ab60c984ec8f8c9786d783c3dd3dc8dc6a9ea76ed4881e
5
5
  SHA512:
6
- metadata.gz: ceb30fb1d87f2ad6b49d46d0437613d1db335b23d2b2b0387017378e710733cc16db249ac394a835f65c6cc4382669e0e6de56b80a0e8f4824d8ced1cf4d949e
7
- data.tar.gz: 56905aa833721288f73fca3603e08083aa4e4c59a988d21c300b7c458f1f3fab610fa4c26542c9e42e1405b390a54b98cee08baad135d03fbcf715f046245f24
6
+ metadata.gz: 3e96a9511dd6560c05ddfdc03b94d71ea83720e982526412a59a8e4a0461d475a4fb970ceb680636f23f144cb2273a811a0014897bf77597eeff7c7652d7e962
7
+ data.tar.gz: 2dcc381256505cebdeb990ac0340200c3134c8e1337f1bbe41082e233d35187ecdc4e30aebf71d316ea99da7de861649415514d9043eaf958df59b630c38d439
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
4
6
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
7
  end
6
8
 
7
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
8
10
  load 'rails/tasks/engine.rake'
9
11
 
10
12
  Bundler::GemHelper.install_tasks
@@ -12,7 +14,7 @@ Bundler::GemHelper.install_tasks
12
14
  require 'rspec/core'
13
15
  require 'rspec/core/rake_task'
14
16
 
15
- desc "Run all specs in spec directory (excluding plugin specs)"
16
- RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
17
+ desc 'Run all specs in spec directory (excluding plugin specs)'
18
+ RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
17
19
 
18
- task :default => :spec
20
+ task default: :spec
data/app/models/signin.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'resolv'
2
4
 
3
5
  class Signin < ActiveRecord::Base
@@ -8,19 +10,36 @@ class Signin < ActiveRecord::Base
8
10
  presence: true,
9
11
  format: { with: Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex) }
10
12
 
13
+ scope :active, -> { where('expiration_time IS NULL OR expiration_time > ?', Time.zone.now) }
14
+
11
15
  before_validation on: :create do
12
- self.token = SecureRandom.urlsafe_base64(rand(50..100))
16
+ self.token = generate_token
13
17
  end
14
18
 
19
+ serialize :custom_data if ActiveRecord::Base.connection.instance_values['config'][:adapter].match('mysql')
20
+
15
21
  def expire!
16
- update_attributes(expiration_time: Time.zone.now)
22
+ renew!(period: 0, ip: ip, user_agent: user_agent)
17
23
  end
18
24
 
19
25
  def expired?
20
- expiration_time && expiration_time <= Time.zone.now
26
+ expireable? && expiration_time.past?
27
+ end
28
+
29
+ def expireable?
30
+ !expiration_time.nil?
31
+ end
32
+
33
+ def renew!(period:, ip:, user_agent:, refresh_token: false)
34
+ update_hash = { ip: ip, user_agent: user_agent }
35
+ update_hash[:expiration_time] = Time.zone.now + period if expireable?
36
+ update_hash[:token] = generate_token if refresh_token
37
+ update!(update_hash)
21
38
  end
22
39
 
23
- if ActiveRecord::Base.connection.instance_values['config'][:adapter].match('mysql')
24
- serialize :custom_data
40
+ private
41
+
42
+ def generate_token
43
+ SecureRandom.urlsafe_base64(rand(50..100))
25
44
  end
26
45
  end
data/config/routes.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  migration_kls = Rails::VERSION::MAJOR > 4 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
2
4
  class CreateSignins < migration_kls
3
5
  def self.up
@@ -5,18 +7,18 @@ class CreateSignins < migration_kls
5
7
  t.integer :signinable_id, null: false
6
8
  t.string :signinable_type, null: false
7
9
  t.string :token, null: false
8
- t.string :referer, default: ""
9
- t.string :user_agent, default: ""
10
+ t.string :referer, default: ''
11
+ t.string :user_agent, default: ''
10
12
  t.string :ip, null: false
11
13
  t.datetime :expiration_time
12
14
  t.timestamps
13
15
  end
14
16
 
15
- if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "postgresql"
16
- execute "ALTER TABLE signins ALTER COLUMN ip TYPE inet USING ip::inet"
17
+ if ActiveRecord::Base.connection.instance_values['config'][:adapter] == 'postgresql'
18
+ execute 'ALTER TABLE signins ALTER COLUMN ip TYPE inet USING ip::inet'
17
19
  end
18
20
 
19
- add_index :signins, [:signinable_id, :signinable_type]
21
+ add_index :signins, %i[signinable_id signinable_type]
20
22
  add_index :signins, :token
21
23
  end
22
24
 
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  migration_kls = Rails::VERSION::MAJOR > 4 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
2
4
 
3
5
  class AddCustomDataToSigins < migration_kls
4
6
  def change
5
-
6
- if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "postgresql"
7
- add_column :signins, :custom_data, :jsonb, null:false, default: {}
7
+ if ActiveRecord::Base.connection.instance_values['config'][:adapter] == 'postgresql'
8
+ add_column :signins, :custom_data, :jsonb, null: false, default: {}
8
9
  else
9
- add_column :signins, :custom_data, :string, null:false, default: {}.to_json
10
+ add_column :signins, :custom_data, :string, null: false, default: {}.to_json
10
11
  end
11
-
12
12
  end
13
13
  end
@@ -1,18 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jwt'
4
+
1
5
  module Signinable
2
6
  class Engine < ::Rails::Engine
3
7
  initializer :append_migrations do |app|
4
8
  unless app.root.to_s.match(root.to_s)
5
- config.paths["db/migrate"].expanded.each do |path|
6
- app.config.paths["db/migrate"] << path
9
+ config.paths['db/migrate'].expanded.each do |path|
10
+ app.config.paths['db/migrate'] << path
7
11
  end
8
12
  end
9
13
  end
10
-
11
- config.generators do |g|
12
- g.test_framework :rspec, :fixture => false
13
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
14
- g.assets false
15
- g.helper false
16
- end
17
14
  end
18
15
  end
@@ -1,87 +1,153 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Signinable
2
4
  module ModelAdditions
3
5
  extend ActiveSupport::Concern
4
6
 
5
7
  module ClassMethods
8
+ ALLOWED_RESTRICTIONS = %i[ip user_agent].freeze
9
+ DEFAULT_REFRESH_EXP = 7200
10
+ DEFAULT_JWT_EXP = 900
11
+
12
+ cattr_reader :refresh_exp
13
+ cattr_reader :simultaneous_signings
14
+ cattr_reader :signin_restrictions
15
+ cattr_reader :jwt_secret
16
+ cattr_reader :jwt_exp
17
+
6
18
  def signinable(options = {})
7
- cattr_accessor :signin_expiration
8
- cattr_accessor :signin_simultaneous
9
- cattr_accessor :signin_restrictions
10
- self.signin_expiration = options.fetch(:expiration, 2.hours)
11
- self.signin_simultaneous = options.fetch(:simultaneous, true)
19
+ self.refresh_exp = options.fetch(:expiration, DEFAULT_REFRESH_EXP)
20
+ self.simultaneous_signings = options.fetch(:simultaneous, true)
12
21
  self.signin_restrictions = options[:restrictions]
22
+ self.jwt_secret = options.fetch(:jwt_secret)
23
+ self.jwt_exp = options.fetch(:jwt_exp, DEFAULT_JWT_EXP)
13
24
 
14
25
  has_many :signins, as: :signinable, dependent: :destroy
26
+
27
+ attr_accessor :jwt
15
28
  end
16
29
 
17
- def authenticate_with_token(token, ip, user_agent, skip_restrictions=[])
18
- if(signin = Signin.find_by_token(token))
19
- if self.signin_expiration.respond_to?(:call)
20
- self.signin_expiration = self.signin_expiration.call(signin.signinable)
21
- end
30
+ def authenticate_with_token(jwt, ip, user_agent, skip_restrictions: [])
31
+ jwt_payload = extract_jwt_payload(jwt)
32
+ return refresh_jwt(jwt, ip, user_agent, skip_restrictions: skip_restrictions) unless jwt_payload
22
33
 
23
- if self.signin_expiration > 0
24
- return nil if signin.expired?
25
- end
34
+ find_by(primary_key => jwt_payload['signinable_id'])
35
+ end
26
36
 
27
- unless self.signin_simultaneous
28
- return nil unless signin == signin.signinable.last_signin
29
- end
37
+ def check_signin_permission(signin, restrictions_to_check, skip_restrictions)
38
+ signin_permitted?(signin, restrictions_to_check, skip_restrictions)
39
+ end
30
40
 
31
- return nil unless self.check_signin_permission(signin, ip, user_agent, skip_restrictions)
32
- signin.update!(expiration_time: (Time.zone.now + self.signin_expiration)) unless signin.expiration_time.nil? || self.signin_expiration == 0
33
- signin.signinable
34
- end
41
+ def expiration_period
42
+ return refresh_exp.call if refresh_exp.respond_to?(:call)
43
+
44
+ refresh_exp
45
+ end
46
+
47
+ def generate_jwt(refresh_token, signinable_id)
48
+ JWT.encode(
49
+ {
50
+ refresh_token: refresh_token,
51
+ signinable_id: signinable_id,
52
+ exp: Time.zone.now.to_i + jwt_exp
53
+ },
54
+ jwt_secret,
55
+ 'HS256'
56
+ )
35
57
  end
36
58
 
37
- def check_signin_permission(signin, ip, user_agent, skip_restrictions)
38
- signin_permitted?(signin, ip, user_agent, skip_restrictions)
59
+ def refresh_jwt(jwt, ip, user_agent, skip_restrictions: [])
60
+ token = refresh_token_from_jwt(jwt)
61
+ return nil unless token
62
+
63
+ signin = Signin.find_by(token: token)
64
+
65
+ return unless signin
66
+ return nil if signin.expired?
67
+ return nil unless check_signin_permission(signin, { ip: ip, user_agent: user_agent }, skip_restrictions)
68
+
69
+ signin.renew!(period: expiration_period, ip: ip, user_agent: user_agent, refresh_token: true)
70
+ signin.signinable.jwt = generate_jwt(signin.token, signin.signinable_id)
71
+ signin.signinable
39
72
  end
40
73
 
41
74
  private
42
- def signin_permitted?(signin, ip, user_agent, skip_restrictions)
43
- restriction_fields = case
44
- when self.signin_restrictions.respond_to?(:call)
45
- self.signin_restrictions.call(signin.signinable)
46
- when self.signin_restrictions.is_a?(Array)
47
- self.signin_restrictions
48
- else
49
- []
50
- end
51
75
 
52
- (restriction_fields - skip_restrictions).each do |field|
53
- if(local_variables.include?(field.to_sym) && signin.respond_to?("#{field}"))
54
- return false unless signin.send("#{field}") == eval("#{field}")
55
- end
76
+ cattr_writer :refresh_exp
77
+ cattr_writer :simultaneous_signings
78
+ cattr_writer :signin_restrictions
79
+ cattr_writer :jwt_secret
80
+ cattr_writer :jwt_exp
81
+
82
+ def extract_jwt_payload(jwt)
83
+ JWT.decode(jwt, jwt_secret, true, { algorithm: 'HS256' })[0]
84
+ rescue JWT::DecodeError
85
+ nil
86
+ end
87
+
88
+ def refresh_token_from_jwt(jwt)
89
+ JWT.decode(jwt, jwt_secret, true, { verify_expiration: false, algorithm: 'HS256' })[0]['refresh_token']
90
+ rescue JWT::DecodeError
91
+ nil
92
+ end
93
+
94
+ def signin_permitted?(signin, restrictions_to_check, skip_restrictions)
95
+ restriction_fields = signin_restriction_fields(signin, skip_restrictions)
96
+
97
+ restrictions_to_check.slice(*restriction_fields).each do |field, value|
98
+ return false unless signin.send(field) == value
56
99
  end
57
100
 
58
- return true
101
+ true
59
102
  end
60
- end
61
103
 
62
- def signin(ip, user_agent, referer, permanent = false, custom_data = {})
63
- if self.class.signin_expiration.respond_to?(:call)
64
- self.class.signin_expiration = self.class.signin_expiration.call(self)
104
+ def signin_restriction_fields(signin, skip_restrictions)
105
+ fields = if signin_restrictions.respond_to?(:call)
106
+ signin_restrictions.call(signin.signinable)
107
+ elsif signin_restrictions.is_a?(Array)
108
+ signin_restrictions
109
+ else
110
+ []
111
+ end
112
+ (fields - skip_restrictions) & ALLOWED_RESTRICTIONS
65
113
  end
66
- expiration_time = (self.class.signin_expiration == 0 || permanent) ? nil : (Time.zone.now + self.class.signin_expiration)
67
- Signin.create!(custom_data: custom_data, signinable: self, ip: ip, referer: referer, user_agent: user_agent, expiration_time: expiration_time).token
68
114
  end
69
115
 
70
- def signout(token, ip, user_agent, skip_restrictions=[])
71
- if(signin = Signin.find_by_token(token))
72
- return nil unless self.class.check_signin_permission(signin, ip, user_agent, skip_restrictions)
73
- signin.expire!
116
+ def signin(ip, user_agent, referer, permanent: false, custom_data: {})
117
+ expires_in = self.class.expiration_period
118
+ expiration_time = expires_in.zero? || permanent ? nil : expires_in.seconds.from_now
119
+ Signin.where(signinable: self).active.map(&:expire!) unless self.class.simultaneous_signings
120
+ signin = Signin.create!(
121
+ signinable: self,
122
+ ip: ip,
123
+ referer: referer,
124
+ user_agent: user_agent,
125
+ expiration_time: expiration_time,
126
+ custom_data: custom_data
127
+ )
128
+
129
+ self.jwt = self.class.generate_jwt(signin.token, signin.signinable_id)
130
+ end
131
+
132
+ def signout(token, ip, user_agent, skip_restrictions: [])
133
+ signin = Signin.find_by_token(token)
74
134
 
75
- return true
76
- end
135
+ return unless signin
136
+ return unless self.class.check_signin_permission(
137
+ signin,
138
+ { ip: ip, user_agent: user_agent },
139
+ skip_restrictions
140
+ )
141
+
142
+ signin.expire!
77
143
 
78
- return nil
144
+ true
79
145
  end
80
146
 
81
147
  def last_signin
82
- signins.last unless signins.empty?
148
+ signins.active.last
83
149
  end
84
150
  end
85
151
  end
86
152
 
87
- ActiveRecord::Base.send(:include, Signinable::ModelAdditions)
153
+ ActiveRecord::Base.include Signinable::ModelAdditions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Signinable
2
- VERSION = "2.0.10"
4
+ VERSION = '2.0.13'
3
5
  end
data/lib/signinable.rb CHANGED
@@ -1,3 +1,5 @@
1
- require "signinable/engine"
1
+ # frozen_string_literal: true
2
+
3
+ require 'signinable/engine'
2
4
  require 'signinable/version'
3
5
  require 'signinable/model_additions'
data/spec/dummy/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
4
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
5
 
4
- require File.expand_path('../config/application', __FILE__)
6
+ require File.expand_path('config/application', __dir__)
5
7
 
6
8
  Dummy::Application.load_tasks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class User < ActiveRecord::Base
2
- signinable
4
+ signinable jwt_secret: 'test', jwt_exp: 100
3
5
  end
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
5
  load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/rails CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
5
  require_relative '../config/boot'
4
6
  require 'rails/commands'
data/spec/dummy/bin/rake CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require_relative '../config/boot'
3
5
  require 'rake'
4
6
  Rake.application.run
@@ -1,28 +1,13 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ # frozen_string_literal: true
2
2
 
3
- # Pick the frameworks you want:
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_mailer/railtie"
7
- require "sprockets/railtie"
8
- # require "rails/test_unit/railtie"
3
+ require File.expand_path('boot', __dir__)
4
+
5
+ require 'active_record/railtie'
9
6
 
10
7
  Bundler.require(*Rails.groups)
11
- require "signinable"
8
+ require 'signinable'
12
9
 
13
10
  module Dummy
14
11
  class Application < Rails::Application
15
- # Settings in config/environments/* take precedence over those specified here.
16
- # Application configuration should go into files in config/initializers
17
- # -- all .rb files in that directory are automatically loaded.
18
-
19
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
20
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
21
- # config.time_zone = 'Central Time (US & Canada)'
22
-
23
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
24
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
25
- # config.i18n.default_locale = :de
26
12
  end
27
13
  end
28
-
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
5
 
4
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
4
+ require File.expand_path('application', __dir__)
3
5
 
4
6
  # Initialize the Rails application.
5
7
  Dummy::Application.initialize!
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -14,7 +16,7 @@ Dummy::Application.configure do
14
16
  config.action_controller.perform_caching = false
15
17
 
16
18
  # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
19
+ # config.action_mailer.raise_delivery_errors = false
18
20
 
19
21
  # Print deprecation notices to the Rails logger.
20
22
  config.active_support.deprecation = :log
@@ -25,5 +27,5 @@ Dummy::Application.configure do
25
27
  # Debug mode disables concatenation and preprocessing of assets.
26
28
  # This option may cause significant delays in view rendering with a large
27
29
  # number of complex assets.
28
- config.assets.debug = true
30
+ # config.assets.debug = true
29
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -14,7 +16,7 @@ Dummy::Application.configure do
14
16
 
15
17
  # Configure static asset server for tests with Cache-Control for performance.
16
18
  config.serve_static_assets = true
17
- config.static_cache_control = "public, max-age=3600"
19
+ config.static_cache_control = 'public, max-age=3600'
18
20
 
19
21
  # Show full error reports and disable caching.
20
22
  config.consider_all_requests_local = true
@@ -29,7 +31,7 @@ Dummy::Application.configure do
29
31
  # Tell Action Mailer not to deliver emails to the real world.
30
32
  # The :test delivery method accumulates sent emails in the
31
33
  # ActionMailer::Base.deliveries array.
32
- config.action_mailer.delivery_method = :test
34
+ # config.action_mailer.delivery_method = :test
33
35
 
34
36
  # Print deprecation notices to the stderr.
35
37
  config.active_support.deprecation = :stderr
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Your secret key is used for verifying the integrity of signed cookies.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.routes.draw do
2
4
  # The priority is based upon order of creation: first created -> highest priority.
3
5
  # See how all your routes lay out with "rake routes".
data/spec/dummy/config.ru CHANGED
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is used by Rack-based servers to start the application.
2
4
 
3
- require ::File.expand_path('../config/environment', __FILE__)
5
+ require ::File.expand_path('config/environment', __dir__)
4
6
  run Rails.application
File without changes
@@ -1,4 +1,6 @@
1
- class CreateUsers < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class CreateUsers < ActiveRecord::Migration[5.0]
2
4
  def self.up
3
5
  create_table :users do |t|
4
6
  t.string :name