tb_core 1.4.7 → 1.4.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dd467d0438cc596f8c289d040049e2e1d41d8d1c03cf2f643fca5bb8a2999ec
4
- data.tar.gz: 374cea46337ada9623d5365024e4bf914f70a25b0c6e2f83997e319000ea342e
3
+ metadata.gz: cd6c66dcf54d5da5213a63e533eb04b5f64e726919654ece63a4565333c8a6d7
4
+ data.tar.gz: 224a045cc261e598c21677bcf28ee60dc82d0ea0f82392dcc9801eb86117aaf8
5
5
  SHA512:
6
- metadata.gz: 94358f3622e59b5f638be9ed1ba51add44a014ddf1748dff548b8f717f9aee662d37b4a7cd9011fb8c46b9423e9b9b9b01bb621e316df41d6390be21650df119
7
- data.tar.gz: ab751288247246638a04c5d779f166e3cb0c426551ec3eac4cbb59ba19ce1c489ea12f1a264c0f424f354e365a8b031e77b7c12ff7b0a367157fb0cc4558064c
6
+ metadata.gz: 5dbc377a0b2723d633ff97989a57b41fd5e797247d442e14f7ad6c63ea5f3f402b82ea244d9eee072301dffbfcfb62896e5ffee978fb88c33858f4e8cb39558f
7
+ data.tar.gz: 4e85b15b625862b800ccb12e1490822d907ee696e6434cf7d08699ca5e0fac0412f032d2153b2d2137c66f87b7f6de10c11fc78c187496ae0bb123c0df691a2e
@@ -43,6 +43,7 @@ private
43
43
  def load_user_using_perishable_token
44
44
  @user = SpudUser.find_using_perishable_token(params[:id])
45
45
  return if @user
46
+
46
47
  flash[:notice] = "We're sorry, but we could not locate your account. " +
47
48
  'If you are having issues try copying and pasting the URL ' +
48
49
  'from your email into your browser or restarting the ' +
@@ -14,6 +14,7 @@ module TbCore
14
14
  if params[:return_to]
15
15
  uri = URI.parse(params[:return_to].to_s)
16
16
  return "#{uri.path}?#{uri.query}" if uri.query
17
+
17
18
  return uri.path
18
19
  end
19
20
  default
@@ -10,27 +10,32 @@ module TbCore
10
10
 
11
11
  def current_user_session
12
12
  return @current_user_session if defined?(@current_user_session)
13
+
13
14
  @current_user_session = SpudUserSession.find
14
15
  end
15
16
 
16
17
  def current_user
17
18
  return @current_user if defined?(@current_user)
19
+
18
20
  @current_user = current_user_session&.spud_user
19
21
  end
20
22
 
21
23
  def current_user_id
22
24
  return 0 unless @current_user
25
+
23
26
  @current_user.id
24
27
  end
25
28
 
26
29
  def require_user
27
30
  raise UnauthorizedError.new unless current_user
31
+
28
32
  true
29
33
  end
30
34
 
31
35
  def require_admin_user
32
36
  raise UnauthorizedError.new unless current_user
33
37
  raise AccessDeniedError.new unless current_user.admin_rights?
38
+
34
39
  true
35
40
  end
36
41
 
@@ -1,6 +1,7 @@
1
1
  module ForgotPasswordMailerHelper
2
2
  def perishable_token_link_expiration_time_text(user)
3
3
  return if user.class.perishable_token_valid_for.blank?
4
+
4
5
  expiration_time = user.updated_at + user.class.perishable_token_valid_for
5
6
 
6
7
  "This link will expire in #{distance_of_time_in_words(Time.current, expiration_time)}."
@@ -16,7 +16,7 @@ module TbCore
16
16
  end
17
17
 
18
18
  belongs_to :role,
19
- class_name: SpudRole.to_s, foreign_key: :spud_role_id, required: false
19
+ class_name: SpudRole.to_s, foreign_key: :spud_role_id, optional: true
20
20
  has_many :spud_user_settings,
21
21
  dependent: :destroy, foreign_key: :spud_user_id
22
22
 
@@ -69,6 +69,7 @@ module TbCore
69
69
 
70
70
  def full_name
71
71
  return login if first_name.blank? && last_name.blank?
72
+
72
73
  [first_name, last_name].reject(&:blank?).join(' ')
73
74
  end
74
75
 
@@ -79,12 +80,14 @@ module TbCore
79
80
  # Returns true if user can view at least one dashboard app
80
81
  def admin_rights?
81
82
  return true if super_admin
