tb_core 1.4.6 → 1.5.2

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.
Files changed (36) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/admin/core/application.js +3 -1
  4. data/app/assets/javascripts/admin/core/editor.js +9 -71
  5. data/app/controllers/admin/password_resets_controller.rb +1 -0
  6. data/app/controllers/admin/users_controller.rb +2 -2
  7. data/app/controllers/concerns/tb_core/error_handling.rb +1 -0
  8. data/app/controllers/concerns/tb_core/redirection.rb +1 -0
  9. data/app/controllers/concerns/tb_core/user_authentication.rb +5 -0
  10. data/app/helpers/forgot_password_mailer_helper.rb +9 -0
  11. data/app/helpers/tb_core/application_helper.rb +17 -0
  12. data/app/mailers/tb_core_mailer.rb +2 -0
  13. data/app/models/concerns/tb_core/user_model.rb +54 -5
  14. data/app/models/spud_role.rb +2 -7
  15. data/app/views/layouts/admin/application.html.erb +2 -1
  16. data/app/views/tb_core_mailer/forgot_password_notification.html.erb +5 -1
  17. data/lib/generators/spud/module_generator.rb +3 -3
  18. data/lib/generators/spud/setup_generator.rb +1 -1
  19. data/lib/tb_core/belongs_to_app.rb +1 -0
  20. data/lib/tb_core/engine.rb +1 -0
  21. data/lib/tb_core/form_builder.rb +1 -1
  22. data/lib/tb_core/test_helper.rb +24 -22
  23. data/lib/tb_core/version.rb +1 -1
  24. data/spec/controllers/admin/application_controller_spec.rb +2 -2
  25. data/spec/controllers/admin/dashboard_controller_spec.rb +1 -1
  26. data/spec/controllers/admin/password_reset_controller_spec.rb +2 -2
  27. data/spec/controllers/admin/settings_controller_spec.rb +1 -1
  28. data/spec/controllers/admin/setup_controller_spec.rb +1 -1
  29. data/spec/controllers/admin/user_sessions_controller_spec.rb +1 -1
  30. data/spec/controllers/admin/users_controller_spec.rb +3 -3
  31. data/spec/dummy/app/assets/config/manifest.js +3 -0
  32. data/spec/dummy/config/application.rb +1 -46
  33. data/spec/dummy/config/initializers/secret_token.rb +0 -1
  34. data/spec/factories/spud_admin_permission_factories.rb +1 -1
  35. data/spec/factories/spud_user_factories.rb +2 -2
  36. metadata +54 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: df57df79c7de9d2b469be1b10dbf13768c0618fc
4
- data.tar.gz: dcfad21bb4faad94fa53f152d377fe8d894cb9a8
2
+ SHA256:
3
+ metadata.gz: b601ae30b70478a2a908e9d8bc6dbf9b5ba8641edfd1768687f5472c5fd0b641
4
+ data.tar.gz: 0102a18e4e539fbe985e32c87eb38df5f6a68e9397316ff578d6bf9f86bd908b
5
5
  SHA512:
6
- metadata.gz: 6c0b426a055515c34d662e6275dc4b24f09ee6caec1d8e12587fd54c51ca360c437b3277daf43eb1422c0f706c017270eeab6ed697579a6760ac4145dca97c40
7
- data.tar.gz: 334d22e9f1e97cf378d256b1fa34e28609589c311bba1b952d3aa526801060249830702582aa66a4610b1510418ee3f047203c047ed79c703b33c797e716ef40
6
+ metadata.gz: bd894b75ba13119b6be69e1ce826d729333fd08f74f60ddd6393a666edc9fc7953449a58e6fce6b05e312625bc34e74afa8feac528932436d0f1488170184379
7
+ data.tar.gz: e4493e6a565cb75c8c0730bd220e4702ee7a19ab22bc371295cc84629ecab0a4012b4a6d81837ebaa5a8df63dfc46d3e6b8a0a7a18abcfdae24e419c760f779d
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://semaphoreci.com/api/v1/moser-it/tb_core/branches/dev/shields_badge.svg)](https://semaphoreci.com/moser-it/tb_core)
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
@@ -12,7 +12,9 @@ window.spud = { admin: window.tb };
12
12
 
