tb_core 1.4.3.1 → 1.4.4

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -54
  3. data/app/assets/javascripts/admin/core/application.js +8 -4
  4. data/app/assets/javascripts/admin/core/dashboard.js +2 -3
  5. data/app/assets/javascripts/admin/core/date_picker.js +2 -2
  6. data/app/assets/javascripts/admin/core/editor.js +2 -2
  7. data/app/assets/javascripts/admin/core/modal.js +1 -1
  8. data/app/assets/javascripts/admin/core/users.js +5 -5
  9. data/app/assets/javascripts/tb_core.js +8 -0
  10. data/app/assets/libs/sortable/sortable.js +152 -91
  11. data/app/controllers/admin/application_controller.rb +1 -2
  12. data/app/controllers/admin/dashboard_controller.rb +2 -2
  13. data/app/controllers/admin/settings_controller.rb +2 -2
  14. data/app/controllers/admin/users_controller.rb +4 -7
  15. data/app/controllers/concerns/tb_core/error_handling.rb +16 -7
  16. data/app/controllers/concerns/tb_core/user_authentication.rb +5 -5
  17. data/app/controllers/tb_core/application_controller.rb +1 -1
  18. data/app/controllers/user_sessions_controller.rb +2 -2
  19. data/app/helpers/tb_core/application_helper.rb +4 -36
  20. data/app/mailers/tb_core_mailer.rb +3 -3
  21. data/app/models/concerns/tb_core/user_model.rb +131 -0
  22. data/app/models/spud/spud_user_model.rb +6 -138
  23. data/app/models/spud_permission.rb +4 -4
  24. data/app/models/spud_role.rb +1 -1
  25. data/app/models/spud_user.rb +2 -1
  26. data/app/views/admin/dashboard/index.html.erb +1 -1
  27. data/app/views/admin/settings/_form.html.erb +1 -1
  28. data/app/views/admin/settings/edit.html.erb +1 -1
  29. data/app/views/admin/setup/new.html.erb +1 -1
  30. data/app/views/admin/users/_form.html.erb +1 -1
  31. data/app/views/admin/users/index.html.erb +2 -2
  32. data/app/views/admin/users/show.html.erb +1 -1
  33. data/app/views/layouts/admin/application.html.erb +6 -6
  34. data/app/views/layouts/admin/login.html.erb +1 -1
  35. data/app/views/tb_core_mailer/forgot_password_notification.html.erb +2 -2
  36. data/app/views/tb_core_mailer/user_credentials.html.erb +2 -2
  37. data/app/views/user_sessions/_form.html.erb +1 -1
  38. data/app/views/user_sessions/new.html.erb +1 -1
  39. data/lib/generators/spud/module_generator.rb +7 -7
  40. data/lib/generators/spud/setup_generator.rb +6 -7
  41. data/lib/generators/spud/templates/assets/admin/application.js +1 -1
  42. data/lib/generators/spud/templates/assets/application.js +3 -4
  43. data/lib/generators/spud/templates/controller_spec.rb.erb +5 -5
  44. data/lib/generators/spud/templates/views/admin/_form.html.erb +1 -1
  45. data/lib/generators/spud/templates/views/admin/index.html.erb +1 -1
  46. data/lib/generators/spud/templates/views/admin/show.html.erb +1 -1
  47. data/lib/generators/spud/templates/views/frontend/index.html.erb +1 -1
  48. data/lib/generators/spud/templates/views/frontend/show.html.erb +1 -1
  49. data/lib/tb_core.rb +3 -5
  50. data/lib/tb_core/belongs_to_app.rb +47 -46
  51. data/lib/tb_core/catch_all_route.rb +3 -0
  52. data/lib/tb_core/configuration.rb +28 -0
  53. data/lib/tb_core/engine.rb +61 -0
  54. data/lib/tb_core/errors.rb +50 -0
  55. data/lib/tb_core/responder.rb +0 -26
  56. data/lib/{spud_core → tb_core}/searchable.rb +4 -1
  57. data/lib/tb_core/spud_core.rb +23 -0
  58. data/lib/{spud_core → tb_core}/test_files.rb +0 -0
  59. data/lib/tb_core/test_helper.rb +3 -3
  60. data/lib/tb_core/version.rb +3 -0
  61. data/spec/controllers/admin/application_controller_spec.rb +5 -5
  62. data/spec/controllers/admin/dashboard_controller_spec.rb +5 -5
  63. data/spec/controllers/admin/password_reset_controller_spec.rb +1 -1
  64. data/spec/controllers/admin/settings_controller_spec.rb +1 -1
  65. data/spec/controllers/admin/setup_controller_spec.rb +2 -2
  66. data/spec/controllers/admin/user_sessions_controller_spec.rb +2 -2
  67. data/spec/controllers/admin/users_controller_spec.rb +17 -17
  68. data/spec/dummy/app/assets/javascripts/admin/application.js +1 -1
  69. data/spec/dummy/app/assets/javascripts/application.js +1 -1
  70. data/spec/dummy/config/application.rb +1 -1
  71. data/spec/factories/spud_admin_permission_factories.rb +2 -2
  72. data/spec/factories/spud_role_factories.rb +2 -2
  73. data/spec/factories/spud_user_factories.rb +6 -6
  74. data/spec/helpers/spud/admin/application_helper_spec.rb +1 -1
  75. data/spec/helpers/tb_core/application_helper_spec.rb +0 -35
  76. data/spec/lib/spud_core/configuration_spec.rb +2 -2
  77. data/spec/lib/tb_core/belongs_to_app_spec.rb +4 -3
  78. data/spec/models/spud_role_spec.rb +2 -2
  79. data/spec/models/spud_user_spec.rb +13 -13
  80. data/spec/rails_helper.rb +1 -1
  81. metadata +59 -67
  82. data/app/assets/javascripts/tb_core.js.erb +0 -9
  83. data/app/assets/javascripts/tb_core/configuration.js.erb +0 -9
  84. data/app/assets/javascripts/tb_core/console.js +0 -12
  85. data/app/assets/javascripts/tb_core/remote.js +0 -237
  86. data/app/assets/javascripts/tb_core/utility.js +0 -55
  87. data/app/controllers/concerns/tb_core/sortable_params.rb +0 -80
  88. data/app/controllers/spud/application_controller.rb +0 -10
  89. data/lib/generators/spud/templates/assets/bootstrap.js +0 -14
  90. data/lib/spud_core/catch_all_route.rb +0 -3
  91. data/lib/spud_core/configuration.rb +0 -56
  92. data/lib/spud_core/engine.rb +0 -76
  93. data/lib/spud_core/errors.rb +0 -47
  94. data/lib/spud_core/version.rb +0 -5
  95. data/lib/tb_core/table_header.rb +0 -92
  96. data/spec/controllers/tb_core/sortable_params_spec.rb +0 -64
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ match '*any' => 'tb_core/application#not_found', via: :all
3
+ end
@@ -0,0 +1,28 @@
1
+ module TbCore
2
+ include ActiveSupport::Configurable
3
+ config_accessor :site_name, :admin_applications, :from_address, :site_id, :short_name,
4
+ :javascripts, :stylesheets, :admin_javascripts, :admin_stylesheets,
5
+ :permissions, :production_alert_domain, :use_email_as_login
6
+ self.admin_applications = []
7
+ self.site_name = 'Company Name'
8
+ self.site_id = 0
9
+ self.short_name = 'default'
10
+ self.javascripts = []
11
+ self.stylesheets = []
12
+ self.from_address = 'no-reply@companyname.com'
13
+ self.permissions = []
14
+ self.admin_javascripts = ['admin/core/application', 'admin/application']
15
+ self.admin_stylesheets = ['admin/core/application', 'admin/application']
16
+ self.production_alert_domain = nil
17
+ self.use_email_as_login = false
18
+
19
+ def self.append_admin_javascripts(*args)
20
+ args = args[0] if args[0].is_a?(Array)
21
+ TbCore.config.admin_javascripts += args
22
+ end
23
+
24
+ def self.append_admin_stylesheets(*args)
25
+ args = args[0] if args[0].is_a?(Array)
26
+ TbCore.config.admin_stylesheets += args
27
+ end
28
+ end
@@ -0,0 +1,61 @@
1
+ require 'responders'
2
+ require 'jquery-rails'
3
+ require 'authlogic'
4
+ require 'bootstrap-sass'
5
+ require 'will_paginate'
6
+ require 'will_paginate-bootstrap'
7
+ require 'breadcrumbs_on_rails'
8
+ require 'rails-ujs'
9
+ require 'sortable_by'
10
+
11
+ module Spud
12
+ end
13
+
14
+ module TbCore
15
+ class Engine < ::Rails::Engine
16
+ require "#{root}/lib/tb_core/errors"
17
+ require "#{root}/lib/tb_core/form_builder"
18
+ require "#{root}/lib/tb_core/searchable"
19
+ require "#{root}/lib/tb_core/spud_core"
20
+
21
+ engine_name :tb_core
22
+ config.autoload_paths << "#{root}/lib"
23
+
24
+ initializer 'tb_core.admin', after: :admin do
25
+ # Translate Hash configured permissions into SpudPermission objects
26
+ TbCore.permissions.collect! do |p|
27
+ if p.is_a? Hash
28
+ SpudPermission.new(p[:tag], p[:name], p[:apps])
29
+ else
30
+ p
31
+ end
32
+ end
33
+
34
+ # Append Users admin module
35
+ TbCore.config.admin_applications.unshift(name: 'Users',
36
+ thumbnail: 'admin/users_thumb.png',
37
+ url: '/admin/users',
38
+ order: 100)
39
+
40
+ # Create default permissions for modules
41
+ TbCore.admin_applications.each do |admin_application|
42
+ admin_application[:key] ||= admin_application[:name].tr(' ', '_').downcase.to_sym
43
+ tag = "admin.#{admin_application[:key]}.full_access"
44
+ name = "#{admin_application[:name]} admin"
45
+ apps = [admin_application[:key]]
46
+ TbCore.permissions.push(SpudPermission.new(tag, name, apps))
47
+ end
48
+ end
49
+
50
+ initializer 'tb_core.catch_all_route' do |config|
51
+ # Handle 404 errors if Spud::Cms is not installed
52
+ unless defined?(Spud::Cms)
53
+ config.routes_reloader.paths << File.expand_path('../catch_all_route.rb', __FILE__)
54
+ end
55
+ end
56
+
57
+ initializer 'tb_core.assets' do
58
+ Rails.application.config.assets.precompile += ['admin/users_thumb.png', 'admin/module_icon.png']
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,50 @@
1
+ module TbCore
2
+
3
+ class RequestError < StandardError
4
+ attr_accessor :request_url, :item, :template
5
+ attr_reader :code, :title
6
+
7
+ # For compatability reasons, this method accepts multiple styles of inputs
8
+ # Going forward the expected input will be:
9
+ #
10
+ # * item: The item that could not be found. String. (default = page)
11
+ # * template (named): ERB template you wish to render
12
+ #
13
+ def initialize(item_or_opts='page', opts={})
14
+ if item_or_opts.is_a?(Hash)
15
+ @item = item_or_opts[:item]
16
+ @template = item_or_opts[:template]
17
+ else
18
+ @item = item_or_opts
19
+ @template = opts[:template]
20
+ end
21
+ @template ||= 'layouts/error_page'
22
+ @title = I18n.t(:title, scope: [:tb_core, :errors, @i18n])
23
+ super(I18n.t(:message, scope: [:tb_core, :errors, @i18n], item: @item))
24
+ end
25
+ end
26
+
27
+ class AccessDeniedError < RequestError
28
+ def initialize(item_or_opts='page', opts={})
29
+ @code = 403
30
+ @i18n = 'access_denied'
31
+ super(item_or_opts, opts)
32
+ end
33
+ end
34
+
35
+ class NotFoundError < RequestError
36
+ def initialize(item_or_opts='page', opts={})
37
+ @code = 404
38
+ @i18n = 'not_found'
39
+ super(item_or_opts, opts)
40
+ end
41
+ end
42
+
43
+ class UnauthorizedError < RequestError
44
+ def initialize(item_or_opts='page', opts={})
45
+ @code = 401
46
+ @i18n = 'unauthorized'
47
+ super(item_or_opts, opts)
48
+ end
49
+ end
50
+ end
@@ -8,30 +8,4 @@ class TbCore::Responder < ActionController::Responder
8
8
  @options[:location] = nil
