tb_cms 1.3.beta1 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +0 -9
- data/app/assets/javascripts/admin/cms/menu_items.js +12 -6
- data/app/assets/javascripts/admin/cms/pages.js +3 -0
- data/app/controllers/cms/sitemaps_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +4 -4
- data/app/helpers/cms/application_helper.rb +4 -4
- data/app/models/spud_menu_item.rb +3 -3
- data/app/models/spud_page.rb +21 -10
- data/app/models/spud_page_partial.rb +3 -20
- data/app/models/spud_snippet.rb +1 -4
- data/app/views/admin/pages/show.html.erb +12 -15
- data/app/views/pages/show.html.erb +2 -2
- data/db/migrate/20120101192412_create_spud_pages.rb +1 -1
- data/db/migrate/20120101193138_create_spud_menus.rb +1 -1
- data/db/migrate/20120101193255_create_spud_menu_items.rb +1 -1
- data/db/migrate/20120101194124_create_spud_templates.rb +1 -1
- data/db/migrate/20120103034659_create_spud_page_partials.rb +1 -1
- data/db/migrate/20120104194032_add_visibility_to_spud_pages.rb +1 -1
- data/db/migrate/20120107181337_add_menu_name_to_spud_menu_items.rb +1 -1
- data/db/migrate/20120111134754_add_use_custom_url_name_to_spud_pages.rb +1 -1
- data/db/migrate/20120118141852_add_notes_to_spud_pages.rb +1 -1
- data/db/migrate/20120126232428_add_menu_id_to_spud_menu_items.rb +1 -1
- data/db/migrate/20120128163601_add_classes_to_spud_menu_items.rb +1 -1
- data/db/migrate/20120329132314_add_site_id_to_spud_pages.rb +1 -1
- data/db/migrate/20120329132322_add_site_id_to_spud_templates.rb +1 -1
- data/db/migrate/20120329132330_add_site_id_to_spud_menus.rb +1 -1
- data/db/migrate/20120510195151_create_spud_page_partial_revisions.rb +1 -1
- data/db/migrate/20120911190030_add_symbol_name_to_spud_page_partials.rb +1 -1
- data/db/migrate/20120912121313_modify_site_id_for_spud_pages.rb +1 -1
- data/db/migrate/20121016233715_add_content_processed_to_spud_page_partials.rb +1 -1
- data/db/migrate/20121112151110_add_layout_to_spud_pages.rb +1 -1
- data/db/migrate/20121119025608_create_spud_snippets.rb +1 -1
- data/db/migrate/20150108162839_remove_site_id_from_cms_tables.rb +1 -1
- data/db/migrate/20150622161403_add_title_tag_to_spud_page.rb +1 -1
- data/lib/spud_cms/engine.rb +4 -15
- data/lib/spud_cms/template_parser.rb +2 -2
- data/lib/spud_cms/version.rb +1 -1
- data/lib/tb_cms.rb +0 -1
- data/spec/controllers/admin/menu_items_controller_spec.rb +18 -18
- data/spec/controllers/admin/menus_controller_spec.rb +9 -9
- data/spec/controllers/admin/pages_controller_spec.rb +9 -9
- data/spec/controllers/pages_controller_spec.rb +5 -5
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/database.yml +3 -6
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/db/migrate/20141231214446_create_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214450_create_spud_user_settings.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214451_create_spud_roles.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214454_drop_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214455_create_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214460_create_spud_menus.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214462_create_spud_templates.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214463_create_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214464_add_visibility_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214465_add_menu_name_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214467_add_notes_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214469_add_classes_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214474_add_symbol_name_to_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214476_add_content_processed_to_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214477_add_layout_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20150911185844_add_title_tag_to_spud_page.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +1 -1
- data/spec/dummy/db/schema.rb +138 -145
- data/spec/helpers/cms/application_helper_spec.rb +37 -37
- data/spec/models/spud_menu_item_spec.rb +4 -4
- data/spec/models/spud_page_partial_spec.rb +5 -5
- data/spec/models/spud_page_spec.rb +20 -12
- data/spec/rails_helper.rb +1 -1
- metadata +68 -95
- data/db/migrate/20121112212113_create_spud_page_liquid_tags.rb +0 -11
- data/db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb +0 -17
- data/db/migrate/20140110142037_drop_spud_page_liquid_tags.rb +0 -31
- data/lib/spud_cms/liquid_snippet.rb +0 -27
- data/spec/dummy/db/migrate/20141231214458_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +0 -13
- data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +0 -12
- data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +0 -18
- data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +0 -30
@@ -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
|
data/lib/spud_cms/engine.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
39
|
-
|
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] = [
|
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: [
|
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
|
data/lib/spud_cms/version.rb
CHANGED
data/lib/tb_cms.rb
CHANGED
@@ -6,12 +6,12 @@ describe Admin::MenuItemsController, type: :controller do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
let (:menu) do
|
9
|
-
|
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 =
|
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:
|
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 =
|
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:
|
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 =
|
50
|
+
menuitem = FactoryBot.create(:spud_menu_item, parent_id: menu.id)
|
51
51
|
|
52
|
-
post :create, params: { menu_id: menu.id, spud_menu_item:
|
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 =
|
58
|
-
post :create, params: { menu_id: menu.id, spud_menu_item:
|
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 =
|
64
|
-
post :create, params: { menu_id: menu.id, spud_menu_item:
|
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 =
|
72
|
-
menu2 =
|
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 =
|
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 =
|
94
|
-
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 =
|
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 =
|
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 {
|
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:
|
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:
|
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 =
|
45
|
-
menu2 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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|
|
18
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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)
|
@@ -4,21 +4,21 @@ describe PagesController, type: :controller do
|
|
4
4
|
describe 'show' do
|
5
5
|
|
6
6
|
it 'should render a page' do
|
7
|
-
page =
|
7
|
+
page = FactoryBot.create(:spud_page)
|
8
8
|
get :show, params: { id: page.url_name }
|
9
9
|
expect(assigns(:layout)).to render_template(layout: "layouts/#{Spud::Cms.default_page_layout}")
|
10
10
|
expect(response).to be_success
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should render home page if id is blank' do
|
14
|
-
page =
|
14
|
+
page = FactoryBot.create(:spud_page, name: 'home')
|
15
15
|
get :show
|
16
16
|
expect(assigns(:page)).to eq(page)
|
17
17
|
expect(response).to be_success
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should redirect to new page url from old page url if it was changed' do
|
21
|
-
page =
|
21
|
+
page = FactoryBot.create(:spud_page, name: 'about', url_name: 'about')
|
22
22
|
page.update(url_name: 'about-us')
|
23
23
|
page.save
|
24
24
|
get :show, params: { id: 'about' }
|
@@ -27,7 +27,7 @@ describe PagesController, type: :controller do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should not allow access to private pages when logged out' do
|
30
|
-
page =
|
30
|
+
page = FactoryBot.create(:spud_page, name: 'about', visibility: 1)
|
31
31
|
|
32
32
|
get :show, params: { id: 'about' }
|
33
33
|
expect(response).to redirect_to login_path(return_to: '/about')
|
@@ -43,7 +43,7 @@ describe PagesController, type: :controller do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should allow access to private pages when logged in' do
|
46
|
-
page =
|
46
|
+
page = FactoryBot.create(:spud_page, name: 'about', visibility: 1)
|
47
47
|
|
48
48
|
get :show, params: { id: 'about' }
|
49
49
|
expect(response).to be_success
|
@@ -4,12 +4,9 @@
|
|
4
4
|
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
5
|
# gem 'sqlite3'
|
6
6
|
development:
|
7
|
-
adapter:
|
7
|
+
adapter: postgresql
|
8
8
|
database: spud_cms_development
|
9
|
-
|
10
|
-
|
9
|
+
|
11
10
|
test:
|
12
|
-
adapter:
|
11
|
+
adapter: postgresql
|
13
12
|
database: spud_cms_test
|
14
|
-
username: root
|
15
|
-
|
@@ -23,11 +23,11 @@ Dummy::Application.configure do
|
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
25
|
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
26
|
+
# config.active_record.mass_assignment_sanitizer = :strict
|
27
27
|
|
28
28
|
# Log the query plan for queries taking more than this (works
|
29
29
|
# with SQLite, MySQL, and PostgreSQL)
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
30
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
31
|
|
32
32
|
# Do not compress assets
|
33
33
|
config.assets.compress = false
|