Skip to content

Commit

Permalink
[#1641] resource_create validates being passed an "url" parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaptista committed Apr 10, 2014
1 parent 5f44b70 commit 072b62b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions ckan/logic/action/create.py
Expand Up @@ -261,6 +261,7 @@ def resource_create(context, data_dict):

package_id = _get_or_bust(data_dict, 'package_id')
data_dict.pop('package_id')
_get_or_bust(data_dict, 'url')

pkg_dict = _get_action('package_show')(context, {'id': package_id})

Expand Down
29 changes: 29 additions & 0 deletions ckan/new_tests/logic/action/test_create.py
@@ -0,0 +1,29 @@
import nose.tools

import ckan.model as model
import ckan.logic as logic
import ckan.new_tests.helpers as helpers
import ckan.new_tests.factories as factories

eq = nose.tools.eq_


class TestCreate(object):

@classmethod
def setup_class(cls):
helpers.reset_db()

def setup(self):
model.repo.rebuild_db()

def test_resource_create_requires_url(self):
user = factories.User()
dataset = factories.Dataset(user=user)
data_dict = {
'package_id': dataset['id']
}

nose.tools.assert_raises(logic.ValidationError,
helpers.call_action,
'resource_create', **data_dict)

0 comments on commit 072b62b

Please sign in to comment.