13
13
  document.addEventListener('DOMContentLoaded', function() {
14
14
 
15
- tb.editor.init();
15
+ if (typeof tinymce != "undefined") {
16
+ tb.editor.init();
17
+ }
16
18
 
17
19
  $("#modal_window .modal-footer .form-submit").bind('click', function() {
18
20
  $("#modal_window .modal-body form").submit();
@@ -14,62 +14,28 @@ tb.editor = {};
14
14
  'undo', 'redo', '|',
15
15
  'bold','italic','underline','strikethrough','|',
16
16
  'formatselect','|',
17
- 'cut','copy','paste', 'pasteword','pastetext','|',
17
+ 'cut','copy','paste', '|',
18
18
  'bullist','numlist','outdent','indent','|',
19
19
  'link','unlink','image', '|', 'code', '|'
20
20
  ];
21
21
 
22
- var validElements = "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|" +
23
- "onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|" +
24
- "onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|" +
25
- "name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u," +
26
- "#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|" +
27
- "src|border|alt=|title|hspace|vspace|width|height|align|hidpi_src],-sub,-sup," +
28
- "-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|" +
29
- "height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|" +
30
- "height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot," +
31
- "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor" +
32
- "|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div," +
33
- "-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face" +
34
- "|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite]," +
35
- "object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width" +
36
- "|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo," +
37
- "button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|" +
38
- "valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method]," +
39
- "input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value]," +
40
- "kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value]," +
41
- "q[cite],samp,select[disabled|multiple|name|size],small," +
42
- "textarea[cols|rows|disabled|name|readonly],tt,var,big";
43
-
44
22
  var extendedValidElements = [
45
23
  "iframe[src|width|height|name|align|frameborder|allowfullscreen]"
46
24
  ];
47
25
 
48
26
  editor.init = function(options) {
49
27
  editor.unload();
50
- editor.checkAndCallTinyMce(options);
51
- };
52
28
 
53
- editor.initMCEWithOptions = function(element, options){
54
- var theme = options.theme || 'modern';
55
- var height = options.height || 400;
56
- var width = options.width || $(element).width();
57
- var buttons = options.buttons || registeredButtons;
58
- var plugins = options.plugins || registeredPlugins;
29
+ options = options || { selector: 'textarea.tinymce' };
59
30
 
60
- $(element).tinymce({
61
- theme: theme,
62
- language: 'en',
31
+ tinymce.init({
32
+ selector: options.selector,
33
+ height: 400,
63
34
  menubar: false,
64
- plugins: plugins.join(' '),
65
- toolbar: buttons.join(' '),
66
- convert_urls: false,
67
- valid_elements: validElements,
68
- media_strict: false,
69
- extended_valid_elements: extendedValidElements.join(","),
70
- width: width,
71
- height: height
72
- });
35
+ toolbar: registeredButtons.join(' '),
36
+ plugins: registeredPlugins.join(' '),
37
+ extended_valid_elements: extendedValidElements.join(",")
38
+ })
73
39
  };
74
40
 
75
41
  editor.unload = function() {
@@ -111,32 +77,4 @@ tb.editor = {};
111
77
  }
112
78
  };
113
79
 
114
- var loadScript = null;
115
-
116
- editor.checkAndCallTinyMce = function(options){
117
- options = options || {};
118
- var selector = options.selector || 'textarea.tinymce';
119
- var $elements = $(selector);
120
-
121
- if($elements.length === 0){
122
- return;
123
- }
124
-
125
- if(loadScript === null){
126
- loadScript = $.when(
127
- $.ajax({url: '//cdn.tinymce.com/4.3/tinymce.min.js', dataType: 'script', cache: true}),
128
- $.ajax({url: '//cdn.tinymce.com/4.3/jquery.tinymce.min.js', dataType: 'script', cache: true})
129
- ).done(function(){
130
- $('body').trigger("tb:tinymce-loaded");
131
- editor.tinymce.loaded = true;
132
- });
133
- }
134
-
135
- loadScript.done(function(){
136
- $elements.each(function(){
137
- editor.initMCEWithOptions(this, options);
138
- });
139
- });
140
- };
141
-
142
80
  })();