9
9
  end
10
10
  end
11
-
12
- # Override the common behavior for formats associated with APIs, such as :xml and :json.
13
- #
14
- def api_behavior
15
- raise MissingRenderer.new(format) unless has_renderer?
16
- if get?
17
- display resource
18
- elsif post? || patch?
19
- display resource, status: :created, location: api_location
20
- else
21
- head :no_content
22
- end
23
- end
24
-
25
- # Default responder only sends the basic errors array
26
- # This override also sends the translated labels for convenience
27
- #
28
- def json_resource_errors
29
- return Hash[resource.errors.messages.map do |attribute, messages|
30
- [attribute, {
31
- label: resource.class.human_attribute_name(attribute),
32
- messages: messages
33
- }]
34
- end]
35
- end
36
-
37
11
  end
@@ -5,7 +5,10 @@ module Spud::Searchable
5
5
  end
6
6
  module ClassMethods
7
7
  def spud_searchable
8
- # puts "Place Holder For #{self.name}"
8
+ ActiveSupport::Deprecation.warn(
9
+ 'Spud::Searchable is deprecated and will be removed from future releases.',
10
+ caller
11
+ )
9
12
  end
10
13
  end
11
14
  end
@@ -0,0 +1,23 @@
1
+ module Spud
2
+ module Core
3
+ module ClassMethods
4
+
5
+ def method_missing(method_signature, *args, &block)
6
+ if TbCore.respond_to?(method_signature)
7
+ ActiveSupport::Deprecation.warn(
8
+ 'The Spud::Core namespace is being replaced by TbCore. Please update your app code accordingly.',
9
+ caller
10
+ )
11
+ TbCore.__send__(method_signature, *args, &block)
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ def respond_to_missing?(method_signature)
18
+ TbCore.respond_to?(method_signature) || super
19
+ end
20
+ end
21
+ extend ClassMethods
22
+ end
23
+ end
File without changes
@@ -15,7 +15,7 @@ module TbCore::SessionHelper
15
15
  else
