tb_cms 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca05ee4d7457942e5e0e8888ac4cd735ed6f12a2
4
- data.tar.gz: c424ef034dde75480e71b01ba42fb29f4a58983f
3
+ metadata.gz: cf65740efa862344b081383199dda50eaa2bc61f
4
+ data.tar.gz: 71e232020d75218667de0f13b3e93b44649871f1
5
5
  SHA512:
6
- metadata.gz: f01e9b141e79e53d697d2c6f17b5738c092bf485aa994ae8a931be992da0088ec1774c671f59373aace6aba6621ef23fb0750a9d3253db40bd3dbab575e81e96
7
- data.tar.gz: c51608c5dc6b307dc9075c7ed6f8980832aecef2ee99d511a560c3f94c4d4da17399d9e352f4201e8f01f8982767b3c8edae18b49147f7547991a751606e0252
6
+ metadata.gz: b7582f9009303390f4a44f57441a2df2a68e8ecc16ce78d0752d6d4886d2c218817a587decc8b46924fc7acc2e33d9d2e46b10df8f60bfafc02af30473116c87
7
+ data.tar.gz: 4ab3e64d0df2deca7acefa2683753c6d3bd239dc97cbcb605b83c7f80c5addc3668a8549eba31d8be6e83ea6b3960171a3c3073b87d5ac9690fdeb6251d1ebfc
@@ -4,32 +4,42 @@ spud.admin.cms.menu_items = {};
4
4
  var menu_items = spud.admin.cms.menu_items;
5
5
 
6
6
  menu_items.init = function() {
7
- return;
8
- $('.sortable').sortable({
9
- connectWith:".connectedSortable",
10
- start: function(event,ui) {
11
- $('#root_menu_list').addClass('menu_edit');
12
- },
13
- axis:"y",
14
- tolerance:'pointer',
15
- cursor: "move",
16
- items:'li',
17
- stop: function(event,ui) {
18
- $('#root_menu_list').removeClass('menu_edit');
19
- },
20
- over: function(event,ui) {
21
-
22
- var source = ui.item[0];
7
+ $("#sort tbody").sortable({helper:fixHelper}).disableSelection();
8
+ sortableIcons();
9
+ };
23
10
 
24
- var destination = $(event.target);
25
- $('ul.left_guide').removeClass('left_guide');
11
+ var sortableIcons = function(){
12
+ $("#sort tbody").sortable({
13
+ update : function(e, ui) {
14
+ var sortArr = [];
15
+ $("#sort tbody > tr > input").each(function() {
16
+ sortArr.push($(this).attr('value'));
17
+ });
18
+ //update order of menuItems
19
+ $.ajax(setUrl(), {
20
+ method: 'PUT',
21
+ data: {order:sortArr},
22
+ dataType: "json",
23
+ success: function(data, status, jqXHR) {
26
24
 
27
- if(destination.hasClass('subitem'))
28
- {
29
- destination.addClass('left_guide');
30
- }
25
+ },
26
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
27
+ alert("Status: " + textStatus); alert("Error: " + errorThrown);
28
+ }
29
+ });
31
30
  }
32
- }).disableSelection();
31
+ });
32
+ };
33
+
34
+ var fixHelper = function(e, ui) {
35
+ ui.children().each(function() {
36
+ $(this).width($(this).width());
37
+ });
38
+ return ui;
39
+ };
40
+
41
+ var setUrl = function(){
42
+ return '/admin/menus/'+$("#menu-id").val()+'/menu_items/update_sort';
33
43
  };
34
44
 
35
45
  })();
@@ -1,6 +1,6 @@
1
1
  class Admin::MenuItemsController < Admin::ApplicationController
2
2
  add_breadcrumb "Menus", :admin_menus_path
3
- belongs_to_spud_app :menus, :page_title => "Menu Items"
3
+ belongs_to_app :menus, :page_title => "Menu Items"
4
4
  before_filter :load_menu
5
5
  before_filter :load_menu_item, :only => [:edit,:update,:show,:destroy,:reorder]
6
6
 
@@ -75,15 +75,20 @@ class Admin::MenuItemsController < Admin::ApplicationController
75
75
  respond_with @menu_item,:location => admin_menu_menu_items_url
76
76
  end
77
77
 
