application_controller_test.rb
3.41 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
require File.dirname(__FILE__) + '/../test_helper'
require 'test_controller'
# Re-raise errors caught by the controller.
class TestController; def rescue_action(e) raise e end; end
class ApplicationControllerTest < Test::Unit::TestCase
all_fixtures
def setup
@controller = TestController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_exist_environment_variable_to_helper_environment_identification
get :index
assert_not_nil assigns(:environment)
end
def test_get_against_post_only
get :post_only
assert_redirected_to :action => 'index'
end
def test_post_against_post_only
post :post_only
assert_response :success
assert_tag :tag => 'span', :content => 'post_only'
end
def test_should_generate_help_box_when_passing_string
get :help_with_string
assert_tag({
:tag => 'div',
:attributes => { :class => 'help_box'},
:descendant => {
:tag => 'div',
:attributes => { :class => 'help_message', :style => /display:\s+none/},
:descendant => { :tag => 'div', :content => /my_help_message/ }
}
})
end
def test_should_generate_help_box_when_passing_block
get :help_with_block
assert_tag({
:tag => 'div',
:attributes => { :class => 'help_box'},
:descendant => {
:tag => 'div',
:attributes => { :class => 'help_message', :style => /display:\s+none/},
:descendant => { :tag => 'div', :content => /my_help_message/ }
}
})
end
def test_should_generate_help_box_expanding_textile_markup_when_passing_string
get :help_textile_with_string
assert_tag({
:tag => 'div',
:attributes => { :class => 'help_box'},
:descendant => {
:tag => 'div',
:attributes => { :class => 'help_message', :style => /display:\s+none/},
:descendant => {
:tag => 'strong',
:content => /my_bold_help_message/
}
}
})
end
def test_should_generate_help_box_expanding_textile_markup_when_passing_block
get :help_textile_with_block
assert_tag({
:tag => 'div',
:attributes => { :class => 'help_box'},
:descendant => {
:tag => 'div',
:attributes => { :class => 'help_message', :style => /display:\s+none/},
:descendant => {
:tag => 'strong',
:content => /my_bold_help_message/
}
}
})
end
def test_shouldnt_generate_help_box_markup_when_no_block_is_passed
get :help_without_block
assert_no_tag({
:tag => 'div',
:attributes => { :class => 'help_box'},
})
end
should 'be able to not use design blocks' do
class UsesBlocksTestController < ApplicationController
end
assert UsesBlocksTestController.new.uses_design_blocks?
class DoesNotUsesBlocksTestController < ApplicationController
no_design_blocks
end
assert !DoesNotUsesBlocksTestController.new.uses_design_blocks?
end
should 'use design plugin to generate blocks' do
get :index
assert_tag :tag => 'div', :attributes => { :id => 'boxes', :class => 'boxes' }
end
should 'not use design plugin when tells so' do
class NoDesignBlocksTestController < ApplicationController
no_design_blocks
end
@controller = NoDesignBlocksTestController.new
get :index
assert_no_tag :tag => 'div', :attributes => { :id => 'boxes', :class => 'boxes' }
end
end