comfortable_mexican_sofa 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/comfortable_mexican_sofa/application.js +3 -3
  5. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +1 -1
  6. data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
  7. data/app/controllers/cms_admin/base_controller.rb +22 -25
  8. data/app/controllers/cms_admin/layouts_controller.rb +21 -21
  9. data/app/controllers/cms_admin/pages_controller.rb +29 -29
  10. data/app/controllers/cms_admin/revisions_controller.rb +6 -6
  11. data/app/controllers/cms_admin/sites_controller.rb +21 -20
  12. data/app/controllers/cms_admin/snippets_controller.rb +19 -20
  13. data/app/controllers/cms_admin/uploads_controller.rb +6 -6
  14. data/app/controllers/cms_content_controller.rb +30 -16
  15. data/app/models/cms/layout.rb +2 -9
  16. data/app/models/cms/site.rb +11 -6
  17. data/app/views/cms_admin/layouts/_form.html.erb +6 -6
  18. data/app/views/cms_admin/layouts/_index_branch.html.erb +10 -10
  19. data/app/views/cms_admin/layouts/edit.html.erb +6 -5
  20. data/app/views/cms_admin/layouts/index.html.erb +3 -3
  21. data/app/views/cms_admin/layouts/new.html.erb +3 -3
  22. data/app/views/cms_admin/pages/_form.html.erb +11 -11
  23. data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -4
  24. data/app/views/cms_admin/pages/_index_branch.html.erb +15 -15
  25. data/app/views/cms_admin/pages/edit.html.erb +6 -5
  26. data/app/views/cms_admin/pages/index.html.erb +4 -4
  27. data/app/views/cms_admin/pages/new.html.erb +3 -3
  28. data/app/views/cms_admin/pages/toggle_branch.js.erb +3 -3
  29. data/app/views/cms_admin/revisions/show.html.erb +4 -4
  30. data/app/views/cms_admin/sites/_form.html.erb +5 -2
  31. data/app/views/cms_admin/sites/_mirrors.html.erb +6 -6
  32. data/app/views/cms_admin/sites/edit.html.erb +3 -3
  33. data/app/views/cms_admin/sites/index.html.erb +9 -9
  34. data/app/views/cms_admin/sites/new.html.erb +3 -3
  35. data/app/views/cms_admin/snippets/_form.html.erb +3 -3
  36. data/app/views/cms_admin/snippets/edit.html.erb +5 -5
  37. data/app/views/cms_admin/snippets/index.html.erb +9 -9
  38. data/app/views/cms_admin/snippets/new.html.erb +3 -3
  39. data/app/views/cms_admin/uploads/_file.html.erb +1 -1
  40. data/app/views/cms_admin/uploads/_index.html.erb +2 -2
  41. data/app/views/cms_admin/uploads/destroy.js.erb +1 -1
  42. data/app/views/layouts/cms_admin/_head.html.erb +2 -0
  43. data/app/views/layouts/cms_admin/_left.html.erb +6 -6
  44. data/comfortable_mexican_sofa.gemspec +10 -6
  45. data/config/boot.rb +3 -10
  46. data/config/initializers/comfortable_mexican_sofa.rb +14 -22
  47. data/config/locales/en.yml +179 -4
  48. data/config/locales/es.yml +179 -0
  49. data/config/routes.rb +25 -27
  50. data/db/migrate/01_create_cms.rb +8 -1
  51. data/db/migrate/upgrades/04_upgrade_to_1_3_0.rb +23 -0
  52. data/lib/comfortable_mexican_sofa/configuration.rb +15 -19
  53. data/lib/comfortable_mexican_sofa/fixtures.rb +12 -3
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +7 -6
  55. data/lib/comfortable_mexican_sofa/is_mirrored.rb +9 -11
  56. data/lib/comfortable_mexican_sofa/tags/asset.rb +2 -2
  57. data/test/fixtures/cms/sites.yml +3 -1
  58. data/test/functional/cms_admin/base_controller_test.rb +18 -0
  59. data/test/functional/cms_admin/layouts_controller_test.rb +20 -19
  60. data/test/functional/cms_admin/pages_controller_test.rb +73 -71
  61. data/test/functional/cms_admin/revisions_controller_test.rb +23 -20
  62. data/test/functional/cms_admin/sites_controller_test.rb +8 -8
  63. data/test/functional/cms_admin/snippets_controller_test.rb +17 -16
  64. data/test/functional/cms_admin/uploads_controller_test.rb +3 -3
  65. data/test/integration/authentication_test.rb +4 -4
  66. data/test/integration/fixtures_test.rb +1 -1
  67. data/test/integration/mirrors_test.rb +15 -18
  68. data/test/integration/routing_extensions_test.rb +4 -19
  69. data/test/integration/sites_test.rb +67 -48
  70. data/test/test_helper.rb +26 -6
  71. data/test/unit/configuration_test.rb +5 -5
  72. data/test/unit/form_builder_test.rb +69 -0
  73. data/test/unit/mirrors_test.rb +2 -6
  74. data/test/unit/models/site_test.rb +30 -3
  75. metadata +55 -56
