Class: ControllerActionTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- ControllerActionTest
show all
- Includes:
- Goldberg::TestHelper
- Defined in:
- lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb
Instance Method Summary
collapse
#form_login, #form_logout, included, #login_user
Instance Method Details
6
7
8
9
10
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb', line 6
def setup
(@sc1, @sc2) = Goldberg::SiteController.find :all
(@p1, @p2) = Goldberg::Permission.find :all
end
|
#test_all_fields ⇒ Object
31
32
33
34
35
36
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb', line 31
def test_all_fields
ca = Goldberg::ControllerAction.new(:name => 'test')
ca.site_controller = @sc1
ca.permission = @p1
assert ca.save
end
|
#test_effective_permission ⇒ Object
The effective permission is the permission of the controller action, if specified; otherwise it is the permission of the action’s site controller.
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb', line 64
def test_effective_permission
@sc1.permission = @p1
@sc1.save!
ca = Goldberg::ControllerAction.new(:name => 'test')
ca.site_controller = @sc1
ca.save!
assert_nil ca.permission
assert_equal @p1.id, ca.effective_permission.id
ca.permission = @p2
ca.save!
assert_not_nil ca.permission
assert_equal @p2.id, ca.effective_permission.id
end
|
#test_minimal_fields ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb', line 21
def test_minimal_fields
ca = Goldberg::ControllerAction.new(:name => 'test')
ca.site_controller = @sc1
assert ca.save
ca.permission = @p1
assert ca.save
end
|
#test_name_unique_within_scope_of_site_controller ⇒ Object
The name of the controller action should be unique within the scope of the site controller.
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb', line 40
def test_name_unique_within_scope_of_site_controller
ca1 = Goldberg::ControllerAction.new(:name => 'test')
ca2 = Goldberg::ControllerAction.new(:name => 'test')
ca1.site_controller = @sc1
ca2.site_controller = @sc1
ca1.save
assert !ca2.save
assert ca2.errors.on(:name)
ca2.site_controller = @sc2
assert ca2.save
ca2.name = 'test2'
ca2.site_controller = @sc1
assert ca2.save
end
|
#test_no_fields ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/controller_action_test.rb', line 12
def test_no_fields
ca = Goldberg::ControllerAction.new
assert !ca.valid?
[:name, :site_controller_id].each do |attr|
assert ca.errors.on(attr)
end
end
|