@@ -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 ' +
@@ -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
- name: [:last_name, :first_name],
12
- default: :email
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)
@@ -29,6 +29,7 @@ module TbCore
29
29
  render template: error.template,
30
30
  layout: nil,
31
31
  formats: [:html],
32
+ locals: { },
32
33
  status: error.code,
33
34
  content_type: 'text/html'
34
35
  end
@@ -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
 
@@ -0,0 +1,9 @@
1
+ module ForgotPasswordMailerHelper
2
+ def perishable_token_link_expiration_time_text(user)
3
+ return if user.class.perishable_token_valid_for.blank?
4
+
5
+ expiration_time = user.updated_at + user.class.perishable_token_valid_for
6
+
7
+ "This link will expire in #{distance_of_time_in_words(Time.current, expiration_time)}."
8
+ end
9
+ end
@@ -13,6 +13,21 @@ module TbCore::ApplicationHelper
13
13
  return form_for(record, options, &block)
14
14
  end
15
15
 
16
+ def tb_form_with(record, **options, &block)
17
+ options[:builder] = TbCore::FormBuilder
18
+
19
+ options[:html] ||= {}
20
+ if options[:html][:class]
21
+ options[:html][:class] += ' form-horizontal'
22
+ else
23
+ options[:html][:class] = 'form-horizontal'
24
+ end
25
+
26
+ options[:model] = record
27
+
28
+ return form_with(options, &block)
29
+ end
30
+
16
31
  def tb_form_errors(record, *fields_to_display)
17
32
  if record.errors.any?
18
33
  content_tag :div, class: 'form-errors test' do
@@ -56,6 +71,7 @@ module TbCore::ApplicationHelper
56
71
  end
57
72
  end
58
73
 
74
+ # rubocop:disable Rails/HelperInstanceVariable
59
75
  def tb_page_title
60
76
  if content_for?(:title)
61
77
  title = content_for(:title) + ' | ' + TbCore.site_name
@@ -66,6 +82,7 @@ module TbCore::ApplicationHelper
66
82
  end
67
83
  return content_tag :title, title
68
84
  end
85
+ # rubocop:enable Rails/HelperInstanceVariable
69
86
 
70
87
  def current_site_name
71
88
  return TbCore.config.site_name
@@ -1,4 +1,6 @@
1
1
  class TbCoreMailer < ActionMailer::Base
2
+ helper ForgotPasswordMailerHelper
3
+
2
4
  default from: TbCore.from_address
3
5
  layout 'mailer'
4
6
 
@@ -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
- if TbCore.config.user_password_length
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.to_s, foreign_key: :spud_role_id, required: false
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
 
@@ -69,6 +112,7 @@ module TbCore
69
112
 
70
113
  def full_name
71
114
  return login if first_name.blank? && last_name.blank?
115
+
72
116
  [first_name, last_name].reject(&:blank?).join(' ')
73
117
  end
74
118
 
@@ -79,12 +123,14 @@ module TbCore
79
123
  # Returns true if user can view at least one dashboard app
80
124
  def admin_rights?
81
125
  return true if super_admin
126
+
82
127
  TbCore.admin_applications.find { |app| can_view_app?(app) }.present?
83
128
  end
84
129
 
85
130
  # Returns true if the user can view a spud app based on it's key