16
16
  role = nil
17
17
  end
18
- @user = FactoryGirl.create(:spud_user, super_admin: admin, role: role)
18
+ @user = FactoryBot.create(:spud_user, super_admin: admin, role: role)
19
19
  SpudUserSession.create(@user)
20
20
  return @user
21
21
  end
@@ -35,8 +35,8 @@ if defined?(RSpec)
35
35
  end
36
36
  end
37
37
 
38
- # Auto load the spud_user factory if FactoryGirl is in use
38
+ # Auto load the spud_user factory if FactoryBot is in use
39
39
  #
40
- if defined?(FactoryGirl)
40
+ if defined?(FactoryBot)
41
41
  Dir[TbCore::Engine.root.join('spec/factories/spud_user_factories.rb')].each{ |f| require f }
42
42
  end
@@ -0,0 +1,3 @@
1
+ module TbCore
2
+ VERSION = '1.4.4'.freeze
3
+ end
@@ -4,8 +4,8 @@ RSpec.describe Admin::ApplicationController, type: :controller do
4
4
 
5
5
  before :each do
6
6
  activate_authlogic
7
- @user = FactoryGirl.create(:spud_user)
8
- @role = FactoryGirl.create(:spud_role)
7
+ @user = FactoryBot.create(:spud_user)
8
+ @role = FactoryBot.create(:spud_role)
9
9
  @session = SpudUserSession.create(@user)
