signinable 2.0.9 → 2.0.12

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 +5 -5
  2. data/Rakefile +6 -4
  3. data/app/models/signin.rb +12 -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 +4 -9
  8. data/lib/signinable/model_additions.rb +77 -52
  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 +2 -0
  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 +8191 -4
  37. data/spec/factories/signins.rb +8 -0
  38. data/spec/factories/users.rb +7 -0
  39. data/spec/models/signin_spec.rb +25 -23
  40. data/spec/models/user_spec.rb +71 -72
  41. data/spec/rails_helper.rb +20 -0
  42. data/spec/spec_helper.rb +11 -12
  43. data/spec/support/utilities.rb +2 -0
  44. metadata +59 -39
  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
- SHA1:
3
- metadata.gz: dfd2f8cb93874c2f44d45af37cb5bd4290a6ee97
4
- data.tar.gz: 2f351adfbffad55c6cb969da80e995876ebbf3e7
2
+ SHA256:
3
+ metadata.gz: dcefec413ade50e4c25e5092ce23033646cb6ed3b7e19bbe473011ecbf4bb649
4
+ data.tar.gz: e9c6374287e726ce2007b3a6654063d017138161cfaf51cb2076167e629708d2
5
5
  SHA512:
6
- metadata.gz: 76d30b26ad8ff5f4c48cfc5a62b83ab5d671ca466e577ede1eee46cb834e60370146cd7f86a5502aca92c00f67e4fb9ff4496d9a57b18536db5fac3a8638bd1e
7
- data.tar.gz: ecc32963b5478ff9f610d0bbd8b8448787eeb070ac0d9232c39fb7f9f1d65ca3f44ecd8c859aa757685a2fe59ee6b4aef86cb11667aa4eac9707b05208e514c3
6
+ metadata.gz: '07509bfee44ecffa2072e9c7730c8b9aa557c60bf1d3d599366f9b793b77b7a4934f7de800a77157bfdba2773be1e7908343ef11d90550a6d52fccb8d8982786'
7
+ data.tar.gz: ecd7ec4b2e43ff9d6a219d255674a8ee0663d190549123af5998300ba1ce52d4c972b9636b433fe685fa43d9da6159303a650c9f2937453c01e40b35719da91f
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
@@ -13,15 +15,20 @@ class Signin < ActiveRecord::Base
13
15
  end
14
16
 
15
17
  def expire!
16
- update_attributes(expiration_time: Time.zone.now)
18
+ renew!(0)
17
19
  end
18
20
 
19
21
  def expired?
20
- expiration_time && expiration_time <= Time.zone.now
22
+ expireable? && expiration_time.past?
23
+ end
24
+
25
+ def expireable?
26
+ !expiration_time.nil?
21
27
  end
22
28
 
23
- if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "mysql"
24
- serialize :custom_data
29
+ def renew!(period)
30
+ update!(expiration_time: (Time.zone.now + period))
25
31
  end
26
-
32
+
33
+ serialize :custom_data if ActiveRecord::Base.connection.instance_values['config'][:adapter].match('mysql')
27
34
  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,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Signinable
2
4
  class Engine < ::Rails::Engine
3
5
  initializer :append_migrations do |app|
4
6
  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
7
+ config.paths['db/migrate'].expanded.each do |path|
8
+ app.config.paths['db/migrate'] << path
7
9
  end
8
10
  end
9
11
  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
12
  end
18
13
  end
@@ -1,88 +1,113 @@
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_EXPIRATION = 7200
10
+
11
+ cattr_reader :signin_expiration
12
+ cattr_reader :simultaneous_signings
13
+ cattr_reader :signin_restrictions
14
+
6
15
  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)
16
+ self.signin_expiration = options.fetch(:expiration, DEFAULT_EXPIRATION)
17
+ self.simultaneous_signings = options.fetch(:simultaneous, true)
12
18
  self.signin_restrictions = options[:restrictions]
13
19
 
14
20
  has_many :signins, as: :signinable, dependent: :destroy
15
21
  end
16
22
 
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
23
+ def authenticate_with_token(token, ip, user_agent, skip_restrictions: [])
24
+ signin = Signin.find_by(token: token)
22
25
 
23
- if self.signin_expiration > 0
24
- return nil if signin.expired?
25
- end
26
+ return unless signin
27
+ return nil if signin.expired?
28
+ return nil unless check_simultaneous_signings(signin)
29
+ return nil unless check_signin_permission(signin, { ip: ip, user_agent: user_agent }, skip_restrictions)
26
30
 
27
- unless self.signin_simultaneous
28
- return nil unless signin == signin.signinable.last_signin
29
- end
31
+ signin.renew!(expiration_period) if signin.expireable?
32
+ signin.signinable
33
+ end
30
34
 
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
35
+ def check_signin_permission(signin, restrictions_to_check, skip_restrictions)
36
+ signin_permitted?(signin, restrictions_to_check, skip_restrictions)
35
37
  end
36
38
 
37
- def check_signin_permission(signin, ip, user_agent, skip_restrictions)
38
- signin_permitted?(signin, ip, user_agent, skip_restrictions)
39
+ def expiration_period
40
+ return signin_expiration.call if signin_expiration.respond_to?(:call)
41
+
42
+ signin_expiration
39
43
  end
