tb_cms 1.2.3 → 1.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/javascripts/admin/cms/menu_items.js +39 -17
- data/app/assets/stylesheets/admin/cms/application.css +11 -0
- data/app/controllers/admin/menu_items_controller.rb +103 -113
- data/app/controllers/admin/menus_controller.rb +52 -53
- data/app/controllers/admin/pages_controller.rb +107 -111
- data/app/controllers/admin/snippets_controller.rb +16 -16
- data/app/controllers/cms/sitemaps_controller.rb +5 -5
- data/app/controllers/pages_controller.rb +30 -34
- data/app/helpers/cms/application_helper.rb +184 -212
- data/app/models/concerns/cms_deprecated_multisite.rb +3 -3
- data/app/models/spud_menu.rb +4 -4
- data/app/models/spud_menu_item.rb +58 -61
- data/app/models/spud_page.rb +63 -67
- data/app/models/spud_page_partial.rb +42 -44
- data/app/models/spud_page_partial_revision.rb +3 -3
- data/app/models/spud_snippet.rb +7 -7
- data/app/views/admin/menu_items/index.html.erb +1 -1
- data/lib/generators/spud/cms/layout_generator.rb +8 -8
- data/lib/spud_cms/configuration.rb +10 -10
- data/lib/spud_cms/engine.rb +28 -28
- data/lib/spud_cms/liquid_snippet.rb +5 -7
- data/lib/spud_cms/page_route.rb +1 -1
- data/lib/spud_cms/template_parser.rb +35 -40
- data/lib/spud_cms/test_files.rb +6 -6
- data/lib/spud_cms/version.rb +3 -3
- data/spec/controllers/admin/menu_items_controller_spec.rb +54 -56
- data/spec/controllers/admin/menus_controller_spec.rb +31 -37
- data/spec/controllers/admin/pages_controller_spec.rb +31 -36
- data/spec/controllers/admin/snippets_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +21 -21
- data/spec/dummy/config/application.rb +3 -4
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +12 -12
- data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +0 -1
- data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +0 -1
- data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +3 -3
- data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +2 -2
- 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 +4 -4
- data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +3 -3
- 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 +2 -2
- data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_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 +0 -1
- data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +8 -8
- data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -2
- data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +2 -2
- data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +6 -8
- data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -0
- data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +3 -3
- data/spec/dummy/db/schema.rb +142 -153
- data/spec/dummy/script/rails +2 -2
- data/spec/helpers/cms/application_helper_spec.rb +39 -41
- data/spec/models/spud_menu_item_spec.rb +13 -13
- data/spec/models/spud_page_partial_revision_spec.rb +1 -1
- data/spec/models/spud_page_partial_spec.rb +19 -20
- data/spec/models/spud_page_spec.rb +90 -91
- data/spec/models/spud_snippet_spec.rb +1 -1
- data/spec/rails_helper.rb +12 -6
- data/spec/spec_helper.rb +42 -44
- metadata +64 -38
- data/spec/authlogic_helper.rb +0 -2
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -11,185 +10,175 @@
|
|
11
10
|
#
|
12
11
|
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20_160_215_180_157) do
|
15
14
|
|
16
|
-
create_table
|
17
|
-
t.integer
|
18
|
-
t.string
|
19
|
-
t.string
|
20
|
-
t.string
|
21
|
-
t.datetime
|
22
|
-
t.datetime
|
15
|
+
create_table 'spud_liquid_tags', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
16
|
+
t.integer 'attachment_id'
|
17
|
+
t.string 'attachment_type'
|
18
|
+
t.string 'tag_name'
|
19
|
+
t.string 'value'
|
20
|
+
t.datetime 'created_at'
|
21
|
+
t.datetime 'updated_at'
|
22
|
+
t.index ['tag_name', 'value'], name: 'index_spud_liquid_tags_on_tag_name_and_value', using: :btree
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
t.
|
29
|
-
t.integer
|
30
|
-
t.integer
|
31
|
-
t.
|
32
|
-
t.
|
33
|
-
t.
|
34
|
-
t.
|
35
|
-
t.
|
36
|
-
t.string
|
37
|
-
t.
|
38
|
-
t.
|
25
|
+
create_table 'spud_menu_items', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
26
|
+
t.string 'parent_type'
|
27
|
+
t.integer 'parent_id'
|
28
|
+
t.integer 'item_type'
|
29
|
+
t.integer 'spud_page_id'
|
30
|
+
t.integer 'menu_order', default: 0
|
31
|
+
t.string 'url'
|
32
|
+
t.datetime 'created_at'
|
33
|
+
t.datetime 'updated_at'
|
34
|
+
t.string 'name'
|
35
|
+
t.integer 'spud_menu_id'
|
36
|
+
t.string 'classes'
|
37
|
+
t.index ['menu_order'], name: 'index_spud_menu_items_on_menu_order', using: :btree
|
38
|
+
t.index ['parent_type', 'parent_id'], name: 'index_spud_menu_items_on_parent_type_and_parent_id', using: :btree
|
39
|
+
t.index ['spud_menu_id'], name: 'index_spud_menu_items_on_spud_menu_id', using: :btree
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
t.string "name", limit: 255
|
47
|
-
t.text "description", limit: 65535
|
48
|
-
t.datetime "created_at"
|
49
|
-
t.datetime "updated_at"
|
42
|
+
create_table 'spud_menus', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
43
|
+
t.string 'name'
|
44
|
+
t.text 'description', limit: 65_535
|
45
|
+
t.datetime 'created_at'
|
46
|
+
t.datetime 'updated_at'
|
50
47
|
end
|
51
48
|
|
52
|
-
create_table
|
53
|
-
t.string
|
54
|
-
t.text
|
55
|
-
t.string
|
56
|
-
t.integer
|
57
|
-
t.datetime
|
58
|
-
t.datetime
|
49
|
+
create_table 'spud_page_partial_revisions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
50
|
+
t.string 'name'
|
51
|
+
t.text 'content', limit: 65_535
|
52
|
+
t.string 'format'
|
53
|
+
t.integer 'spud_page_id'
|
54
|
+
t.datetime 'created_at'
|
55
|
+
t.datetime 'updated_at'
|
56
|
+
t.index ['spud_page_id', 'name'], name: 'revision_idx', using: :btree
|
59
57
|
end
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
t.
|
65
|
-
t.string
|
66
|
-
t.
|
67
|
-
t.
|
68
|
-
t.
|
69
|
-
t.
|
70
|
-
t.
|
71
|
-
t.text "content_processed", limit: 65535
|
59
|
+
create_table 'spud_page_partials', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
60
|
+
t.integer 'spud_page_id'
|
61
|
+
t.string 'name'
|
62
|
+
t.text 'content', limit: 65_535
|
63
|
+
t.string 'format'
|
64
|
+
t.datetime 'created_at'
|
65
|
+
t.datetime 'updated_at'
|
66
|
+
t.string 'symbol_name'
|
67
|
+
t.text 'content_processed', limit: 65_535
|
68
|
+
t.index ['spud_page_id'], name: 'index_spud_page_partials_on_spud_page_id', using: :btree
|
72
69
|
end
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
t.
|
78
|
-
t.
|
79
|
-
t.
|
80
|
-
t.
|
81
|
-
t.integer
|
82
|
-
t.
|
83
|
-
t.
|
84
|
-
t.
|
85
|
-
t.
|
86
|
-
t.
|
87
|
-
t.
|
88
|
-
t.
|
89
|
-
t.
|
90
|
-
t.
|
91
|
-
t.
|
92
|
-
t.
|
93
|
-
t.string "layout", limit: 255
|
94
|
-
t.string "page_title", limit: 255
|
71
|
+
create_table 'spud_pages', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
72
|
+
t.string 'name'
|
73
|
+
t.string 'url_name'
|
74
|
+
t.datetime 'publish_at'
|
75
|
+
t.integer 'created_by'
|
76
|
+
t.integer 'updated_by'
|
77
|
+
t.string 'format', default: 'html'
|
78
|
+
t.integer 'spud_page_id'
|
79
|
+
t.text 'meta_description', limit: 65_535
|
80
|
+
t.string 'meta_keywords'
|
81
|
+
t.integer 'page_order'
|
82
|
+
t.datetime 'created_at'
|
83
|
+
t.datetime 'updated_at'
|
84
|
+
t.integer 'visibility', default: 0
|
85
|
+
t.boolean 'published', default: true
|
86
|
+
t.boolean 'use_custom_url_name', default: false
|
87
|
+
t.text 'notes', limit: 65_535
|
88
|
+
t.string 'layout'
|
89
|
+
t.string 'page_title'
|
95
90
|
end
|
96
91
|
|
97
|
-
create_table
|
98
|
-
t.string
|
99
|
-
t.string
|
100
|
-
t.integer
|
101
|
-
t.datetime
|
102
|
-
t.datetime
|
103
|
-
t.integer
|
92
|
+
create_table 'spud_permalinks', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
93
|
+
t.string 'url_name'
|
94
|
+
t.string 'attachment_type'
|
95
|
+
t.integer 'attachment_id'
|
96
|
+
t.datetime 'created_at'
|
97
|
+
t.datetime 'updated_at'
|
98
|
+
t.integer 'site_id', default: 0, null: false
|
99
|
+
t.index ['attachment_type', 'attachment_id'], name: 'idx_permalink_attachment', using: :btree
|
100
|
+
t.index ['site_id'], name: 'idx_permalinks_site_id', using: :btree
|
104
101
|
end
|
105
102
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
t.
|
111
|
-
t.
|
112
|
-
t.datetime "created_at"
|
113
|
-
t.datetime "updated_at"
|
103
|
+
create_table 'spud_permissions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
104
|
+
t.string 'name', null: false
|
105
|
+
t.string 'tag', null: false
|
106
|
+
t.datetime 'created_at'
|
107
|
+
t.datetime 'updated_at'
|
108
|
+
t.index ['tag'], name: 'index_spud_permissions_on_tag', unique: true, using: :btree
|
114
109
|
end
|
115
110
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
t.
|
120
|
-
t.
|
121
|
-
t.
|
122
|
-
t.
|
111
|
+
create_table 'spud_role_permissions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
112
|
+
t.integer 'spud_role_id', null: false
|
113
|
+
t.string 'spud_permission_tag', null: false
|
114
|
+
t.datetime 'created_at'
|
115
|
+
t.datetime 'updated_at'
|
116
|
+
t.index ['spud_permission_tag'], name: 'index_spud_role_permissions_on_spud_permission_tag', using: :btree
|
117
|
+
t.index ['spud_role_id'], name: 'index_spud_role_permissions_on_spud_role_id', using: :btree
|
123
118
|
end
|
124
119
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
t.string "name", limit: 255
|
130
|
-
t.datetime "created_at"
|
131
|
-
t.datetime "updated_at"
|
120
|
+
create_table 'spud_roles', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
121
|
+
t.string 'name'
|
122
|
+
t.datetime 'created_at'
|
123
|
+
t.datetime 'updated_at'
|
132
124
|
end
|
133
125
|
|
134
|
-
create_table
|
135
|
-
t.string
|
136
|
-
t.text
|
137
|
-
t.string
|
138
|
-
t.text
|
139
|
-
t.datetime
|
140
|
-
t.datetime
|
126
|
+
create_table 'spud_snippets', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
127
|
+
t.string 'name'
|
128
|
+
t.text 'content', limit: 65_535
|
129
|
+
t.string 'format'
|
130
|
+
t.text 'content_processed', limit: 65_535
|
131
|
+
t.datetime 'created_at'
|
132
|
+
t.datetime 'updated_at'
|
133
|
+
t.index ['name'], name: 'index_spud_snippets_on_name', using: :btree
|
141
134
|
end
|
142
135
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
t.
|
147
|
-
t.
|
148
|
-
t.
|
149
|
-
t.datetime "created_at"
|
150
|
-
t.datetime "updated_at"
|
136
|
+
create_table 'spud_user_settings', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
137
|
+
t.integer 'spud_user_id'
|
138
|
+
t.string 'key'
|
139
|
+
t.string 'value'
|
140
|
+
t.datetime 'created_at'
|
141
|
+
t.datetime 'updated_at'
|
151
142
|
end
|
152
143
|
|
153
|
-
create_table
|
154
|
-
t.string
|
155
|
-
t.string
|
156
|
-
t.boolean
|
157
|
-
t.string
|
158
|
-
t.string
|
159
|
-
t.string
|
160
|
-
t.string
|
161
|
-
t.string
|
162
|
-
t.string
|
163
|
-
t.string
|
164
|
-
t.integer
|
165
|
-
t.integer
|
166
|
-
t.datetime
|
167
|
-
t.datetime
|
168
|
-
t.datetime
|
169
|
-
t.string
|
170
|
-
t.string
|
171
|
-
t.datetime
|
172
|
-
t.datetime
|
173
|
-
t.string
|
174
|
-
t.integer
|
175
|
-
t.boolean
|
144
|
+
create_table 'spud_users', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
145
|
+
t.string 'first_name'
|
146
|
+
t.string 'last_name'
|
147
|
+
t.boolean 'super_admin'
|
148
|
+
t.string 'login', null: false
|
149
|
+
t.string 'email', null: false
|
150
|
+
t.string 'crypted_password', null: false
|
151
|
+
t.string 'password_salt', null: false
|
152
|
+
t.string 'persistence_token', null: false
|
153
|
+
t.string 'single_access_token', null: false
|
154
|
+
t.string 'perishable_token', null: false
|
155
|
+
t.integer 'login_count', default: 0, null: false
|
156
|
+
t.integer 'failed_login_count', default: 0, null: false
|
157
|
+
t.datetime 'last_request_at'
|
158
|
+
t.datetime 'current_login_at'
|
159
|
+
t.datetime 'last_login_at'
|
160
|
+
t.string 'current_login_ip'
|
161
|
+
t.string 'last_login_ip'
|
162
|
+
t.datetime 'created_at'
|
163
|
+
t.datetime 'updated_at'
|
164
|
+
t.string 'time_zone'
|
165
|
+
t.integer 'spud_role_id'
|
166
|
+
t.boolean 'requires_password_change', default: false
|
167
|
+
t.index ['email'], name: 'index_spud_users_on_email', using: :btree
|
168
|
+
t.index ['login'], name: 'index_spud_users_on_login', using: :btree
|
169
|
+
t.index ['spud_role_id'], name: 'index_spud_users_on_spud_role_id', using: :btree
|
176
170
|
end
|
177
171
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
t.string
|
184
|
-
t.
|
185
|
-
t.
|
186
|
-
t.
|
187
|
-
t.
|
188
|
-
t.datetime "created_at", null: false
|
189
|
-
t.datetime "updated_at", null: false
|
172
|
+
create_table 'tb_redirects', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
173
|
+
t.string 'owner_type'
|
174
|
+
t.integer 'owner_id'
|
175
|
+
t.string 'source', null: false
|
176
|
+
t.string 'destination', null: false
|
177
|
+
t.string 'created_by'
|
178
|
+
t.datetime 'created_at', null: false
|
179
|
+
t.datetime 'updated_at', null: false
|
180
|
+
t.index ['owner_type', 'owner_id'], name: 'index_tb_redirects_on_owner_type_and_owner_id', using: :btree
|
181
|
+
t.index ['source'], name: 'index_tb_redirects_on_source', unique: true, using: :btree
|
190
182
|
end
|
191
183
|
|
192
|
-
add_index "tb_redirects", ["owner_type", "owner_id"], name: "index_tb_redirects_on_owner_type_and_owner_id", using: :btree
|
193
|
-
add_index "tb_redirects", ["source"], name: "index_tb_redirects_on_source", unique: true, using: :btree
|
194
|
-
|
195
184
|
end
|
data/spec/dummy/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path('../../config/application',
|
5
|
-
require File.expand_path('../../config/boot',
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
6
|
require 'rails/commands'
|
@@ -1,108 +1,106 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Cms::ApplicationHelper, :
|
3
|
+
describe Cms::ApplicationHelper, type: :helper do
|
4
4
|
before(:each) do
|
5
5
|
helper.output_buffer = ''
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#sp_list_menu' do
|
9
|
-
it
|
10
|
-
menu = FactoryGirl.create(:spud_menu, :
|
11
|
-
2.times { |
|
9
|
+
it 'should be able to find a menu by its name' do
|
10
|
+
menu = FactoryGirl.create(:spud_menu, name: 'Main')
|
11
|
+
2.times { |_x| FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/') }
|
12
12
|
|
13
|
-
helper.sp_list_menu(:
|
13
|
+
helper.sp_list_menu(name: 'Main', active_class: 'active')
|
14
14
|
expect(helper.output_buffer).to match /\<li/
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'should assign id to ul block' do
|
18
18
|
menu = FactoryGirl.create(:spud_menu)
|
19
|
-
2.times {|
|
19
|
+
2.times { |_x| s = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/') }
|
20
20
|
|
21
|
-
helper.sp_list_menu(:
|
21
|
+
helper.sp_list_menu(name: menu.name, id: 'nav')
|
22
22
|
expect(helper.output_buffer).to match /id=\'nav\'/
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
menu = FactoryGirl.create(:spud_menu
|
27
|
-
s = FactoryGirl.create(:spud_menu_item
|
28
|
-
s2 = FactoryGirl.create(:spud_menu_item
|
29
|
-
s3 = FactoryGirl.create(:spud_menu_item
|
25
|
+
it 'should render nested menu items' do
|
26
|
+
menu = FactoryGirl.create(:spud_menu, name: 'Main2')
|
27
|
+
s = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/')
|
28
|
+
s2 = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/')
|
29
|
+
s3 = FactoryGirl.create(:spud_menu_item, parent_type: 'SpudMenuItem', parent_id: s.id, spud_menu_id: menu.id, url: '/', name: 'SubItem')
|
30
30
|
|
31
|
-
helper.sp_list_menu(:
|
31
|
+
helper.sp_list_menu(name: 'Main2')
|
32
32
|
expect(helper.output_buffer).to match /SubItem/
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
36
|
-
menu = FactoryGirl.create(:spud_menu
|
37
|
-
s = FactoryGirl.create(:spud_menu_item
|
38
|
-
s2 = FactoryGirl.create(:spud_menu_item
|
39
|
-
s3 = FactoryGirl.create(:spud_menu_item
|
35
|
+
it 'should respect max depth' do
|
36
|
+
menu = FactoryGirl.create(:spud_menu, name: 'Main4')
|
37
|
+
s = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/')
|
38
|
+
s2 = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/')
|
39
|
+
s3 = FactoryGirl.create(:spud_menu_item, parent_type: 'SpudMenuItem', parent_id: s.id, spud_menu_id: menu.id, url: '/', name: 'SubItem')
|
40
40
|
|
41
|
-
helper.sp_list_menu(:
|
41
|
+
helper.sp_list_menu(name: 'Main4', max_depth: 1)
|
42
42
|
expect(helper.output_buffer).to_not match /SubItem/
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#sp_menu_with_seperator' do
|
47
|
-
it
|
48
|
-
menu = FactoryGirl.create(:spud_menu
|
49
|
-
s = FactoryGirl.create(:spud_menu_item
|
50
|
-
s2 = FactoryGirl.create(:spud_menu_item
|
51
|
-
s3 = FactoryGirl.create(:spud_menu_item
|
47
|
+
it 'should render a flattened list of links' do
|
48
|
+
menu = FactoryGirl.create(:spud_menu, name: 'Main3')
|
49
|
+
s = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/')
|
50
|
+
s2 = FactoryGirl.create(:spud_menu_item, parent_id: menu.id, spud_menu_id: menu.id, url: '/')
|
51
|
+
s3 = FactoryGirl.create(:spud_menu_item, parent_type: 'SpudMenuItem', parent_id: s.id, spud_menu_id: menu.id, url: '/', name: 'SubItem')
|
52
52
|
|
53
|
-
content = helper.sp_menu_with_seperator(:
|
53
|
+
content = helper.sp_menu_with_seperator(name: 'Main3')
|
54
54
|
expect(content).to match /SubItem/
|
55
55
|
expect(content).to_not match /\<li/
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe '#sp_list_pages' do
|
60
|
-
it
|
60
|
+
it 'should be able to list created pages' do
|
61
61
|
page = FactoryGirl.create(:spud_page)
|
62
62
|
page2 = FactoryGirl.create(:spud_page)
|
63
|
-
page3 = FactoryGirl.create(:spud_page
|
63
|
+
page3 = FactoryGirl.create(:spud_page, spud_page_id: page.id)
|
64
64
|
|
65
|
-
|
66
|
-
content = helper.sp_list_pages(:active_class => "active")
|
65
|
+
content = helper.sp_list_pages(active_class: 'active')
|
67
66
|
expect(content).to match /#{page.name}/
|
68
67
|
expect(content).to match /#{page2.name}/
|
69
68
|
expect(content).to match /#{page3.name}/
|
70
69
|
end
|
71
70
|
|
72
|
-
it
|
71
|
+
it 'should assign id' do
|
73
72
|
page = FactoryGirl.create(:spud_page)
|
74
73
|
page2 = FactoryGirl.create(:spud_page)
|
75
74
|
|
76
|
-
content = helper.sp_list_pages(:
|
75
|
+
content = helper.sp_list_pages(id: 'page_nav')
|
77
76
|
expect(content).to match /id=\'page_nav\'/
|
78
77
|
|
79
78
|
end
|
80
79
|
|
81
|
-
it
|
80
|
+
it 'should be able to exclude certain pages' do
|
82
81
|
page = FactoryGirl.create(:spud_page)
|
83
82
|
page2 = FactoryGirl.create(:spud_page)
|
84
83
|
|
85
|
-
content = helper.sp_list_pages(:
|
84
|
+
content = helper.sp_list_pages(exclude: [page2.name])
|
86
85
|
expect(content).to match /#{page.name}/
|
87
86
|
expect(content).to_not match /#{page2.name}/
|
88
87
|
end
|
89
|
-
it
|
88
|
+
it 'should respect max depth' do
|
90
89
|
page = FactoryGirl.create(:spud_page)
|
91
90
|
page2 = FactoryGirl.create(:spud_page)
|
92
|
-
page3 = FactoryGirl.create(:spud_page
|
93
|
-
|
91
|
+
page3 = FactoryGirl.create(:spud_page, spud_page_id: page.id)
|
94
92
|
|
95
|
-
content = helper.sp_list_pages(:
|
93
|
+
content = helper.sp_list_pages(max_depth: 1)
|
96
94
|
expect(content).to match /#{page.name}/
|
97
95
|
expect(content).to match /#{page2.name}/
|
98
96
|
expect(content).to_not match /#{page3.name}/
|
99
97
|
end
|
100
98
|
|
101
|
-
it
|
99
|
+
it 'should be able to list sub pages of a particular page' do
|
102
100
|
page = FactoryGirl.create(:spud_page)
|
103
101
|
page2 = FactoryGirl.create(:spud_page)
|
104
|
-
page3 = FactoryGirl.create(:spud_page
|
105
|
-
content = helper.sp_list_pages(:
|
102
|
+
page3 = FactoryGirl.create(:spud_page, spud_page_id: page.id)
|
103
|
+
content = helper.sp_list_pages(start_page_id: page.id)
|
106
104
|
expect(content).to_not match /#{page.name}/
|
107
105
|
expect(content).to_not match /#{page2.name}/
|
108
106
|
expect(content).to match /#{page3.name}/
|
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe SpudMenuItem, :
|
3
|
+
describe SpudMenuItem, type: :model do
|
4
4
|
|
5
|
-
it {should have_many(:spud_menu_items)}
|
6
|
-
it {should belong_to(:spud_page)}
|
7
|
-
it {should belong_to(:spud_menu)}
|
8
|
-
it {should belong_to(:parent)}
|
5
|
+
it { should have_many(:spud_menu_items) }
|
6
|
+
it { should belong_to(:spud_page) }
|
7
|
+
it { should belong_to(:spud_menu) }
|
8
|
+
it { should belong_to(:parent) }
|
9
9
|
|
10
10
|
describe :validations do
|
11
|
-
it
|
12
|
-
p = FactoryGirl.build(:spud_menu_item
|
11
|
+
it 'should require a name' do
|
12
|
+
p = FactoryGirl.build(:spud_menu_item, name: nil)
|
13
13
|
expect(p).to_not be_valid
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
p = FactoryGirl.build(:spud_menu_item
|
16
|
+
it 'should require a menu_id' do
|
17
|
+
p = FactoryGirl.build(:spud_menu_item, spud_menu_id: nil)
|
18
18
|
expect(p).to_not be_valid
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
p = FactoryGirl.build(:spud_menu_item
|
21
|
+
it 'should require a parent_type' do
|
22
|
+
p = FactoryGirl.build(:spud_menu_item, parent_type: nil)
|
23
23
|
expect(p).to_not be_valid
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
p = FactoryGirl.build(:spud_menu_item
|
26
|
+
it 'should require a parent_id' do
|
27
|
+
p = FactoryGirl.build(:spud_menu_item, parent_id: nil)
|
28
28
|
expect(p).to_not be_valid
|
29
29
|
end
|
30
30
|
end
|
@@ -1,44 +1,43 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe SpudPagePartial, :
|
4
|
-
describe
|
3
|
+
describe SpudPagePartial, type: :model do
|
4
|
+
describe 'validations' do
|
5
5
|
|
6
|
-
it
|
7
|
-
p = FactoryGirl.build(:spud_page_partial
|
6
|
+
it 'should require a name' do
|
7
|
+
p = FactoryGirl.build(:spud_page_partial, name: nil)
|
8
8
|
expect(p).to_not be_valid
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
p = FactoryGirl.build(:spud_page_partial
|
13
|
-
expect(p.symbol_name).to eq(
|
11
|
+
it 'should respond with a symbol_name based on name' do
|
12
|
+
p = FactoryGirl.build(:spud_page_partial, name: 'Test Page')
|
13
|
+
expect(p.symbol_name).to eq('test_page')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
18
|
-
it
|
19
|
-
p = FactoryGirl.create(:spud_page_partial, :
|
20
|
-
expect(p.attributes[
|
17
|
+
describe 'save hooks' do
|
18
|
+
it 'should save the symbol name' do
|
19
|
+
p = FactoryGirl.create(:spud_page_partial, name: 'Test Page')
|
20
|
+
expect(p.attributes['symbol_name']).to eq('test_page')
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
p = FactoryGirl.create(:spud_page_partial, :
|
25
|
-
expect(SpudPagePartialRevision.where(:
|
23
|
+
it 'should create a new revision if content is changed' do
|
24
|
+
p = FactoryGirl.create(:spud_page_partial, name: 'Test Page', content: 'Content')
|
25
|
+
expect(SpudPagePartialRevision.where(spud_page_id: p.spud_page_id).count).to eq(1)
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'should delete old revisions beyond max_revision count' do
|
29
29
|
Spud::Cms.configure do |config|
|
30
30
|
config.max_revisions = 2
|
31
31
|
end
|
32
|
-
p = FactoryGirl.create(:spud_page_partial
|
33
|
-
p.content =
|
32
|
+
p = FactoryGirl.create(:spud_page_partial, name: 'Test Page', content: 'Home Sweet Home', spud_page_id: 1)
|
33
|
+
p.content = 'Nah'
|
34
34
|
p.save
|
35
35
|
|
36
|
-
p.content =
|
36
|
+
p.content = 'Another change'
|
37
37
|
p.save
|
38
|
-
expect(SpudPagePartialRevision.where(:
|
38
|
+
expect(SpudPagePartialRevision.where(spud_page_id: 1, name: 'Test Page').count).to eq(2)
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
43
|
end
|