tb_cms 1.3.0 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -9
  3. data/app/assets/javascripts/admin/cms/application.js +1 -1
  4. data/app/assets/javascripts/admin/cms/menu_items.js +14 -8
  5. data/app/assets/javascripts/admin/cms/pages.js +9 -7
  6. data/app/controllers/admin/pages_controller.rb +1 -1
  7. data/app/controllers/cms/sitemaps_controller.rb +1 -1
  8. data/app/controllers/pages_controller.rb +4 -4
  9. data/app/helpers/cms/application_helper.rb +4 -4
  10. data/app/models/spud_menu_item.rb +3 -3
  11. data/app/models/spud_page.rb +22 -10
  12. data/app/models/spud_page_partial.rb +3 -20
  13. data/app/models/spud_snippet.rb +1 -4
  14. data/app/views/admin/menu_items/index.html.erb +2 -2
  15. data/app/views/admin/pages/_form.html.erb +2 -2
  16. data/app/views/admin/pages/_page_partials_form.html.erb +1 -1
  17. data/app/views/admin/pages/_page_row.html.erb +1 -1
  18. data/app/views/admin/pages/show.html.erb +12 -15
  19. data/app/views/pages/show.html.erb +2 -2
  20. data/db/migrate/20120101192412_create_spud_pages.rb +1 -1
  21. data/db/migrate/20120101193138_create_spud_menus.rb +1 -1
  22. data/db/migrate/20120101193255_create_spud_menu_items.rb +1 -1
  23. data/db/migrate/20120101194124_create_spud_templates.rb +1 -1
  24. data/db/migrate/20120103034659_create_spud_page_partials.rb +1 -1
  25. data/db/migrate/20120104194032_add_visibility_to_spud_pages.rb +1 -1
  26. data/db/migrate/20120107181337_add_menu_name_to_spud_menu_items.rb +1 -1
  27. data/db/migrate/20120111134754_add_use_custom_url_name_to_spud_pages.rb +1 -1
  28. data/db/migrate/20120118141852_add_notes_to_spud_pages.rb +1 -1
  29. data/db/migrate/20120126232428_add_menu_id_to_spud_menu_items.rb +1 -1
  30. data/db/migrate/20120128163601_add_classes_to_spud_menu_items.rb +1 -1
  31. data/db/migrate/20120329132314_add_site_id_to_spud_pages.rb +1 -1
  32. data/db/migrate/20120329132322_add_site_id_to_spud_templates.rb +1 -1
  33. data/db/migrate/20120329132330_add_site_id_to_spud_menus.rb +1 -1
  34. data/db/migrate/20120510195151_create_spud_page_partial_revisions.rb +1 -1
  35. data/db/migrate/20120911190030_add_symbol_name_to_spud_page_partials.rb +1 -1
  36. data/db/migrate/20120912121313_modify_site_id_for_spud_pages.rb +1 -1
  37. data/db/migrate/20121016233715_add_content_processed_to_spud_page_partials.rb +1 -1
  38. data/db/migrate/20121112151110_add_layout_to_spud_pages.rb +1 -1
  39. data/db/migrate/20121119025608_create_spud_snippets.rb +1 -1
  40. data/db/migrate/20150108162839_remove_site_id_from_cms_tables.rb +1 -1
  41. data/db/migrate/20150622161403_add_title_tag_to_spud_page.rb +1 -1
  42. data/lib/spud_cms/engine.rb +4 -15
  43. data/lib/spud_cms/template_parser.rb +2 -2
  44. data/lib/spud_cms/version.rb +1 -1
  45. data/lib/tb_cms.rb +0 -1
  46. data/spec/controllers/admin/menu_items_controller_spec.rb +18 -18
  47. data/spec/controllers/admin/menus_controller_spec.rb +9 -9
  48. data/spec/controllers/admin/pages_controller_spec.rb +9 -9
  49. data/spec/controllers/pages_controller_spec.rb +5 -5
  50. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  51. data/spec/dummy/config/application.rb +1 -1
  52. data/spec/dummy/config/database.yml +3 -6
  53. data/spec/dummy/config/environments/development.rb +2 -2
  54. data/spec/dummy/db/migrate/20141231214446_create_spud_admin_permissions.tb_core.rb +1 -1
  55. data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +1 -1
  56. data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +1 -1
  57. data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +1 -1
  58. data/spec/dummy/db/migrate/20141231214450_create_spud_user_settings.tb_core.rb +1 -1
  59. data/spec/dummy/db/migrate/20141231214451_create_spud_roles.tb_core.rb +1 -1
  60. data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +1 -1
  61. data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +1 -1
  62. data/spec/dummy/db/migrate/20141231214454_drop_spud_admin_permissions.tb_core.rb +1 -1
  63. data/spec/dummy/db/migrate/20141231214455_create_spud_permalinks.tb_permalinks.rb +1 -1
  64. data/spec/dummy/db/migrate/20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb +1 -1
  65. data/spec/dummy/db/migrate/20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb +1 -1
  66. data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
  67. data/spec/dummy/db/migrate/20141231214460_create_spud_menus.tb_cms.rb +1 -1
  68. data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +1 -1
  69. data/spec/dummy/db/migrate/20141231214462_create_spud_templates.tb_cms.rb +1 -1
  70. data/spec/dummy/db/migrate/20141231214463_create_spud_page_partials.tb_cms.rb +1 -1
  71. data/spec/dummy/db/migrate/20141231214464_add_visibility_to_spud_pages.tb_cms.rb +1 -1
  72. data/spec/dummy/db/migrate/20141231214465_add_menu_name_to_spud_menu_items.tb_cms.rb +1 -1
  73. data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb +1 -1
  74. data/spec/dummy/db/migrate/20141231214467_add_notes_to_spud_pages.tb_cms.rb +1 -1
  75. data/spec/dummy/db/migrate/20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb +1 -1
  76. data/spec/dummy/db/migrate/20141231214469_add_classes_to_spud_menu_items.tb_cms.rb +1 -1
  77. data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +1 -1
  78. data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +1 -1
  79. data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +1 -1
  80. data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
  81. data/spec/dummy/db/migrate/20141231214474_add_symbol_name_to_spud_page_partials.tb_cms.rb +1 -1
  82. data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +1 -1
  83. data/spec/dummy/db/migrate/20141231214476_add_content_processed_to_spud_page_partials.tb_cms.rb +1 -1
  84. data/spec/dummy/db/migrate/20141231214477_add_layout_to_spud_pages.tb_cms.rb +1 -1
  85. data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -1
  86. data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -1
  87. data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
  88. data/spec/dummy/db/migrate/20150911185844_add_title_tag_to_spud_page.tb_cms.rb +1 -1
  89. data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +1 -1
  90. data/spec/dummy/db/schema.rb +108 -115
  91. data/spec/helpers/cms/application_helper_spec.rb +37 -37
  92. data/spec/models/spud_menu_item_spec.rb +4 -4
  93. data/spec/models/spud_page_partial_spec.rb +5 -5
  94. data/spec/models/spud_page_spec.rb +20 -12
  95. data/spec/rails_helper.rb +1 -1
  96. metadata +70 -96
  97. data/db/migrate/20121112212113_create_spud_page_liquid_tags.rb +0 -11
  98. data/db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb +0 -17
  99. data/db/migrate/20140110142037_drop_spud_page_liquid_tags.rb +0 -31
  100. data/lib/spud_cms/liquid_snippet.rb +0 -27
  101. data/spec/dummy/db/migrate/20141231214458_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +0 -13
  102. data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +0 -12
  103. data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +0 -18
  104. data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +0 -30