@@ -5,16 +5,13 @@ module ComfortableMexicanSofa::IsMirrored
5
5
  end
6
6
 
7
7
  module ClassMethods
8
-
9
8
  def cms_is_mirrored
10
- if ComfortableMexicanSofa.config.enable_mirror_sites
11
- include ComfortableMexicanSofa::IsMirrored::InstanceMethods
12
-
13
- attr_accessor :is_mirrored
14
-
15
- after_save :sync_mirror
16
- after_destroy :destroy_mirror
17
- end
9
+ include ComfortableMexicanSofa::IsMirrored::InstanceMethods
10
+
11
+ attr_accessor :is_mirrored
12
+
13
+ after_save :sync_mirror
14
+ after_destroy :destroy_mirror
18
15
  end
19
16
  end
20
17
 
@@ -22,7 +19,8 @@ module ComfortableMexicanSofa::IsMirrored
22
19
 
23
20
  # Mirrors of the object found on other sites
24
21
  def mirrors
25
- (Cms::Site.all - [self.site]).collect do |site|
22
+ return [] unless self.site.is_mirrored?
23
+ (Cms::Site.mirrored - [self.site]).collect do |site|
26
24
  case self
27
25
  when Cms::Layout then site.layouts.find_by_slug(self.slug)
28
26
  when Cms::Page then site.pages.find_by_full_path(self.full_path)
@@ -37,7 +35,7 @@ module ComfortableMexicanSofa::IsMirrored
37
35
  def sync_mirror
38
36
  return if self.is_mirrored
39
37
 
40
- (Cms::Site.all - [self.site]).each do |site|
38
+ (Cms::Site.mirrored - [self.site]).each do |site|
41
39
  mirror = case self
42
40
  when Cms::Layout
43
41
  m = site.layouts.find_by_slug(self.slug_was || self.slug) || site.layouts.new
@@ -13,11 +13,11 @@ class ComfortableMexicanSofa::Tag::Asset
13
13
 
14
14
  case type
15
15
  when 'css'
16
- out = "#{ComfortableMexicanSofa.config.content_route_prefix}/cms-css/#{label}.css"
16
+ out = "#{page.site.path}/cms-css/#{label}.css"
17
17
  out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
18
18
  out
19
19
  when 'js'
20
- out = "#{ComfortableMexicanSofa.config.content_route_prefix}/cms-js/#{label}.js"
20
+ out = "#{page.site.path}/cms-js/#{label}.js"
21
21
  out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
22
22
  out
23
23
  end
@@ -1,3 +1,5 @@
1
1
  default:
2
2
  label: Default Site
