-
Notifications
You must be signed in to change notification settings - Fork 41
/
manage_controller_spec.rb
55 lines (42 loc) · 1.77 KB
/
manage_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require File.expand_path(File.dirname(__FILE__)) + '/../../simple_content_spec_helper'
describe SimpleContent::ManageController do
reset_domain_tables :simple_content_models
it "should handle table list" do
mock_editor
# Test all the permutations of an active table
controller.should handle_active_table(:simple_content_table) do |args|
post 'simple_content_table', args
end
end
it "should be able to create simple content" do
mock_editor
assert_difference 'SimpleContentModel.count', 1 do
post 'create', :content_model => { :name => 'Test Simple Content' }
@model = SimpleContentModel.find(:last)
response.should redirect_to(:action => 'edit', :path => [@model.id])
end
end
it "should redirect to create if there are no simple content models" do
mock_editor
get 'index'
response.should redirect_to(:action => 'create')
end
it "should be able to edit simple content" do
mock_editor
@field_types = ContentModel.simple_content_field_options
@model = SimpleContentModel.create :name => 'Test'
fields = []
@field_types.each_with_index do |type, idx|
content_field = ContentModel.content_field('content/core_field', type[1].to_s)
fields[idx] = {:name => type[0].to_s, :field_type => type[1].to_s, :field_module => 'content/core_field', :position => idx}
end
post 'edit', :path => [@model.id], :content_model => {:content_model_fields => fields}
@model = SimpleContentModel.find(@model.id)
@model.content_model_fields.length.should == fields.length
end
it "should render the new field partial" do
mock_editor
post 'new_field', :add_field => {:name => 'Name', :field_type => 'content/core_field::string'}
response.should render_template('_edit_field')
end
end