@@ -1,4 +1,4 @@
1
- class CreateSpudMenus < ActiveRecord::Migration
1
+ class CreateSpudMenus < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_menus do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateSpudMenuItems < ActiveRecord::Migration
1
+ class CreateSpudMenuItems < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_menu_items do |t|
4
4
  t.string :parent_type
@@ -1,4 +1,4 @@
1
- class CreateSpudTemplates < ActiveRecord::Migration
1
+ class CreateSpudTemplates < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_templates do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateSpudPagePartials < ActiveRecord::Migration
1
+ class CreateSpudPagePartials < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_page_partials do |t|
4
4
  t.integer :spud_page_id
@@ -1,4 +1,4 @@
1
- class AddVisibilityToSpudPages < ActiveRecord::Migration
1
+ class AddVisibilityToSpudPages < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_pages, :visibility, :integer,:default => 0
4
4
  add_column :spud_pages, :published, :boolean,:default => true
@@ -1,4 +1,4 @@
1
- class AddMenuNameToSpudMenuItems < ActiveRecord::Migration
1
+ class AddMenuNameToSpudMenuItems < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_menu_items, :name, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddUseCustomUrlNameToSpudPages < ActiveRecord::Migration
1
+ class AddUseCustomUrlNameToSpudPages < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_pages, :use_custom_url_name, :boolean,:default => false
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddNotesToSpudPages < ActiveRecord::Migration
1
+ class AddNotesToSpudPages < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_pages, :notes, :text
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddMenuIdToSpudMenuItems < ActiveRecord::Migration
1
+ class AddMenuIdToSpudMenuItems < ActiveRecord::Migration[4.2]
2
2
 