10
10
  end
11
11
 
@@ -15,6 +15,7 @@ RSpec.describe Admin::ApplicationController, type: :controller do
15
15
  head :ok
16
16
  end
17
17
  end
18
+
18
19
  it 'should respond successfully if the current user is a super admin' do
19
20
  @user.update_attributes(super_admin: true)
20
21
  get :index
@@ -23,9 +24,9 @@ RSpec.describe Admin::ApplicationController, type: :controller do
23
24
 
24
25
  it 'should respond successfully if the current user has admin permissions' do
25
26
  @role.permission_tags = ['admin.users.full_access']
26
- @role.save()
27
+ @role.save
27
28
  @user.role = @role
28
- @user.save()
29
+ @user.save
29
30
  get :index
30
31
  expect(response).to be_success
31
32
  end
@@ -44,6 +45,5 @@ RSpec.describe Admin::ApplicationController, type: :controller do
44
45
  expect(response.code).to eq('403')
45
46
  expect(response).to render_template('layouts/admin/error_page')
46
47
  end
47
-
48
48
  end
49
49
  end
@@ -3,7 +3,7 @@ require 'rails_helper'
3
3
  RSpec.describe Admin::DashboardController, type: :controller do
4
4
 
5
5
  before(:all) do
6
- Spud::Core.admin_applications += [{
6
+ TbCore.admin_applications += [{
7
7
  name: 'Test App',
8
8
  url: '/test/app',
9
9
  permissions: ['admin.test_app.full_access']
@@ -22,7 +22,7 @@ RSpec.describe Admin::DashboardController, type: :controller do
22
22
  describe 'index' do
23
23
  it 'should display applications the current user has access to given that the current user is not a super admin' do
24
24
  @user.super_admin = false
25
- @user.role = FactoryGirl.create(:spud_role, permission_tags: ['admin.users.full_access'])
25
+ @user.role = FactoryBot.create(:spud_role, permission_tags: ['admin.users.full_access'])
26
26
  @user.save()
27
27
  get :index
28
28
 
@@ -32,7 +32,7 @@ RSpec.describe Admin::DashboardController, type: :controller do
32
32
  it 'should not display applications the current user does not have access
33
33
  to given that the current user is not a super admin' do
34
34
  @user.super_admin = false
35
- @user.role = FactoryGirl.create(:spud_role, permission_tags: ['admin.users.full_access'])
35
+ @user.role = FactoryBot.create(:spud_role, permission_tags: ['admin.users.full_access'])
36
36
  @user.save()
37
37
  get :index
38
38
 
@@ -46,7 +46,7 @@ RSpec.describe Admin::DashboardController, type: :controller do
46
46
  @user.save
47
47
  get :index
48
48
 
49
- excectation = Spud::Core.admin_applications.collect{|app| app[:name] }
49
+ excectation = TbCore.admin_applications.collect{|app| app[:name] }
50
50
  expect(assigns(:admin_applications).collect{|app| app[:name] }).to eq(excectation)
51
51
  end
52
52
  end
@@ -54,7 +54,7 @@ RSpec.describe Admin::DashboardController, type: :controller do
54
54
  describe 'badges' do
55
55
  before(:each) do
56
56
  request.accept = 'application/json'
57
- Spud::Core.configure do |config|
57
+ TbCore.configure do |config|
58
58
  config.site_name = 'Test Site'
59
59
  end
60
60
  @user.super_admin = true
@@ -2,7 +2,7 @@ require 'rails_helper'
2
2
 
3
3
  describe Admin::PasswordResetsController, type: :controller do
4
4
 
5
- let(:user) { FactoryGirl.build(:spud_user, id: 1, perishable_token: 'jfdlsafhbkvabuadfbds') }
5
+ let(:user) { FactoryBot.build(:spud_user, id: 1, perishable_token: 'jfdlsafhbkvabuadfbds') }
6
6
 
7
7
  context 'get' do
8
8
  describe 'index' do
@@ -14,7 +14,7 @@ describe Admin::SettingsController, type: :controller do
14
14
 
15
15
  describe 'update' do
16
16
  it 'should give an error if password change does not include a valid current password' do
17
- u = FactoryGirl.build(:spud_user)
17
+ u = FactoryBot.build(:spud_user)
18
18
  u.password = 'test'
19
19
  put :update, params: { spud_user: {first_name: 'Mike', password: 'Imapassword', current_password: 'ImaTest'} }
20
20
  expect(response).to have_http_status(401)
@@ -20,12 +20,12 @@ describe Admin::SetupController, type: :controller do
20
20
  describe 'create' do
21
21
  it 'should create a new user' do
22
22
  expect{
23
- post :create, params: { spud_user: FactoryGirl.attributes_for(:spud_user) }
23
+ post :create, params: { spud_user: FactoryBot.attributes_for(:spud_user) }
24
24
  }.to change(SpudUser, :count).by(1)
25
25
  end
26
26
 
27
27
  it 'should redirect to the admin dashboard when first admin user has been created' do
28
- post :create, params: { spud_user: FactoryGirl.attributes_for(:spud_user) }
28
+ post :create, params: { spud_user: FactoryBot.attributes_for(:spud_user) }
29
29
  expect(response).to redirect_to(admin_root_path)
30
30
  end
31
31
  end
@@ -3,7 +3,7 @@ require 'rails_helper'
3
3
  describe Admin::UserSessionsController, type: :controller do
4
4
  before(:each) do
5
5
  # activate_authlogic
6
- # SpudUserSession.create(FactoryGirl.build(:spud_user))
6
+ # SpudUserSession.create(FactoryBot.build(:spud_user))
7
7
  end
8
8
 
9
9
  describe 'new' do
@@ -13,7 +13,7 @@ describe Admin::UserSessionsController, type: :controller do
13
13
  end
14
14
 
15
15
  it 'should render login form if users do exist' do
16
- u = FactoryGirl.create(:spud_user)
16
+ u = FactoryBot.create(:spud_user)
17
17
  u.save
18
18
  get :new
19
19
  expect(response).to be_success
@@ -4,14 +4,14 @@ describe Admin::UsersController, type: :controller do
4
4
 
5
5
  before(:each) do
6
6
  activate_session(admin: true)
7
- @role = FactoryGirl.create(:spud_role)
8
- Spud::Core.admin_applications += [{name: 'Test', key: :test}]
9
- Spud::Core.permissions.push(SpudPermission.new('admin.test.full_access', 'Test', [:test]))
7
+ @role = FactoryBot.create(:spud_role)
8
+ TbCore.admin_applications += [{name: 'Test', key: :test}]
9
+ TbCore.permissions.push(SpudPermission.new('admin.test.full_access', 'Test', [:test]))
10
10
  end
11
11
 
12
12
  describe 'index' do
13
13
  it 'should return an array of users' do
14
- 2.times {|x| FactoryGirl.create(:spud_user) }
14
+ 2.times {|x| FactoryBot.create(:spud_user) }
15
15
  get :index
16
16
 
17
17
  expect(assigns(:spud_users).count).to be > 1
@@ -24,7 +24,7 @@ describe Admin::UsersController, type: :controller do
24
24
  end
25
25
 
26
26
  it 'should not allow access to users with NO permissions' do
27
- SpudUserSession.create(FactoryGirl.build(:spud_user, super_admin: false))
27
+ SpudUserSession.create(FactoryBot.build(:spud_user, super_admin: false))
28
28
  get :index
29
29
 
30
30
  expect(response.code).to eq('403')
@@ -32,7 +32,7 @@ describe Admin::UsersController, type: :controller do
32
32
  end
33
33
 
34
34
  it 'should allow access to users with the correct permissions' do
35
- u = FactoryGirl.create(:spud_user, super_admin: false)
35
+ u = FactoryBot.create(:spud_user, super_admin: false)
36
36
  @role.permission_tags = ['admin.users.full_access']
37
37
  @role.save()
38
38
  u.role = @role
@@ -44,7 +44,7 @@ describe Admin::UsersController, type: :controller do
44
44
 
45
45
  it 'should not allow access to users without a role,
46
46
  and redirect to render error page if the user has no permissions' do
47
- u = FactoryGirl.create(:spud_user, super_admin: false)
47
+ u = FactoryBot.create(:spud_user, super_admin: false)
48
48
  u.role = nil
49
49
  SpudUserSession.create(u)
50
50
  get :index
@@ -55,7 +55,7 @@ describe Admin::UsersController, type: :controller do
55
55
 
56
56
  it 'should not allow access to users with a role that contains no permissions,
57
57
  and render error page if the users has no other admin modules' do
58
- u = FactoryGirl.create(:spud_user, super_admin: false)
58
+ u = FactoryBot.create(:spud_user, super_admin: false)
59
59
  u.role = @role
60
60
  @role.spud_role_permissions = []
61
61
  SpudUserSession.create(u)
@@ -67,7 +67,7 @@ describe Admin::UsersController, type: :controller do
67
67
 
68
68
  it 'should not allow access to users without permission
69
69
  and render error page if the users has other admin modules' do
70
- u = FactoryGirl.create(:spud_user, super_admin: false)
70
+ u = FactoryBot.create(:spud_user, super_admin: false)
71
71
  @role.permission_tags = ['admin.test.full_access']
72
72
  u.role = @role
73
73
  SpudUserSession.create(u)
@@ -80,7 +80,7 @@ describe Admin::UsersController, type: :controller do
80
80
 
81
81
  describe 'show' do
82
82
  it 'should respond successfully' do
83
- user = FactoryGirl.create(:spud_user)
83
+ user = FactoryBot.create(:spud_user)
84
84
  get :show, params: { id: user.id }
85
85
  expect(response).to be_success
86
86
  end
@@ -97,13 +97,13 @@ describe Admin::UsersController, type: :controller do
97
97
  context 'HTML format' do
98
98
  it 'should create a new user with a valid form submission' do
99
99
  expect {
100
- post :create, params: { spud_user: FactoryGirl.attributes_for(:spud_user) }
100
+ post :create, params: { spud_user: FactoryBot.attributes_for(:spud_user) }
101
101
  }.to change(SpudUser, :count).by(1)
102
102
  end
103
103
 
104
104
  it 'should not create a user with an invalid form entry' do
105
105
  expect {
106
- post :create, params: { spud_user: FactoryGirl.attributes_for(:spud_user, email: nil) }
106
+ post :create, params: { spud_user: FactoryBot.attributes_for(:spud_user, email: nil) }
107
107
  }.to_not change(SpudUser, :count)
108
108
  end
109
109
  end
@@ -112,7 +112,7 @@ describe Admin::UsersController, type: :controller do
112
112
  describe 'edit' do
113
113
  context 'HTML format' do
114
114
  it 'should load the correct user for the edit form' do
115
- user = FactoryGirl.create(:spud_user)
115
+ user = FactoryBot.create(:spud_user)
116
116
  get :edit, params: { id: user.id }
117
117
 
118
118
  expect(assigns(:user).id).to eq(user.id)
@@ -122,7 +122,7 @@ describe Admin::UsersController, type: :controller do
122
122
 
123
123
  describe 'update' do
124
124
  it 'should update the email when the first name attribute is changed' do
125
- user = FactoryGirl.create(:spud_user)
125
+ user = FactoryBot.create(:spud_user)
126
126
  new_name = 'Adam'
127
127
  expect {
128
128
  put :update, params: { id: user.id, spud_user: { first_name: new_name } }
@@ -131,7 +131,7 @@ describe Admin::UsersController, type: :controller do
131
131
  end
132
132
 
133
133
  it 'should redirect to the admin users show view after a successful update' do
134
- user = FactoryGirl.create(:spud_user)
134
+ user = FactoryBot.create(:spud_user)
135
135
  put :update, params: { id: user.id, spud_user: user.attributes.merge!(first_name: 'Adam') }
136
136
 
137
137
  expect(response).to redirect_to(admin_user_path(user))
@@ -140,7 +140,7 @@ describe Admin::UsersController, type: :controller do
140
140
 
141
141
  describe 'destroy' do
142
142
  it 'should destroy the user' do
143
- user = FactoryGirl.create(:spud_user)
143
+ user = FactoryBot.create(:spud_user)
144
144
  expect {
145
145
  delete :destroy, params: { id: user.id }
146
146
  }.to change(SpudUser, :count).by(-1)
@@ -148,7 +148,7 @@ describe Admin::UsersController, type: :controller do
148
148
  end
149
149
 
150
150
  it 'should destroy the user with the wrong id' do
151
- FactoryGirl.create(:spud_user)
151
+ FactoryBot.create(:spud_user)
152
152
  expect {
153
153
  delete :destroy, params: { id: '23532' }
154
154
  }.to_not change(SpudUser, :count)