tb_cms 1.2.3 → 1.3.beta1

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/javascripts/admin/cms/menu_items.js +39 -17
  4. data/app/assets/stylesheets/admin/cms/application.css +11 -0
  5. data/app/controllers/admin/menu_items_controller.rb +103 -113
  6. data/app/controllers/admin/menus_controller.rb +52 -53
  7. data/app/controllers/admin/pages_controller.rb +107 -111
  8. data/app/controllers/admin/snippets_controller.rb +16 -16
  9. data/app/controllers/cms/sitemaps_controller.rb +5 -5
  10. data/app/controllers/pages_controller.rb +30 -34
  11. data/app/helpers/cms/application_helper.rb +184 -212
  12. data/app/models/concerns/cms_deprecated_multisite.rb +3 -3
  13. data/app/models/spud_menu.rb +4 -4
  14. data/app/models/spud_menu_item.rb +58 -61
  15. data/app/models/spud_page.rb +63 -67
  16. data/app/models/spud_page_partial.rb +42 -44
  17. data/app/models/spud_page_partial_revision.rb +3 -3
  18. data/app/models/spud_snippet.rb +7 -7
  19. data/app/views/admin/menu_items/index.html.erb +1 -1
  20. data/lib/generators/spud/cms/layout_generator.rb +8 -8
  21. data/lib/spud_cms/configuration.rb +10 -10
  22. data/lib/spud_cms/engine.rb +28 -28
  23. data/lib/spud_cms/liquid_snippet.rb +5 -7
  24. data/lib/spud_cms/page_route.rb +1 -1
  25. data/lib/spud_cms/template_parser.rb +35 -40
  26. data/lib/spud_cms/test_files.rb +6 -6
  27. data/lib/spud_cms/version.rb +3 -3
  28. data/spec/controllers/admin/menu_items_controller_spec.rb +54 -56
  29. data/spec/controllers/admin/menus_controller_spec.rb +31 -37
  30. data/spec/controllers/admin/pages_controller_spec.rb +31 -36
  31. data/spec/controllers/admin/snippets_controller_spec.rb +1 -1
  32. data/spec/controllers/pages_controller_spec.rb +21 -21
  33. data/spec/dummy/config/application.rb +3 -4
  34. data/spec/dummy/config/boot.rb +1 -1
  35. data/spec/dummy/config/environments/production.rb +1 -1
  36. data/spec/dummy/config/environments/test.rb +3 -3
  37. data/spec/dummy/config.ru +1 -1
  38. data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +12 -12
  39. data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +0 -1
  40. data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +0 -1
  41. data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +3 -3
  42. data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +2 -2
  43. data/spec/dummy/db/migrate/20141231214455_create_spud_permalinks.tb_permalinks.rb +1 -1
  44. data/spec/dummy/db/migrate/20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb +1 -1
  45. data/spec/dummy/db/migrate/20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb +4 -4
  46. data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
  47. data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +3 -3
  48. data/spec/dummy/db/migrate/20141231214463_create_spud_page_partials.tb_cms.rb +1 -1
  49. data/spec/dummy/db/migrate/20141231214464_add_visibility_to_spud_pages.tb_cms.rb +2 -2
  50. data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb +1 -1
  51. data/spec/dummy/db/migrate/20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb +1 -1
  52. data/spec/dummy/db/migrate/20141231214469_add_classes_to_spud_menu_items.tb_cms.rb +0 -1
  53. data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +2 -2
  54. data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +2 -2
  55. data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +2 -2
  56. data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
  57. data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +8 -8
  58. data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +1 -1
  59. data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -2
  60. data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +2 -2
  61. data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +6 -8
  62. data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -0
  63. data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
  64. data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +3 -3
  65. data/spec/dummy/db/schema.rb +142 -153
  66. data/spec/dummy/script/rails +2 -2
  67. data/spec/helpers/cms/application_helper_spec.rb +39 -41
  68. data/spec/models/spud_menu_item_spec.rb +13 -13
  69. data/spec/models/spud_page_partial_revision_spec.rb +1 -1
  70. data/spec/models/spud_page_partial_spec.rb +19 -20
  71. data/spec/models/spud_page_spec.rb +90 -91
  72. data/spec/models/spud_snippet_spec.rb +1 -1
  73. data/spec/rails_helper.rb +12 -6
  74. data/spec/spec_helper.rb +42 -44
  75. metadata +64 -38
  76. data/spec/authlogic_helper.rb +0 -2
@@ -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: 20160215180157) do
13
+ ActiveRecord::Schema.define(version: 20_160_215_180_157) do
15
14
 