86
131
  def can_view_app?(admin_application)
87
132
  return true if super_admin?
133
+
88
134
  key = admin_application[:key]
89
135
  permissions.find { |p| p.apps.include?(key) }.present?
90
136
  end
@@ -95,6 +141,7 @@ module TbCore
95
141
  # * if multiple tags are supplied, return true if ALL tags match
96
142
  def permission?(*tags)
97
143
  return true if super_admin?
144
+
98
145
  my_tags = permissions.collect(&:tag)
99
146
  tags.find { |tag| !my_tags.include?(tag) }.blank?
100
147
  end
@@ -105,12 +152,14 @@ module TbCore
105
152
  # * if multiple tags are supplied, return true if ANY tag matches
106
153
  def any_permission?(*tags)
107
154
  return true if super_admin?
155
+
108
156
  permissions.find { |p| tags.include?(p.tag) }.present?
109
157
  end
110
158
 
111
159
  # Return a list of SpudPermission objects for the user's SpudRole
112
160
  def permissions
113
161
  return [] if role.blank?
162
+
114
163
  role.permissions
115
164
  end
116
165
 
@@ -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
@@ -2,6 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <title><%= TbCore.config.site_name %> Admin</title>
5
+ <%= tinymce_assets unless ENV['TB_SKIP_TINYMCE'] %>
5
6
  <%= stylesheet_link_tag *TbCore.config.admin_stylesheets %>
6
7
  <%= javascript_include_tag *TbCore.config.admin_javascripts %>
7
8
  <%= csrf_meta_tags %>
@@ -49,7 +50,7 @@
49
50
  <h3 class="modal-title"></h3>
50
51
  </div>
51
52
  <div class="modal-body">
52
- <p>One fine body&hellip;</p>
53
+ <p>...</p>
53
54
  </div>
54
55
  <div class="modal-footer modal-footer-default">
55
56
  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@@ -1,6 +1,10 @@
1
1
  <h1>Hello <%= @user.full_name %>,</h1>
2
2
 
3
- <p>A password reset has recently been requested for your user account on <strong><%= TbCore.config.site_name %></strong>. Click the link below to set your new password.</p>
3
+ <p>
4
+ A password reset has recently been requested for your user account on <strong><%= TbCore.config.site_name %></strong>.
5
+ Click the link below to set your new password.
6
+ <%= perishable_token_link_expiration_time_text(@user) %>
7
+ </p>
4
8
 
5
9
  <p><%= link_to @url, @url %></p>
6
10
 
@@ -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
@@ -7,6 +7,7 @@ require 'will_paginate-bootstrap'
7
7
  require 'breadcrumbs_on_rails'
8
8
  require 'rails-ujs'
9
9
  require 'sortable_by'
10
+ require 'tinymce-rails'
10
11
 
11
12
  module Spud
12
13
  end
@@ -219,7 +219,7 @@ class TbCore::FormBuilder < ActionView::Helpers::FormBuilder
219
219
  # Builds a file field group
220
220
  #
221
221
  def tb_file_field(attribute, options={})
222
- tb_input_field(attribute) do
222
+ tb_input_field(attribute, nil, options) do
223
223
  file_field(attribute)
224
224
  end
225
225
  end
@@ -1,29 +1,31 @@
1
1
  require 'authlogic/test_case'
2
2
 
3
- module TbCore::SessionHelper
4
- include Authlogic::TestCase
3
+ module TbCore
4
+ module TestHelper
5
+ include Authlogic::TestCase
5
6
 
6
- # Use this helper in controller specs to establish a login session
7
- # - admin: Set to true to create a super_admin
8
- # - permissions: One or more permissions you want to assign to the user (a role will be auto generated)
9
- #
10
- def activate_session(admin: false, permissions: nil)
11
- activate_authlogic()
12
- if permissions
13
- permissions = [permissions] unless permissions.is_a?(Array)
14
- role = SpudRole.create(name: 'New Role', permission_tags: permissions)
15
- else
16
- role = nil
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
- # Returns the current user
24
- #
25
- def current_user
26
- return @user
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::SessionHelper
36
+ config.include TbCore::TestHelper
35
37
  end