3
3
  def change
4
4
  add_column :spud_menu_items, :spud_menu_id, :integer
@@ -1,4 +1,4 @@
1
- class AddClassesToSpudMenuItems < ActiveRecord::Migration
1
+ class AddClassesToSpudMenuItems < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_menu_items, :classes, :string
4
4
 
@@ -1,4 +1,4 @@
1
- class AddSiteIdToSpudPages < ActiveRecord::Migration
1
+ class AddSiteIdToSpudPages < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_pages, :site_id, :integer
4
4
  add_index :spud_pages,:site_id
@@ -1,4 +1,4 @@
1
- class AddSiteIdToSpudTemplates < ActiveRecord::Migration
1
+ class AddSiteIdToSpudTemplates < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_templates, :site_id, :integer
4
4
  add_index :spud_templates,:site_id
@@ -1,4 +1,4 @@
1
- class AddSiteIdToSpudMenus < ActiveRecord::Migration
1
+ class AddSiteIdToSpudMenus < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_menus, :site_id, :integer
4
4
  add_index :spud_menus,:site_id
@@ -1,4 +1,4 @@
1
- class CreateSpudPagePartialRevisions < ActiveRecord::Migration
1
+ class CreateSpudPagePartialRevisions < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_page_partial_revisions do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class AddSymbolNameToSpudPagePartials < ActiveRecord::Migration
1
+ class AddSymbolNameToSpudPagePartials < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_page_partials, :symbol_name, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class ModifySiteIdForSpudPages < ActiveRecord::Migration
1
+ class ModifySiteIdForSpudPages < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  change_column :spud_pages,:site_id,:integer,:default => 0,:null => false
4
4
  change_column :spud_templates,:site_id,:integer,:default => 0,:null => false
@@ -1,4 +1,4 @@
1
- class AddContentProcessedToSpudPagePartials < ActiveRecord::Migration
1
+ class AddContentProcessedToSpudPagePartials < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_page_partials, :content_processed, :text
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddLayoutToSpudPages < ActiveRecord::Migration
1
+ class AddLayoutToSpudPages < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_pages, :layout, :string
4
4
 
@@ -1,4 +1,4 @@
1
- class CreateSpudSnippets < ActiveRecord::Migration
1
+ class CreateSpudSnippets < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_snippets do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class RemoveSiteIdFromCmsTables < ActiveRecord::Migration
1
+ class RemoveSiteIdFromCmsTables < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  remove_column :spud_menus, :site_id
4
4
  remove_column :spud_pages, :site_id