3
- hostname: test.host
3
+ hostname: test.host
4
+ path:
5
+ is_mirrored: false
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
+
3
+ class CmsAdmin::BaseControllerTest < ActionController::TestCase
4
+
5
+ def test_get_jump
6
+ get :jump
7
+ assert_response :redirect
8
+ assert_redirected_to cms_admin_site_pages_path(cms_sites(:default))
9
+ end
10
+
11
+ def test_get_jump_with_redirect_setting
12
+ ComfortableMexicanSofa.config.admin_route_redirect = '/cms-admin/sites'
13
+ get :jump
14
+ assert_response :redirect
15
+ assert_redirected_to '/cms-admin/sites'
16
+ end
17
+
18
+ end
@@ -3,39 +3,40 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
3
3
  class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
4
4
 
5
5
  def test_get_index
6
- get :index
6
+ get :index, :site_id => cms_sites(:default)
7
7
  assert_response :success
8
- assert assigns(:cms_layouts)
8
+ assert assigns(:layouts)
9
9
  assert_template :index
10
10
  end
11
11
 
12
12
  def test_get_index_with_no_layouts
13
13
  Cms::Layout.delete_all
14
- get :index
14
+ get :index, :site_id => cms_sites(:default)
15
15
  assert_response :redirect
16
16
  assert_redirected_to :action => :new
17
17
  end
18
18
 
19
19
  def test_get_new
20
- get :new
20
+ site = cms_sites(:default)
21
+ get :new, :site_id => site
21
22
  assert_response :success
22
- assert assigns(:cms_layout)
23
- assert_equal '{{ cms:page:content:text }}', assigns(:cms_layout).content
23
+ assert assigns(:layout)
24
+ assert_equal '{{ cms:page:content:text }}', assigns(:layout).content
24
25
  assert_template :new
25
- assert_select 'form[action=/cms-admin/layouts]'
26
+ assert_select "form[action=/cms-admin/sites/#{site.id}/layouts]"
26
27
  end
27
28
 
28
29
  def test_get_edit
29
30
  layout = cms_layouts(:default)
30
- get :edit, :id => layout
31
+ get :edit, :site_id => cms_sites(:default), :id => layout
31
32
  assert_response :success
32
- assert assigns(:cms_layout)
33
+ assert assigns(:layout)
33
34
  assert_template :edit
34
- assert_select "form[action=/cms-admin/layouts/#{layout.id}]"
35
+ assert_select "form[action=/cms-admin/sites/#{layout.site.id}/layouts/#{layout.id}]"
35
36
  end
36
37
 
37
38
  def test_get_edit_failure
38
- get :edit, :id => 'not_found'
39
+ get :edit, :site_id => cms_sites(:default), :id => 'not_found'
39
40
  assert_response :redirect
40
41
  assert_redirected_to :action => :index
41
42
  assert_equal 'Layout not found', flash[:error]
@@ -43,22 +44,22 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
43
44
 
44
45
  def test_creation
45
46
  assert_difference 'Cms::Layout.count' do
46
- post :create, :cms_layout => {
47
+ post :create, :site_id => cms_sites(:default), :layout => {
47
48
  :label => 'Test Layout',
48
49
  :slug => 'test',
49
50
  :content => 'Test {{cms:page:content}}'
50
- }, :commit => 'Create Layout'
51
+ }
51
52
  assert_response :redirect
52
53
  layout = Cms::Layout.last
53
54
  assert_equal cms_sites(:default), layout.site
54
- assert_redirected_to :action => :edit, :id => layout
55
+ assert_redirected_to :action => :edit, :site_id => layout.site, :id => layout
55
56
  assert_equal 'Layout created', flash[:notice]
56
57
  end
57
58
  end
58
59
 
59
60
  def test_creation_failure
60
61
  assert_no_difference 'Cms::Layout.count' do
61
- post :create, :cms_layout => { }
62
+ post :create, :site_id => cms_sites(:default), :layout => { }
62
63
  assert_response :success
63
64
  assert_template :new
64
65
  assert_equal 'Failed to create layout', flash[:error]
@@ -67,12 +68,12 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
67
68
 
68
69
  def test_update
69
70
  layout = cms_layouts(:default)
