[noosfero/noosfero][master] admin-panel: refactoring of manage organizations
Rodrigo Souto
gitlab at gitlab.com
Thu May 28 12:49:51 BRT 2015
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
4c1e0c9f by Gabriela Navarro at 2015-05-28T12:49:23Z
admin-panel: refactoring of manage organizations
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Fabio Teixeira <fabio1079 at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>
Signed-off-by: David Carlos <ddavidcarlos1392 at gmail.com>
Signed-off-by: Rodrigo Souto <rodrigo at colivre.coop.br>
- - - - -
20 changed files:
- app/controllers/admin/admin_panel_controller.rb
- + app/controllers/admin/organizations_controller.rb
- app/helpers/users_helper.rb
- app/models/environment.rb
- app/models/profile.rb
- app/views/admin_panel/index.html.erb
- − app/views/admin_panel/manage_organizations_status.html.erb
- + app/views/organizations/_results.html.erb
- + app/views/organizations/index.html.erb
- + app/views/organizations/index.js.erb
- + app/views/shared/admin/profiles/index.js.rb
- app/views/users/_users_list.html.erb
- lib/noosfero/plugin.rb
- + public/javascripts/manage-organizations.js
- public/stylesheets/application.css
- test/factories.rb
- test/fixtures/roles.yml
- test/functional/admin_panel_controller_test.rb
- + test/functional/organizations_controller_test.rb
- test/functional/profile_editor_controller_test.rb
Changes:
=====================================
app/controllers/admin/admin_panel_controller.rb
=====================================
--- a/app/controllers/admin/admin_panel_controller.rb
+++ b/app/controllers/admin/admin_panel_controller.rb
@@ -71,22 +71,4 @@ class AdminPanelController < AdminController
end
end
end
-
- def manage_organizations_status
- scope = environment.organizations
- @filter = params[:filter] || 'any'
- @title = "Organization profiles"
- @title = @title+" - "+ at filter if @filter != 'any'
-
- if @filter == 'enabled'
- scope = scope.visible
- elsif @filter == 'disabled'
- scope = scope.disabled
- end
-
- scope = scope.order('name ASC')
-
- @q = params[:q]
- @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => 10, :page => params[:npage]})[:results]
- end
end
=====================================
app/controllers/admin/organizations_controller.rb
=====================================
--- /dev/null
+++ b/app/controllers/admin/organizations_controller.rb
@@ -0,0 +1,66 @@
+class OrganizationsController < AdminController
+
+ protect 'manage_environment_organizations', :environment
+
+ def index
+ @filter = params[:filter] || 'any'
+ @title = _('Organization profiles')
+ @type = params[:type] || "any"
+ @types_filter = [[_('All'), 'any'], [_('Community'), 'Community'], [_('Enterprise'), 'Enterprise']]
+ @types_filter = @types_filter | @plugins.dispatch(:organization_types_filter_options)
+
+ scope = @plugins.dispatch_first(:filter_manage_organization_scope, @type)
+ if scope.blank?
+ scope = environment.organizations
+ scope = scope.where(:type => @type) if @type != 'any'
+ end
+
+ if @filter == 'enabled'
+ scope = scope.visible
+ elsif @filter == 'disabled'
+ scope = scope.disabled
+ end
+
+ scope = scope.order('name ASC')
+
+ @q = params[:q]
+ @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => per_page, :page => params[:npage]})[:results]
+ end
+
+ def activate
+ organization = environment.organizations.find(params[:id])
+ if organization.enable
+ render :text => (_('%s enabled') % organization.name).to_json
+ else
+ render :text => (_('%s could not be enabled') % organization.name).to_json
+ end
+ end
+
+ def deactivate
+ organization = environment.organizations.find(params[:id])
+ if organization.disable
+ render :text => (_('%s disabled') % organization.name).to_json
+ else
+ render :text => (_('%s could not be disable') % organization.name).to_json
+ end
+ end
+
+ def destroy
+ if request.post?
+ organization = environment.organizations.find(params[:id])
+ if organization && organization.destroy
+ render :text => (_('%s removed') % organization.name).to_json
+ else
+ render :text => (_('%s could not be removed') % organization.name).to_json
+ end
+ else
+ render :nothing => true
+ end
+ end
+
+ private
+
+ def per_page
+ 10
+ end
+end
=====================================
app/helpers/users_helper.rb
=====================================
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -14,7 +14,7 @@ module UsersHelper
select_field = select_tag(:filter, options, :onchange => onchange)
content_tag('div',
content_tag('strong', _('Filter')) + ': ' + select_field,
- :class => "environment-users-customize-search"
+ :class => "environment-profiles-customize-search"
)
end
=====================================
app/models/environment.rb
=====================================
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -29,6 +29,7 @@ class Environment < ActiveRecord::Base
'manage_environment_roles' => N_('Manage environment roles'),
'manage_environment_validators' => N_('Manage environment validators'),
'manage_environment_users' => N_('Manage environment users'),
+ 'manage_environment_organizations' => N_('Manage environment organizations'),
'manage_environment_templates' => N_('Manage environment templates'),
'manage_environment_licenses' => N_('Manage environment licenses'),
'manage_environment_trusted_sites' => N_('Manage environment trusted sites'),
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -957,11 +957,19 @@ private :generate_url, :url_options
self.save
end
+ def disabled?
+ !visible
+ end
+
def enable
self.visible = true
self.save
end
+ def enabled?
+ visible
+ end
+
def control_panel_settings_button
{:title => _('Edit Profile'), :icon => 'edit-profile'}
end
=====================================
app/views/admin_panel/index.html.erb
=====================================
--- a/app/views/admin_panel/index.html.erb
+++ b/app/views/admin_panel/index.html.erb
@@ -18,9 +18,9 @@
<table>
<tr><td><%= link_to _('User roles'), :controller => 'role' %></td></tr>
<tr><td><%= link_to _('Users'), :controller => 'users' %></td></tr>
+ <tr><td><%= link_to _('Organizations'), :controller => 'organizations' %></td></tr>
<tr><td><%= link_to _('Profile templates'), :controller => 'templates' %></td></tr>
<tr><td><%= link_to _('Fields'), :controller => 'features', :action => 'manage_fields' %></td></tr>
- <tr><td><%= link_to _('Manage organizations status'), :action => 'manage_organizations_status' %></td></tr>
</table>
=====================================
app/views/admin_panel/manage_organizations_status.html.erb deleted
=====================================
--- a/app/views/admin_panel/manage_organizations_status.html.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-<h1><%= _('Manage organizations') %></h1>
-
-<%= form_tag( { :action => 'manage_organizations_status' }, :method => 'get', :class => 'users-search' ) do %>
-
- <div class="search-field">
- <span class="formfield">
- <%= text_field_tag 'q', @q, :title => _("Find profiles"), :style=>"width:85%" %>
- </span>
-
- <%= submit_button(:search, _('Search')) %>
- </div>
-
- <div class="environment-users-results-header">
- <div id='environment-users-filter-title'><%= @title %></div>
-
- <div id="environment-users-filter-filter">
- <strong><%= _("Filter by: ") %></strong>
-
- <select id="profile_filter_select">
- <%= options_for_select([['Any', 'any'],["Disabled profiles", "disabled"], ["Enabled profiles", "enabled"]], @filter) %>
- </select>
- </div>
- <div style="clear: both"></div>
- </div>
-
- <table>
- <colgroup>
- <col width="80%">
- <col width="20%">
- </colgroup>
-
- <tr>
- <th><%= _('Member') %></th>
- <th><%= _('Actions') %></th>
- </tr>
-
- <% @collection.each do |p| %>
- <tr title="<%= p.name %>">
- <td><%= link_to_profile p.short_name, p.identifier, :title => p.name %> </td>
-
- <td class='actions'>
- <div class="members-buttons-cell">
- <% if p.visible %>
- <%= button_without_text :'deactivate-user', _('Deactivate'), {:controller => "profile_editor", :action => 'deactivate_profile', :profile => p.identifier, :id => p.id}, :confirm => _("Do you want to deactivate this profile ?") %>
- <% else %>
- <%= button_without_text :'activate-user', _('Activate'), {:controller => "profile_editor", :action => 'activate_profile', :profile => p.identifier, :id => p.id}, :confirm => _("Do you want to activate this profile ?") %>
- <% end %>
- <%= button_without_text :'delete', _('Remove'), {:controller => "profile_editor", :action => 'destroy_profile', :profile => p.identifier, :id => p.id, :return_to => "/admin/admin_panel/manage_organizations_status"}, :method => :post, :confirm => _("Do you want to deactivate this profile ?") %>
- </div>
- </td>
- </tr>
- <% end %>
- </table>
-
-<% end %>
-
-<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %>
-
-<% button_bar do %>
- <%= button :back, _('Back'), :controller => 'admin_panel' %>
-<% end %>
-
-<script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery("#profile_filter_select").change(function(){
- document.location.href = '/admin/admin_panel/manage_organizations_status?filter='+this.value;
- });
- });
-</script>
\ No newline at end of file
=====================================
app/views/organizations/_results.html.erb
=====================================
--- /dev/null
+++ b/app/views/organizations/_results.html.erb
@@ -0,0 +1,41 @@
+<div class='results'>
+ <table id='organizations-list'>
+ <colgroup>
+ <col width="60%">
+ <col width="20%">
+ <col width="20%">
+ </colgroup>
+
+ <tr>
+ <th><%= _('Profile') %></th>
+ <th><%= _('Actions') %></th>
+ <th><%= _('Type') %>
+
+ <%= select_tag(:type, options_for_select(@types_filter, @type)) %>
+ </th>
+ </tr>
+
+ <% @collection.each do |p| %>
+ <tr title="<%= p.name %>">
+ <td><%= link_to_profile p.short_name, p.identifier, :title => p.name %> </td>
+
+ <td class='actions'>
+ <div class="members-buttons-cell">
+ <% if p.visible %>
+ <%= button_without_text :'deactivate-user', _('Deactivate'), {:action => 'deactivate', :id => p.id}, :class => 'action', 'data-confirm' => _("Do you want to deactivate this organization?") %>
+ <% else %>
+ <%= button_without_text :'activate-user', _('Activate'), {:action => 'activate', :id => p.id}, :class => 'action', 'data-confirm' => _("Do you want to activate this organization?") %>
+ <% end %>
+ <%= button_without_text :'delete', _('Remove'), {:action => 'destroy', :id => p.id}, :class => 'action', 'data-method' => :post, 'data-confirm' => _("Do you want to destroy this organization?") %>
+ </div>
+ </td>
+
+ <td> <%= _("#{p.type}") %> </td>
+ </tr>
+ <% end %>
+ </table>
+
+ <div>
+ <%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %>
+ </div>
+</div>
=====================================
app/views/organizations/index.html.erb
=====================================
--- /dev/null
+++ b/app/views/organizations/index.html.erb
@@ -0,0 +1,30 @@
+<h1><%= _('Organizations') %></h1>
+
+<%= form_tag( { :action => 'index' }, :method => 'get', :id => 'manage-profiles' ) do %>
+
+ <div class="search-field">
+ <span class="formfield">
+ <%= text_field_tag 'q', @q, :title => _('Find organizations'), :style=>"width:85%" %>
+ </span>
+
+ <%= submit_button(:search, _('Search')) %>
+ </div>
+
+ <div class="environment-profiles-results-header">
+ <div id='environment-profiles-filter-title'><%= @title %></div>
+
+ <div id="environment-profiles-filter-filter">
+ <strong><%= _("Filter by: ") %></strong>
+ <%= select_tag(:filter, options_for_select([[_('Any'), 'any'],[_('Disabled'), "disabled"], [_('Enabled') , "enabled"]], @filter)) %>
+ </div>
+ <div style="clear: both"></div>
+ </div>
+
+ <%= render :partial => 'results' %>
+
+ <% button_bar do %>
+ <%= button :back, _('Back'), :controller => 'admin_panel' %>
+ <% end %>
+<% end %>
+
+<%= javascript_include_tag 'manage-organizations' %>
=====================================
app/views/organizations/index.js.erb
=====================================
--- /dev/null
+++ b/app/views/organizations/index.js.erb
@@ -0,0 +1 @@
+../../views/shared/admin/profiles/index.js.rb
\ No newline at end of file
=====================================
app/views/shared/admin/profiles/index.js.rb
=====================================
--- /dev/null
+++ b/app/views/shared/admin/profiles/index.js.rb
@@ -0,0 +1 @@
+jQuery('#manage-profiles .results').replaceWith('<%= escape_javascript(render 'results') %>');
=====================================
app/views/users/_users_list.html.erb
=====================================
--- a/app/views/users/_users_list.html.erb
+++ b/app/views/users/_users_list.html.erb
@@ -1,5 +1,5 @@
-<div class="environment-users-results-header">
- <div id='environment-users-filter-title'><%= users_filter_title(@filter) %></div>
+<div class="environment-profiles-results-header">
+ <div id='environment-profiles-filter-title'><%= users_filter_title(@filter) %></div>
<%= filter_selector(@filter) %>
<div style="clear: both"></div>
</div>
=====================================
lib/noosfero/plugin.rb
=====================================
--- a/lib/noosfero/plugin.rb
+++ b/lib/noosfero/plugin.rb
@@ -299,6 +299,18 @@ class Noosfero::Plugin
nil
end
+ # -> Filters the types of organizations that are shown on manage organizations
+ # returns a scope filtered by the specified type
+ def filter_manage_organization_scope type
+ nil
+ end
+
+ # -> Add new options for manage organization filters
+ # returns an array of new options
+ # i.e [[_('Type'), 'type'], [_('Type2'), 'type2']]
+ def organization_types_filter_options
+ nil
+ end
# -> Adds content to profile editor info and settings
# returns = lambda block that creates html code or raw rhtml/html.erb
def profile_editor_extras
=====================================
public/javascripts/manage-organizations.js
=====================================
--- /dev/null
+++ b/public/javascripts/manage-organizations.js
@@ -0,0 +1,49 @@
+(function($) {
+ // Pagination
+ $('#manage-profiles').on('click', '.pagination a', function () {
+ $.ajax({
+ url: this.href,
+ beforeSend: function(){$('#manage-profiles .results').addClass('fetching')},
+ complete: function() {$('#manage-profiles .results').removeClass('fetching')},
+ dataType: 'script'
+ })
+ return false;
+ });
+
+ // Actions
+ $('#manage-profiles').on('click', '.action', function () {
+ if(confirm($(this).data('confirm'))) {
+ $.ajax({
+ url: this.href,
+ method: $(this).data('method') || 'get',
+ dataType: 'script',
+ success: function(data){
+ if(data)
+ display_notice(JSON.parse(data));
+ },
+ error: function(xhr, textStatus, message){
+ display_notice(message);
+ }
+ });
+ $('#manage-profiles').submit();
+ }
+ return false;
+ });
+
+ // Sorting and Views
+ $('#manage-profiles select').live('change', function(){
+ $('#manage-profiles').submit();
+ });
+
+ // Form Ajax submission
+ $('#manage-profiles').submit(function () {
+ $.ajax({
+ url: this.action,
+ data: $(this).serialize(),
+ beforeSend: function(){$('#manage-profiles .results').addClass('fetching')},
+ complete: function() {$('#manage-profiles .results').removeClass('fetching')},
+ dataType: 'script'
+ })
+ return false;
+ });
+})(jQuery);
=====================================
public/stylesheets/application.css
=====================================
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -4763,7 +4763,7 @@ h1#agenda-title {
float: right;
}
-#environment-users-search form {
+#environment-profiles-search form {
padding: 10px;
margin-bottom: 15px;
background-color: #E6E6E6;
@@ -4771,14 +4771,14 @@ h1#agenda-title {
-webkit-border-radius: 5px;
}
-.environment-users-results-header {
+.environment-profiles-results-header {
font-size: 0.9em;
padding: 6px 0px 0px 0px;
margin:0 0 5px 0;
border-bottom: 2px dotted #999;
text-align: right;
}
-#environment-users-filter-title {
+#environment-profiles-filter-title {
font-weight: bold;
font-size: 130%;
line-height: 35px;
=====================================
test/factories.rb
=====================================
--- a/test/factories.rb
+++ b/test/factories.rb
@@ -65,7 +65,7 @@ module Noosfero::Factory
###### old stuff to be rearranged
def create_admin_user(env)
admin_user = User.find_by_login('adminuser') || create_user('adminuser', :email => 'adminuser at noosfero.org', :password => 'adminuser', :password_confirmation => 'adminuser', :environment => env)
- admin_role = Role.find_by_name('admin_role') || Role.create!(:name => 'admin_role', :permissions => ['view_environment_admin_panel','edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_trusted_sites', 'manage_environment_validators', 'manage_environment_users', 'manage_environment_templates', 'manage_environment_licenses', 'edit_appearance'])
+ admin_role = Role.find_by_name('admin_role') || Role.create!(:name => 'admin_role', :permissions => ['view_environment_admin_panel','edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_trusted_sites', 'manage_environment_validators', 'manage_environment_users', 'manage_environment_organizations', 'manage_environment_templates', 'manage_environment_licenses', 'edit_appearance'])
create(RoleAssignment, :accessor => admin_user.person, :role => admin_role, :resource => env) unless admin_user.person.role_assignments.map{|ra|[ra.role, ra.accessor, ra.resource]}.include?([admin_role, admin_user, env])
admin_user.login
end
=====================================
test/fixtures/roles.yml
=====================================
--- a/test/fixtures/roles.yml
+++ b/test/fixtures/roles.yml
@@ -35,6 +35,7 @@ four:
- moderate_comments
- perform_task
- manage_environment_users
+ - manage_environment_organizations
- manage_environment_templates
- manage_environment_licenses
profile_admin:
@@ -94,6 +95,7 @@ environment_administrator:
- manage_environment_validators
- moderate_comments
- manage_environment_users
+ - manage_environment_organizations
- edit_profile
- destroy_profile
- manage_environment_templates
=====================================
test/functional/admin_panel_controller_test.rb
=====================================
--- a/test/functional/admin_panel_controller_test.rb
+++ b/test/functional/admin_panel_controller_test.rb
@@ -17,12 +17,12 @@ class AdminPanelControllerTest < ActionController::TestCase
should 'manage the correct environment' do
current = fast_create(Environment, :name => 'test environment', :is_default => false)
current.domains.create!(:name => 'example.com')
-
+
@request.expects(:host).returns('example.com').at_least_once
get :index
assert_equal current, assigns(:environment)
end
-
+
should 'link to site_info editing page' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/admin_panel/site_info' }
@@ -379,36 +379,4 @@ class AdminPanelControllerTest < ActionController::TestCase
assert_equal body, Environment.default.signup_welcome_screen_body
assert !Environment.default.signup_welcome_screen_body.blank?
end
-
- should 'show list to deactivate organizations' do
- enabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"enabled community")
- disabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"disabled community")
- user = create_user('user')
-
- disabled_community.disable
-
- Environment.default.add_admin user.person
- login_as('user')
-
- get :manage_organizations_status, :filter=>"enabled"
- assert_match(/Organization profiles - enabled/, @response.body)
- assert_match(/enabled community/, @response.body)
- assert_not_match(/disabled community/, @response.body)
- end
-
- should 'show list to activate organizations' do
- enabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"enabled community")
- disabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"disabled community")
- user = create_user('user')
-
- disabled_community.disable
-
- Environment.default.add_admin user.person
- login_as('user')
-
- get :manage_organizations_status, :filter=>"disabled"
- assert_match(/Organization profiles - disabled/, @response.body)
- assert_not_match(/enabled community/, @response.body)
- assert_match(/disabled community/, @response.body)
- end
end
=====================================
test/functional/organizations_controller_test.rb
=====================================
--- /dev/null
+++ b/test/functional/organizations_controller_test.rb
@@ -0,0 +1,116 @@
+require_relative "../test_helper"
+require 'organizations_controller'
+
+# Re-raise errors caught by the controller.
+class OrganizationsController; def rescue_action(e) raise e end; end
+
+class OrganizationsControllerTest < ActionController::TestCase
+
+ def setup
+ @controller = OrganizationsController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+
+ Environment.destroy_all
+ @environment = fast_create(Environment, :is_default => true)
+
+ admin_user = create_user_with_permission('adminuser', 'manage_environment_organizations', environment)
+ login_as('adminuser')
+ end
+
+ attr_accessor :environment
+
+ should 'not access without right permission' do
+ create_user('guest')
+ login_as 'guest'
+ get :index
+ assert_response 403 # forbidden
+ end
+
+ should 'grant access with right permission' do
+ get :index
+ assert_response :success
+ end
+
+ should 'show list to deactivate organizations' do
+ enabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"enabled community")
+ disabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"disabled community")
+ disabled_community.disable
+
+ get :index, :filter => 'enabled'
+
+ assert_match(/enabled community/, @response.body)
+ assert_not_match(/disabled community/, @response.body)
+ end
+
+ should 'show list to activate organizations' do
+ enabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"enabled community")
+ disabled_community = fast_create(Community, :environment_id => Environment.default, :name=>"disabled community")
+ disabled_community.disable
+
+ get :index, :filter => 'disabled'
+
+ assert_not_match(/enabled community/, @response.body)
+ assert_match(/disabled community/, @response.body)
+ end
+
+ should 'show list only of enterprises' do
+ community = fast_create(Community, :environment_id => Environment.default, :name=>"Community Test")
+ enterprise = fast_create(Enterprise, :environment_id => Environment.default, :name=>"Enterprise Test")
+
+ get :index, :type => 'Enterprise'
+
+ assert_match(/Enterprise Test/, @response.body)
+ assert_not_match(/Community Test/, @response.body)
+ end
+
+ should 'show list only of communities' do
+ community = fast_create(Community, :environment_id => Environment.default, :name=>"Community Test")
+ enterprise = fast_create(Enterprise, :environment_id => Environment.default, :name=>"Enterprise Test")
+
+ get :index, :type => 'Community'
+
+ assert_not_match(/Enterprise Test/, @response.body)
+ assert_match(/Community Test/, @response.body)
+ end
+
+ should 'show list all organizations' do
+ community = fast_create(Community, :environment_id => Environment.default, :name=>"Community Test")
+ enterprise = fast_create(Enterprise, :environment_id => Environment.default, :name=>"Enterprise Test")
+
+ get :index, :type => 'any'
+
+ assert_match(/Enterprise Test/, @response.body)
+ assert_match(/Community Test/, @response.body)
+ end
+
+ should 'activate organization profile' do
+ organization = fast_create(Organization, :visible => false, :environment_id => environment.id)
+ assert organization.disabled?
+
+ get :activate, {:id => organization.id}
+ organization.reload
+
+ assert organization.enabled?
+ end
+
+ should 'deactivate organization profile' do
+ organization = fast_create(Organization, :visible => true, :environment_id => environment.id)
+ assert organization.enabled?
+
+ get :deactivate, {:id => organization.id}
+ organization.reload
+
+ assert organization.disabled?
+ end
+
+ should 'destroy organization profile' do
+ organization = fast_create(Organization, :environment_id => environment.id)
+
+ post :destroy, {:id => organization.id}
+
+ assert_raise ActiveRecord::RecordNotFound do
+ organization.reload
+ end
+ end
+end
=====================================
test/functional/profile_editor_controller_test.rb
=====================================
--- a/test/functional/profile_editor_controller_test.rb
+++ b/test/functional/profile_editor_controller_test.rb
@@ -1152,57 +1152,4 @@ class ProfileEditorControllerTest < ActionController::TestCase
get :index, :profile => user.identifier
assert_tag :tag => 'div', :descendant => { :tag => 'a', :content => 'Edit Header and Footer' }
end
-
- should 'deactivate organization profile' do
- @request.env['HTTP_REFERER'] = 'http://localhost:3000/admin/admin_panel/manage_organizations_status'
- user = create_user('user').person
- Environment.default.add_admin user
- login_as('user')
-
- community = fast_create(Community)
- assert_equal true, community.enable
-
- get :index, :profile => community.identifier
- get :deactivate_profile, {:profile => community.identifier, :id => community.id}
- assert_equal @request.session[:notice], "The profile '#{community.name}' was deactivated."
- end
-
- should 'activate organization profile' do
- @request.env['HTTP_REFERER'] = 'http://localhost:3000/admin/admin_panel/manage_organizations_status'
- user = create_user('user').person
- Environment.default.add_admin user
- login_as('user')
-
- community = fast_create(Community)
- assert_equal true, community.disable
-
- get :index, :profile => community.identifier
- get :activate_profile, {:profile => community.identifier, :id => community.id}
- assert_equal @request.session[:notice], "The profile '#{community.name}' was activated."
- end
-
- should 'not deactivate organization profile if user is not an admin' do
- @request.env['HTTP_REFERER'] = 'http://localhost:3000/admin/admin_panel/manage_organizations_status'
- user = create_user('user').person
- login_as('user')
-
- community = fast_create(Community)
- get :index, :profile => community.identifier
- get :deactivate_profile, {:profile => community.identifier, :id => community.id}
- assert_not_equal @request.session[:notice], "The profile '#{community.name}' was disabled."
- end
-
- should 'destroy organization profile' do
- @request.env['HTTP_REFERER'] = 'http://localhost:3000/admin/admin_panel/manage_organizations_status'
- user = create_user('user').person
- Environment.default.add_admin user
- login_as('user')
-
- community = fast_create(Community)
- assert_equal true, community.enable
-
- get :index, :profile => community.identifier
- post :destroy_profile, {:profile => community.identifier, :id => community.id}
- assert_equal @request.session[:notice], "The profile was deleted."
- end
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/4c1e0c9f4535c1cd2292b9cc62391777ac4afdc4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150528/2dc6c05a/attachment-0001.html>
More information about the Noosfero-dev
mailing list