environment_design_controller_test.rb
2.24 KB
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
56
57
58
59
60
61
62
63
64
require File.dirname(__FILE__) + '/../test_helper'
require 'environment_design_controller'
# Re-raise errors caught by the controller.
class EnvironmentDesignController; def rescue_action(e) raise e end; end
class EnvironmentDesignControllerTest < Test::Unit::TestCase
def setup
@controller = EnvironmentDesignController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_local_files_reference
assert_local_files_reference
end
def test_valid_xhtml
assert_valid_xhtml
end
should 'indicate only actual blocks as such' do
assert(@controller.available_blocks.all? {|item| item.new.is_a? Block})
end
should 'LinkListBlock is available' do
assert_includes @controller.available_blocks, LinkListBlock
end
should 'SlideshowBlock be available' do
assert_includes @controller.available_blocks, SlideshowBlock
end
should 'be able to edit LinkListBlock' do
login_as(create_admin_user(Environment.default))
l = LinkListBlock.create!(:links => [{:name => 'link 1', :address => '/address_1'}])
Environment.default.boxes.create!
Environment.default.boxes.first.blocks << l
get :edit, :id => l.id
assert_tag :tag => 'input', :attributes => { :name => 'block[links][][name]' }
assert_tag :tag => 'input', :attributes => { :name => 'block[links][][address]' }
end
should 'be able to save LinkListBlock' do
login_as(create_admin_user(Environment.default))
l = LinkListBlock.create!()
Environment.default.boxes.create!
Environment.default.boxes.first.blocks << l
post :save, :id => l.id, :block => { :links => [{:name => 'link 1', :address => '/address_1'}] }
l.reload
assert_equal [{'name' => 'link 1', 'address' => '/address_1'}], l.links
end
should 'create back link to environment control panel' do
Environment.default.boxes.create!.blocks << CommunitiesBlock.new
Environment.default.boxes.create!.blocks << EnterprisesBlock.new
Environment.default.boxes.create!.blocks << LoginBlock.new
login_as(create_admin_user(Environment.default))
get :index
assert_tag :tag => 'a', :attributes => {:href => '/admin'}, :child => {:tag => 'span', :content => "Back to control panel"}
end
end