@@ -1,4 +1,4 @@
1
- class AddTitleTagToSpudPage < ActiveRecord::Migration
1
+ class AddTitleTagToSpudPage < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_pages, :page_title, :string
4
4
  end
@@ -1,6 +1,5 @@
1
1
  require 'tb_core'
2
2
  require 'tb_redirects'
3
- require 'tb_liquid'
4
3
 
5
4
  module Spud
6
5
  module Cms
@@ -12,7 +11,7 @@ module Spud
12
11
  end
13
12
 
14
13
  initializer :admin do
15
- Spud::Core.configure do |config|
14
+ TbCore.configure do |config|
16
15
  config.admin_applications += [{ name: 'Pages', thumbnail: 'admin/pages_thumb.png', url: '/admin/pages', order: 0 }]
17
16
  if Spud::Cms.menus_enabled
18
17
  config.admin_applications += [{ name: 'Menus', thumbnail: 'admin/menus_thumb.png', url: '/admin/menus', order: 2 }]
@@ -24,28 +23,18 @@ module Spud
24
23
  end
25
24
  end
26
25
 
27
- initializer :model_overrides_cms do |_config|
28
- ActiveRecord::Base.class_eval do
29
- include Spud::Searchable
30
- end
31
- end
32
-
33
26
  initializer :spud_cms_routes do |config|
34
27
  config.routes_reloader.paths << File.expand_path('../page_route.rb', __FILE__)
35
28
  end
36
29
 
37
30
  initializer 'tb_cms.assets' do |_config|
38
- Spud::Core.append_admin_javascripts('admin/cms/application')
39
- Spud::Core.append_admin_stylesheets('admin/cms/application')
31
+ TbCore.append_admin_javascripts('admin/cms/application')
32
+ TbCore.append_admin_stylesheets('admin/cms/application')
40
33
  Rails.application.config.assets.precompile += ['admin/pages_thumb.png', 'admin/snippets_thumb.png', 'admin/menus_thumb.png']
41
34
  end
42
35
 
43
- initializer :liquid do |_config|
44
- Liquid::Template.register_tag('snippet', Spud::Cms::LiquidSnippet)
45
- end
46
-
47
36
  initializer :template_parser do |_config|
48
- @template_parser = Spud::Cms::TemplateParser.new()
37
+ @template_parser = Spud::Cms::TemplateParser.new
49
38
  end
50
39
 
51
40
  def template_parser
@@ -44,7 +44,7 @@ module Spud
44
44
  process_directive(header_line, layout)
45
45
  end
46
46
  layout[:partials] = ['Body'] if layout[:partials].blank?
47
- layout[:sites] = [Spud::Core.config.short_name.downcase] if layout[:sites].blank?
47
+ layout[:sites] = [TbCore.config.short_name.downcase] if layout[:sites].blank?
48
48
  if layout[:template_name].blank? == false
49
49
  return layout
50
50
  else
@@ -58,7 +58,7 @@ module Spud
58
58
  default_layout_path = layout_path(Rails.application.root.join('app', 'views', 'layouts', Spud::Cms.default_page_layout))
59
59
  # puts(layouts)
60
60
  if layouts[default_layout_path].blank?
61
- layouts[default_layout_path] = { template_name: 'Default', partials: ['Body'], sites: [Spud::Core.short_name.downcase], default: true }
61
+ layouts[default_layout_path] = { template_name: 'Default', partials: ['Body'], sites: [TbCore.short_name.downcase], default: true }
62
62
  else
63
63
  layouts[default_layout_path][:default] = true
64
64
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Cms
3
- VERSION = '1.3.0'.freeze
3
+ VERSION = '1.3.6'.freeze
4
4
  end
5
5
  end
@@ -2,7 +2,6 @@ module Spud
2
2
  module Cms
