Skip to content

Commit

Permalink
Merge branch 'k-nut-2990-server-error-for-organization_list'
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed May 24, 2016
2 parents e538161 + 391ebe7 commit 28eb8c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions ckan/controllers/group.py
Expand Up @@ -159,6 +159,7 @@ def index(self):
sort_by = c.sort_by_selected = request.params.get('sort')
try:
self._check_access('site_read', context)
self._check_access('group_list', context)
except NotAuthorized:
abort(403, _('Not authorized to see this page'))

Expand Down
17 changes: 17 additions & 0 deletions ckan/tests/controllers/test_organization.py
@@ -1,6 +1,7 @@
from bs4 import BeautifulSoup
from nose.tools import assert_equal, assert_true
from routes import url_for
from mock import patch

from ckan.tests import factories, helpers
from ckan.tests.helpers import webtest_submit, submit_and_follow, assert_in
Expand Down Expand Up @@ -61,6 +62,22 @@ def test_all_fields_saved(self):
assert_equal(group['description'], 'Sciencey datasets')


class TestOrganizationList(helpers.FunctionalTestBase):
def setup(self):
super(TestOrganizationList, self).setup()
self.app = helpers._get_test_app()
self.user = factories.User()
self.user_env = {'REMOTE_USER': self.user['name'].encode('ascii')}
self.organization_list_url = url_for(controller='organization',
action='index')

@patch('ckan.logic.auth.get.organization_list', return_value={'success': False})
def test_error_message_shown_when_no_organization_list_permission(self, mock_check_access):
response = self.app.get(url=self.organization_list_url,
extra_environ=self.user_env,
status=403)


class TestOrganizationRead(helpers.FunctionalTestBase):
def setup(self):
super(TestOrganizationRead, self).setup()
Expand Down

0 comments on commit 28eb8c0

Please sign in to comment.