78
- def reorder
79
- #id param
80
- #source position
81
- #destination position
82
- #parent
83
- # @menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items).paginate :page => params[:page]
84
-
85
-
78
+ def update_sort
79
+ if params[:order]
80
+ params[:order].each_with_index do |item, index|
81
+ val = item.to_i
82
+ menu_item = @menu.spud_menu_items.find_by_id(val)
83
+ menu_item.menu_order = index
84
+ menu_item.save
85
+ end
86
+ end
87
+ respond_to do |format|
88
+ format.json { head :no_content }
89
+ end
86
90
  end
91
+
87
92
  private
88
93
  def load_menu
89
94
 
@@ -1,5 +1,5 @@
1
1
  class Admin::MenusController < Admin::ApplicationController
2
- belongs_to_spud_app :menus
2
+ belongs_to_app :menus
3
3
  add_breadcrumb "Menus", :admin_menus_path
4
4
  before_filter :load_menu,:only => [:edit,:update,:show,:destroy]
5
5
 
@@ -38,6 +38,7 @@ class Admin::MenusController < Admin::ApplicationController
38
38
  respond_with @menu,:location => admin_menus_url
39
39
  end
40
40
 
41
+
41
42
  private
42
43
 
43
44
  def load_menu
@@ -1,6 +1,6 @@
1
1
  class Admin::PagesController < Admin::ApplicationController
2
2
  add_breadcrumb "Pages", :admin_pages_path
3
- belongs_to_spud_app :pages
3
+ belongs_to_app :pages
4
4
  before_filter :load_page,:only => [:edit,:update,:show,:destroy]
5
5
 
6
6
  def index
@@ -1,5 +1,5 @@
1
1
  class Admin::SnippetsController < Admin::ApplicationController
2
- belongs_to_spud_app :snippets
2
+ belongs_to_app :snippets
3
3
  add_breadcrumb "Snippets", :admin_snippets_url
4
4
 
5
5
  before_filter :load_snippet, :only => [:show, :edit, :update, :destroy]
@@ -15,12 +15,6 @@ class PagesController < ApplicationController
15
15
  @page = SpudPage.published_pages.find_by(:url_name => url_name)
16
16
 
17
17
  if @page.blank?
18
- @permalink = SpudPermalink.find_by(:url_name => url_name)
19
-
20
- if !@permalink.blank? && @permalink.attachment_type == 'SpudPage'
21
- redirect_to @permalink.attachment.url_name == Spud::Cms.root_page_name ? root_url() : page_url(:id => @permalink.attachment.url_name) , :status => :moved_permanently and return
22
- end
23
-
24
18
  render_404
25
19
  return
26
20
  end
@@ -1,20 +1,19 @@
1
1
  class SpudPage < ActiveRecord::Base
2
2
  include CmsDeprecatedMultisite
3
+ include TbRedirects::HasRedirects
3
4
 
4
5
  spud_searchable
5
6
  belongs_to :spud_page
6
7
  has_many :spud_page_partial_revisions
7
8
  has_many :spud_pages, :dependent => :nullify
8
9
  has_many :spud_page_partials,:dependent => :destroy
9
- has_many :spud_permalinks,:as => :attachment, :dependent => :destroy
10
10
  belongs_to :created_by_user,:class_name => "SpudUser",:foreign_key => :created_by
11
11
  belongs_to :updated_by_user,:class_name => "SpudUser",:foreign_key => :updated_by
12
12
 
13
13
  before_validation :generate_url_name
14
- validates :name,:presence => true
15
- validates_uniqueness_of :name, :scope => [:spud_page_id]
16
- validates :url_name,:presence => true
17
- validates_uniqueness_of :url_name
14
+ validates :name, :presence => true, :uniqueness => {:scope => :spud_page_id}
15
+ validates :url_name, :presence => true, :uniqueness => true
16
+ after_update :create_redirect_if_necessary
18
17
 
19
18
  accepts_nested_attributes_for :spud_page_partials, :allow_destroy => true
20
19
 
@@ -51,71 +50,32 @@ class SpudPage < ActiveRecord::Base
51
50
  return list
52
51
  end
53
52
 
53
+ def is_private?
54
+ return self.visibility == 1
55
+ end
54
56
 