83
+
82
84
  TbCore.admin_applications.find { |app| can_view_app?(app) }.present?
83
85
  end
84
86
 
85
87
  # Returns true if the user can view a spud app based on it's key
86
88
  def can_view_app?(admin_application)
87
89
  return true if super_admin?
90
+
88
91
  key = admin_application[:key]
89
92
  permissions.find { |p| p.apps.include?(key) }.present?
90
93
  end
@@ -95,6 +98,7 @@ module TbCore
95
98
  # * if multiple tags are supplied, return true if ALL tags match
96
99
  def permission?(*tags)
97
100
  return true if super_admin?
101
+
98
102
  my_tags = permissions.collect(&:tag)
99
103
  tags.find { |tag| !my_tags.include?(tag) }.blank?
100
104
  end
@@ -105,12 +109,14 @@ module TbCore
105
109
  # * if multiple tags are supplied, return true if ANY tag matches
106
110
  def any_permission?(*tags)
107
111
  return true if super_admin?
112
+
108
113
  permissions.find { |p| tags.include?(p.tag) }.present?
109
114
  end
110
115
 
111
116
  # Return a list of SpudPermission objects for the user's SpudRole
112
117
  def permissions
113
118
  return [] if role.blank?
119
+
114
120
  role.permissions
115
121
  end
116
122
 
@@ -14,14 +14,9 @@ class SpudRole < ActiveRecord::Base
14
14
  end
15
15
 
16
16
  def permission_tags=(tags)
17
- self.spud_role_permissions.each do |role_permission|
18
- if role_permission.permission.nil? || !tags.include?(role_permission.permission.tag)
19
- role_permission.destroy()
20
- else
21
- tags.delete(role_permission.permission.tag)
22
- end
17
+ self.spud_role_permissions = tags.map do |tag|
18
+ SpudRolePermission.new(spud_permission_tag: tag)
23
19
  end
24
- self.spud_role_permissions += tags.collect{ |tag| SpudRolePermission.new(spud_permission_tag: tag) }
25
20
  end
26
21
 
27
22
  def permission_tags
@@ -49,7 +49,7 @@
49
49
  <h3 class="modal-title"></h3>
50
50
  </div>
51
51
  <div class="modal-body">
52
- <p>One fine body&hellip;</p>
52
+ <p>...</p>
53
53
  </div>
54
54
  <div class="modal-footer modal-footer-default">
55
55
  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@@ -79,7 +79,7 @@ class Spud::ModuleGenerator < ::Rails::Generators::Base
79
79
  resources :#{module_name_formatted}
80
80
  end
81
81
  resources :#{module_name_formatted}, :only => [:index, :show]
82
- RUBY
82
+ RUBY
83
83
  end
84
84
 
85
85
  def create_specs
@@ -136,7 +136,7 @@ RUBY
136
136
  inject_into_file "app/models/#{module_name.singularize.underscore}.rb", after: "ApplicationRecord\n" do <<-RUBY