70
- put :update, :id => layout, :cms_layout => {
71
+ put :update, :site_id => cms_sites(:default), :id => layout, :layout => {
71
72
  :label => 'New Label',
72
73
  :content => 'New {{cms:page:content}}'
73
74
  }
74
75
  assert_response :redirect
75
- assert_redirected_to :action => :edit, :id => layout
76
+ assert_redirected_to :action => :edit, :site_id => layout.site, :id => layout
76
77
  assert_equal 'Layout updated', flash[:notice]
77
78
  layout.reload
78
79
  assert_equal 'New Label', layout.label
@@ -81,7 +82,7 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
81
82
 
82
83
  def test_update_failure
83
84
  layout = cms_layouts(:default)
84
- put :update, :id => layout, :cms_layout => {
85
+ put :update, :site_id => cms_sites(:default), :id => layout, :layout => {
85
86
  :slug => ''
86
87
  }
87
88
  assert_response :success
@@ -93,7 +94,7 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
93
94
 
94
95
  def test_destroy
95
96
  assert_difference 'Cms::Layout.count', -1 do
96
- delete :destroy, :id => cms_layouts(:default)
97
+ delete :destroy, :site_id => cms_sites(:default), :id => cms_layouts(:default)
97
98
  assert_response :redirect
98
99
  assert_redirected_to :action => :index
99
100
  assert_equal 'Layout deleted', flash[:notice]
@@ -3,110 +3,111 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
3
3
  class CmsAdmin::PagesControllerTest < ActionController::TestCase
4
4
 
5
5
  def test_get_index
6
- get :index
6
+ get :index, :site_id => cms_sites(:default)
7
7
  assert_response :success
8
- assert assigns(:cms_pages)
8
+ assert assigns(:pages)
9
9
  assert_template :index
10
10
  end
11
11
 
12
12
  def test_get_index_with_no_pages
13
13
  Cms::Page.delete_all
14
- get :index
14
+ get :index, :site_id => cms_sites(:default)
15
15
  assert_response :redirect
16
16
  assert_redirected_to :action => :new
17
17
  end
18
18
 
19
19
  def test_get_new
20
- get :new
20
+ site = cms_sites(:default)
21
+ get :new, :site_id => site
21
22
  assert_response :success
22
- assert assigns(:cms_page)
23
- assert_equal cms_layouts(:default), assigns(:cms_page).layout
23
+ assert assigns(:page)
24
+ assert_equal cms_layouts(:default), assigns(:page).layout
24
25
  assert_template :new
25
- assert_select 'form[action=/cms-admin/pages]'
26
+ assert_select "form[action=/cms-admin/sites/#{site.id}/pages]"
26
27
  end
27
28
 
28
29
  def test_get_new_with_field_datetime
29
30
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:datetime}}')
30
- get :new
31
- assert_select "input[type='datetime'][name='cms_page[blocks_attributes][][content]']"
32
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
31
+ get :new, :site_id => cms_sites(:default)
32
+ assert_select "input[type='datetime'][name='page[blocks_attributes][][content]']"
33
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
33
34
  end
34
35
 
35
36
  def test_get_new_with_field_integer
36
37
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:integer}}')
37
- get :new
38
- assert_select "input[type='number'][name='cms_page[blocks_attributes][][content]']"
39
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
38
+ get :new, :site_id => cms_sites(:default)
39
+ assert_select "input[type='number'][name='page[blocks_attributes][][content]']"
40
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
40
41
  end
41
42
 
42
43
  def test_get_new_with_field_string
43
44
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label}}')
44
- get :new
45
- assert_select "input[type='text'][name='cms_page[blocks_attributes][][content]']"
46
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
45
+ get :new, :site_id => cms_sites(:default)
46
+ assert_select "input[type='text'][name='page[blocks_attributes][][content]']"
47
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
47
48
  end
48
49
 
49
50
  def test_get_new_with_field_text
50
51
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:text}}')
51
- get :new
52
- assert_select "textarea[name='cms_page[blocks_attributes][][content]']"
53
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
52
+ get :new, :site_id => cms_sites(:default)
53
+ assert_select "textarea[name='page[blocks_attributes][][content]']"
54
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
54
55
  end