55
- def generate_url_name
56
- return true if self.name.blank?
57
- if !self.use_custom_url_name || self.url_name.blank?
58
- url_name = ""
59
- if !self.spud_page.blank?
60
- url_name += self.spud_page.url_name + "/"
61
- end
62
- url_name += self.name.parameterize.downcase
63
- if !self.use_custom_url_name
64
- pages = SpudPage.all
65
-
66
- if !self.id.blank?
67
- pages = pages.where("id != #{self.id}")
68
- end
69
- url_names = pages.to_a.collect{|p| p.url_name}
70
-
71
- counter = 1
72
- url_name_new = url_name
73
- while url_names.include?(url_name_new) do
74
- url_name_new = url_name + "-#{counter}"
75
- counter += 1
76
- end
77
- # url_name = url_name_new
78
- # Check Permalinks List
57
+ private
79
58
 
80
- permalink = SpudPermalink.where(:url_name => url_name_new).first
81
- counter = 1
82
- while permalink.blank? == false
59
+ def generate_url_name
60
+ if url_name.blank?
61
+ parts = []
62
+ parts << spud_page.url_name if spud_page.present?
63
+ parts << name.try(:parameterize)
64
+ self.url_name = parts.join('/')
65
+ end
66
+ return true
67
+ end
83
68
 
84
- if permalink.attachment == self
85
- permalink.destroy
86
- permalink = nil
87
- else
88
- url_name_new = url_name + "-#{counter}"
89
- counter += 1
90
- permalink = SpudPermalink.where(:url_name => url_name_new).first
91
- end
92
- end
93
- url_name = url_name_new
94
- end
95
- if self.url_name.blank? == false && url_name != self.url_name
96
- self.spud_permalinks.create(:url_name => self.url_name)
97
- end
98
- self.url_name = url_name
99
- self.use_custom_url_name = false
100
- elsif self.id.to_i > 0
101
- page = SpudPage.where(:id => self.id).first
102
- if page.url_name.blank? == false && page.url_name != self.url_name
103
- permalink = SpudPermalink.where(:url_name => self.url_name).first
104
- if permalink.blank? == false
105
- if permalink.attachment == self
106
- permalink.destroy
107
- else
108
- self.errors.add :url_name, "This permalink has already been used by another page."
109
- return false
110
- end
111
- end
112
- self.spud_permalinks.create(:url_name => page.url_name)
113
- end
114
- end
115
- return true
116
- end
69
+ def create_redirect_if_necessary
70
+ if url_name_changed?
71
+ TbRedirect.create_smart({
72
+ :source => "/#{url_name_was}",
73
+ :destination => "/#{url_name}",
74
+ :created_by => 'cms',
75
+ :owner => self
76
+ })
77
+ end
78
+ return true
79
+ end
117
80
 
118
- def is_private?
119
- return self.visibility == 1
120
- end
121
81
  end
@@ -8,6 +8,7 @@
8
8
  <%=link_to 'Edit', edit_admin_menu_menu_item_path(:id => menu_item.id), :title => "Edit Menu Item", :class => 'btn btn-default btn-sm' %>
9
9
  <%=link_to 'Delete', admin_menu_menu_item_path(:id => menu_item.id), :method => :delete, :class => 'btn btn-danger btn-sm', :data => {:confirm => "Are you sure you want to remove this menu item?"} %>
10
10
  </td>
11
+ <input type="hidden" value=<%= menu_item.id %>>
11
12
  </tr>
12
13
  <% menu_item.spud_menu_items.each do |item| %>
13
14
  <%= render :partial => 'menu_item_row', :locals => {:menu_item => item, :depth => depth+1} %>
@@ -3,7 +3,7 @@
3
3
  <% end %>
4
4
 
5
5
  <% content_for :detail do %>
6
- <div class="table-responsive">
6
+ <div id="sort" class="table-responsive">
7
7
  <table class="table table-striped table-hover">
8
8
  <thead>
9
9
  <tr>
@@ -18,10 +18,11 @@
18
18
  <% end %>
19
19
  </tbody>
20
20
  </table>
21
+ <input type="hidden" value=<%= @menu.id %> id="menu-id">
21
22
  </div>
22
-
23
23
  <script type="text/javascript">
24
- $(document).ready(function() { spud.admin.cms.menu_items.init();})
24
+ $(document).ready(function() {spud.admin.cms.menu_items.init();})
25
25
  </script>
26
26
 
27
27
  <% end %>
28
+
@@ -1,4 +1,4 @@
1
- <% @page_title = (@page.page_title)? @page.page_title : @page.name %>
1
+ <% @page_title = @page.page_title.present? ? @page.page_title : @page.name %>
2
2
 
3
3
  <%= content_for :head do %>
4
4
  <% cache([@page, 'head']) do %>
