Commit a4aab71d226b46e6b2770cdf508cf8fb32364422
1 parent
2a17ccba
Exists in
staging
and in
42 other branches
ActionItem427: add way do environment admin edit message for disabled
enterprises git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2075 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
42 additions
and
4 deletions
Show diff stats
app/models/environment.rb
@@ -193,7 +193,7 @@ class Environment < ActiveRecord::Base | @@ -193,7 +193,7 @@ class Environment < ActiveRecord::Base | ||
193 | 193 | ||
194 | validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.blank? }) | 194 | validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.blank? }) |
195 | 195 | ||
196 | - xss_terminate :only => [ :description ], :with => 'white_list' | 196 | + xss_terminate :only => [ :description, :message_for_disabled_enterprise ], :with => 'white_list' |
197 | 197 | ||
198 | # ################################################# | 198 | # ################################################# |
199 | # Business logic in general | 199 | # Business logic in general |
app/views/admin_panel/index.rhtml
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | 4 | ||
5 | <ul> | 5 | <ul> |
6 | <li><%= link_to _('Edit site info'), :action => 'site_info' %></li> | 6 | <li><%= link_to _('Edit site info'), :action => 'site_info' %></li> |
7 | + <li><%= link_to _('Edit message for disabled enterprises'), :action => 'message_for_disabled_enterprise' %></li> | ||
7 | <li><%= link_to _('Enable/disable features'), :controller => 'features' %></li> | 8 | <li><%= link_to _('Enable/disable features'), :controller => 'features' %></li> |
8 | <li><%= link_to _('Edit the Visual Design'), :controller => 'environment_design'%></li> | 9 | <li><%= link_to _('Edit the Visual Design'), :controller => 'environment_design'%></li> |
9 | <li><%= link_to _('Manage Categories'), :controller => 'categories'%></li> | 10 | <li><%= link_to _('Manage Categories'), :controller => 'categories'%></li> |
app/views/admin_panel/message_for_disabled_enterprise.rhtml
0 → 100644
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<h2><%= _('Site info') %></h2> | ||
2 | + | ||
3 | +<%= render :file => 'shared/tiny_mce' %> | ||
4 | + | ||
5 | +<% labelled_form_for :environment, @environment, :url => {:action => 'site_info'} do |f| %> | ||
6 | + | ||
7 | + <%= f.text_area :message_for_disabled_enterprise, :cols => 40, :style => 'width: 90%' %> | ||
8 | + | ||
9 | + <% button_bar do %> | ||
10 | + <%= submit_button(:save, _('Save')) %> | ||
11 | + <%= button(:cancel, _('Cancel'), :action => 'index') %> | ||
12 | + <% end %> | ||
13 | + | ||
14 | +<% end %> |
test/functional/admin_panel_controller_test.rb
@@ -51,6 +51,11 @@ class AdminPanelControllerTest < Test::Unit::TestCase | @@ -51,6 +51,11 @@ class AdminPanelControllerTest < Test::Unit::TestCase | ||
51 | get :index | 51 | get :index |
52 | assert_tag :tag => 'a', :attributes => { :href => '/admin/region_validators' } | 52 | assert_tag :tag => 'a', :attributes => { :href => '/admin/region_validators' } |
53 | end | 53 | end |
54 | + | ||
55 | + should 'link to edit message for disabled enterprise' do | ||
56 | + get :index | ||
57 | + assert_tag :tag => 'a', :attributes => { :href => '/admin/admin_panel/message_for_disabled_enterprise' } | ||
58 | + end | ||
54 | 59 | ||
55 | should 'display form for editing site info' do | 60 | should 'display form for editing site info' do |
56 | get :site_info | 61 | get :site_info |
@@ -58,18 +63,36 @@ class AdminPanelControllerTest < Test::Unit::TestCase | @@ -58,18 +63,36 @@ class AdminPanelControllerTest < Test::Unit::TestCase | ||
58 | assert_tag :tag => 'textarea', :attributes => { :name => 'environment[description]'} | 63 | assert_tag :tag => 'textarea', :attributes => { :name => 'environment[description]'} |
59 | end | 64 | end |
60 | 65 | ||
61 | - should 'save site description' do | 66 | + should 'display form for editing message for disabled enterprise' do |
67 | + get :message_for_disabled_enterprise | ||
68 | + assert_template 'message_for_disabled_enterprise' | ||
69 | + assert_tag :tag => 'textarea', :attributes => { :name => 'environment[message_for_disabled_enterprise]'} | ||
70 | + end | ||
62 | 71 | ||
72 | + should 'save site description' do | ||
63 | post :site_info, :environment => { :description => "This is my new environment" } | 73 | post :site_info, :environment => { :description => "This is my new environment" } |
64 | assert_redirected_to :action => 'index' | 74 | assert_redirected_to :action => 'index' |
65 | 75 | ||
66 | assert_equal "This is my new environment", Environment.default.description | 76 | assert_equal "This is my new environment", Environment.default.description |
67 | end | 77 | end |
68 | 78 | ||
79 | + should 'save message for disabled enterprise' do | ||
80 | + post :site_info, :environment => { :message_for_disabled_enterprise => "This enterprise is disabled" } | ||
81 | + assert_redirected_to :action => 'index' | ||
82 | + | ||
83 | + assert_equal "This enterprise is disabled", Environment.default.message_for_disabled_enterprise | ||
84 | + end | ||
85 | + | ||
69 | should 'sanitize description with white_list' do | 86 | should 'sanitize description with white_list' do |
70 | - post :site_info, :environment => { :description => "This <strong>is</strong> <scrypt>alert('alow')</script>my new environment" } | 87 | + post :site_info, :environment => { :description => "This <strong>is</strong> <script>alert('alow')</script>my new environment" } |
88 | + assert_redirected_to :action => 'index' | ||
89 | + assert_equal "This <strong>is</strong> my new environment", Environment.default.description | ||
90 | + end | ||
91 | + | ||
92 | + should 'sanitize message for disabled enterprise with white_list' do | ||
93 | + post :site_info, :environment => { :message_for_disabled_enterprise => "This <strong>is</strong> <script>alert('alow')</script>my new environment" } | ||
71 | assert_redirected_to :action => 'index' | 94 | assert_redirected_to :action => 'index' |
72 | - assert_equal "This <strong>is</strong> alert('alow')my new environment", Environment.default.description | 95 | + assert_equal "This <strong>is</strong> my new environment", Environment.default.message_for_disabled_enterprise |
73 | end | 96 | end |
74 | 97 | ||
75 | end | 98 | end |