36
38
  end
37
39
 
@@ -1,3 +1,3 @@
1
1
  module TbCore
2
- VERSION = '1.4.6'.freeze
2
+ VERSION = '1.5.2'.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
@@ -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.content_type).to eq('application/json')
72
+ expect(response.media_type).to eq('application/json')
73
73
  expect(json).to have_key('data')
74
74
  end
75
75
 
@@ -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
 
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -12,51 +12,6 @@ module Dummy
12
12
  config.from_address = 'no-reply@dummy.com'
13
13
  end
14
14
 
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
- # 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
@@ -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.6
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-03 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: authlogic
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.4.3
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.4.3
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bootstrap-sass
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: tinymce-rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: will_paginate
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -236,6 +250,20 @@ dependencies:
236
250
  version: '0'
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: rspec-rails
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: 4.0.0.beta2
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: 4.0.0.beta2
265
+ - !ruby/object:Gem::Dependency
266
+ name: rubocop
239
267
  requirement: !ruby/object:Gem::Requirement
240
268
  requirements:
241
269
  - - ">="
@@ -249,7 +277,21 @@ dependencies:
249
277
  - !ruby/object:Gem::Version
250
278
  version: '0'
251
279
  - !ruby/object:Gem::Dependency
252
- name: rubocop
280
+ name: rubocop-performance
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: rubocop-rails
253
295
  requirement: !ruby/object:Gem::Requirement
254
296
  requirements:
255
297
  - - ">="
@@ -324,6 +366,7 @@ files:
324
366
  - app/controllers/user_sessions_controller.rb
325
367
  - app/helpers/admin/application_helper.rb
326
368
  - app/helpers/admin/roles_helper.rb
369
+ - app/helpers/forgot_password_mailer_helper.rb
327
370
  - app/helpers/tb_core/application_helper.rb
328
371
  - app/mailers/tb_core_mailer.rb
329
372
  - app/models/concerns/tb_core/user_model.rb
@@ -435,6 +478,7 @@ files:
435
478
  - spec/controllers/tb_core/application_controller_spec.rb
436
479
  - spec/dummy/README.rdoc
437
480
  - spec/dummy/Rakefile
481
+ - spec/dummy/app/assets/config/manifest.js
438
482
  - spec/dummy/app/assets/javascripts/admin/application.js
439
483
  - spec/dummy/app/assets/javascripts/application.js
440
484
  - spec/dummy/app/assets/stylesheets/admin/application.scss
@@ -481,7 +525,7 @@ files:
481
525
  homepage: http://bitbucket.org/moser-inc/tb_core
482
526
  licenses: []
483
527
  metadata: {}
484
- post_install_message:
528
+ post_install_message:
485
529
  rdoc_options: []
486
530
  require_paths:
487
531
  - lib
@@ -496,15 +540,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
496
540
  - !ruby/object:Gem::Version
497
541
  version: '0'
498
542
  requirements: []
499
- rubyforge_project:
500
- rubygems_version: 2.6.14
501
- signing_key:
543
+ rubygems_version: 3.0.3
544
+ signing_key:
502
545
  specification_version: 4
503
546
  summary: Twice Baked Core Engine
504
547
  test_files:
505
548
  - spec/spec_helper.rb
506
549
  - spec/dummy/app/controllers/application_controller.rb
507
550
  - spec/dummy/app/views/layouts/application.html.erb
551
+ - spec/dummy/app/assets/config/manifest.js
508
552
  - spec/dummy/app/assets/javascripts/admin/application.js
509
553
  - spec/dummy/app/assets/javascripts/application.js
510
554
  - spec/dummy/app/assets/stylesheets/application.scss