137
137
  scope :ordered, -> { order(#{sort_field}: :desc) }
138
138
  scope :search, ->(term) { where('#{search_field} LIKE ?', "%\#{term}%") }
139
- RUBY
139
+ RUBY
140
140
  end
141
141
  end
142
142
 
@@ -156,7 +156,7 @@ RUBY
156
156
 
157
157
  validates #{string_attrs_as_symbols}, :length => {:maximum => 255}
158
158
 
159
- RUBY
159
+ RUBY
160
160
  end
161
161
  end
162
162
  end
@@ -47,7 +47,7 @@ private
47
47
  config.site_name = "#{site_name}"
48
48
  config.from_address = "no-reply@#{domain_name}.com"
49
49
  end
50
- RUBY
50
+ RUBY
51
51
  end
52
52
 
53
53
  def application_name
@@ -38,6 +38,7 @@ module TbCore
38
38
  elsif !current_user.can_view_app?(@page_application)
39
39
  raise AccessDeniedError.new(item: 'module', template: '/layouts/admin/error_page')
40
40
  end
41
+
41
42
  @page_thumbnail = @page_application[:thumbnail]
42
43
  @page_name = determine_page_name(page_title || @page_application[:name], action_name)
43
44
  end
@@ -1,3 +1,3 @@
1
1
  module TbCore
2
- VERSION = '1.4.7'.freeze
2
+ VERSION = '1.4.8'.freeze
3
3
  end
@@ -19,7 +19,7 @@ RSpec.describe Admin::ApplicationController, type: :controller do
19
19
  it 'should respond successfully if the current user is a super admin' do
20
20
  @user.update(super_admin: true)
21
21
  get :index
22
- expect(response).to be_success
22
+ expect(response).to be_successful
23
23
  end
24
24
 
25
25
  it 'should respond successfully if the current user has admin permissions' do
@@ -28,7 +28,7 @@ RSpec.describe Admin::ApplicationController, type: :controller do
28
28
  @user.role = @role
29
29
  @user.save
30
30
  get :index
31
- expect(response).to be_success
31
+ expect(response).to be_successful
32
32
  end
33
33
 
34
34
  it 'should redirect to the login if the current user is not logged in' do
@@ -8,7 +8,7 @@ describe Admin::PasswordResetsController, type: :controller do
8
8
  describe 'index' do
9
9
  it 'should return success' do
10
10
  get :index
11
- expect(response).to be_success
11
+ expect(response).to be_successful
12
12
  end
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ describe Admin::PasswordResetsController, type: :controller do
17
17
  it 'should render the edit form' do
18
18
  allow(SpudUser).to receive(:find_using_perishable_token).and_return(user)
19
19
  get :show, params: { id: 1 }
20
- expect(response).to be_success
20
+ expect(response).to be_successful
21
21
  end
22
22
  end
23
23
 
@@ -8,7 +8,7 @@ describe Admin::SettingsController, type: :controller do
8
8
  describe 'edit' do
9
9
  it 'should respond with success' do
10
10
  get :edit
11
- expect(response).to be_success
11
+ expect(response).to be_successful
12
12
  end
13
13
  end
14
14
 
@@ -6,7 +6,7 @@ describe Admin::SetupController, type: :controller do
6
6
  it 'should be successful' do
7
7
  get :new
8
8
 
9
- expect(response).to be_success
9
+ expect(response).to be_successful
10
10
  end
11
11
 
12
12
  it 'should redirect to the admin login form when there is already a user' do
@@ -16,7 +16,7 @@ describe Admin::UserSessionsController, type: :controller do
16
16
  u = FactoryBot.create(:spud_user)
17
17
  u.save
18
18
  get :new
19
- expect(response).to be_success
19
+ expect(response).to be_successful
20
20
  end
21
21
  end
22
22
 
@@ -39,7 +39,7 @@ describe Admin::UsersController, type: :controller do
39
39
  SpudUserSession.create(u)
40
40
  get :index
41
41
 
42
- expect(response).to be_success
42
+ expect(response).to be_successful
43
43
  end
44
44
 
45
45
  it 'should not allow access to users without a role,
@@ -82,14 +82,14 @@ describe Admin::UsersController, type: :controller do
82
82
  it 'should respond successfully' do
83
83
  user = FactoryBot.create(:spud_user)
84
84
  get :show, params: { id: user.id }
85
- expect(response).to be_success
85
+ expect(response).to be_successful
86
86
  end
87
87
  end
88
88
 
89
89
  describe 'new' do
90
90
  it 'should render the form' do
91
91
  get :new, format: :html
92
- expect(response).to be_success
92
+ expect(response).to be_successful
93
93
  end
94
94
  end
95
95
 
@@ -4,5 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = 'f89bbe176924c011473e15af21c4e8b72c3fd12f887f26014c24ea32e1e3d2bf0250a671a30232047d5c5431e67c7361aca07b10d847405b99fce4543589e117'
8
7
  Dummy::Application.config.secret_key_base = 'b43711419c807b9c9efe9365dd79f87ebe31e9f72e1aa6744c1ecac68aace664c0a3a4f791d92bd2fa324fce1d6d09701a54b88453f131b7c460eeb9c530bd72'
@@ -5,6 +5,6 @@ FactoryBot.define do
5
5
 
6
6
  factory :spud_admin_permission do
7
7
  name { FactoryBot.generate(:permission_name) }
8
- access true
8
+ access { true }
9
9
  end
10
10
  end
@@ -24,8 +24,8 @@ FactoryBot.define do
24
24
  last_name { FactoryBot.generate(:last_name) }
25
25
  login { FactoryBot.generate(:login) }
26
26
  email { FactoryBot.generate(:email) }
27
- password 'password'
28
- password_confirmation 'password'
27
+ password { 'password' }
28
+ password_confirmation { 'password' }
29
29
  single_access_token { FactoryBot.generate(:single_access_token) }
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-10 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: authlogic
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.4.3
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 3.4.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bootstrap-sass
29
35
  requirement: !ruby/object:Gem::Requirement