16
- create_table "spud_liquid_tags", force: :cascade do |t|
17
- t.integer "attachment_id", limit: 4
18
- t.string "attachment_type", limit: 255
19
- t.string "tag_name", limit: 255
20
- t.string "value", limit: 255
21
- t.datetime "created_at"
22
- t.datetime "updated_at"
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
- add_index "spud_liquid_tags", ["tag_name", "value"], name: "index_spud_liquid_tags_on_tag_name_and_value", using: :btree
26
-
27
- create_table "spud_menu_items", force: :cascade do |t|
28
- t.string "parent_type", limit: 255
29
- t.integer "parent_id", limit: 4
30
- t.integer "item_type", limit: 4
31
- t.integer "spud_page_id", limit: 4
32
- t.integer "menu_order", limit: 4, default: 0
33
- t.string "url", limit: 255
34
- t.datetime "created_at"
35
- t.datetime "updated_at"
36
- t.string "name", limit: 255
37
- t.integer "spud_menu_id", limit: 4
38
- t.string "classes", limit: 255
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
- add_index "spud_menu_items", ["menu_order"], name: "index_spud_menu_items_on_menu_order", using: :btree
42
- add_index "spud_menu_items", ["parent_type", "parent_id"], name: "index_spud_menu_items_on_parent_type_and_parent_id", using: :btree
43
- add_index "spud_menu_items", ["spud_menu_id"], name: "index_spud_menu_items_on_spud_menu_id", using: :btree
44
-
45
- create_table "spud_menus", force: :cascade do |t|
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 "spud_page_partial_revisions", force: :cascade do |t|
53
- t.string "name", limit: 255
54
- t.text "content", limit: 65535
55
- t.string "format", limit: 255
56
- t.integer "spud_page_id", limit: 4
57
- t.datetime "created_at"
58
- t.datetime "updated_at"
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
- add_index "spud_page_partial_revisions", ["spud_page_id", "name"], name: "revision_idx", using: :btree
62
-
63
- create_table "spud_page_partials", force: :cascade do |t|
64
- t.integer "spud_page_id", limit: 4
65
- t.string "name", limit: 255
66
- t.text "content", limit: 65535
67
- t.string "format", limit: 255
68
- t.datetime "created_at"
69
- t.datetime "updated_at"
70
- t.string "symbol_name", limit: 255
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
- add_index "spud_page_partials", ["spud_page_id"], name: "index_spud_page_partials_on_spud_page_id", using: :btree
75
-
76
- create_table "spud_pages", force: :cascade do |t|
77
- t.string "name", limit: 255
78
- t.string "url_name", limit: 255
79
- t.datetime "publish_at"
80
- t.integer "created_by", limit: 4
81
- t.integer "updated_by", limit: 4
82
- t.string "format", limit: 255, default: "html"
83
- t.integer "spud_page_id", limit: 4
84
- t.text "meta_description", limit: 65535
85
- t.string "meta_keywords", limit: 255
86
- t.integer "page_order", limit: 4
87
- t.datetime "created_at"
88
- t.datetime "updated_at"
89
- t.integer "visibility", limit: 4, default: 0
90
- t.boolean "published", default: true
91
- t.boolean "use_custom_url_name", default: false
92
- t.text "notes", limit: 65535
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 "spud_permalinks", force: :cascade do |t|
98
- t.string "url_name", limit: 255
99
- t.string "attachment_type", limit: 255
100
- t.integer "attachment_id", limit: 4
101
- t.datetime "created_at"
102
- t.datetime "updated_at"
103
- t.integer "site_id", limit: 4, default: 0, null: false
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
- add_index "spud_permalinks", ["attachment_type", "attachment_id"], name: "idx_permalink_attachment", using: :btree
107
- add_index "spud_permalinks", ["site_id"], name: "idx_permalinks_site_id", using: :btree
108
-
109
- create_table "spud_permissions", force: :cascade do |t|
110
- t.string "name", limit: 255, null: false
111
- t.string "tag", limit: 255, null: false
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
- add_index "spud_permissions", ["tag"], name: "index_spud_permissions_on_tag", unique: true, using: :btree
117
-
118
- create_table "spud_role_permissions", force: :cascade do |t|
119
- t.integer "spud_role_id", limit: 4, null: false
120
- t.string "spud_permission_tag", limit: 255, null: false
121
- t.datetime "created_at"
122
- t.datetime "updated_at"
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
- add_index "spud_role_permissions", ["spud_permission_tag"], name: "index_spud_role_permissions_on_spud_permission_tag", using: :btree
126
- add_index "spud_role_permissions", ["spud_role_id"], name: "index_spud_role_permissions_on_spud_role_id", using: :btree
127
-
128
- create_table "spud_roles", force: :cascade do |t|
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 "spud_snippets", force: :cascade do |t|
135
- t.string "name", limit: 255
136
- t.text "content", limit: 65535
137
- t.string "format", limit: 255
138
- t.text "content_processed", limit: 65535
139
- t.datetime "created_at"
140
- t.datetime "updated_at"
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
- add_index "spud_snippets", ["name"], name: "index_spud_snippets_on_name", using: :btree
144
-
145
- create_table "spud_user_settings", force: :cascade do |t|
146
- t.integer "spud_user_id", limit: 4
147
- t.string "key", limit: 255
148
- t.string "value", limit: 255
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 "spud_users", force: :cascade do |t|
154
- t.string "first_name", limit: 255
155
- t.string "last_name", limit: 255
156
- t.boolean "super_admin"
157
- t.string "login", limit: 255, null: false
158
- t.string "email", limit: 255, null: false
159
- t.string "crypted_password", limit: 255, null: false
160
- t.string "password_salt", limit: 255, null: false
161
- t.string "persistence_token", limit: 255, null: false
162
- t.string "single_access_token", limit: 255, null: false
163
- t.string "perishable_token", limit: 255, null: false
164
- t.integer "login_count", limit: 4, default: 0, null: false
165
- t.integer "failed_login_count", limit: 4, default: 0, null: false
166
- t.datetime "last_request_at"
167
- t.datetime "current_login_at"
168
- t.datetime "last_login_at"
169
- t.string "current_login_ip", limit: 255
170
- t.string "last_login_ip", limit: 255
171
- t.datetime "created_at"
172
- t.datetime "updated_at"
173
- t.string "time_zone", limit: 255
174
- t.integer "spud_role_id", limit: 4
175
- t.boolean "requires_password_change", default: false
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
- add_index "spud_users", ["email"], name: "index_spud_users_on_email", using: :btree
179
- add_index "spud_users", ["login"], name: "index_spud_users_on_login", using: :btree
180
- add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
181
-
182
- create_table "tb_redirects", force: :cascade do |t|
183
- t.string "owner_type", limit: 255
184
- t.integer "owner_id", limit: 4
185
- t.string "source", limit: 255, null: false
186
- t.string "destination", limit: 255, null: false
187
- t.string "created_by", limit: 255
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
@@ -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', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
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, :type => :helper do
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 "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 => "/") }
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(:name => "Main", :active_class => "active")
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 "should assign id to ul block" do
17
+ it 'should assign id to ul block' do
18
18
  menu = FactoryGirl.create(:spud_menu)