data/config/routes.rb CHANGED
@@ -10,7 +10,9 @@ Rails.application.routes.draw do
10
10
  end
11
11
  resources :snippets
12
12
  resources :menus do
13
- resources :menu_items
13
+ resources :menu_items do
14
+ put :update_sort, :on => :collection
15
+ end
14
16
  end
15
17
  resources :contacts
16
18
  end
@@ -1,5 +1,5 @@
1
1
  require 'tb_core'
2
- require 'tb_permalinks'
2
+ require 'tb_redirects'
3
3
  require 'tb_liquid'
4
4
 
5
5
  module Spud
@@ -13,13 +13,13 @@ module Spud
13
13
 
14
14
  initializer :admin do
15
15
  Spud::Core.configure do |config|
16
- config.admin_applications += [{:name => "Pages",:thumbnail => "spud/admin/pages_thumb.png",:url => "/admin/pages",:order => 0}]
16
+ config.admin_applications += [{:name => "Pages",:thumbnail => "admin/pages_thumb.png",:url => "/admin/pages",:order => 0}]
17
17
  if Spud::Cms.menus_enabled
18
- config.admin_applications += [{:name => "Menus",:thumbnail => "spud/admin/menus_thumb.png",:url => "/admin/menus",:order => 2}]
18
+ config.admin_applications += [{:name => "Menus",:thumbnail => "admin/menus_thumb.png",:url => "/admin/menus",:order => 2}]
19
19
  end
20
20
 
21
21
  if Spud::Cms.snippets_enabled
22
- config.admin_applications += [{:name => "Snippets",:thumbnail => "spud/admin/snippets_thumb.png",:url => "/admin/snippets",:order => 3}]
22
+ config.admin_applications += [{:name => "Snippets",:thumbnail => "admin/snippets_thumb.png",:url => "/admin/snippets",:order => 3}]
23
23
  end
24
24
  end
25
25
  end
@@ -34,10 +34,11 @@ module Spud
34
34
  config.routes_reloader.paths << File.expand_path('../page_route.rb', __FILE__)
35
35
  end
36
36
 
37
- initializer :assets do |config|
37
+ initializer 'tb_cms.assets' do |config|
38
38
  Spud::Core.append_admin_javascripts('admin/cms/application')
39
39
  Spud::Core.append_admin_stylesheets('admin/cms/application')
40
- end
40
+ Rails.application.config.assets.precompile += ['admin/pages_thumb.png', 'admin/snippets_thumb.png', 'admin/menus_thumb.png']
41
+ end
41
42
 
42
43
  initializer :liquid do |config|
43
44
  Liquid::Template.register_tag('snippet', Spud::Cms::LiquidSnippet)
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Cms
3
- VERSION = "1.2.2"
3
+ VERSION = "1.2.3"
4
4
  end
5
5
  end
@@ -102,7 +102,6 @@ describe Admin::MenuItemsController, :type => :controller do
102
102
  end
103
103
  end
104
104
 
105
-
106
105
  describe 'destroy' do
107
106
  it "should destroy the menu item" do
108
107
  menu_item = FactoryGirl.create(:spud_menu_item,:parent_id => @menu.id)
@@ -112,4 +111,18 @@ describe Admin::MenuItemsController, :type => :controller do
112
111
  end
113
112
  end
114
113
 
114
+ describe 'update_sort' do
115
+ it "should update all menu items menu_order fields" do
116
+ ordered_arr = Array.new(5)
117
+ ordered_arr.each_with_index do |item, index|
118
+ item = FactoryGirl.create(:spud_menu_item,:parent_id => @menu.id, :menu_order => index)
119
+ ordered_arr[index] = item.id.to_s
120
+ end
121
+ new_order_arr = ordered_arr.shuffle
122
+ put :update_sort, :menu_id => @menu.id,:id => ordered_arr[0], :order => new_order_arr
123
+ new_order_arr.each_with_index do |item, index|
124
+ expect(@menu.spud_menu_items.find_by_id(item.to_i).menu_order).to be(index)
125
+ end
126
+ end
127
+ end
115
128
  end
@@ -18,14 +18,12 @@ describe PagesController, :type => :controller do
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 = FactoryGirl.create(:spud_page,:name => "about")
22
- page.name = "about us"
21
+ page = FactoryGirl.create(:spud_page, :name => "about", :url_name => "about")
22
+ page.update(:url_name => "about-us")
23
23
  page.save
