introspective_admin 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +75 -0
- data/.ruby-version +1 -1
- data/Gemfile +20 -11
- data/Gemfile.lock +190 -135
- data/Rakefile +3 -5
- data/introspective_admin.gemspec +16 -21
- data/lib/introspective_admin/base.rb +64 -47
- data/lib/introspective_admin/version.rb +3 -1
- data/lib/introspective_admin.rb +2 -0
- data/lib/tasks/introspective_admin_tasks.rake +2 -0
- data/spec/admin/company_admin_spec.rb +24 -23
- data/spec/admin/job_admin_spec.rb +21 -19
- data/spec/admin/location_admin_spec.rb +27 -23
- data/spec/admin/location_beacon_admin_spec.rb +26 -24
- data/spec/admin/project__admin_spec.rb +26 -24
- data/spec/admin/user_admin_spec.rb +25 -24
- data/spec/dummy/Gemfile +6 -4
- data/spec/dummy/Rakefile +3 -1
- data/spec/dummy/app/admin/admin_users.rb +2 -1
- data/spec/dummy/app/admin/company_admin.rb +4 -3
- data/spec/dummy/app/admin/dashboard.rb +10 -8
- data/spec/dummy/app/admin/job_admin.rb +3 -2
- data/spec/dummy/app/admin/location_admin.rb +3 -2
- data/spec/dummy/app/admin/location_beacon_admin.rb +2 -0
- data/spec/dummy/app/admin/project_admin.rb +3 -4
- data/spec/dummy/app/admin/role_admin.rb +3 -3
- data/spec/dummy/app/admin/user_admin.rb +5 -5
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -1
- data/spec/dummy/app/models/abstract_adapter.rb +10 -8
- data/spec/dummy/app/models/admin_user.rb +4 -2
- data/spec/dummy/app/models/company.rb +3 -2
- data/spec/dummy/app/models/job.rb +3 -3
- data/spec/dummy/app/models/locatable.rb +3 -1
- data/spec/dummy/app/models/location.rb +4 -3
- data/spec/dummy/app/models/location_beacon.rb +5 -5
- data/spec/dummy/app/models/location_gps.rb +2 -2
- data/spec/dummy/app/models/project.rb +6 -6
- data/spec/dummy/app/models/project_job.rb +2 -1
- data/spec/dummy/app/models/role.rb +8 -7
- data/spec/dummy/app/models/team.rb +2 -1
- data/spec/dummy/app/models/team_user.rb +5 -4
- data/spec/dummy/app/models/user.rb +22 -18
- data/spec/dummy/app/models/user_location.rb +14 -14
- data/spec/dummy/app/models/user_project_job.rb +4 -3
- data/spec/dummy/bin/bundle +3 -1
- data/spec/dummy/bin/rails +3 -1
- data/spec/dummy/bin/rake +2 -0
- data/spec/dummy/bin/setup +10 -8
- data/spec/dummy/config/application.rb +12 -11
- data/spec/dummy/config/boot.rb +4 -2
- data/spec/dummy/config/environment.rb +6 -5
- data/spec/dummy/config/environments/development.rb +3 -1
- data/spec/dummy/config/environments/production.rb +4 -3
- data/spec/dummy/config/environments/test.rb +5 -5
- data/spec/dummy/config/initializers/active_admin.rb +5 -4
- data/spec/dummy/config/initializers/assets.rb +3 -1
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +2 -0
- data/spec/dummy/config/initializers/mime_types.rb +2 -0
- data/spec/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config/initializers/zeitwerk.rb +6 -4
- data/spec/dummy/config/routes.rb +5 -3
- data/spec/dummy/config.ru +3 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20141002205024_devise_create_users.rb +4 -3
- data/spec/dummy/db/migrate/20141002211055_devise_create_admin_users.rb +4 -3
- data/spec/dummy/db/migrate/20141002211057_create_active_admin_comments.rb +4 -2
- data/spec/dummy/db/migrate/20141002220722_add_lockable_to_users.rb +2 -0
- data/spec/dummy/db/migrate/20150406213646_create_companies.rb +2 -0
- data/spec/dummy/db/migrate/20150414213154_add_user_authentication_token.rb +4 -2
- data/spec/dummy/db/migrate/20150415222005_create_roles.rb +3 -2
- data/spec/dummy/db/migrate/20150505181635_create_chats.rb +2 -0
- data/spec/dummy/db/migrate/20150505181636_create_chat_users.rb +2 -0
- data/spec/dummy/db/migrate/20150505181640_create_chat_messages.rb +2 -0
- data/spec/dummy/db/migrate/20150507191529_create_chat_message_users.rb +2 -0
- data/spec/dummy/db/migrate/20150601200526_create_locations.rb +3 -1
- data/spec/dummy/db/migrate/20150601200533_create_locatables.rb +2 -0
- data/spec/dummy/db/migrate/20150601212924_create_location_beacons.rb +4 -2
- data/spec/dummy/db/migrate/20150601213542_create_location_gps.rb +2 -0
- data/spec/dummy/db/migrate/20150609201823_create_user_locations.rb +2 -0
- data/spec/dummy/db/migrate/20150617232519_create_projects.rb +2 -0
- data/spec/dummy/db/migrate/20150617232521_create_jobs.rb +2 -0
- data/spec/dummy/db/migrate/20150617232522_create_project_jobs.rb +3 -1
- data/spec/dummy/db/migrate/20150623170133_create_user_project_jobs.rb +3 -1
- data/spec/dummy/db/migrate/20150701234929_create_teams.rb +2 -0
- data/spec/dummy/db/migrate/20150701234930_create_team_users.rb +3 -1
- data/spec/dummy/db/migrate/20150727214950_add_confirmable_to_devise.rb +4 -2
- data/spec/dummy/db/migrate/20150820190524_add_user_names.rb +4 -2
- data/spec/dummy/db/migrate/20150909225019_add_password_to_project.rb +2 -0
- data/spec/dummy/db/migrate/20220806003731_add_devise_to_admin_users.rb +2 -3
- data/spec/dummy/db/schema.rb +197 -198
- data/spec/rails_helper.rb +17 -11
- data/spec/support/blueprints.rb +50 -49
- data/spec/support/location_helper.rb +28 -29
- metadata +13 -153
- data/spec/dummy/db/development.sqlite3-shm +0 -0
- data/spec/dummy/db/development.sqlite3-wal +0 -0
- data/spec/dummy/introspective_admin.gemspec +0 -34
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Role < AbstractAdapter
|
|
2
4
|
belongs_to :user
|
|
3
5
|
belongs_to :ownable, polymorphic: true
|
|
4
6
|
|
|
5
|
-
validates_uniqueness_of :user_id, scope: [
|
|
6
|
-
validates_inclusion_of :ownable_type, in: [
|
|
7
|
+
validates_uniqueness_of :user_id, scope: %i[ownable_type ownable_id], unless: proc { |u| u.user_id.nil? }, message: 'user has already been assigned that role'
|
|
8
|
+
validates_inclusion_of :ownable_type, in: %w[Company Project]
|
|
7
9
|
|
|
8
|
-
delegate :email, to: :user,
|
|
10
|
+
delegate :email, to: :user, allow_nil: true
|
|
9
11
|
def attributes
|
|
10
12
|
scuper.merge(email: email)
|
|
11
13
|
end
|
|
12
14
|
|
|
13
|
-
def self.ownable_assign_options(
|
|
14
|
-
(Company.all + Project.all).map { |i| [
|
|
15
|
+
def self.ownable_assign_options(_model = nil)
|
|
16
|
+
(Company.all + Project.all).map { |i| ["#{i.class}: #{i.name}", "#{i.class}-#{i.id}"] }
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def ownable_assign
|
|
@@ -19,7 +21,6 @@ class Role < AbstractAdapter
|
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def ownable_assign=(value)
|
|
22
|
-
self.ownable_type,self.ownable_id = value.split('-')
|
|
24
|
+
self.ownable_type, self.ownable_id = value.split('-')
|
|
23
25
|
end
|
|
24
|
-
|
|
25
26
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Team < AbstractAdapter
|
|
2
4
|
belongs_to :project
|
|
3
5
|
belongs_to :creator, class_name: 'User'
|
|
@@ -5,5 +7,4 @@ class Team < AbstractAdapter
|
|
|
5
7
|
has_many :team_users, inverse_of: :team
|
|
6
8
|
has_many :users, through: :team_users
|
|
7
9
|
accepts_nested_attributes_for :team_users, allow_destroy: true
|
|
8
|
-
|
|
9
10
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class TeamUser < AbstractAdapter
|
|
2
4
|
belongs_to :user
|
|
3
5
|
belongs_to :team
|
|
@@ -5,9 +7,8 @@ class TeamUser < AbstractAdapter
|
|
|
5
7
|
validate :user_on_project
|
|
6
8
|
|
|
7
9
|
def user_on_project
|
|
8
|
-
|
|
9
|
-
errors.add(:user, "#{user.try(:name)} is not on the #{team.try(:project).try(:name)} project")
|
|
10
|
-
end
|
|
11
|
-
end
|
|
10
|
+
return if user && team && user.projects.include?(team.project)
|
|
12
11
|
|
|
12
|
+
errors.add(:user, "#{user.try(:name)} is not on the #{team.try(:project).try(:name)} project")
|
|
13
|
+
end
|
|
13
14
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class User < AbstractAdapter
|
|
2
4
|
# Include default devise modules. Others available are:
|
|
3
5
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
4
6
|
devise :database_authenticatable, :registerable, :confirmable,
|
|
5
7
|
:recoverable, :rememberable, :trackable, :validatable, :lockable
|
|
6
8
|
|
|
7
|
-
scope :active, -> { where(:
|
|
9
|
+
scope :active, -> { where(locked_at: nil) }
|
|
8
10
|
scope :inactive, -> { where('locked_at is not null') }
|
|
9
11
|
|
|
10
12
|
has_many :user_locations, dependent: :destroy
|
|
@@ -24,45 +26,47 @@ class User < AbstractAdapter
|
|
|
24
26
|
has_many :admin_companies, through: :roles, source: :ownable, source_type: 'Company'
|
|
25
27
|
has_many :admin_projects, through: :roles, source: :ownable, source_type: 'Project'
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
# aggregate companies' projects with project admin roles
|
|
30
|
+
def all_admin_projects
|
|
31
|
+
(admin_companies.map(&:projects) + admin_projects).flatten
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
def admin?(record)
|
|
32
|
-
roles.detect{|r| r.ownable == record }.present?
|
|
35
|
+
roles.detect { |r| r.ownable == record }.present?
|
|
33
36
|
end
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
# an admin of any company
|
|
39
|
+
def company_admin?
|
|
40
|
+
roles.detect { |r| r.ownable_type == 'Company' }.present?
|
|
37
41
|
end
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
# an admin of any project
|
|
44
|
+
def project_admin?
|
|
45
|
+
company_admin? || roles.detect { |r| r.ownable_type == 'Project' }.present?
|
|
41
46
|
end
|
|
42
47
|
|
|
43
|
-
|
|
44
48
|
def set_default_password_from_project
|
|
45
49
|
self.password = user_project_jobs.first.try(:project).try(:default_password) if password.blank?
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
def name
|
|
49
|
-
[first_name,last_name].delete_if(&:blank?).join(' ')
|
|
53
|
+
[first_name, last_name].delete_if(&:blank?).join(' ')
|
|
50
54
|
end
|
|
51
55
|
|
|
52
|
-
def avatar_url(size='medium')
|
|
53
|
-
avatar.try(:file).try(:url,size)
|
|
56
|
+
def avatar_url(size = 'medium')
|
|
57
|
+
avatar.try(:file).try(:url, size)
|
|
54
58
|
end
|
|
55
59
|
|
|
56
60
|
def self.attribute_param_types
|
|
57
|
-
{
|
|
61
|
+
{ 'skip_confirmation_email' => Virtus::Attribute::Boolean }
|
|
58
62
|
end
|
|
59
63
|
|
|
60
|
-
def skip_confirmation_email=(
|
|
61
|
-
return unless
|
|
64
|
+
def skip_confirmation_email=(skip)
|
|
65
|
+
return unless skip.to_s == 'true'
|
|
66
|
+
|
|
62
67
|
# skip_confirmation! does not work with update_attributes, a work-around:
|
|
63
|
-
|
|
68
|
+
update_column(:email, email) && reload if valid? && id
|
|
64
69
|
# devise: confirm the user without requiring a confirmation email
|
|
65
|
-
|
|
70
|
+
skip_confirmation!
|
|
66
71
|
end
|
|
67
|
-
|
|
68
72
|
end
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class UserLocation < AbstractAdapter
|
|
2
4
|
belongs_to :user
|
|
3
5
|
belongs_to :location
|
|
4
6
|
belongs_to :detectable, polymorphic: true
|
|
5
7
|
|
|
6
|
-
validates_inclusion_of :detectable_type, in: %w
|
|
8
|
+
validates_inclusion_of :detectable_type, in: %w[LocationBeacon LocationGps]
|
|
7
9
|
|
|
8
|
-
default_scope { includes(:detectable).order(
|
|
10
|
+
default_scope { includes(:detectable).order('created_at desc') }
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
self.
|
|
13
|
-
self.
|
|
12
|
+
# convenience method to set coordinates by an array of [lat,lng,alt]
|
|
13
|
+
def coords=(coords)
|
|
14
|
+
self.lat = coords[0]
|
|
15
|
+
self.lng = coords[1]
|
|
16
|
+
self.alt = coords[2]
|
|
14
17
|
end
|
|
15
18
|
|
|
16
|
-
def beacon
|
|
19
|
+
def beacon
|
|
17
20
|
detectable.is_a?(LocationBeacon) ? detectable : {}
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
def distance
|
|
21
|
-
|
|
22
|
-
location.gps.distance_from(lat,lng)
|
|
23
|
-
else
|
|
24
|
-
nil
|
|
25
|
-
end
|
|
26
|
-
end
|
|
23
|
+
def distance
|
|
24
|
+
return unless location.gps && lat && lng
|
|
27
25
|
|
|
26
|
+
location.gps.distance_from(lat, lng)
|
|
27
|
+
end
|
|
28
28
|
end
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class UserProjectJob < AbstractAdapter
|
|
2
4
|
belongs_to :user, inverse_of: :user_project_jobs
|
|
3
5
|
belongs_to :project, inverse_of: :user_project_jobs
|
|
4
6
|
belongs_to :job, inverse_of: :user_project_jobs
|
|
5
7
|
|
|
6
|
-
validates_inclusion_of :job, in: proc {|r| r.project.try(:jobs) || [] }
|
|
8
|
+
validates_inclusion_of :job, in: proc { |r| r.project.try(:jobs) || [] }
|
|
7
9
|
|
|
8
10
|
delegate :email, :avatar_url, to: :user
|
|
9
11
|
delegate :title, to: :job
|
|
10
12
|
delegate :name, to: :project
|
|
11
13
|
|
|
12
|
-
def self.options_for_job(project=nil)
|
|
14
|
+
def self.options_for_job(project = nil)
|
|
13
15
|
project.jobs
|
|
14
16
|
end
|
|
15
|
-
|
|
16
17
|
end
|
data/spec/dummy/bin/bundle
CHANGED
data/spec/dummy/bin/rails
CHANGED
data/spec/dummy/bin/rake
CHANGED
data/spec/dummy/bin/setup
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
require 'pathname'
|
|
3
5
|
|
|
4
6
|
# path to your application root.
|
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('
|
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('..', __dir__)
|
|
6
8
|
|
|
7
9
|
Dir.chdir APP_ROOT do
|
|
8
10
|
# This script is a starting point to setup your application.
|
|
9
11
|
# Add necessary setup steps to this file:
|
|
10
12
|
|
|
11
|
-
puts
|
|
12
|
-
system
|
|
13
|
-
system
|
|
13
|
+
puts '== Installing dependencies =='
|
|
14
|
+
system 'gem install bundler --conservative'
|
|
15
|
+
system 'bundle check || bundle install'
|
|
14
16
|
|
|
15
17
|
# puts "\n== Copying sample files =="
|
|
16
18
|
# unless File.exist?("config/database.yml")
|
|
@@ -18,12 +20,12 @@ Dir.chdir APP_ROOT do
|
|
|
18
20
|
# end
|
|
19
21
|
|
|
20
22
|
puts "\n== Preparing database =="
|
|
21
|
-
system
|
|
23
|
+
system 'bin/rake db:setup'
|
|
22
24
|
|
|
23
25
|
puts "\n== Removing old logs and tempfiles =="
|
|
24
|
-
system
|
|
25
|
-
system
|
|
26
|
+
system 'rm -f log/*'
|
|
27
|
+
system 'rm -rf tmp/cache'
|
|
26
28
|
|
|
27
29
|
puts "\n== Restarting application server =="
|
|
28
|
-
system
|
|
30
|
+
system 'touch tmp/restart.txt'
|
|
29
31
|
end
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.expand_path('boot', __dir__)
|
|
2
4
|
|
|
3
5
|
# Pick the frameworks you want:
|
|
4
6
|
require 'rails'
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
#require "action_mailer/railtie"
|
|
9
|
-
require
|
|
10
|
-
require
|
|
7
|
+
require 'active_support/railtie'
|
|
8
|
+
require 'active_record/railtie'
|
|
9
|
+
require 'action_controller/railtie'
|
|
10
|
+
# require "action_mailer/railtie"
|
|
11
|
+
require 'action_view/railtie'
|
|
12
|
+
require 'sprockets/railtie'
|
|
11
13
|
# require "rails/test_unit/railtie"
|
|
12
14
|
|
|
13
|
-
#Bundler.require(*Rails.groups)
|
|
14
|
-
require
|
|
15
|
+
# Bundler.require(*Rails.groups)
|
|
16
|
+
require 'introspective_admin'
|
|
15
17
|
|
|
16
18
|
module Dummy
|
|
17
19
|
class Application < Rails::Application
|
|
@@ -28,7 +30,6 @@ module Dummy
|
|
|
28
30
|
# config.i18n.default_locale = :de
|
|
29
31
|
|
|
30
32
|
# Do not swallow errors in after_commit/after_rollback callbacks.
|
|
31
|
-
#config.active_record.raise_in_transactional_callbacks = true
|
|
33
|
+
# config.active_record.raise_in_transactional_callbacks = true
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
|
-
|
data/spec/dummy/config/boot.rb
CHANGED
|
@@ -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('
|
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
|
3
5
|
|
|
4
6
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Load the Rails application.
|
|
2
|
-
require File.expand_path('
|
|
4
|
+
require File.expand_path('application', __dir__)
|
|
3
5
|
|
|
4
6
|
# Initialize the Rails application.
|
|
5
7
|
Rails.application.initialize!
|
|
6
8
|
|
|
7
|
-
#load "#{Rails.root}/db/schema.rb"
|
|
8
|
-
#Dir[Rails.root.join("app/models/**/*.rb")].each { |f| require f }
|
|
9
|
-
Dir[Rails.root.join(
|
|
9
|
+
# load "#{Rails.root}/db/schema.rb"
|
|
10
|
+
# Dir[Rails.root.join("app/models/**/*.rb")].each { |f| require f }
|
|
11
|
+
Dir[Rails.root.join('app/admin/**/*.rb')].sort.each { |f| require f }
|
|
10
12
|
Rails.application.reload_routes!
|
|
11
|
-
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.configure do
|
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
5
|
|
|
@@ -18,7 +20,7 @@ Rails.application.configure do
|
|
|
18
20
|
config.assets.precompile += %w[active_admin.css active_admin.js]
|
|
19
21
|
|
|
20
22
|
# Don't care if the mailer can't send.
|
|
21
|
-
#config.action_mailer.raise_delivery_errors = false
|
|
23
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
22
24
|
|
|
23
25
|
# Print deprecation notices to the Rails logger.
|
|
24
26
|
config.active_support.deprecation = :log
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.configure do
|
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
5
|
|
|
@@ -10,7 +12,6 @@ Rails.application.configure do
|
|
|
10
12
|
# Rake tasks automatically ignore this option for performance.
|
|
11
13
|
config.eager_load = true
|
|
12
14
|
|
|
13
|
-
|
|
14
15
|
# Full error reports are disabled and caching is turned on.
|
|
15
16
|
config.consider_all_requests_local = false
|
|
16
17
|
config.action_controller.perform_caching = true
|
|
@@ -26,7 +27,7 @@ Rails.application.configure do
|
|
|
26
27
|
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
|
27
28
|
|
|
28
29
|
# Compress JavaScripts and CSS.
|
|
29
|
-
#config.assets.js_compressor = :uglifier
|
|
30
|
+
# config.assets.js_compressor = :uglifier
|
|
30
31
|
config.assets.css_compressor = :sass
|
|
31
32
|
|
|
32
33
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
|
@@ -75,7 +76,7 @@ Rails.application.configure do
|
|
|
75
76
|
config.active_support.deprecation = :notify
|
|
76
77
|
|
|
77
78
|
# Use default logging formatter so that PID and timestamp are not suppressed.
|
|
78
|
-
config.log_formatter =
|
|
79
|
+
config.log_formatter = Logger::Formatter.new
|
|
79
80
|
|
|
80
81
|
# Do not dump schema after migrations.
|
|
81
82
|
config.active_record.dump_schema_after_migration = false
|
|
@@ -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
|
|
|
@@ -5,14 +7,13 @@ Dummy::Application.configure do
|
|
|
5
7
|
# test suite. You never need to work with it otherwise. Remember that
|
|
6
8
|
# your test database is "scratch space" for the test suite and is wiped
|
|
7
9
|
# and recreated between test runs. Don't rely on the data there!
|
|
8
|
-
config.cache_classes =
|
|
10
|
+
config.cache_classes = false
|
|
9
11
|
|
|
10
12
|
# Do not eager load code on boot. This avoids loading your whole application
|
|
11
13
|
# just for the purpose of running a single test. If you are using a tool that
|
|
12
14
|
# preloads Rails for running tests, you may have to set it to true.
|
|
13
15
|
config.eager_load = false
|
|
14
16
|
|
|
15
|
-
|
|
16
17
|
# Configure static file server for tests with Cache-Control for performance.
|
|
17
18
|
config.serve_static_files = true
|
|
18
19
|
config.static_cache_control = 'public, max-age=3600'
|
|
@@ -32,12 +33,11 @@ Dummy::Application.configure do
|
|
|
32
33
|
config.assets.digest = false
|
|
33
34
|
config.active_support.deprecation = :stderr
|
|
34
35
|
|
|
35
|
-
|
|
36
36
|
# Tell Action Mailer not to deliver emails to the real world.
|
|
37
37
|
# The :test delivery method accumulates sent emails in the
|
|
38
38
|
# ActionMailer::Base.deliveries array.
|
|
39
|
-
#config.action_mailer.perform_deliveries = false
|
|
40
|
-
#config.action_mailer.delivery_method = :test
|
|
39
|
+
# config.action_mailer.perform_deliveries = false
|
|
40
|
+
# config.action_mailer.delivery_method = :test
|
|
41
41
|
|
|
42
42
|
# Randomize the order test cases are executed.
|
|
43
43
|
config.active_support.test_order = :random
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
ActiveAdmin.setup do |config|
|
|
2
|
-
config.authentication_method = nil
|
|
3
|
-
config.current_user_method = nil
|
|
4
|
+
config.authentication_method = nil # :authenticate_admin_user!
|
|
5
|
+
config.current_user_method = nil # :current_admin_user
|
|
4
6
|
config.logout_link_path = :destroy_admin_user_session_path
|
|
5
|
-
config.batch_actions = true
|
|
7
|
+
# config.batch_actions = true
|
|
6
8
|
end
|
|
7
|
-
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Be sure to restart your server when you modify this file.
|
|
2
4
|
|
|
3
5
|
# Version of your assets, change this if you want to expire all your assets.
|
|
4
|
-
#Rails.application.config.assets.version = '1.2'
|
|
6
|
+
# Rails.application.config.assets.version = '1.2'
|
|
5
7
|
|
|
6
8
|
Rails.application.config.assets.precompile += %w[active_admin.css active_admin.js]
|
|
7
9
|
|
data/spec/dummy/config/routes.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.routes.draw do
|
|
2
|
-
#devise_for :admin_users, ActiveAdmin::Devise.config
|
|
3
|
-
#devise_for :admin_users, ActiveAdmin::Devise.config
|
|
4
|
+
# devise_for :admin_users, ActiveAdmin::Devise.config
|
|
5
|
+
# devise_for :admin_users, ActiveAdmin::Devise.config
|
|
4
6
|
devise_for :users
|
|
7
|
+
|
|
5
8
|
ActiveAdmin.routes(self)
|
|
6
9
|
|
|
7
10
|
# You can have the root of your site routed with "root"
|
|
8
11
|
root 'home#index'
|
|
9
|
-
|
|
10
12
|
end
|
data/spec/dummy/config.ru
CHANGED
|
Binary file
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class DeviseCreateUsers < ActiveRecord::Migration
|
|
2
4
|
def change
|
|
3
5
|
create_table(:users) do |t|
|
|
4
6
|
## Database authenticatable
|
|
5
|
-
t.string :email, null: false, default:
|
|
6
|
-
t.string :encrypted_password, null: false, default:
|
|
7
|
+
t.string :email, null: false, default: ''
|
|
8
|
+
t.string :encrypted_password, null: false, default: ''
|
|
7
9
|
|
|
8
10
|
## Recoverable
|
|
9
11
|
t.string :reset_password_token
|
|
@@ -30,7 +32,6 @@ class DeviseCreateUsers < ActiveRecord::Migration
|
|
|
30
32
|
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
|
31
33
|
# t.datetime :locked_at
|
|
32
34
|
|
|
33
|
-
|
|
34
35
|
t.timestamps null: false
|
|
35
36
|
end
|
|
36
37
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class DeviseCreateAdminUsers < ActiveRecord::Migration
|
|
2
4
|
def migrate(direction)
|
|
3
5
|
super
|
|
@@ -8,8 +10,8 @@ class DeviseCreateAdminUsers < ActiveRecord::Migration
|
|
|
8
10
|
def change
|
|
9
11
|
create_table(:admin_users) do |t|
|
|
10
12
|
## Database authenticatable
|
|
11
|
-
t.string :email, null: false, default:
|
|
12
|
-
t.string :encrypted_password, null: false, default:
|
|
13
|
+
t.string :email, null: false, default: ''
|
|
14
|
+
t.string :encrypted_password, null: false, default: ''
|
|
13
15
|
|
|
14
16
|
## Recoverable
|
|
15
17
|
t.string :reset_password_token
|
|
@@ -36,7 +38,6 @@ class DeviseCreateAdminUsers < ActiveRecord::Migration
|
|
|
36
38
|
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
|
37
39
|
# t.datetime :locked_at
|
|
38
40
|
|
|
39
|
-
|
|
40
41
|
t.timestamps null: false
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class CreateActiveAdminComments < ActiveRecord::Migration
|
|
2
4
|
def self.up
|
|
3
5
|
create_table :active_admin_comments do |t|
|
|
@@ -9,8 +11,8 @@ class CreateActiveAdminComments < ActiveRecord::Migration
|
|
|
9
11
|
t.timestamps null: false
|
|
10
12
|
end
|
|
11
13
|
add_index :active_admin_comments, [:namespace]
|
|
12
|
-
add_index :active_admin_comments, [
|
|
13
|
-
add_index :active_admin_comments, [
|
|
14
|
+
add_index :active_admin_comments, %i[author_type author_id]
|
|
15
|
+
add_index :active_admin_comments, %i[resource_type resource_id]
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def self.down
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class AddUserAuthenticationToken < ActiveRecord::Migration
|
|
2
4
|
def change
|
|
3
|
-
add_column :users, :authentication_token, :string
|
|
4
|
-
add_index :users, :authentication_token, :
|
|
5
|
+
add_column :users, :authentication_token, :string
|
|
6
|
+
add_index :users, :authentication_token, unique: true
|
|
5
7
|
end
|
|
6
8
|
|
|
7
9
|
def down
|