19
- 2.times {|x| s = FactoryGirl.create(:spud_menu_item,:parent_id => menu.id,:spud_menu_id => menu.id,:url => "/")}
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(:name => menu.name,:id => "nav")
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 "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")
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(:name => "Main2")
31
+ helper.sp_list_menu(name: 'Main2')
32
32
  expect(helper.output_buffer).to match /SubItem/
33
33
  end
34
34
 
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")
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(:name => "Main4",:max_depth => 1)
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 "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")
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(:name => "Main3")
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 "should be able to list created pages" do
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,:spud_page_id => page.id)
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 "should assign id" do
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(:id => "page_nav")
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 "should be able to exclude certain pages" do
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(:exclude => [page2.name])
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 "should respect max depth" do
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,:spud_page_id => page.id)
93
-
91
+ page3 = FactoryGirl.create(:spud_page, spud_page_id: page.id)
94
92
 
95
- content = helper.sp_list_pages(:max_depth => 1)
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 "should be able to list sub pages of a particular page" do
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,:spud_page_id => page.id)
105
- content = helper.sp_list_pages(:start_page_id => page.id)
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, :type => :model do
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 "should require a name" do
12
- p = FactoryGirl.build(:spud_menu_item,:name => nil)
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 "should require a menu_id" do
17
- p = FactoryGirl.build(:spud_menu_item,:spud_menu_id => nil)
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 "should require a parent_type" do
22
- p = FactoryGirl.build(:spud_menu_item,:parent_type => nil)
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 "should require a parent_id" do
27
- p = FactoryGirl.build(:spud_menu_item,:parent_id => nil)
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,5 +1,5 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe SpudPagePartialRevision, :type => :model do
3
+ describe SpudPagePartialRevision, type: :model do
4
4
  pending "add some examples to (or delete) #{__FILE__}"
5
5
  end
@@ -1,44 +1,43 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe SpudPagePartial, :type => :model do
4
- describe "validations" do
3
+ describe SpudPagePartial, type: :model do
4
+ describe 'validations' do
5
5
 
6
- it "should require a name" do
7
- p = FactoryGirl.build(:spud_page_partial,:name => nil)
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 "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")
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 "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")
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 "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)
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 "should delete old revisions beyond max_revision count" do
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,:name => "Test Page",:content =>"Home Sweet Home",:spud_page_id => 1)
33
- p.content = "Nah"
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 = "Another change"
36
+ p.content = 'Another change'
37
37
  p.save
38
- expect(SpudPagePartialRevision.where(:spud_page_id => 1,:name => "Test Page").count).to eq(2)
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