40
44
 
41
45
  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
46
 
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
47
+ cattr_writer :signin_expiration
48
+ cattr_writer :simultaneous_signings
49
+ cattr_writer :signin_restrictions
50
+
51
+ def signin_permitted?(signin, restrictions_to_check, skip_restrictions)
52
+ restriction_fields = signin_restriction_fields(signin, skip_restrictions)
53
+
54
+ restrictions_to_check.slice(*restriction_fields).each do |field, value|
55
+ return false unless signin.send(field) == value
56
56
  end
57
57
 
58
- return true
58
+ true
59
59
  end
60
- end
61
60
 
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)
61
+ def signin_restriction_fields(signin, skip_restrictions)
62
+ fields = if signin_restrictions.respond_to?(:call)
63
+ signin_restrictions.call(signin.signinable)
64
+ elsif signin_restrictions.is_a?(Array)
65
+ signin_restrictions
66
+ else
67
+ []
68
+ end
69
+ (fields - skip_restrictions) & ALLOWED_RESTRICTIONS
65
70
  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
- end
69
71
 
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!
72
+ def check_simultaneous_signings(signin)
73
+ return true if simultaneous_signings
74
74
 
75
- return true
75
+ signin == signin.signinable.last_signin
76
76
  end
77
+ end
77
78
 
78
- return nil
79
+ def signin(ip, user_agent, referer, permanent: false, custom_data: {})
80
+ expires_in = self.class.expiration_period
81
+ expiration_time = expires_in.zero? || permanent ? nil : expires_in.seconds.from_now
82
+ Signin.create!(
83
+ signinable: self,
84
+ ip: ip,
85
+ referer: referer,
86
+ user_agent: user_agent,
87
+ expiration_time: expiration_time,
88
+ custom_data: custom_data
89
+ ).token
79
90
  end
80
91
 
81
- def last_signin
82
- signins.last unless signins.empty?
92
+ def signout(token, ip, user_agent, skip_restrictions: [])
93
+ signin = Signin.find_by_token(token)
94
+
95
+ return unless signin
96
+ return unless self.class.check_signin_permission(
97
+ signin,
98
+ { ip: ip, user_agent: user_agent },
99
+ skip_restrictions
100
+ )
101
+
102
+ signin.expire!
103
+
104
+ true
83
105
  end
84
106
 
107
+ def last_signin
108
+ signins.last
109
+ end
85
110
  end
86
111
  end
87
112
 
88
- ActiveRecord::Base.send(:include, Signinable::ModelAdditions)
113
+ ActiveRecord::Base.include Signinable::ModelAdditions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Signinable
2
- VERSION = "2.0.9"
4
+ VERSION = '2.0.12'
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
4
  signinable
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
@@ -1,35 +1,34 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  # This file is auto-generated from the current state of the database. Instead
3
4
  # of editing this file, please use the migrations feature of Active Record to
4
5
  # incrementally modify your database, and then regenerate this schema definition.
5
6
  #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
7
+ # This file is the source Rails uses to define your schema when running `bin/rails
8
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
9
+ # be faster and is potentially less error prone than running all of your
10
+ # migrations from scratch. Old migrations may fail to apply correctly if those
11
+ # migrations use external dependencies or application code.
11
12
  #
12
13
  # It's strongly recommended that you check this file into your version control system.
13
14
 
14
- ActiveRecord::Schema.define(version: 20140103165607) do
15
-
16
- create_table "signins", force: true do |t|
17
- t.integer "signinable_id", null: false
18
- t.string "signinable_type", null: false
19
- t.string "token", null: false
20
- t.string "referer", default: ""
21
- t.string "user_agent", default: ""
22
- t.string "ip", null: false
23
- t.datetime "expiration_time"
24
- t.datetime "created_at"
25
- t.datetime "updated_at"
15
+ ActiveRecord::Schema.define(version: 20_180_530_131_006) do
16
+ create_table 'signins', force: :cascade do |t|
17
+ t.integer 'signinable_id', null: false
18
+ t.string 'signinable_type', null: false
19
+ t.string 'token', null: false
20
+ t.string 'referer', default: ''
21
+ t.string 'user_agent', default: ''
22
+ t.string 'ip', null: false
23
+ t.datetime 'expiration_time'
24
+ t.datetime 'created_at', null: false
25
+ t.datetime 'updated_at', null: false
26
+ t.string 'custom_data', default: '{}', null: false
27
+ t.index %w[signinable_id signinable_type], name: 'index_signins_on_signinable_id_and_signinable_type'
28
+ t.index ['token'], name: 'index_signins_on_token'
26
29
  end
27
30
 
28
- add_index "signins", ["signinable_id", "signinable_type"], name: "index_signins_on_signinable_id_and_signinable_type"
29
- add_index "signins", ["token"], name: "index_signins_on_token"
30
-
31
- create_table "users", force: true do |t|
32
- t.string "name"
31
+ create_table 'users', force: :cascade do |t|
32
+ t.string 'name'
33
33
  end
34
-
35
34
  end
Binary file