enterprise_validation_test.rb
1.69 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
require File.dirname(__FILE__) + '/../test_helper'
require 'enterprise_validation_controller'
# Re-raise errors caught by the controller.
class EnterpriseValidationController; def rescue_action(e) raise e end; end
class EnterpriseValidationControllerTest < Test::Unit::TestCase
# all_fixtures:users
all_fixtures
def setup
@controller = EnterpriseValidationController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
login_as 'ze'
@org = Organization.create!(:identifier => 'myorg', :name => "My Org")
Profile.expects(:find_by_identifier).with('myorg').returns(@org).at_least_once
end
should 'list pending validations on index' do
empty = []
@org.expects(:pending_validations).returns(empty)
get :index, :profile => 'myorg'
assert_same empty, assigns(:pending_validations)
assert_template 'index'
end
should 'display details and prompt for needed data when approving or rejecting enterprise' do
validating = CreateEnterprise.new
@org.expects(:pending_validations).with(:code => 'kakakaka').returns([validating])
get :details, :profile => 'myorg', :id => 'kakakaka'
assert_same validating, assigns(:pending)
end
should 'refuse to validate unexisting request' do
@org.expects(:pending_validations).with(:code => 'kakakaka').returns([])
get :details , :profile => 'myorg', :id => 'kakakaka'
assert_response 404
end
should 'be able to actually validate enterprise on request' do
flunk 'not yet'
end
should 'be able to reject an enterprise' do
flunk 'not yet'
end
should 'require the user to fill in the justification for an rejection' do
flunk 'not yet'
end
end