Commit 438ab96ef52421bb2950cd3c2f94d478517ab47c

Authored by MoisesMachado
1 parent a9b5d881

ActionItem17: added the form for editing the validation_info and an icon in the …

…control panel to reach the validation area


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1201 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/organization.rb
... ... @@ -38,6 +38,10 @@ class Organization < Profile
38 38 CreateEnterprise.processed_for(self, :code => code).first
39 39 end
40 40  
  41 + def is_validation_entity?
  42 + !self.validation_info.nil?
  43 + end
  44 +
41 45 def info
42 46 organization_info
43 47 end
... ...
app/views/enterprise_validation/edit_validation_info.rhtml 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +<% _('Editing the validation info') %>
  2 +
  3 +<%= error_messages_for :info %>
  4 +
  5 +<% labelled_form_for :info, @info do |f| %>
  6 + <%= f.text_area(:validation_methodology, :cols => 50, :rows => 10) %>
  7 + <%= f.text_area(:restrictions, :cols => 50, :rows => 7) %>
  8 + <% button_bar do %>
  9 + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %>
  10 + <% end %>
  11 +<% end %>
... ...
app/views/profile_editor/index.rhtml
... ... @@ -21,6 +21,8 @@
21 21  
22 22 <%= file_manager_button(_('Manage Products'), 'icons-app/products.png', :controller => 'manage_products') if profile.enterprise? %>
23 23  
  24 + <%= file_manager_button(_('Enterprise Validation'), 'icons-app/validation.png', :controller => 'enterprise_validation') if profile.is_validation_entity? %>
  25 +
24 26 <% end %>
25 27  
26 28 <% if @profile.person? %>
... ...
public/images/icons-app/README
... ... @@ -24,6 +24,7 @@ abiword_48.png dlg-neu
24 24 gnome-other.png Nuovo
25 25 user_icon.png dlg-neu
26 26 temp-home.png Nuovo
  27 +gtk-yes.png dlg-neu
27 28  
28 29 Icons rasterization
29 30 ===================
... ...
public/images/icons-app/gtk-yes.png 0 → 100644

2.69 KB

public/images/icons-app/validation.png 0 → 120000
... ... @@ -0,0 +1 @@
  1 +gtk-yes.png
0 2 \ No newline at end of file
... ...
test/functional/enterprise_validation_test.rb
... ... @@ -92,4 +92,31 @@ class EnterpriseValidationControllerTest &lt; Test::Unit::TestCase
92 92 assert_same validation, assigns(:processed)
93 93 end
94 94  
  95 + should 'display a form for editing the validation info' do
  96 + info = ValidationInfo.new(:validation_methodology => 'none')
  97 + @org.expects(:validation_info).returns(info)
  98 + get :edit_validation_info, :profile => 'myorg'
  99 + assert_response :success
  100 + assert_equal info, assigns(:info)
  101 + end
  102 +
  103 + should 'save an alteration of the validation info' do
  104 + info = ValidationInfo.new(:validation_methodology => 'none')
  105 + @org.expects(:validation_info).returns(info)
  106 + post :edit_validation_info, :profile => 'myorg', :validation_info => {:validatin_methodology => 'new methodaology'}
  107 +
  108 + assert_response :redirect
  109 + assert_redirected_to :action => 'index'
  110 + assert_equal info, assigns(:info)
  111 + end
  112 +
  113 + should 'not save an empaty validation mthodology' do
  114 + info = ValidationInfo.new(:validation_methodology => 'none')
  115 + @org.expects(:validation_info).returns(info)
  116 + post :edit_validation_info, :profile => 'myorg', :info => {:validation_methodology => ''}
  117 +
  118 + assert_response :success
  119 + assert_equal info, assigns(:info)
  120 + end
  121 +
95 122 end
... ...