55
56
 
56
57
  def test_get_new_with_page_datetime
57
58
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:datetime}}')
58
- get :new
59
- assert_select "input[type='datetime'][name='cms_page[blocks_attributes][][content]']"
60
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
59
+ get :new, :site_id => cms_sites(:default)
60
+ assert_select "input[type='datetime'][name='page[blocks_attributes][][content]']"
61
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
61
62
  end
62
63
 
63
64
  def test_get_new_with_page_integer
64
65
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:integer}}')
65
- get :new
66
- assert_select "input[type='number'][name='cms_page[blocks_attributes][][content]']"
67
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
66
+ get :new, :site_id => cms_sites(:default)
67
+ assert_select "input[type='number'][name='page[blocks_attributes][][content]']"
68
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
68
69
  end
69
70
 
70
71
  def test_get_new_with_page_string
71
72
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:string}}')
72
- get :new
73
- assert_select "input[type='text'][name='cms_page[blocks_attributes][][content]']"
74
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
73
+ get :new, :site_id => cms_sites(:default)
74
+ assert_select "input[type='text'][name='page[blocks_attributes][][content]']"
75
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
75
76
  end
76
77
 
77
78
  def test_get_new_with_page_text
78
79
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label}}')
79
- get :new
80
- assert_select "textarea[name='cms_page[blocks_attributes][][content]']"
81
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
80
+ get :new, :site_id => cms_sites(:default)
81
+ assert_select "textarea[name='page[blocks_attributes][][content]']"
82
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
82
83
  end
83
84
 
84
85
  def test_get_new_with_rich_page_text
85
86
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:rich_text}}')
86
- get :new
87
- assert_select "textarea[name='cms_page[blocks_attributes][][content]']"
88
- assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
87
+ get :new, :site_id => cms_sites(:default)
88
+ assert_select "textarea[name='page[blocks_attributes][][content]']"
89
+ assert_select "input[type='hidden'][name='page[blocks_attributes][][label]'][value='test_label']"
89
90
  end
90
91
 
91
92
  def test_get_new_as_child_page
92
- get :new, :parent_id => cms_pages(:default)
93
+ get :new, :site_id => cms_sites(:default), :parent_id => cms_pages(:default)
93
94
  assert_response :success
94
- assert assigns(:cms_page)
95
- assert_equal cms_pages(:default), assigns(:cms_page).parent
95
+ assert assigns(:page)
96
+ assert_equal cms_pages(:default), assigns(:page).parent
96
97
  assert_template :new
97
98
  end
98
99
 
99
100
  def test_get_edit
100
101
  page = cms_pages(:default)
101
- get :edit, :id => page
102
+ get :edit, :site_id => page.site, :id => page
102
103
  assert_response :success
103
- assert assigns(:cms_page)
104
+ assert assigns(:page)
104
105
  assert_template :edit
105
- assert_select "form[action=/cms-admin/pages/#{page.id}]"
106
+ assert_select "form[action=/cms-admin/sites/#{page.site.id}/pages/#{page.id}]"
106
107
  end
107
108
 
108
109
  def test_get_edit_failure
109
- get :edit, :id => 'not_found'
110
+ get :edit, :site_id => cms_sites(:default), :id => 'not_found'
110
111
  assert_response :redirect
111
112
  assert_redirected_to :action => :index
112
113
  assert_equal 'Page not found', flash[:error]
@@ -115,16 +116,16 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
115
116
  def test_get_edit_with_blank_layout
116
117
  page = cms_pages(:default)
117
118
  page.update_attribute(:layout_id, nil)
118
- get :edit, :id => page
119
+ get :edit, :site_id => page.site, :id => page
119
120
  assert_response :success
120
- assert assigns(:cms_page)
121
- assert assigns(:cms_page).layout
121
+ assert assigns(:page)
122
+ assert assigns(:page).layout
122
123
  end
123
124
 
124
125
  def test_creation
125
126
  assert_difference 'Cms::Page.count' do
