tb_core 1.4.7 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  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 +1 -0
  11. data/app/helpers/tb_core/application_helper.rb +17 -0
  12. data/app/models/concerns/tb_core/user_model.rb +42 -5
  13. data/app/models/spud_role.rb +2 -7
  14. data/app/views/layouts/admin/application.html.erb +2 -1
  15. data/lib/generators/spud/module_generator.rb +3 -3
  16. data/lib/generators/spud/setup_generator.rb +1 -1
  17. data/lib/tb_core/belongs_to_app.rb +1 -0
  18. data/lib/tb_core/engine.rb +2 -0
  19. data/lib/tb_core/form_builder.rb +1 -1
  20. data/lib/tb_core/regex.rb +12 -0
  21. data/lib/tb_core/test_helper.rb +24 -22
  22. data/lib/tb_core/version.rb +1 -1
  23. data/spec/controllers/admin/application_controller_spec.rb +2 -2
  24. data/spec/controllers/admin/dashboard_controller_spec.rb +1 -1
  25. data/spec/controllers/admin/password_reset_controller_spec.rb +2 -2
  26. data/spec/controllers/admin/settings_controller_spec.rb +1 -1
  27. data/spec/controllers/admin/setup_controller_spec.rb +1 -1
  28. data/spec/controllers/admin/user_sessions_controller_spec.rb +1 -1
  29. data/spec/controllers/admin/users_controller_spec.rb +3 -3
  30. data/spec/dummy/app/assets/config/manifest.js +3 -0
  31. data/spec/dummy/config/application.rb +1 -46
  32. data/spec/dummy/config/initializers/secret_token.rb +0 -1
  33. data/spec/factories/spud_admin_permission_factories.rb +1 -1
  34. data/spec/factories/spud_user_factories.rb +2 -2
  35. metadata +54 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dd467d0438cc596f8c289d040049e2e1d41d8d1c03cf2f643fca5bb8a2999ec
4
- data.tar.gz: 374cea46337ada9623d5365024e4bf914f70a25b0c6e2f83997e319000ea342e
3
+ metadata.gz: 7be83cc72ea702d72548da1c9bf4d25eb632e154169ef241e11bfa845d842a3f
4
+ data.tar.gz: 191e53b35d46f8f5b91acef66b14015cfb69fc6dd6cd57ae68db1ac9d8e6540e
5
5
  SHA512:
6
- metadata.gz: 94358f3622e59b5f638be9ed1ba51add44a014ddf1748dff548b8f717f9aee662d37b4a7cd9011fb8c46b9423e9b9b9b01bb621e316df41d6390be21650df119
7
- data.tar.gz: ab751288247246638a04c5d779f166e3cb0c426551ec3eac4cbb59ba19ce1c489ea12f1a264c0f424f354e365a8b031e77b7c12ff7b0a367157fb0cc4558064c
6
+ metadata.gz: 3eb99e7178bd58e87539f5ffec183614fccd1a1aa801a7c531d962d0a4a8408228736007b62172f04bd344f402bbed45c7771b768eb1278b14218fa9a3d46b4a
7
+ data.tar.gz: 04016da2d6563e8857c02c924b08878ecf238da9f63a871dd991498fc6f4765792a16c965b2053eb4add1ab75a71287af73d01475b52afa4596655ac2f8ee0d6
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
 
@@ -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)}."
@@ -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
@@ -2,26 +2,27 @@ module TbCore
2
2
  module UserModel
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ # rubocop:disable Metrics/BlockLength
5
6
  included do
6
7
  self.table_name = 'spud_users'
7
8
 
8
9
  acts_as_authentic do |c|
9
- c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
10
10
  c.crypto_provider = Authlogic::CryptoProviders::SCrypt
11
11
  c.logged_in_timeout = 24.hours
12
12
  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
13
+ c.require_password_confirmation = true
16
14
  end
17
15
 
16
+ attr_accessor :password_confirmation
17
+
18
18
  belongs_to :role,
19
- class_name: SpudRole.to_s, foreign_key: :spud_role_id, required: false
19
+ class_name: 'SpudRole', 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
 
23
23
  validates :first_name, :last_name, presence: true
24
24
  before_validation :set_login_to_email, if: -> { TbCore.config.use_email_as_login }
25
+
25
26
  before_update :unset_requires_password_change
26
27
 
27
28
  scope :admins, lambda {
@@ -29,7 +30,37 @@ module TbCore
29
30
  }
30
31
 
31
32
  scope :ordered, -> { order('last_name asc, first_name asc, email asc') }
33
+
34
+ # These used to be built in to Authlogic
35
+ # See: https://github.com/binarylogic/authlogic/blob/5986e1bd056ccecc519d9f49cc83a0ba757668b4/doc/use_normal_rails_validation.md
36
+ validates :email,
37
+ format: {
38
+ with: ::TbCore::Regex::EMAIL,
39
+ message: proc {
40
+ ::Authlogic::I18n.t(
41
+ 'error_messages.email_invalid',
42
+ default: 'should look like an email address.'
43
+ )
44
+ }
45
+ },
46
+ length: { maximum: 100 },
47
+ uniqueness: {
48
+ case_sensitive: false,
49
+ if: :will_save_change_to_email?
50
+ }
51
+ validates :password,
52
+ confirmation: { if: :require_password? },
53
+ length: {
54
+ minimum: 8,
55
+ if: :require_password?
56
+ }
57
+ validates :password_confirmation,
58
+ length: {
59
+ minimum: 8,
60
+ if: :require_password?
61
+ }
32
62
  end