24
-
25
24
  get :show, :id => "about"
26
25
 
27
26
  expect(response).to redirect_to page_url(:id => "about-us")
28
-
29
27
  end
30
28
 
31
29
  it "should not allow access to private pages when logged out" do
@@ -0,0 +1,15 @@
1
+ # This migration comes from tb_redirects (originally 20160211162513)
2
+ class CreateTbRedirects < ActiveRecord::Migration
3
+ def change
4
+ create_table :tb_redirects do |t|
5
+ t.string :owner_type
6
+ t.integer :owner_id
7
+ t.string :source, :null => false
8
+ t.string :destination, :null => false
9
+ t.string :created_by
10
+ t.timestamps null: false
11
+ end
12
+ add_index :tb_redirects, [:owner_type, :owner_id]
13
+ add_index :tb_redirects, :source, :unique => true
14
+ end
15
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150911185844) do
14
+ ActiveRecord::Schema.define(version: 20160215180157) do
15
15
 
16
16
  create_table "spud_liquid_tags", force: :cascade do |t|
17
17
  t.integer "attachment_id", limit: 4
@@ -87,8 +87,8 @@ ActiveRecord::Schema.define(version: 20150911185844) do
87
87
  t.datetime "created_at"
88
88
  t.datetime "updated_at"
89
89
  t.integer "visibility", limit: 4, default: 0
90
- t.boolean "published", limit: 1, default: true
91
- t.boolean "use_custom_url_name", limit: 1, default: false
90
+ t.boolean "published", default: true
91
+ t.boolean "use_custom_url_name", default: false
92
92
  t.text "notes", limit: 65535
93
93
  t.string "layout", limit: 255
94
94
  t.string "page_title", limit: 255
@@ -153,7 +153,7 @@ ActiveRecord::Schema.define(version: 20150911185844) do
153
153
  create_table "spud_users", force: :cascade do |t|
154
154
  t.string "first_name", limit: 255
155
155
  t.string "last_name", limit: 255
156
- t.boolean "super_admin", limit: 1
156
+ t.boolean "super_admin"
157
157
  t.string "login", limit: 255, null: false
158
158
  t.string "email", limit: 255, null: false
159
159
  t.string "crypted_password", limit: 255, null: false
@@ -172,11 +172,24 @@ ActiveRecord::Schema.define(version: 20150911185844) do
172
172
  t.datetime "updated_at"
173
173
  t.string "time_zone", limit: 255
174
174
  t.integer "spud_role_id", limit: 4
175
- t.boolean "requires_password_change", limit: 1, default: false
175
+ t.boolean "requires_password_change", default: false
176
176
  end
177
177
 
178
178
  add_index "spud_users", ["email"], name: "index_spud_users_on_email", using: :btree
179
179
  add_index "spud_users", ["login"], name: "index_spud_users_on_login", using: :btree
180
180
  add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
181
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
190
+ end
191
+
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
+
182
195
  end
@@ -63,76 +63,34 @@ describe SpudPage, :type => :model do
63
63
  end
64
64
  end
65
65
 
66
- describe "generate_url_name" do
67
- it "should add the parent url name if a page has a parent" do
68
- parent_page = FactoryGirl.build(:spud_page,:name => "about")
69
- parent_page.save
70
- t = FactoryGirl.build(:spud_page, :name => "test")
71
- t.spud_page = parent_page
72
- t.valid?
73
-
74
- expect(t.url_name).to eq('about/test')
75
-
76
- end
77
-
78
- it "should add a counter to url_name if the url_name is already in use" do
79
- page = FactoryGirl.build(:spud_page,:name => "testimonials")
80
- page.save
81
-
82
- page2 = FactoryGirl.build(:spud_page,:name => "testimonials")
83
- page2.valid?
84
-
85
- expect(page2.url_name).to eq('testimonials-1')
86
- end
87
-
88
- it "should add a counter to url_name if the url_name was once in use by another page that was renamed" do
89
- page = FactoryGirl.build(:spud_page,:name => "another")
90
- page.save
91
- page.name = "again"
92
- page.save
93
-
94
- page2 = FactoryGirl.build(:spud_page,:name => "another")
95
- page2.valid?
96
-
97
- expect(page2.url_name).to eq('another-1')
66
+ describe "#generate_url_name" do
67
+ it 'should use the provided url' do
68
+ @page = FactoryGirl.create(:spud_page, :url_name => 'test')
69
+ expect(@page.url_name).to eq('test')
98
70
  end