126
127
  assert_difference 'Cms::Block.count', 2 do
127
- post :create, :cms_page => {
128
+ post :create, :site_id => cms_sites(:default), :page => {
128
129
  :label => 'Test Page',
129
130
  :slug => 'test-page',
130
131
  :parent_id => cms_pages(:default).id,
@@ -140,14 +141,14 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
140
141
  page = Cms::Page.last
141
142
  assert_equal cms_sites(:default), page.site
142
143
  assert_redirected_to :action => :edit, :id => page
143
- assert_equal 'Page saved', flash[:notice]
144
+ assert_equal 'Page created', flash[:notice]
144
145
  end
145
146
  end
146
147
  end
147
148
 
148
149
  def test_creation_failure
149
150
  assert_no_difference ['Cms::Page.count', 'Cms::Block.count'] do
150
- post :create, :cms_page => {
151
+ post :create, :site_id => cms_sites(:default), :page => {
151
152
  :layout_id => cms_layouts(:default).id,
152
153
  :blocks_attributes => [
153
154
  { :label => 'default_page_text',
@@ -157,7 +158,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
157
158
  ]
158
159
  }
159
160
  assert_response :success
160
- page = assigns(:cms_page)
161
+ page = assigns(:page)
161
162
  assert_equal 2, page.blocks.size
162
163
  assert_equal ['content content', 'title content'], page.blocks.collect{|b| b.content}
163
164
  assert_template :new
@@ -168,7 +169,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
168
169
  def test_update
169
170
  page = cms_pages(:default)
170
171
  assert_no_difference 'Cms::Block.count' do
171
- put :update, :id => page, :cms_page => {
172
+ put :update, :site_id => page.site, :id => page, :page => {
172
173
  :label => 'Updated Label'
173
174
  }
174
175
  page.reload
@@ -182,7 +183,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
182
183
  def test_update_with_layout_change
183
184
  page = cms_pages(:default)
184
185
  assert_difference 'Cms::Block.count', 2 do
185
- put :update, :id => page, :cms_page => {
186
+ put :update, :site_id => page.site, :id => page, :page => {
186
187
  :label => 'Updated Label',
187
188
  :layout_id => cms_layouts(:nested).id,
188
189
  :blocks_attributes => [
@@ -202,19 +203,19 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
202
203
  end
203
204
 
204
205
  def test_update_failure
205
- put :update, :id => cms_pages(:default), :cms_page => {
206
+ put :update, :site_id => cms_sites(:default), :id => cms_pages(:default), :page => {
206
207
  :label => ''
207
208
  }
208
209
  assert_response :success
209
210
  assert_template :edit
210
- assert assigns(:cms_page)
211
+ assert assigns(:page)
211
212
  assert_equal 'Failed to update page', flash[:error]
212
213
  end
213
214
 
214
215
  def test_destroy
215
216
  assert_difference 'Cms::Page.count', -2 do
216
217
  assert_difference 'Cms::Block.count', -2 do
217
- delete :destroy, :id => cms_pages(:default)
218
+ delete :destroy, :site_id => cms_sites(:default), :id => cms_pages(:default)
218
219
  assert_response :redirect
219
220
  assert_redirected_to :action => :index
220
221
  assert_equal 'Page deleted', flash[:notice]
@@ -223,30 +224,31 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
223
224
  end
224
225
 
225
226
  def test_get_form_blocks
226
- xhr :get, :form_blocks, :id => cms_pages(:default), :layout_id => cms_layouts(:nested).id
227
+ site = cms_sites(:default)
228
+ xhr :get, :form_blocks, :site_id => site, :id => cms_pages(:default), :layout_id => cms_layouts(:nested).id
227
229
  assert_response :success
228
- assert assigns(:cms_page)
229
- assert_equal 2, assigns(:cms_page).tags.size
230
+ assert assigns(:page)
231
+ assert_equal 2, assigns(:page).tags.size
230
232
  assert_template :form_blocks
231
233
 
232
- xhr :get, :form_blocks, :id => cms_pages(:default), :layout_id => cms_layouts(:default).id
234
+ xhr :get, :form_blocks, :site_id => site, :id => cms_pages(:default), :layout_id => cms_layouts(:default).id
233
235
  assert_response :success
234
- assert assigns(:cms_page)
235
- assert_equal 4, assigns(:cms_page).tags.size
236
+ assert assigns(:page)
237
+ assert_equal 4, assigns(:page).tags.size
236
238
  assert_template :form_blocks
237
239
  end
238
240
 
239
241
  def test_get_form_blocks_for_new_page
240
- xhr :get, :form_blocks, :id => 0, :layout_id => cms_layouts(:default).id
242
+ xhr :get, :form_blocks, :site_id => cms_sites(:default), :id => 0, :layout_id => cms_layouts(:default).id
241
243
  assert_response :success
242
- assert assigns(:cms_page)
243
- assert_equal 3, assigns(:cms_page).tags.size
244
+ assert assigns(:page)
245
+ assert_equal 3, assigns(:page).tags.size
244
246
  assert_template :form_blocks
245
247
  end
246
248
 
247
249
  def test_creation_preview
248
250
  assert_no_difference 'Cms::Page.count' do
249
- post :create, :preview => 'Preview', :cms_page => {
251
+ post :create, :site_id => cms_sites(:default), :preview => 'Preview', :page => {
250
252
  :label => 'Test Page',
251
253
  :slug => 'test-page',
252
254
  :parent_id => cms_pages(:default).id,
@@ -264,7 +266,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
264
266
  def test_update_preview
265
267
  page = cms_pages(:default)
266
268
  assert_no_difference 'Cms::Page.count' do
267
- put :update, :preview => 'Preview', :id => page, :cms_page => {
269
+ put :update, :site_id => page.site, :preview => 'Preview', :id => page, :page => {
268
270
  :label => 'Updated Label',
269
271
  :blocks_attributes => [
270
272
  { :label => 'default_page_text',
@@ -281,28 +283,28 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
281
283
 
282
284
  def test_get_new_with_no_layout
283
285
  Cms::Layout.destroy_all
284
- get :new
286
+ get :new, :site_id => cms_sites(:default)
285
287
  assert_response :redirect
286
- assert_redirected_to new_cms_admin_layout_path
288
+ assert_redirected_to new_cms_admin_site_layout_path(cms_sites(:default))
287
289
  assert_equal 'No Layouts found. Please create one.', flash[:error]
288
290
  end
289
291
 
290
292
  def test_get_edit_with_no_layout
291
293
  Cms::Layout.destroy_all
292
294
  page = cms_pages(:default)
293
- get :edit, :id => page
295
+ get :edit, :site_id => page.site, :id => page
294
296
  assert_response :redirect
295
- assert_redirected_to new_cms_admin_layout_path
297
+ assert_redirected_to new_cms_admin_site_layout_path(page.site)
296
298
  assert_equal 'No Layouts found. Please create one.', flash[:error]
297
299
  end
298
300
 
299
301
  def test_get_toggle_branch
300
302
  page = cms_pages(:default)
301
- get :toggle_branch, :id => page, :format => :js
303
+ get :toggle_branch, :site_id => page.site, :id => page, :format => :js
302
304
  assert_response :success
303
305
  assert_equal [page.id.to_s], session[:cms_page_tree]
304
306
 
305
- get :toggle_branch, :id => page, :format => :js
307
+ get :toggle_branch, :site_id => page.site, :id => page, :format => :js
306
308
  assert_response :success
307
309
  assert_equal [], session[:cms_page_tree]
308
310
  end
@@ -318,7 +320,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
318
320
  assert_equal 0, page_one.position
319
321
  assert_equal 1, page_two.position
320
322
 
321
- post :reorder, :cms_page => [page_two.id, page_one.id]
323
+ post :reorder, :site_id => cms_sites(:default), :page => [page_two.id, page_one.id]
322
324
  assert_response :success
323
325
  page_one.reload
324
326
  page_two.reload