tb_core 1.4.8 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/admin/users_controller.rb +2 -2
- data/app/controllers/concerns/tb_core/error_handling.rb +1 -0
- data/app/helpers/tb_core/application_helper.rb +2 -0
- data/app/models/concerns/tb_core/user_model.rb +48 -5
- data/lib/tb_core/test_helper.rb +24 -22
- data/lib/tb_core/version.rb +1 -1
- data/spec/controllers/admin/dashboard_controller_spec.rb +1 -1
- data/spec/dummy/config/application.rb +1 -46
- metadata +32 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fb40b06cd9d72dcf61527d02359b39271963c85617f550553733de463437876
|
4
|
+
data.tar.gz: 5ec39967bba64ceabba51a32860fcd93bf7b9c3b93c59953deff2224628a44e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c478ff7b5e4405d6a2e02cdafd9fa6b97624de932e66e2d8f018d5929d27ccc4da590bf150ab04fa9e4c20acb65b6720271c1c0267ce253f11f3c4320574c84
|
7
|
+
data.tar.gz: 10eb5db5f0dd886d65cbede9e99cd27647fb11ad7e9693ffac83c732de6d53824968c4fc3e43e95e34f46d704809460485d44555f1aafb6b9f38d637cd8ac23c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![
|
1
|
+
[![CircleCI](https://circleci.com/bb/moser-inc/tb_core.svg?style=svg)](https://circleci.com/bb/moser-inc/tb_core)
|
2
2
|
|
3
3
|
Twice Baked Core
|
4
4
|
================
|
@@ -105,7 +105,7 @@ Create a file in your app at `app/views/admin/users/_form_additions.html.erb`.
|
|
105
105
|
<%= f.label :avatar, :class=>"control-label"%>
|
106
106
|
<div class="controls">
|
107
107
|
<%= f.file_field :avatar %>
|
108
|
-
</div>
|
108
|
+
</div>
|
109
109
|
</div>
|
110
110
|
|
111
111
|
### Adding fields to the user show action
|
@@ -8,8 +8,8 @@ class Admin::UsersController < Admin::ApplicationController
|
|
8
8
|
respond_to :html, :csv
|
9
9
|
|
10
10
|
sortable_by :email, :current_login_at,
|
11
|
-
|
12
|
-
|
11
|
+
name: [:last_name, :first_name],
|
12
|
+
default: :email
|
13
13
|
|
14
14
|
def index
|
15
15
|
@spud_users = SpudUser.order(sortable_query).paginate(page: params[:page], per_page: 15)
|
@@ -56,6 +56,7 @@ module TbCore::ApplicationHelper
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# rubocop:disable Rails/HelperInstanceVariable
|
59
60
|
def tb_page_title
|
60
61
|
if content_for?(:title)
|
61
62
|
title = content_for(:title) + ' | ' + TbCore.site_name
|
@@ -66,6 +67,7 @@ module TbCore::ApplicationHelper
|
|
66
67
|
end
|
67
68
|
return content_tag :title, title
|
68
69
|
end
|
70
|
+
# rubocop:enable Rails/HelperInstanceVariable
|
69
71
|
|
70
72
|
def current_site_name
|
71
73
|
return TbCore.config.site_name
|
@@ -1,27 +1,40 @@
|
|
1
1
|
module TbCore
|
2
|
+
|
3
|
+
module Regex
|
4
|
+
EMAIL = /
|
5
|
+
\A
|
6
|
+
[A-Z0-9_.&%+\-']+ # mailbox
|
7
|
+
@
|
8
|
+
(?:[A-Z0-9\-]+\.)+ # subdomains
|
9
|
+
(?:[A-Z]{2,25}) # TLD
|
10
|
+
\z
|
11
|
+
/ix.freeze
|
12
|
+
end
|
13
|
+
|
2
14
|
module UserModel
|
3
15
|
extend ActiveSupport::Concern
|
4
16
|
|
17
|
+
# rubocop:disable Metrics/BlockLength
|
5
18
|
included do
|
6
19
|
self.table_name = 'spud_users'
|
7
20
|
|
8
21
|
acts_as_authentic do |c|
|
9
|
-
c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
|
10
22
|
c.crypto_provider = Authlogic::CryptoProviders::SCrypt
|
11
23
|
c.logged_in_timeout = 24.hours
|
12
24
|
c.login_field = :email if TbCore.config.use_email_as_login
|
13
|
-
|
14
|
-
c.merge_validates_length_of_password_field_options(minimum: TbCore.config.user_password_length)
|
15
|
-
end
|
25
|
+
c.require_password_confirmation = true
|
16
26
|
end
|
17
27
|
|
28
|
+
attr_accessor :password_confirmation
|
29
|
+
|
18
30
|
belongs_to :role,
|
19
|
-
class_name: SpudRole
|
31
|
+
class_name: 'SpudRole', foreign_key: :spud_role_id, optional: true
|
20
32
|
has_many :spud_user_settings,
|
21
33
|
dependent: :destroy, foreign_key: :spud_user_id
|
22
34
|
|
23
35
|
validates :first_name, :last_name, presence: true
|
24
36
|
before_validation :set_login_to_email, if: -> { TbCore.config.use_email_as_login }
|
37
|
+
|
25
38
|
before_update :unset_requires_password_change
|
26
39
|
|
27
40
|
scope :admins, lambda {
|
@@ -29,7 +42,37 @@ module TbCore
|
|
29
42
|
}
|
30
43
|
|
31
44
|
scope :ordered, -> { order('last_name asc, first_name asc, email asc') }
|
45
|
+
|
46
|
+
# These used to be built in to Authlogic
|
47
|
+
# See: https://github.com/binarylogic/authlogic/blob/5986e1bd056ccecc519d9f49cc83a0ba757668b4/doc/use_normal_rails_validation.md
|
48
|
+
validates :email,
|
49
|
+
format: {
|
50
|
+
with: ::TbCore::Regex::EMAIL,
|
51
|
+
message: proc {
|
52
|
+
::Authlogic::I18n.t(
|
53
|
+
'error_messages.email_invalid',
|
54
|
+
default: 'should look like an email address.'
|
55
|
+
)
|
56
|
+
}
|
57
|
+
},
|
58
|
+
length: { maximum: 100 },
|
59
|
+
uniqueness: {
|
60
|
+
case_sensitive: false,
|
61
|
+
if: :will_save_change_to_email?
|
62
|
+
}
|
63
|
+
validates :password,
|
64
|
+
confirmation: { if: :require_password? },
|
65
|
+
length: {
|
66
|
+
minimum: 8,
|
67
|
+
if: :require_password?
|
68
|
+
}
|
69
|
+
validates :password_confirmation,
|
70
|
+
length: {
|
71
|
+
minimum: 8,
|
72
|
+
if: :require_password?
|
73
|
+
}
|
32
74
|
end
|
75
|
+
# rubocop:enable Metrics/BlockLength
|
33
76
|
|
34
77
|
module ClassMethods
|
35
78
|
|
data/lib/tb_core/test_helper.rb
CHANGED
@@ -1,29 +1,31 @@
|
|
1
1
|
require 'authlogic/test_case'
|
2
2
|
|
3
|
-
module TbCore
|
4
|
-
|
3
|
+
module TbCore
|
4
|
+
module TestHelper
|
5
|
+
include Authlogic::TestCase
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
# Use this helper in controller specs to establish a login session
|
8
|
+
# - admin: Set to true to create a super_admin
|
9
|
+
# - permissions: One or more permissions you want to assign to the user (a role will be auto generated)
|
10
|
+
#
|
11
|
+
def activate_session(admin: false, permissions: nil)
|
12
|
+
activate_authlogic()
|
13
|
+
if permissions
|
14
|
+
permissions = [permissions] unless permissions.is_a?(Array)
|
15
|
+
role = SpudRole.create(name: 'New Role', permission_tags: permissions)
|
16
|
+
else
|
17
|
+
role = nil
|
18
|
+
end
|
19
|
+
@user = FactoryBot.create(:spud_user, super_admin: admin, role: role)
|
20
|
+
SpudUserSession.create(@user)
|
21
|
+
return @user
|
17
22
|
end
|
18
|
-
@user = FactoryBot.create(:spud_user, super_admin: admin, role: role)
|
19
|
-
SpudUserSession.create(@user)
|
20
|
-
return @user
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
# Returns the current user
|
25
|
+
#
|
26
|
+
def current_user
|
27
|
+
return @user
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -31,7 +33,7 @@ end
|
|
31
33
|
#
|
32
34
|
if defined?(RSpec)
|
33
35
|
RSpec.configure do |config|
|
34
|
-
config.include TbCore::
|
36
|
+
config.include TbCore::TestHelper
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
data/lib/tb_core/version.rb
CHANGED
@@ -69,7 +69,7 @@ RSpec.describe Admin::DashboardController, type: :controller do
|
|
69
69
|
it 'should contain data array in reponse' do
|
70
70
|
get :badges
|
71
71
|
json = JSON.parse(response.body)
|
72
|
-
expect(response.
|
72
|
+
expect(response.media_type).to eq('application/json')
|
73
73
|
expect(json).to have_key('data')
|
74
74
|
end
|
75
75
|
|
@@ -12,51 +12,6 @@ module Dummy
|
|
12
12
|
config.from_address = 'no-reply@dummy.com'
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
# Application configuration should go into files in config/initializers
|
17
|
-
# -- all .rb files in that directory are automatically loaded.
|
18
|
-
|
19
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
20
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
21
|
-
|
22
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
23
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
24
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
25
|
-
|
26
|
-
# Activate observers that should always be running.
|
27
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
28
|
-
|
29
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
30
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
31
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
32
|
-
|
33
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
34
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
35
|
-
# config.i18n.default_locale = :de
|
36
|
-
config.i18n.enforce_available_locales = true
|
37
|
-
|
38
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
39
|
-
config.encoding = 'utf-8'
|
40
|
-
|
41
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
42
|
-
config.filter_parameters += [:password]
|
43
|
-
|
44
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
45
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
46
|
-
# like if you have constraints or database-specific column types
|
47
|
-
# config.active_record.schema_format = :sql
|
48
|
-
|
49
|
-
# Enforce whitelist mode for mass assignment.
|
50
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
51
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
52
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
53
|
-
# config.active_record.whitelist_attributes = true
|
54
|
-
|
55
|
-
# Enable the asset pipeline
|
56
|
-
# config.assets.enabled = true
|
57
|
-
|
58
|
-
# Version of your assets, change this if you want to expire all your assets
|
59
|
-
# config.assets.version = '1.0'
|
60
|
-
|
15
|
+
config.load_defaults '6.0'
|
61
16
|
end
|
62
17
|
end
|
metadata
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Woods
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: authlogic
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 3.4.3
|
20
|
-
- - "<"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '5.0'
|
23
20
|
type: :runtime
|
@@ -25,9 +22,6 @@ dependencies:
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 3.4.3
|
30
|
-
- - "<"
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: '5.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
@@ -242,6 +236,20 @@ dependencies:
|
|
242
236
|
version: '0'
|
243
237
|
- !ruby/object:Gem::Dependency
|
244
238
|
name: rspec-rails
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: 4.0.0.beta2
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: 4.0.0.beta2
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: rubocop
|
245
253
|
requirement: !ruby/object:Gem::Requirement
|
246
254
|
requirements:
|
247
255
|
- - ">="
|
@@ -255,7 +263,21 @@ dependencies:
|
|
255
263
|
- !ruby/object:Gem::Version
|
256
264
|
version: '0'
|
257
265
|
- !ruby/object:Gem::Dependency
|
258
|
-
name: rubocop
|
266
|
+
name: rubocop-performance
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: rubocop-rails
|
259
281
|
requirement: !ruby/object:Gem::Requirement
|
260
282
|
requirements:
|
261
283
|
- - ">="
|
@@ -503,8 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
503
525
|
- !ruby/object:Gem::Version
|
504
526
|
version: '0'
|
505
527
|
requirements: []
|
506
|
-
|
507
|
-
rubygems_version: 2.7.7
|
528
|
+
rubygems_version: 3.0.3
|
508
529
|
signing_key:
|
509
530
|
specification_version: 4
|
510
531
|
summary: Twice Baked Core Engine
|