63
+ # rubocop:enable Metrics/BlockLength
33
64
 
34
65
  module ClassMethods
35
66
 
@@ -69,6 +100,7 @@ module TbCore
69
100
 
70
101
  def full_name
71
102
  return login if first_name.blank? && last_name.blank?
103
+
72
104
  [first_name, last_name].reject(&:blank?).join(' ')
73
105
  end
74
106
 
@@ -79,12 +111,14 @@ module TbCore
79
111
  # Returns true if user can view at least one dashboard app
80
112
  def admin_rights?
81
113
  return true if super_admin
114
+
82
115
  TbCore.admin_applications.find { |app| can_view_app?(app) }.present?
83
116
  end
84
117
 
85
118
  # Returns true if the user can view a spud app based on it's key
86
119
  def can_view_app?(admin_application)
87
120
  return true if super_admin?
121
+
88
122
  key = admin_application[:key]
89
123
  permissions.find { |p| p.apps.include?(key) }.present?
90
124
  end
@@ -95,6 +129,7 @@ module TbCore
95
129
  # * if multiple tags are supplied, return true if ALL tags match
96
130
  def permission?(*tags)
97
131
  return true if super_admin?
132
+
98
133
  my_tags = permissions.collect(&:tag)
99
134
  tags.find { |tag| !my_tags.include?(tag) }.blank?
100
135
  end
@@ -105,12 +140,14 @@ module TbCore
105
140
  # * if multiple tags are supplied, return true if ANY tag matches
106
141
  def any_permission?(*tags)
107
142
  return true if super_admin?
143
+
108
144
  permissions.find { |p| tags.include?(p.tag) }.present?
109
145
  end
110
146
 
111
147
  # Return a list of SpudPermission objects for the user's SpudRole
112
148
  def permissions
113
149
  return [] if role.blank?
150
+
114
151
  role.permissions
115
152
  end
116
153
 
@@ -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>
@@ -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
@@ -15,6 +16,7 @@ module TbCore
15
16
  class Engine < ::Rails::Engine
16
17
  require "#{root}/lib/tb_core/errors"
17
18
  require "#{root}/lib/tb_core/form_builder"
19
+ require "#{root}/lib/tb_core/regex"
18
20
  require "#{root}/lib/tb_core/searchable"
19
21
  require "#{root}/lib/tb_core/spud_core"
20
22
 
@@ -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
@@ -0,0 +1,12 @@
1
+ module TbCore
2
+ module Regex
3
+ EMAIL = /
4
+ \A
5
+ [A-Z0-9_.&%+\-']+ # mailbox
6
+ @
7
+ (?:[A-Z0-9\-]+\.)+ # subdomains
8
+ (?:[A-Z]{2,25}) # TLD
9
+ \z
10
+ /ix.freeze
11
+ end
12
+ 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.7'.freeze
2
+ VERSION = '1.5.3'.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.7
4
+ version: 1.5.3
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-12-10 00:00:00.000000000 Z
11
+ date: 2021-01-11 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
  - - ">="
@@ -420,6 +462,7 @@ files:
420
462
  - lib/tb_core/engine.rb
421
463
  - lib/tb_core/errors.rb
422
464
  - lib/tb_core/form_builder.rb
465
+ - lib/tb_core/regex.rb
423
466
  - lib/tb_core/responder.rb
424
467
  - lib/tb_core/searchable.rb
425
468
  - lib/tb_core/spud_core.rb
@@ -436,6 +479,7 @@ files:
436
479
  - spec/controllers/tb_core/application_controller_spec.rb
437
480
  - spec/dummy/README.rdoc
438
481
  - spec/dummy/Rakefile
482
+ - spec/dummy/app/assets/config/manifest.js
439
483
  - spec/dummy/app/assets/javascripts/admin/application.js
440
484
  - spec/dummy/app/assets/javascripts/application.js
441
485
  - spec/dummy/app/assets/stylesheets/admin/application.scss
@@ -482,7 +526,7 @@ files:
482
526
  homepage: http://bitbucket.org/moser-inc/tb_core
483
527
  licenses: []
484
528
  metadata: {}
485
- post_install_message:
529
+ post_install_message:
486
530
  rdoc_options: []
487
531
  require_paths:
488
532
  - lib
@@ -497,15 +541,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
497
541
  - !ruby/object:Gem::Version
498
542
  version: '0'
499
543
  requirements: []
500
- rubyforge_project:
501
- rubygems_version: 2.7.7
502
- signing_key:
544
+ rubygems_version: 3.0.3
545
+ signing_key:
503
546
  specification_version: 4
504
547
  summary: Twice Baked Core Engine
505
548
  test_files:
506
549
  - spec/spec_helper.rb
507
550
  - spec/dummy/app/controllers/application_controller.rb
508
551
  - spec/dummy/app/views/layouts/application.html.erb
552
+ - spec/dummy/app/assets/config/manifest.js
509
553
  - spec/dummy/app/assets/javascripts/admin/application.js
510
554
  - spec/dummy/app/assets/javascripts/application.js
511
555
  - spec/dummy/app/assets/stylesheets/application.scss