Commit ae2c32316f541c8c3d89e96650d4bffcaf8e8039
1 parent
9159f4b7
Exists in
master
and in
29 other branches
ActionItem16: checkpoint; almost there
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@872 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
104 additions
and
44 deletions
Show diff stats
app/controllers/profile_admin/enterprise_validation_controller.rb
... | ... | @@ -11,4 +11,34 @@ class EnterpriseValidationController < ProfileAdminController |
11 | 11 | end |
12 | 12 | end |
13 | 13 | |
14 | + post_only :approve | |
15 | + def approve | |
16 | + @pending = profile.find_pending_validation(params[:id]) | |
17 | + if @pending | |
18 | + @pending.approve | |
19 | + redirect_to :action => 'view_processed', :id => @pending.code | |
20 | + else | |
21 | + render_not_found | |
22 | + end | |
23 | + end | |
24 | + | |
25 | + post_only :reject | |
26 | + def reject | |
27 | + @pending = profile.find_pending_validation(params[:id]) | |
28 | + @pending.reject_explanation = params[:reject_explanation] | |
29 | + if @pending | |
30 | + @pending.reject | |
31 | + redirect_to :action => 'view_processed', :id => @pending.code | |
32 | + else | |
33 | + render_not_found | |
34 | + end | |
35 | + end | |
36 | + | |
37 | + def view_processed | |
38 | + @processed = profile.find_processed_validation(params[:id]) | |
39 | + unless @processed | |
40 | + render_not_found | |
41 | + end | |
42 | + end | |
43 | + | |
14 | 44 | end | ... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +<table> | |
2 | + <tr> | |
3 | + <th><%= _('Name') %></th> | |
4 | + <td><%= request.name %></td> | |
5 | + </tr> | |
6 | + <tr> | |
7 | + <th><%= _('Address') %></th> | |
8 | + <td><%= request.address %></td> | |
9 | + </tr> | |
10 | + <tr> | |
11 | + <th><%= _('Contact Phone') %></th> | |
12 | + <td><%= request.contact_phone %></td> | |
13 | + </tr> | |
14 | + <tr> | |
15 | + <th><%= _('Contact Person') %></th> | |
16 | + <td><%= request.contact_person %></td> | |
17 | + </tr> | |
18 | + <tr> | |
19 | + <th><%= _('Acronym') %></th> | |
20 | + <td><%= request.acronym %></td> | |
21 | + </tr> | |
22 | + <tr> | |
23 | + <th><%= _('Identifier') %></th> | |
24 | + <td><%= request.identifier %></td> | |
25 | + </tr> | |
26 | + <tr> | |
27 | + <th><%= _('Foundation Year') %></th> | |
28 | + <td><%= request.foundation_year %></td> | |
29 | + </tr> | |
30 | + <tr> | |
31 | + <th><%= _('Legal Year') %></th> | |
32 | + <td><%= request.legal_form %></td> | |
33 | + </tr> | |
34 | + <tr> | |
35 | + <th><%= _('Economic Activity') %></th> | |
36 | + <td><%= request.economic_activity %></td> | |
37 | + </tr> | |
38 | + <tr> | |
39 | + <th><%= _('Management Information') %></th> | |
40 | + <td><%= request.management_information %></td> | |
41 | + </tr> | |
42 | +</table> | ... | ... |
app/views/enterprise_validation/details.rhtml
... | ... | @@ -2,48 +2,7 @@ |
2 | 2 | |
3 | 3 | <h3><%= _('Provided information') %></h3> |
4 | 4 | |
5 | -<table> | |
6 | - <tr> | |
7 | - <th><%= _('Name') %></th> | |
8 | - <td><%= @pending.name %></td> | |
9 | - </tr> | |
10 | - <tr> | |
11 | - <th><%= _('Address') %></th> | |
12 | - <td><%= @pending.address %></td> | |
13 | - </tr> | |
14 | - <tr> | |
15 | - <th><%= _('Contact Phone') %></th> | |
16 | - <td><%= @pending.contact_phone %></td> | |
17 | - </tr> | |
18 | - <tr> | |
19 | - <th><%= _('Contact Person') %></th> | |
20 | - <td><%= @pending.contact_person %></td> | |
21 | - </tr> | |
22 | - <tr> | |
23 | - <th><%= _('Acronym') %></th> | |
24 | - <td><%= @pending.acronym %></td> | |
25 | - </tr> | |
26 | - <tr> | |
27 | - <th><%= _('Identifier') %></th> | |
28 | - <td><%= @pending.identifier %></td> | |
29 | - </tr> | |
30 | - <tr> | |
31 | - <th><%= _('Foundation Year') %></th> | |
32 | - <td><%= @pending.foundation_year %></td> | |
33 | - </tr> | |
34 | - <tr> | |
35 | - <th><%= _('Legal Year') %></th> | |
36 | - <td><%= @pending.legal_form %></td> | |
37 | - </tr> | |
38 | - <tr> | |
39 | - <th><%= _('Economic Activity') %></th> | |
40 | - <td><%= @pending.economic_activity %></td> | |
41 | - </tr> | |
42 | - <tr> | |
43 | - <th><%= _('Management Information') %></th> | |
44 | - <td><%= @pending.management_information %></td> | |
45 | - </tr> | |
46 | -</table> | |
5 | +<%= render :partial => 'details', :locals => { :request => @pending } %> | |
47 | 6 | |
48 | 7 | <h3><%= _('Final decision') %></h3> |
49 | 8 | ... | ... |
test/functional/enterprise_validation_test.rb
... | ... | @@ -41,15 +41,41 @@ all_fixtures |
41 | 41 | end |
42 | 42 | |
43 | 43 | should 'be able to actually validate enterprise on request' do |
44 | - flunk 'not yet' | |
44 | + validation = CreateEnterprise.new | |
45 | + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) | |
46 | + validation.expects(:approve) | |
47 | + validation.expects(:code).returns('kakakaka') | |
48 | + post :approve, :profile => 'myorg', :id => 'kakakaka' | |
49 | + assert_redirected_to :action => 'view_processed', :id => 'kakakaka' | |
45 | 50 | end |
46 | 51 | |
47 | 52 | should 'be able to reject an enterprise' do |
48 | - flunk 'not yet' | |
53 | + validation = CreateEnterprise.new | |
54 | + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) | |
55 | + validation.expects(:reject) | |
56 | + validation.expects(:code).returns('kakakaka') | |
57 | + post :reject, :profile => 'myorg', :id => 'kakakaka' | |
58 | + assert_redirected_to :action => 'view_processed', :id => 'kakakaka' | |
49 | 59 | end |
50 | 60 | |
51 | 61 | should 'require the user to fill in the justification for an rejection' do |
62 | + validation = CreateEnterprise.new | |
63 | + @org.expects(:find_pending_validation).with('kakakaka').returns(validation) | |
64 | + validation.expects(:reject).raises(ActiveRecord::RecordInvalid) | |
65 | + post :reject, :profile => 'myorg', :id => 'kakakaka' | |
66 | + assert_response :success | |
67 | + assert_template 'details' | |
68 | + end | |
69 | + | |
70 | + should 'list validations already processed' do | |
52 | 71 | flunk 'not yet' |
53 | 72 | end |
73 | + | |
74 | + should 'be able to display a validation that was already processed' do | |
75 | + validation = CreateEnterprise.new | |
76 | + @org.expects(:find_processed_validation).with('kakakaka').returns(validation) | |
77 | + get :view_processed, :profile => 'myorg', :id => 'kakakaka' | |
78 | + assert_same validation, assigns(:processed) | |
79 | + end | |
54 | 80 | |
55 | 81 | end | ... | ... |