99
71
 
100
- it "should destroy historical permalink if a page is renamed back to its previous name" do
101
- page = FactoryGirl.build(:spud_page,:name => "permapage")
102
- page.save
103
-
104
- page.name = 'permapage new'
105
- page.save
106
-
107
- page.name = 'permapage'
108
-
109
- basecount = SpudPermalink.count
110
-
111
- expect {
112
- page.valid?
113
- }.to change(page.spud_permalinks.where(:url_name => 'permapage'), :count).from(1).to(0)
72
+ it 'should generate a url based on the page name' do
73
+ @page = FactoryGirl.create(:spud_page, :name => 'Hello World')
74
+ expect(@page.url_name).to eq('hello-world')
114
75
  end
115
76
 
116
- it "should not allow a custom url to be reused by another page" do
117
- page = FactoryGirl.build(:spud_page,:name => "original")
118
- page.save
119
-
120
- page = FactoryGirl.build(:spud_page,:name => "new",:use_custom_url_name => true,:url_name => "original")
121
-
122
- expect(page.valid?).to eq(false)
77
+ it 'should generate a url based on the page name and parent page' do
78
+ @parent = FactoryGirl.create(:spud_page, :name => 'About Us')
79
+ @page = FactoryGirl.create(:spud_page, :name => 'Hello World', :spud_page => @parent)
80
+ expect(@page.url_name).to eq('about-us/hello-world')
123
81
  end
82
+ end
124
83
 
125
- it "should not allow a custom url to be reused by another page even if it is a historical permalink" do
126
- page = FactoryGirl.build(:spud_page,:name => "original")
127
- page.save
128
- page.name = "original2"
129
- page.save
130
-
131
- page = FactoryGirl.build(:spud_page,:name => "new")
132
- page.save
133
- page.use_custom_url_name = true
134
- page.url_name = 'original'
135
- expect(page.valid?).to eq(false)
84
+ describe '#create_redirect_if_necessary' do
85
+ it 'should create a redirect' do
86
+ page = FactoryGirl.create(:spud_page, :url_name => 'page-a')
87
+ expect{
88
+ page.update(:url_name => 'page-b')
89
+ }.to change(page.tb_redirects, :count).by(1)
90
+ redirect = page.tb_redirects.last
91
+ expect(redirect.source).to eq('/page-a')
92
+ expect(redirect.destination).to eq('/page-b')
136
93
  end
137
94
  end
95
+
138
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Westlake Design
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tb_core
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 1.3.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0
26
+ version: 1.3.7
27
27
  - !ruby/object:Gem::Dependency
28
- name: tb_permalinks
28
+ name: tb_redirects
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: 0.0.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: 0.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tb_liquid
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.1.0
75
+ version: 3.4.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.1.0
82
+ version: 3.4.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: factory_girl_rails
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -146,9 +146,9 @@ files:
146
146
  - MIT-LICENSE
147
147
  - README.md
148
148
  - Rakefile
149
- - app/assets/images/spud/admin/menus_thumb.png
150
- - app/assets/images/spud/admin/pages_thumb.png
151
- - app/assets/images/spud/admin/snippets_thumb.png
149
+ - app/assets/images/admin/menus_thumb.png
150
+ - app/assets/images/admin/pages_thumb.png
151
+ - app/assets/images/admin/snippets_thumb.png
152
152
  - app/assets/javascripts/admin/cms/application.js
153
153
  - app/assets/javascripts/admin/cms/menu_items.js
154
154
  - app/assets/javascripts/admin/cms/pages.js
@@ -299,6 +299,7 @@ files:
299
299
  - spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb
300
300
  - spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb
301
301
  - spec/dummy/db/migrate/20150911185844_add_title_tag_to_spud_page.tb_cms.rb
302
+ - spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb
302
303
  - spec/dummy/db/schema.rb
303
304
  - spec/dummy/public/404.html
304
305
  - spec/dummy/public/422.html
@@ -404,6 +405,7 @@ test_files:
404
405
  - spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb
405
406
  - spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb
406
407
  - spec/dummy/db/migrate/20150911185844_add_title_tag_to_spud_page.tb_cms.rb
408
+ - spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb
407
409
  - spec/dummy/db/schema.rb
408
410
  - spec/dummy/public/404.html
409
411
  - spec/dummy/public/422.html