Fix #16
This commit is contained in:
parent
8d9208544f
commit
44bdef8b5c
|
@ -27,6 +27,7 @@
|
||||||
this.ckan.module('allowed-users', function ($, _) {
|
this.ckan.module('allowed-users', function ($, _) {
|
||||||
return {
|
return {
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
this.original_acquire_url = $('[name=acquire_url]').val();
|
||||||
$('#field-private').on('change', this._onChange);
|
$('#field-private').on('change', this._onChange);
|
||||||
this._onChange(); //Initial
|
this._onChange(); //Initial
|
||||||
},
|
},
|
||||||
|
@ -34,17 +35,19 @@ this.ckan.module('allowed-users', function ($, _) {
|
||||||
var ds_private = $('#field-private').val();
|
var ds_private = $('#field-private').val();
|
||||||
|
|
||||||
if (ds_private == 'True') {
|
if (ds_private == 'True') {
|
||||||
$('#field-allowed_users_str').prop('disabled', false); //Enable
|
$('#field-allowed_users_str').prop('disabled', false); //Enable
|
||||||
$('#field-acquire_url').prop('disabled', false); //Enable
|
$('#field-acquire_url').prop('disabled', false); //Enable
|
||||||
$('#field-searchable').prop('disabled', false); //Enable
|
$('#field-searchable').prop('disabled', false); //Enable
|
||||||
|
$('[name=acquire_url]').val(this.original_acquire_url); //Set previous acquire URL
|
||||||
} else {
|
} else {
|
||||||
$('#field-allowed_users_str').prop('disabled', true); //Disable
|
$('#field-allowed_users_str').prop('disabled', true); //Disable
|
||||||
$('#field-acquire_url').prop('disabled', true); //Disable
|
$('#field-acquire_url').prop('disabled', true); //Disable
|
||||||
$('#field-searchable').prop('disabled', true); //Disable
|
$('#field-searchable').prop('disabled', true); //Disable
|
||||||
|
|
||||||
//Remove previous values
|
//Remove previous values
|
||||||
$('#field-allowed_users_str').select2('val', '');
|
$('#field-allowed_users_str').select2('val', '');
|
||||||
$('#field-acquire_url').val('');
|
this.original_acquire_url = $('[name=acquire_url]').val(); //Get previous value
|
||||||
|
$('[name=acquire_url]').val(''); //Acquire URL should be reseted
|
||||||
$('#field-searchable').val('True');
|
$('#field-searchable').val('True');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ class TestSelenium(unittest.TestCase):
|
||||||
driver.find_element_by_id('username').send_keys(user)
|
driver.find_element_by_id('username').send_keys(user)
|
||||||
driver.find_element_by_name('submit').click()
|
driver.find_element_by_name('submit').click()
|
||||||
|
|
||||||
def create_ds_first_page(self, name, description, tags, private, searchable, allowed_users, acquire_url):
|
def fill_ds_general_info(self, name, description, tags, private, searchable, allowed_users, acquire_url):
|
||||||
# FIRST PAGE: Dataset properties
|
# FIRST PAGE: Dataset properties
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
driver.get(self.base_url)
|
driver.get(self.base_url)
|
||||||
|
@ -160,7 +160,7 @@ class TestSelenium(unittest.TestCase):
|
||||||
|
|
||||||
def create_ds(self, name, description, tags, private, searchable, allowed_users, acquire_url, resource_url, resource_name, resource_description, resource_format):
|
def create_ds(self, name, description, tags, private, searchable, allowed_users, acquire_url, resource_url, resource_name, resource_description, resource_format):
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
self.create_ds_first_page(name, description, tags, private, searchable, allowed_users, acquire_url)
|
self.fill_ds_general_info(name, description, tags, private, searchable, allowed_users, acquire_url)
|
||||||
|
|
||||||
# SECOND PAGE: Add Resources
|
# SECOND PAGE: Add Resources
|
||||||
try:
|
try:
|
||||||
|
@ -182,6 +182,11 @@ class TestSelenium(unittest.TestCase):
|
||||||
# THIRD PAGE: Metadata
|
# THIRD PAGE: Metadata
|
||||||
driver.find_element_by_xpath('(//button[@name=\'save\'])[4]').click()
|
driver.find_element_by_xpath('(//button[@name=\'save\'])[4]').click()
|
||||||
|
|
||||||
|
def modify_ds(self, url, name, description, tags, private, searchable, allowed_users, acquire_url):
|
||||||
|
driver = self.driver
|
||||||
|
driver.get('%sdataset/edit/%s' % (self.base_url, url))
|
||||||
|
self.fill_ds_general_info(name, description, tags, private, searchable, allowed_users, acquire_url)
|
||||||
|
|
||||||
def check_ds_values(self, url, private, searchable, allowed_users, acquire_url):
|
def check_ds_values(self, url, private, searchable, allowed_users, acquire_url):
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
driver.get(self.base_url + 'dataset/edit/' + url)
|
driver.get(self.base_url + 'dataset/edit/' + url)
|
||||||
|
@ -330,7 +335,7 @@ class TestSelenium(unittest.TestCase):
|
||||||
# Create the dataset
|
# Create the dataset
|
||||||
self.login(user, user)
|
self.login(user, user)
|
||||||
pkg_name = 'Dataset 2'
|
pkg_name = 'Dataset 2'
|
||||||
self.create_ds_first_page(pkg_name, 'Example description', ['tag1'], True, True, allowed_users, acquire_url)
|
self.fill_ds_general_info(pkg_name, 'Example description', ['tag1'], True, True, allowed_users, acquire_url)
|
||||||
|
|
||||||
# Check the error message
|
# Check the error message
|
||||||
msg_error = self.driver.find_element_by_xpath('//div[@id=\'content\']/div[3]/div/section/div/form/div/ul/li').text
|
msg_error = self.driver.find_element_by_xpath('//div[@id=\'content\']/div[3]/div/section/div/form/div/ul/li').text
|
||||||
|
@ -481,4 +486,29 @@ class TestSelenium(unittest.TestCase):
|
||||||
acquired = user in adquiring_users
|
acquired = user in adquiring_users
|
||||||
in_org = user in orgs[0]['users']
|
in_org = user in orgs[0]['users']
|
||||||
self.check_user_access(pkg_name, url, False, acquired, in_org, private, searchable, acquire_url)
|
self.check_user_access(pkg_name, url, False, acquired, in_org, private, searchable, acquire_url)
|
||||||
self.check_acquired(pkg_name, url, acquired, private)
|
self.check_acquired(pkg_name, url, acquired, private)
|
||||||
|
|
||||||
|
def test_bug_16(self):
|
||||||
|
"""
|
||||||
|
Private datasets cannot be turned to public datasets when the Acquisition URL is set
|
||||||
|
"""
|
||||||
|
user = 'user1'
|
||||||
|
self.default_register(user)
|
||||||
|
|
||||||
|
# The user creates a dataset
|
||||||
|
self.login(user, user)
|
||||||
|
pkg_name = 'Dataset 1'
|
||||||
|
description = 'Example Description'
|
||||||
|
tags = ['tag1', 'tag2', 'tag3']
|
||||||
|
url = get_dataset_url(pkg_name)
|
||||||
|
self.create_ds(pkg_name, 'Example description', ['tag1', 'tag2', 'tag3'], True, True,
|
||||||
|
[], 'http://example.com', 'http://upm.es', 'UPM Main', 'Example Description', 'CSV')
|
||||||
|
|
||||||
|
self.modify_ds(self, url, pkg_name, description, tags, False, None, None, None)
|
||||||
|
expected_url = 'dataset/%s' % url
|
||||||
|
current_url = self.driver.current_url
|
||||||
|
self.assertEquals(expected_url, current_url)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue