tb_cms 1.2.0.beta1 → 1.2.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/menu_items_controller.rb +0 -3
  3. data/app/controllers/admin/menus_controller.rb +1 -6
  4. data/app/controllers/admin/pages_controller.rb +3 -7
  5. data/app/controllers/admin/snippets_controller.rb +0 -4
  6. data/app/controllers/cms/sitemaps_controller.rb +0 -4
  7. data/app/controllers/pages_controller.rb +3 -34
  8. data/app/helpers/cms/application_helper.rb +2 -18
  9. data/app/models/concerns/cms_deprecated_multisite.rb +21 -0
  10. data/app/models/spud_menu.rb +3 -3
  11. data/app/models/spud_page.rb +12 -20
  12. data/app/models/spud_snippet.rb +2 -3
  13. data/app/views/admin/menu_items/_form.html.erb +1 -1
  14. data/app/views/admin/pages/_form.html.erb +1 -1
  15. data/db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb +1 -3
  16. data/db/migrate/20150108162839_remove_site_id_from_cms_tables.rb +12 -0
  17. data/lib/spud_cms/engine.rb +0 -4
  18. data/lib/spud_cms/template_parser.rb +2 -30
  19. data/lib/spud_cms/version.rb +1 -1
  20. data/spec/{support/authlogic_helper.rb → authlogic_helper.rb} +1 -1
  21. data/spec/controllers/admin/menu_items_controller_spec.rb +28 -59
  22. data/spec/controllers/admin/menus_controller_spec.rb +32 -54
  23. data/spec/controllers/admin/pages_controller_spec.rb +26 -43
  24. data/spec/controllers/admin/snippets_controller_spec.rb +2 -2
  25. data/spec/controllers/pages_controller_spec.rb +11 -63
  26. data/spec/dummy/config/application.rb +5 -0
  27. data/spec/dummy/config/environments/production.rb +1 -1
  28. data/spec/dummy/config/environments/test.rb +1 -1
  29. data/spec/dummy/db/migrate/{20140110051458_create_spud_liquid_tags.tb_core.rb → 20141231214458_create_tb_liquid_spud_liquid_tags.tb_liquid.rb} +2 -2
  30. data/spec/dummy/db/migrate/{20140110051483_change_liquid_tags_to_polymorphic.tb_cms.rb → 20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb} +1 -3
  31. data/spec/dummy/db/migrate/{20140110051484_drop_spud_page_liquid_tags.tb_cms.rb → 20141231214481_drop_spud_page_liquid_tags.tb_cms.rb} +10 -8
  32. data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +13 -0
  33. data/spec/dummy/db/schema.rb +85 -93
  34. data/spec/helpers/cms/application_helper_spec.rb +23 -74
  35. data/spec/models/spud_menu_item_spec.rb +6 -6
  36. data/spec/models/spud_page_partial_revision_spec.rb +2 -2
  37. data/spec/models/spud_page_partial_spec.rb +9 -9
  38. data/spec/models/spud_page_spec.rb +20 -44
  39. data/spec/models/spud_snippet_spec.rb +2 -2
  40. data/spec/rails_helper.rb +72 -0
  41. data/spec/spec_helper.rb +77 -32
  42. metadata +104 -142
  43. data/spec/controllers/cms/sitemaps_controller_spec.rb +0 -41
  44. /data/spec/dummy/db/migrate/{20140110051449_create_spud_admin_permissions.tb_core.rb → 20141231214446_create_spud_admin_permissions.tb_core.rb} +0 -0
  45. /data/spec/dummy/db/migrate/{20140110051450_create_spud_users.tb_core.rb → 20141231214447_create_spud_users.tb_core.rb} +0 -0
  46. /data/spec/dummy/db/migrate/{20140110051451_add_time_zone_to_spud_user.tb_core.rb → 20141231214448_add_time_zone_to_spud_user.tb_core.rb} +0 -0
  47. /data/spec/dummy/db/migrate/{20140110051452_add_scope_to_spud_admin_permissions.tb_core.rb → 20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb} +0 -0
  48. /data/spec/dummy/db/migrate/{20140110051453_create_spud_user_settings.tb_core.rb → 20141231214450_create_spud_user_settings.tb_core.rb} +0 -0
  49. /data/spec/dummy/db/migrate/{20140110051454_create_spud_roles.tb_core.rb → 20141231214451_create_spud_roles.tb_core.rb} +0 -0
  50. /data/spec/dummy/db/migrate/{20140110051455_create_spud_permissions.tb_core.rb → 20141231214452_create_spud_permissions.tb_core.rb} +0 -0
  51. /data/spec/dummy/db/migrate/{20140110051456_create_spud_role_permissions.tb_core.rb → 20141231214453_create_spud_role_permissions.tb_core.rb} +0 -0
  52. /data/spec/dummy/db/migrate/{20140110051457_drop_spud_admin_permissions.tb_core.rb → 20141231214454_drop_spud_admin_permissions.tb_core.rb} +0 -0
  53. /data/spec/dummy/db/migrate/{20140110051459_create_spud_permalinks.tb_permalinks.rb → 20141231214455_create_spud_permalinks.tb_permalinks.rb} +0 -0
  54. /data/spec/dummy/db/migrate/{20140110051460_add_site_id_to_spud_permalinks.tb_permalinks.rb → 20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb} +0 -0
  55. /data/spec/dummy/db/migrate/{20140110051461_modify_site_id_for_spud_permalinks.tb_permalinks.rb → 20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb} +0 -0
  56. /data/spec/dummy/db/migrate/{20140110051462_create_spud_pages.tb_cms.rb → 20141231214459_create_spud_pages.tb_cms.rb} +0 -0
  57. /data/spec/dummy/db/migrate/{20140110051463_create_spud_menus.tb_cms.rb → 20141231214460_create_spud_menus.tb_cms.rb} +0 -0
  58. /data/spec/dummy/db/migrate/{20140110051464_create_spud_menu_items.tb_cms.rb → 20141231214461_create_spud_menu_items.tb_cms.rb} +0 -0
  59. /data/spec/dummy/db/migrate/{20140110051465_create_spud_templates.tb_cms.rb → 20141231214462_create_spud_templates.tb_cms.rb} +0 -0
  60. /data/spec/dummy/db/migrate/{20140110051466_create_spud_page_partials.tb_cms.rb → 20141231214463_create_spud_page_partials.tb_cms.rb} +0 -0
  61. /data/spec/dummy/db/migrate/{20140110051467_add_visibility_to_spud_pages.tb_cms.rb → 20141231214464_add_visibility_to_spud_pages.tb_cms.rb} +0 -0
  62. /data/spec/dummy/db/migrate/{20140110051468_add_menu_name_to_spud_menu_items.tb_cms.rb → 20141231214465_add_menu_name_to_spud_menu_items.tb_cms.rb} +0 -0
  63. /data/spec/dummy/db/migrate/{20140110051469_add_use_custom_url_name_to_spud_pages.tb_cms.rb → 20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb} +0 -0
  64. /data/spec/dummy/db/migrate/{20140110051470_add_notes_to_spud_pages.tb_cms.rb → 20141231214467_add_notes_to_spud_pages.tb_cms.rb} +0 -0
  65. /data/spec/dummy/db/migrate/{20140110051471_add_menu_id_to_spud_menu_items.tb_cms.rb → 20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb} +0 -0
  66. /data/spec/dummy/db/migrate/{20140110051472_add_classes_to_spud_menu_items.tb_cms.rb → 20141231214469_add_classes_to_spud_menu_items.tb_cms.rb} +0 -0
  67. /data/spec/dummy/db/migrate/{20140110051473_add_site_id_to_spud_pages.tb_cms.rb → 20141231214470_add_site_id_to_spud_pages.tb_cms.rb} +0 -0
  68. /data/spec/dummy/db/migrate/{20140110051474_add_site_id_to_spud_templates.tb_cms.rb → 20141231214471_add_site_id_to_spud_templates.tb_cms.rb} +0 -0
  69. /data/spec/dummy/db/migrate/{20140110051475_add_site_id_to_spud_menus.tb_cms.rb → 20141231214472_add_site_id_to_spud_menus.tb_cms.rb} +0 -0
  70. /data/spec/dummy/db/migrate/{20140110051476_create_spud_page_partial_revisions.tb_cms.rb → 20141231214473_create_spud_page_partial_revisions.tb_cms.rb} +0 -0
  71. /data/spec/dummy/db/migrate/{20140110051477_add_symbol_name_to_spud_page_partials.tb_cms.rb → 20141231214474_add_symbol_name_to_spud_page_partials.tb_cms.rb} +0 -0
  72. /data/spec/dummy/db/migrate/{20140110051478_modify_site_id_for_spud_pages.tb_cms.rb → 20141231214475_modify_site_id_for_spud_pages.tb_cms.rb} +0 -0
  73. /data/spec/dummy/db/migrate/{20140110051479_add_content_processed_to_spud_page_partials.tb_cms.rb → 20141231214476_add_content_processed_to_spud_page_partials.tb_cms.rb} +0 -0
  74. /data/spec/dummy/db/migrate/{20140110051480_add_layout_to_spud_pages.tb_cms.rb → 20141231214477_add_layout_to_spud_pages.tb_cms.rb} +0 -0
  75. /data/spec/dummy/db/migrate/{20140110051481_create_spud_page_liquid_tags.tb_cms.rb → 20141231214478_create_spud_page_liquid_tags.tb_cms.rb} +0 -0
  76. /data/spec/dummy/db/migrate/{20140110051482_create_spud_snippets.tb_cms.rb → 20141231214479_create_spud_snippets.tb_cms.rb} +0 -0
@@ -1,146 +1,115 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::MenuItemsController do
3
+ describe Admin::MenuItemsController, :type => :controller do
4
4
  before(:each) do
5
5
  activate_authlogic
6
6
  u = SpudUser.new(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
7
7
  u.super_admin = true
8
8
  u.save
9
9
  @user = SpudUserSession.create(u)
10
- Spud::Core.configure do |config|
11
- config.site_name = "Test Site"
12
- config.multisite_mode_enabled = false
13
- config.multisite_config = []
14
- end
15
-
16
10
  @menu = FactoryGirl.create(:spud_menu)
17
11
  end
18
12
 
19
13
 
20
- describe :index do
14
+ describe 'index' do
21
15
  it "should return an array of menus" do
22
16
  2.times {|x| s = FactoryGirl.create(:spud_menu_item,:spud_menu_id => @menu.id,:parent_id => @menu.id)}
23
17
  get :index,:menu_id =>@menu.id
24
18
 
25
- assigns(:menu_items).count.should be > 1
19
+ expect(assigns(:menu_items).count).to be > 1
26
20
  end
27
21
  it "should redirect if the menu is not found" do
28
22
  get :index,:menu_id => @menu.id + 1
29
- response.should redirect_to admin_menus_url
30
- flash[:error].should_not be_blank
23
+ expect(response).to redirect_to admin_menus_url
31
24
  end
32
25
  end
33
26
 
34
- describe :new do
27
+ describe 'new' do
35
28
  it "should assign a new menu" do
36
29
  get :new,:menu_id =>@menu.id
37
- assigns(:menu_item).should_not be_blank
38
- response.should be_success
30
+ expect(assigns(:menu_item)).to_not be_blank
31
+ expect(response).to be_success
39
32
  end
40
33
  end
41
34
 
42
- describe :create do
35
+ describe 'create' do
43
36
  it "should create a new menu item with a valid form submission" do
44
- lambda {
37
+ expect {
45
38
  post :create,:menu_id => @menu.id, :spud_menu_item => FactoryGirl.attributes_for(:spud_menu_item,:parent_id => nil).reject{|k,v| k == 'id' || k == :spud_menu_id}
46
- }.should change(SpudMenuItem,:count).by(1)
47
- response.should be_redirect
39
+ }.to change(SpudMenuItem,:count).by(1)
40
+ expect(response).to be_redirect
48
41
  end
49
42
 
50
43
  it "should not create a menu item with an invalid form entry" do
51
44
  yamldata = FactoryGirl.attributes_for(:spud_menu_item,:name => nil).reject{|k,v| k == 'id' || k == :spud_menu_id}
52
45
 
53
- lambda {
46
+ expect {
54
47
  post :create,:menu_id => @menu.id, :spud_menu_item => FactoryGirl.attributes_for(:spud_menu_item,:name => nil,:parent_id => nil).reject{|k,v| k == 'id' || k == :spud_menu_id}
55
- }.should_not change(SpudMenuItem,:count)
48
+ }.to_not change(SpudMenuItem,:count)
56
49
  end
57
50
 
58
51
  it "should autoset order if not specified" do
59
52
  menuitem = FactoryGirl.create(:spud_menu_item,:parent_id => @menu.id)
60
53
 
61
54
  post :create,:menu_id => @menu.id, :spud_menu_item => FactoryGirl.attributes_for(:spud_menu_item,:menu_order => nil,:parent_id => nil).reject{|k,v| k == 'id' || k == :spud_menu_id}
62
- assigns(:menu_item).menu_order.should == 1
55
+ expect(assigns(:menu_item).menu_order).to eq(1)
63
56
  end
64
57
 
65
58
  it "should assign the menu name based on page name if left blank" do
66
59
  page = FactoryGirl.create(:spud_page)
67
60
  post :create,:menu_id => @menu.id, :spud_menu_item => FactoryGirl.attributes_for(:spud_menu_item,:name => nil,:spud_page_id => page.id).reject{|k,v| k == 'id' || k == :spud_menu_id}
68
- assigns(:menu_item).name.should == page.name
61
+ expect(assigns(:menu_item).name).to eq(page.name)
69
62
  end
70
63
 
71
64
  it "should set the parent to a submenu if specified" do
72
65
  menuitem = FactoryGirl.create(:spud_menu_item,:parent_id => @menu.id)
73
66
  post :create,:menu_id => @menu.id, :spud_menu_item => FactoryGirl.attributes_for(:spud_menu_item,:parent_id => menuitem.id).reject{|k,v| k == 'id' || k == :spud_menu_id}
74
- assigns(:menu_item).parent.should == menuitem
67
+ expect(assigns(:menu_item).parent).to eq(menuitem)
75
68
  end
76
69
  end
77
70
 
78
- describe :edit do
71
+ describe 'edit' do
79
72
  it "should respond with menu item by id" do
80
73
  menu1 = FactoryGirl.create(:spud_menu_item)
81
74
  menu2 = FactoryGirl.create(:spud_menu_item)
82
75
  get :edit, :menu_id => @menu.id,:id => menu2.id
83
- assigns(:menu_item).should == menu2
76
+ expect(assigns(:menu_item)).to eq(menu2)
84
77
  end
85
78
 
86
79
  it "should redirect_to index if menu item not found" do
87
80
  get :edit,:menu_id => @menu.id,:id => "345"
88
- response.should redirect_to admin_menu_menu_items_url(:menu_id => @menu.id)
81
+ expect(response).to redirect_to admin_menu_menu_items_url(:menu_id => @menu.id)
89
82
  end
90
83
  end
91
84
 
92
- describe :update do
85
+ describe 'update' do
93
86
  it "should update the name when the name attribute is changed" do
94
87
  menu_item = FactoryGirl.create(:spud_menu_item)
95
88
  new_name = 'MyMenu'
96
- lambda {
89
+ expect {
97
90
  put :update,: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}
98
91
  menu_item.reload
99
- }.should change(menu_item,:name).to(new_name)
92
+ }.to change(menu_item,:name).to(new_name)
100
93
  end
101
94
  it "should assign a menu to a submenu if parentid is defined" do
102
95
  menu_item1 = FactoryGirl.create(:spud_menu_item)
103
96
  menu_item = FactoryGirl.create(:spud_menu_item)
104
97
 
105
- lambda {
98
+ expect {
106
99
  put :update,: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}
107
100
  menu_item.reload
108
- }.should change(menu_item,:parent).to(menu_item1)
101
+ }.to change(menu_item,:parent).to(menu_item1)
109
102
  end
110
103
  end
111
104
 
112
105
 
113
- describe :destroy do
106
+ describe 'destroy' do
114
107
  it "should destroy the menu item" do
115
108
  menu_item = FactoryGirl.create(:spud_menu_item,:parent_id => @menu.id)
116
- lambda {
109
+ expect {
117
110
  delete :destroy,:menu_id => @menu.id,:id => menu_item.id
118
- }.should change(SpudMenuItem,:count).by(-1)
111
+ }.to change(SpudMenuItem,:count).by(-1)
119
112
  end
120
113
  end
121
114
 
122
- describe :multisite do
123
- before(:each) do
124
- Spud::Core.configure do |config|
125
- config.site_name = "Test Site"
126
- config.multisite_mode_enabled = true
127
- config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1,:short_name => "siteb"}]
128
- end
129
- Spud::Cms.configure do |config|
130
- config.multisite_config = [{:short_name => "siteb",:default_page_parts => ["Body","Sidebar"]}]
131
- end
132
- session[:admin_site] = 1
133
- end
134
-
135
-
136
- describe :edit do
137
- it "should not allow editing of a menu_item in a menu that is different from the current admin site" do
138
- menu_item = FactoryGirl.create(:spud_menu_item)
139
- get :edit,:id => menu_item.id,:menu_id => @menu.id
140
- response.should redirect_to admin_menus_url
141
- flash[:warning].should_not be_blank
142
- end
143
- end
144
-
145
- end
146
115
  end
@@ -1,120 +1,98 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::MenusController do
3
+ describe Admin::MenusController, :type => :controller do
4
4
  before(:each) do
5
5
  activate_authlogic
6
6
  u = SpudUser.new(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
7
7
  u.super_admin = true
8
8
  u.save
9
9
  @user = SpudUserSession.create(u)
10
- Spud::Core.configure do |config|
11
- config.site_name = "Test Site"
12
- config.multisite_mode_enabled = false
13
- config.multisite_config = []
14
- end
15
10
  end
16
11
 
17
12
 
18
- describe :index do
13
+ describe 'index' do
19
14
  it "should return an array of menus" do
20
- 2.times {|x| s = FactoryGirl.create(:spud_menu)}
15
+ 2.times { FactoryGirl.create(:spud_menu) }
21
16
  get :index
22
17
 
23
- assigns(:menus).count.should be > 1
18
+ expect(assigns(:menus).count).to be > 1
24
19
  end
25
20
 
26
21
  end
27
22
 
28
- describe :new do
23
+ describe 'new' do
29
24
  it "should response with new menu" do
30
25
  get :new
31
- assigns(:menu).should_not be_blank
32
- response.should be_success
26
+ expect(assigns(:menu)).to_not be_blank
27
+ expect(response).to be_success
33
28
  end
34
29
  end
35
30
 
36
- describe :create do
31
+ describe 'create' do
37
32
  it "should create a new menu with a valid form submission" do
38
- lambda {
39
- post :create, :spud_menu => FactoryGirl.attributes_for(:spud_menu).reject{|k,v| k == 'site_id' || k == 'id'}
40
- }.should change(SpudMenu,:count).by(1)
41
- response.should be_redirect
33
+ expect {
34
+ post :create, :spud_menu => FactoryGirl.attributes_for(:spud_menu).reject{|k,v| k == 'id'}
35
+ }.to change(SpudMenu,:count).by(1)
36
+ expect(response).to be_redirect
42
37
  end
43
38
 
44
39
  it "should not create a menu with an invalid form entry" do
45
- lambda {
46
- post :create, :spud_menu => FactoryGirl.attributes_for(:spud_menu,:name => nil).reject{|k,v| k == 'site_id' || k == 'id'}
47
- }.should_not change(SpudMenu,:count)
48
-
49
-
50
- end
51
- end
52
-
53
- describe :multisite do
54
- before(:each) do
55
- Spud::Core.configure do |config|
56
- config.site_name = "Test Site"
57
- config.multisite_mode_enabled = true
58
- config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
59
- end
40
+ expect {
41
+ post :create, :spud_menu => FactoryGirl.attributes_for(:spud_menu,:name => nil).reject{|k,v| k == 'id'}
42
+ }.to_not change(SpudMenu,:count)
60
43
 
61
- end
62
- it "should not allow editing of a menu on a different site id" do
63
- menu2 = FactoryGirl.create(:spud_menu,:site_id => 1)
64
- get :edit,:id => menu2.id
65
44
 
66
- response.should redirect_to admin_menus_url
67
45
  end
68
46
  end
69
47
 
70
- describe :edit do
48
+ describe 'edit' do
71
49
  it "should response with menu by id" do
72
50
  menu1 = FactoryGirl.create(:spud_menu)
73
51
  menu2 = FactoryGirl.create(:spud_menu)
74
52
  get :edit,:id => menu2.id
75
- assigns(:menu).should == menu2
53
+ expect(assigns(:menu)).to eq(menu2)
76
54
  end
77
55
  it "should redirect to index if menu not found" do
78
56
  get :edit,:id => 3
79
- response.should redirect_to admin_menus_url
57
+ expect(response).to redirect_to admin_menus_url
80
58
  end
81
59
 
82
60
  end
83
61
 
84
- describe :update do
62
+ describe 'update' do
85
63
  it "should update the name when the name attribute is changed" do
86
64
  menu = FactoryGirl.create(:spud_menu)
87
65
  new_name = 'MyMenu'
88
- lambda {
89
- put :update,:id => menu.id, :spud_menu => menu.attributes.merge!(:name => new_name).reject{|k,v| k == 'site_id' || k == 'id'}
66
+ expect {
67
+ put :update,:id => menu.id, :spud_menu => menu.attributes.merge!(:name => new_name).reject{|k,v| k == 'id'}
90
68
  menu.reload
91
- }.should change(menu,:name).to(new_name)
69
+ }.to change(menu,:name).to(new_name)
92
70
 
93
71
  end
94
72
 
95
73
  it "should redirect to the admin menus after a successful update" do
96
74
  menu = FactoryGirl.create(:spud_menu)
97
- put :update,:id => menu.id,:spud_menu => menu.attributes.merge!(:name => "MyMenu").reject{|k,v| k == 'site_id' || k == 'id'}
75
+ put :update,:id => menu.id,:spud_menu => menu.attributes.merge!(:name => "MyMenu").reject{|k,v| k == 'id'}
98
76
 
99
- response.should redirect_to(admin_menu_menu_items_url(:menu_id => menu.id))
77
+ expect(response).to redirect_to(admin_menu_menu_items_url(:menu_id => menu.id))
100
78
  end
101
79
  end
102
80
 
103
- describe :destroy do
81
+ describe 'destroy' do
104
82
  it "should destroy the menu" do
105
83
  menu = FactoryGirl.create(:spud_menu)
106
- lambda {
84
+ expect {
107
85
  delete :destroy, :id => menu.id
108
- }.should change(SpudMenu,:count).by(-1)
109
- response.should be_redirect
86
+ }.to change(SpudMenu,:count).by(-1)
87
+ expect(response).to be_redirect
110
88
  end
111
89
 
112
90
  it "should not destroy the menu with a wrong id" do
113
91
  menu = FactoryGirl.create(:spud_menu)
114
- lambda {
92
+ expect {
115
93
  delete :destroy,:id => "23532"
116
- }.should_not change(SpudMenu,:count)
117
- response.should be_redirect
94
+ }.to_not change(SpudMenu,:count)
95
+ expect(response).to be_redirect
118
96
  end
119
97
 
120
98
  end
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::PagesController do
3
+ describe Admin::PagesController, :type => :controller do
4
4
  before(:each) do
5
5
  activate_authlogic
6
6
  u = SpudUser.new(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
@@ -9,20 +9,12 @@ describe Admin::PagesController do
9
9
  @user = SpudUserSession.create(u)
10
10
  end
11
11
 
12
- it "should return site_config by short_name" do
13
- Spud::Cms.configure do |config|
14
- config.multisite_config = [{:short_name => "siteb",:site_name => "Test Site B",:site_id => 2}]
15
- end
16
-
17
- Spud::Cms.site_config_for_short_name(:siteb)[:site_id].should == 2
18
- end
19
-
20
- describe :index do
12
+ describe 'index' do
21
13
  it "should return an array of parent pages" do
22
14
  2.times {|x| s = FactoryGirl.create(:spud_page)}
23
15
  get :index
24
16
 
25
- assigns(:pages).count.should be > 1
17
+ expect(assigns(:pages).count).to be > 1
26
18
  end
27
19
 
28
20
  it "should only return parent pages" do
@@ -30,89 +22,80 @@ describe Admin::PagesController do
30
22
  FactoryGirl.create(:spud_page,:spud_page_id => 1)
31
23
 
32
24
  get :index
33
- assigns(:pages).count.should == 2
25
+ expect(assigns(:pages).count).to eq(2)
34
26
  end
35
27
  end
36
28
 
37
- describe :show do
29
+ describe 'show' do
38
30
  it "should respond successfully" do
39
31
  p = FactoryGirl.create(:spud_page)
40
32
  get :show ,:id => p.id
41
- assigns(:layout).should render_template(:layout => "layouts/#{Spud::Cms.default_page_layout}")
42
- response.should be_success
33
+ expect(assigns(:layout)).to render_template(:layout => "layouts/#{Spud::Cms.default_page_layout}")
34
+ expect(response).to be_success
43
35
  end
44
-
45
-
46
-
47
- # it "should redirect if no id specified" do
48
- # get :show,:id => nil
49
-
50
- # response.should redirect_to admin_pages_url
51
- # end
52
-
53
36
  end
54
37
 
55
- describe :new do
38
+ describe 'new' do
56
39
  it "should respond successfully" do
57
40
  get :new
58
41
 
59
- response.should be_success
42
+ expect(response).to be_success
60
43
  end
61
44
 
62
45
  it "should build a page object for the form" do
63
46
  get :new
64
47
 
65
- assigns(:page).should_not be_blank
48
+ expect(assigns(:page)).to_not be_blank
66
49
  end
67
50
  end
68
51
 
69
- describe :edit do
52
+ describe 'edit' do
70
53
  context "HTML format" do
71
54
  it "should load the correct page for the edit form" do
72
55
  page = FactoryGirl.create(:spud_page)
73
56
  get :edit, :id => page.id
74
57
 
75
- assigns(:page).id.should == page.id
58
+ expect(assigns(:page).id).to eq(page.id)
76
59
  end
77
60
  end
78
61
 
79
62
  end
80
63
 
81
64
 
82
- describe :update do
65
+ describe 'update' do
83
66
  it "should update the name when the attribute is changed" do
84
67
  page = FactoryGirl.create(:spud_page)
85
68
  new_name = "Adam"
86
- lambda {
87
- put :update, :id => page.id, :spud_page => page.attributes.merge!(:name => new_name).reject{ |key,value| key == 'id' || key == 'created_at' || key == 'updated_at' || key == 'site_id'}
69
+ expect {
70
+ put :update, :id => page.id, :spud_page => page.attributes.merge!(:name => new_name).reject{ |key,value| key == 'id' || key == 'created_at' || key == 'updated_at'}
88
71
  page.reload
89
- }.should change(page, :name).to(new_name)
72
+ }.to change(page, :name).to(new_name)
90
73
  end
91
74
 
92
75
  it "should redirect to the page root index after a successful update" do
93
76
  page = FactoryGirl.create(:spud_page)
94
77
  new_name = "Adam"
95
- put :update, :id => page.id, :spud_page => page.attributes.merge!(:name => new_name).reject{ |key,value| key == 'id' || key == 'created_at' || key == 'updated_at' || key == 'site_id'}
78
+ put :update, :id => page.id, :spud_page => page.attributes.merge!(:name => new_name).reject{ |key,value| key == 'id' || key == 'created_at' || key == 'updated_at'}
96
79
 
97
- response.should redirect_to(admin_pages_url)
80
+ expect(response).to redirect_to(admin_pages_url)
98
81
  end
99
82
  end
100
83
 
101
- describe :destroy do
84
+ describe 'destroy' do
102
85
  it "should destroy the page" do
103
86
  page = FactoryGirl.create(:spud_page)
104
- lambda {
87
+ expect {
105
88
  delete :destroy, :id => page.id
106
- }.should change(SpudPage, :count).by(-1)
107
- response.should be_redirect
89
+ }.to change(SpudPage, :count).by(-1)
90
+ expect(response).to be_redirect
108
91
  end
109
92
 
110
93
  it "should destroy the user with the wrong id" do
111
94
  page = FactoryGirl.create(:spud_page)
112
- lambda {
95
+ expect {
113
96
  delete :destroy, :id => "23532"
114
- }.should_not change(SpudPage, :count)
115
- response.should be_redirect
97
+ }.to_not change(SpudPage, :count)
98
+ expect(response).to be_redirect
116
99
  end
117
100
  end
118
101
 
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::SnippetsController do
3
+ describe Admin::SnippetsController, :type => :controller do
4
4
 
5
5
  end
@@ -1,29 +1,20 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
+
3
+ describe PagesController, :type => :controller do
4
+ describe 'show' do
2
5
 
3
- describe PagesController do
4
- describe :show do
5
- before(:each) do
6
- Spud::Core.configure do |config|
7
- config.site_name = "Test Site"
8
- config.multisite_mode_enabled = false
9
- config.multisite_config = []
10
- end
11
- Spud::Cms.configure do |config|
12
- config.cache_mode = false
13
- end
14
- end
15
6
  it "should render a page" do
16
7
  page = FactoryGirl.create(:spud_page)
17
8
  get :show ,:id => page.url_name
18
- assigns(:layout).should render_template(:layout => "layouts/#{Spud::Cms.default_page_layout}")
19
- response.should be_success
9
+ expect(assigns(:layout)).to render_template(:layout => "layouts/#{Spud::Cms.default_page_layout}")
10
+ expect(response).to be_success
20
11
  end
21
12
 
22
13
  it "should render home page if id is blank" do
23
14
  page = FactoryGirl.create(:spud_page,:name => "home")
24
15
  get :show
25
- assigns(:page).should == page
26
- response.should be_success
16
+ expect(assigns(:page)).to eq(page)
17
+ expect(response).to be_success
27
18
  end
28
19
 
29
20
  it "should redirect to new page url from old page url if it was changed" do
@@ -33,27 +24,15 @@ describe PagesController do
33
24
 
34
25
  get :show, :id => "about"
35
26
 
36
- response.should redirect_to page_url(:id => "about-us")
27
+ expect(response).to redirect_to page_url(:id => "about-us")
37
28
 
38
29
  end
39
30
 
40
-
41
-
42
31
  it "should not allow access to private pages when logged out" do
43
32
  page = FactoryGirl.create(:spud_page,:name => "about",:visibility => 1)
44
33
 
45
34
  get :show, :id => "about"
46
- response.should redirect_to login_path
47
- end
48
-
49
- describe "page caching" do
50
- before(:each) do
51
- Spud::Cms.configure do |config|
52
- config.cache_mode = nil
53
- end
54
- end
55
-
56
-
35
+ expect(response).to redirect_to login_path(:return_to => '/about')
57
36
  end
58
37
 
59
38
  describe "authorized login" do
@@ -69,40 +48,9 @@ describe PagesController do
69
48
  page = FactoryGirl.create(:spud_page,:name => "about",:visibility => 1)
70
49
 
71
50
  get :show, :id => "about"
72
- response.should be_success
51
+ expect(response).to be_success
73
52
  end
74
53
  end
75
54
 
76
- describe "multisite enabled" do
77
- before(:each) do
78
- Spud::Core.configure do |config|
79
- config.site_name = "Test Site"
80
- config.multisite_mode_enabled = true
81
- config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
82
- end
83
- end
84
-
85
- it "should not show a page on a different site" do
86
- page = FactoryGirl.create(:spud_page,:name => "about",:site_id => 0)
87
- get :show,:id=>"about"
88
- response.response_code.should == 404
89
- end
90
-
91
- it "should show the right page" do
92
- page = FactoryGirl.create(:spud_page,:name => "about",:site_id => 0)
93
- page2 = FactoryGirl.create(:spud_page,:name => "about",:site_id => 1)
94
- get :show,:id=>"about"
95
- assigns(:page).should == page2
96
- end
97
-
98
- it "should return the homepage of the current site" do
99
- page = FactoryGirl.create(:spud_page,:name => "home",:site_id => 0)
100
- page_site1 = FactoryGirl.create(:spud_page,:name => "home",:site_id => 1)
101
-
102
- get :show
103
- assigns(:page).should == page_site1
104
- end
105
-
106
- end
107
55
  end
108
56
  end
@@ -7,6 +7,11 @@ require "tb_cms"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
10
+
11
+ Spud::Core.configure do |config|
12
+ config.site_name = "Test Site"
13
+ end
14
+
10
15
  # Settings in config/environments/* take precedence over those specified here.
11
16
  # Application configuration should go into files in config/initializers
12
17
  # -- all .rb files in that directory are automatically loaded.
@@ -9,7 +9,7 @@ Dummy::Application.configure do
9
9
  config.action_controller.perform_caching = true
10
10
 
11
11
  # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
12
+ config.serve_static_files = false
13
13
 
14
14
  # Compress JavaScripts and CSS
15
15
  config.assets.compress = true
@@ -8,7 +8,7 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
11
+ config.serve_static_files = true
12
12
  config.static_cache_control = "public, max-age=3600"
13
13
 
14
14
  # Deprecated
@@ -1,5 +1,5 @@
1
- # This migration comes from tb_core (originally 20140110040026)
2
- class CreateSpudLiquidTags < ActiveRecord::Migration
1
+ # This migration comes from tb_liquid (originally 20140110142037)
2
+ class CreateTbLiquidSpudLiquidTags < ActiveRecord::Migration
3
3
  def change
4
4
  create_table :spud_liquid_tags do |t|
5
5
  t.integer :attachment_id
@@ -3,9 +3,7 @@ class ChangeLiquidTagsToPolymorphic < ActiveRecord::Migration
3
3
  def up
4
4
  rename_column :spud_page_liquid_tags, :spud_page_partial_id, :attachment_id
5
5
  add_column :spud_page_liquid_tags, :attachment_type, :string
6
-
7
- add_index :spud_page_liquid_tags, [:attachment_type,:attachment_id]
8
-
6
+ add_index :spud_page_liquid_tags, [:attachment_type, :attachment_id], :name => 'inde_spud_page_liquid_tags_on_attachment'
9
7
  if defined?(SpudPageLiquidTag)
10
8
  SpudPageLiquidTag.all.each do |f|
11
9
  f.update_attributes(:attachment_type => "SpudPagePartial")