3
3
  require 'spud_cms/configuration'
4
4
  require 'spud_cms/template_parser'
5
- require 'spud_cms/liquid_snippet'
6
5
  require 'spud_cms/engine' if defined?(Rails)
7
6
  end
8
7
  end
@@ -6,12 +6,12 @@ describe Admin::MenuItemsController, type: :controller do
6
6
  end
7
7
 
8
8
  let (:menu) do
9
- FactoryGirl.create(:spud_menu)
9
+ FactoryBot.create(:spud_menu)
10
10
  end
11
11
 
12
12
  describe 'index' do
13
13
  it 'should return an array of menus' do
14
- 2.times { |_x| s = FactoryGirl.create(:spud_menu_item, spud_menu_id: menu.id, parent_id: menu.id) }
14
+ 2.times { |_x| s = FactoryBot.create(:spud_menu_item, spud_menu_id: menu.id, parent_id: menu.id) }
15
15
  get :index, params: { menu_id: menu.id }
16
16
 
17
17
  expect(assigns(:menu_items).count).to be > 1
@@ -33,43 +33,43 @@ describe Admin::MenuItemsController, type: :controller do
33
33
  describe 'create' do
34
34
  it 'should create a new menu item with a valid form submission' do
35
35
  expect do
36
- post :create, params: { menu_id: menu.id, spud_menu_item: FactoryGirl.attributes_for(:spud_menu_item, parent_id: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
36
+ post :create, params: { menu_id: menu.id, spud_menu_item: FactoryBot.attributes_for(:spud_menu_item, parent_id: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
37
37
  end.to change(SpudMenuItem, :count).by(1)
38
38
  expect(response).to be_redirect
39
39
  end
40
40
 
41
41
  it 'should not create a menu item with an invalid form entry' do
42
- yamldata = FactoryGirl.attributes_for(:spud_menu_item, name: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id }
42
+ yamldata = FactoryBot.attributes_for(:spud_menu_item, name: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id }
43
43
 
44
44
  expect do
45
- post :create, params: { menu_id: menu.id, spud_menu_item: FactoryGirl.attributes_for(:spud_menu_item, name: nil, parent_id: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
45
+ post :create, params: { menu_id: menu.id, spud_menu_item: FactoryBot.attributes_for(:spud_menu_item, name: nil, parent_id: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
46
46
  end.to_not change(SpudMenuItem, :count)
47
47
  end
48
48
 
49
49
  it 'should autoset order if not specified' do
50
- menuitem = FactoryGirl.create(:spud_menu_item, parent_id: menu.id)
50
+ menuitem = FactoryBot.create(:spud_menu_item, parent_id: menu.id)
51
51
 
52
- post :create, params: { menu_id: menu.id, spud_menu_item: FactoryGirl.attributes_for(:spud_menu_item, menu_order: nil, parent_id: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
52
+ post :create, params: { menu_id: menu.id, spud_menu_item: FactoryBot.attributes_for(:spud_menu_item, menu_order: nil, parent_id: nil).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
53
53
  expect(assigns(:menu_item).menu_order).to eq(1)
54
54
  end
55
55
 
56
56
  it 'should assign the menu name based on page name if left blank' do
57
- page = FactoryGirl.create(:spud_page)
58
- post :create, params: { menu_id: menu.id, spud_menu_item: FactoryGirl.attributes_for(:spud_menu_item, name: nil, spud_page_id: page.id).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
57
+ page = FactoryBot.create(:spud_page)
58
+ post :create, params: { menu_id: menu.id, spud_menu_item: FactoryBot.attributes_for(:spud_menu_item, name: nil, spud_page_id: page.id).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
59
59
  expect(assigns(:menu_item).name).to eq(page.name)
60
60
  end
61
61
 
62
62
  it 'should set the parent to a submenu if specified' do
63
- menuitem = FactoryGirl.create(:spud_menu_item, parent_id: menu.id)
64
- post :create, params: { menu_id: menu.id, spud_menu_item: FactoryGirl.attributes_for(:spud_menu_item, parent_id: menuitem.id).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
63
+ menuitem = FactoryBot.create(:spud_menu_item, parent_id: menu.id)
64
+ post :create, params: { menu_id: menu.id, spud_menu_item: FactoryBot.attributes_for(:spud_menu_item, parent_id: menuitem.id).reject { |k, _v| k == 'id' || k == :spud_menu_id } }
65
65
  expect(assigns(:menu_item).parent).to eq(menuitem)
66
66
  end
67
67
  end
68
68
 
69
69
  describe 'edit' do
70
70
  it 'should respond with menu item by id' do
71
- menu1 = FactoryGirl.create(:spud_menu_item)
72
- menu2 = FactoryGirl.create(:spud_menu_item)
71
+ menu1 = FactoryBot.create(:spud_menu_item)
72
+ menu2 = FactoryBot.create(:spud_menu_item)
73
73
  get :edit, params: { menu_id: menu.id, id: menu2.id }
74
74
  expect(assigns(:menu_item)).to eq(menu2)
75
75
  end
@@ -82,7 +82,7 @@ describe Admin::MenuItemsController, type: :controller do
82
82
 
83
83
  describe 'update' do
84
84
  it 'should update the name when the name attribute is changed' do
85
- menu_item = FactoryGirl.create(:spud_menu_item)
85
+ menu_item = FactoryBot.create(:spud_menu_item)
86
86
  new_name = 'MyMenu'
87
87
  expect do
88
88
  put :update, params: { menu_id: menu.id, id: menu_item.id, spud_menu_item: menu_item.attributes.merge!(name: new_name, parent_id: nil).reject { |k, _v| k.to_sym == :spud_menu_id || k == 'id' || k.to_sym == :updated_at || k.to_sym == :created_at } }
@@ -90,8 +90,8 @@ describe Admin::MenuItemsController, type: :controller do
90
90
  end.to change(menu_item, :name).to(new_name)
91
91
  end
92
92
  it 'should assign a menu to a submenu if parentid is defined' do
93
- menu_item1 = FactoryGirl.create(:spud_menu_item)
94
- menu_item = FactoryGirl.create(:spud_menu_item)
93
+ menu_item1 = FactoryBot.create(:spud_menu_item)
94
+ menu_item = FactoryBot.create(:spud_menu_item)
95
95
 
96
96
  expect do
97
97
  put :update, params: { menu_id: menu.id, id: menu_item.id, spud_menu_item: menu_item.attributes.merge!(parent_id: menu_item1.id).reject { |k, _v| k.to_sym == :spud_menu_id || k == 'id' || k.to_sym == :updated_at || k.to_sym == :created_at } }
@@ -102,7 +102,7 @@ describe Admin::MenuItemsController, type: :controller do
102
102
 
103
103
  describe 'destroy' do
104
104
  it 'should destroy the menu item' do
105
- menu_item = FactoryGirl.create(:spud_menu_item, parent_id: menu.id)
105
+ menu_item = FactoryBot.create(:spud_menu_item, parent_id: menu.id)
106
106
  expect do
107
107
  delete :destroy, params: { menu_id: menu.id, id: menu_item.id }
108
108
  end.to change(SpudMenuItem, :count).by(-1)
@@ -113,7 +113,7 @@ describe Admin::MenuItemsController, type: :controller do
113
113
  it 'should update all menu items menu_order fields' do
114
114
  ordered_arr = Array.new(5)
115
115
  ordered_arr.each_with_index do |item, index|
116
- item = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, menu_order: index)
116
+ item = FactoryBot.create(:spud_menu_item, parent_id: menu.id, menu_order: index)
117
117
  ordered_arr[index] = item.id.to_s
118
118
  end
119
119
  new_order_arr = ordered_arr.shuffle
@@ -7,7 +7,7 @@ describe Admin::MenusController, type: :controller do
7
7
 
8
8
  describe 'index' do
9
9
  it 'should return an array of menus' do
10
- 2.times { FactoryGirl.create(:spud_menu) }
10
+ 2.times { FactoryBot.create(:spud_menu) }
11
11
  get :index
12
12
 
13
13
  expect(assigns(:menus).count).to be > 1
@@ -26,14 +26,14 @@ describe Admin::MenusController, type: :controller do
26
26
  describe 'create' do
27
27
  it 'should create a new menu with a valid form submission' do
28
28
  expect do
29
- post :create, params: { spud_menu: FactoryGirl.attributes_for(:spud_menu).reject { |k, _v| k == 'id' } }
29
+ post :create, params: { spud_menu: FactoryBot.attributes_for(:spud_menu).reject { |k, _v| k == 'id' } }
30
30
  end.to change(SpudMenu, :count).by(1)
31
31
  expect(response).to be_redirect
32
32
  end
33
33
 
34
34
  it 'should not create a menu with an invalid form entry' do
35
35
  expect do
36
- post :create, params: { spud_menu: FactoryGirl.attributes_for(:spud_menu, name: nil).reject { |k, _v| k == 'id' } }
36
+ post :create, params: { spud_menu: FactoryBot.attributes_for(:spud_menu, name: nil).reject { |k, _v| k == 'id' } }
37
37
  end.to_not change(SpudMenu, :count)
38
38
 
39
39
  end
@@ -41,8 +41,8 @@ describe Admin::MenusController, type: :controller do
41
41
 
42
42
  describe 'edit' do
43
43
  it 'should response with menu by id' do
44
- menu1 = FactoryGirl.create(:spud_menu)
45
- menu2 = FactoryGirl.create(:spud_menu)
44
+ menu1 = FactoryBot.create(:spud_menu)
45
+ menu2 = FactoryBot.create(:spud_menu)
46
46
  get :edit, params: { id: menu2.id }
47
47
  expect(assigns(:menu)).to eq(menu2)
48
48
  end
@@ -55,7 +55,7 @@ describe Admin::MenusController, type: :controller do
55
55
 
56
56
  describe 'update' do
57
57
  it 'should update the name when the name attribute is changed' do
58
- menu = FactoryGirl.create(:spud_menu)
58
+ menu = FactoryBot.create(:spud_menu)
59
59
  new_name = 'MyMenu'
60
60
  expect do
61
61
  put :update, params: { id: menu.id, spud_menu: menu.attributes.merge!(name: new_name).reject { |k, _v| k == 'id' } }
@@ -65,7 +65,7 @@ describe Admin::MenusController, type: :controller do
65
65
  end
66
66
 
67
67
  it 'should redirect to the admin menus after a successful update' do
68
- menu = FactoryGirl.create(:spud_menu)
68
+ menu = FactoryBot.create(:spud_menu)
69
69
  put :update, params: { id: menu.id, spud_menu: menu.attributes.merge!(name: 'MyMenu').reject { |k, _v| k == 'id' } }
70
70
 
71
71
  expect(response).to redirect_to(admin_menu_menu_items_url(menu_id: menu.id))
@@ -74,7 +74,7 @@ describe Admin::MenusController, type: :controller do
74
74
 
75
75
  describe 'destroy' do
76
76
  it 'should destroy the menu' do
77
- menu = FactoryGirl.create(:spud_menu)
77
+ menu = FactoryBot.create(:spud_menu)
78
78
  expect do
79
79
  delete :destroy, params: { id: menu.id }
80
80
  end.to change(SpudMenu, :count).by(-1)
@@ -82,7 +82,7 @@ describe Admin::MenusController, type: :controller do
82
82
  end
83
83
 
84
84
  it 'should not destroy the menu with a wrong id' do
85
- menu = FactoryGirl.create(:spud_menu)
85
+ menu = FactoryBot.create(:spud_menu)
86
86
  expect do
87
87
  delete :destroy, params: { id: '23532' }
88
88
  end.to_not change(SpudMenu, :count)
@@ -7,15 +7,15 @@ describe Admin::PagesController, type: :controller do
7
7
 
8
8
  describe 'index' do
9
9
  it 'should return an array of parent pages' do
10
- 2.times { |_x| s = FactoryGirl.create(:spud_page) }
10
+ 2.times { |_x| s = FactoryBot.create(:spud_page) }
11
11
  get :index
12
12
 
13
13
  expect(assigns(:pages).count).to be > 1
14
14
  end
15
15
 
16
16
  it 'should only return parent pages' do
17
- 2.times { |_x| FactoryGirl.create(:spud_page) }
18
- FactoryGirl.create(:spud_page, spud_page_id: 1)
17
+ 2.times { |_x| FactoryBot.create(:spud_page) }
18
+ FactoryBot.create(:spud_page, spud_page_id: 1)
19
19
 
20
20
  get :index
21
21
  expect(assigns(:pages).count).to eq(2)
@@ -24,7 +24,7 @@ describe Admin::PagesController, type: :controller do
24
24
 
25
25
  describe 'show' do
26
26
  it 'should respond successfully' do
27
- p = FactoryGirl.create(:spud_page)
27
+ p = FactoryBot.create(:spud_page)
28
28
  get :show, params: { id: p.id }
29
29
  expect(assigns(:layout)).to render_template(layout: "layouts/#{Spud::Cms.default_page_layout}")
30
30
  expect(response).to be_success
@@ -48,7 +48,7 @@ describe Admin::PagesController, type: :controller do
48
48
  describe 'edit' do
49
49
  context 'HTML format' do
50
50
  it 'should load the correct page for the edit form' do
51
- page = FactoryGirl.create(:spud_page)
51
+ page = FactoryBot.create(:spud_page)
52
52
  get :edit, params: { id: page.id }
53
53
 
54
54
  expect(assigns(:page).id).to eq(page.id)
@@ -59,7 +59,7 @@ describe Admin::PagesController, type: :controller do
59
59
 
60
60
  describe 'update' do
61
61
  it 'should update the name when the attribute is changed' do
62
- page = FactoryGirl.create(:spud_page)
62
+ page = FactoryBot.create(:spud_page)
63
63
  new_name = 'Adam'
64
64
  expect do
65
65
  put :update, params: { id: page.id, spud_page: { name: new_name } }
@@ -68,7 +68,7 @@ describe Admin::PagesController, type: :controller do
68
68
  end
69
69
 
70
70
  it 'should redirect to the page root index after a successful update' do
71
- page = FactoryGirl.create(:spud_page)
71
+ page = FactoryBot.create(:spud_page)
72
72
  new_name = 'Adam'
73
73
  put :update, params: { id: page.id, spud_page: page.attributes.merge!(name: new_name).reject { |key, _value| key == 'id' || key == 'created_at' || key == 'updated_at' } }
74
74
 
@@ -78,7 +78,7 @@ describe Admin::PagesController, type: :controller do
78
78
 
79
79
  describe 'destroy' do
80
80
  it 'should destroy the page' do
81
- page = FactoryGirl.create(:spud_page)
81
+ page = FactoryBot.create(:spud_page)
82
82
  expect do
83
83
  delete :destroy, params: { id: page.id }
84
84
  end.to change(SpudPage, :count).by(-1)
@@ -86,7 +86,7 @@ describe Admin::PagesController, type: :controller do
86
86
  end
87
87
 
88
88
  it 'should destroy the user with the wrong id' do
89
- page = FactoryGirl.create(:spud_page)
89
+ page = FactoryBot.create(:spud_page)
90
90
  expect do
91
91
  delete :destroy, params: { id: '23532' }
92
92
  end.to_not change(SpudPage, :count)