Merge branch 'develop' into feature/gutenberg-terms-parent
This commit is contained in:
commit
944e097fcf
|
@ -211,6 +211,10 @@
|
|||
max-width: 100% !important; }
|
||||
.wp-block-tainacan-search-bar .tainacan-search-container #taincan-search-bar-block input#taincan-search-bar-block_input {
|
||||
width: 100% !important; } }
|
||||
.wp-block-tainacan-search-bar .search-bar-collection-header-container .search-bar-collection-header-title {
|
||||
max-width: 1400px;
|
||||
margin-left: auto;
|
||||
margin-right: auto; }
|
||||
@media only screen and (max-width: 768px) {
|
||||
.wp-block-tainacan-search-bar .search-bar-collection-header-container {
|
||||
flex-wrap: wrap !important; }
|
||||
|
@ -377,7 +381,7 @@
|
|||
text-align: center;
|
||||
text-decoration: none !important; }
|
||||
.wp-block-tainacan-search-bar .search-bar-collection-header-container.is-aligned-left {
|
||||
min-height: 100px;
|
||||
min-height: 115px;
|
||||
text-align: left;
|
||||
flex-direction: row-reverse;
|
||||
flex-wrap: nowrap;
|
||||
|
@ -385,7 +389,7 @@
|
|||
.wp-block-tainacan-search-bar .search-bar-collection-header-container.is-aligned-left .search-bar-collection-header-title {
|
||||
text-align: right; }
|
||||
.wp-block-tainacan-search-bar .search-bar-collection-header-container.is-aligned-right {
|
||||
min-height: 100px;
|
||||
min-height: 115px;
|
||||
text-align: right;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
|
@ -407,7 +411,7 @@
|
|||
.wp-block-tainacan-search-bar .search-bar-collection-header-container .search-bar-collection-header-title span.label {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin-top: -12px;
|
||||
margin-top: -8px;
|
||||
font-weight: normal;
|
||||
font-size: 1rem; }
|
||||
@media only screen and (max-width: 1024px) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -142,7 +142,7 @@ class Media {
|
|||
|
||||
do_action('tainacan-pre-insert-attachment', $blob, $filename, $post_id);
|
||||
|
||||
$upload = wp_upload_bits( $filename, null, $blob );
|
||||
$upload = wp_upload_bits( $filename, null, '' );
|
||||
if( !empty( $upload['error'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,11 @@
|
|||
}
|
||||
}
|
||||
.search-bar-collection-header-container {
|
||||
.search-bar-collection-header-title {
|
||||
max-width: 1400px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
@media only screen and (max-width: 768px) {
|
||||
flex-wrap: wrap !important;
|
||||
|
||||
|
@ -352,7 +357,7 @@
|
|||
text-decoration: none !important;
|
||||
|
||||
&.is-aligned-left {
|
||||
min-height: 100px;
|
||||
min-height: 115px;
|
||||
text-align: left;
|
||||
flex-direction: row-reverse;
|
||||
flex-wrap: nowrap;
|
||||
|
@ -361,7 +366,7 @@
|
|||
.search-bar-collection-header-title { text-align: right; }
|
||||
}
|
||||
&.is-aligned-right {
|
||||
min-height: 100px;
|
||||
min-height: 115px;
|
||||
text-align: right;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
|
@ -388,7 +393,7 @@
|
|||
span.label {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin-top: -12px;
|
||||
margin-top: -8px;
|
||||
font-weight: normal;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
|
|
@ -616,10 +616,12 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$this->assertEquals('Lean Startup', $data['items'][0]['title']);
|
||||
|
||||
$metadata_1 = $item1->get_metadata();
|
||||
sort($metadata_1);
|
||||
|
||||
$duplicated = \Tainacan\Repositories\Items::get_instance()->fetch( (int) $data['items'][0]['id'] );
|
||||
|
||||
$metadata_2 = $duplicated->get_metadata();
|
||||
sort($metadata_2);
|
||||
|
||||
foreach( $metadata_1 as $k => $m ) {
|
||||
$this->assertEquals( $m->get_value(), $metadata_2[$k]->get_value() );
|
||||
|
@ -647,6 +649,7 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$this->assertEquals('publish', $created_item['status']);
|
||||
|
||||
$metadata_2 = $duplicated->get_metadata();
|
||||
sort($metadata_2);
|
||||
|
||||
foreach( $metadata_1 as $k => $m ) {
|
||||
$this->assertEquals( $m->get_value(), $metadata_2[$k]->get_value() );
|
||||
|
|
|
@ -14,9 +14,9 @@ use Tainacan\Entities\Collection;
|
|||
* @group permissions
|
||||
*/
|
||||
class Permissions extends TAINACAN_UnitTestCase {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function test_roles () {
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
|
@ -28,7 +28,7 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$new_user = $this->factory()->user->create(array( 'role' => 'subscriber' ));
|
||||
wp_set_current_user($new_user);
|
||||
$user_id = get_current_user_id();
|
||||
|
@ -37,23 +37,23 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
$this->assertTrue(user_can($user_id, $collection->cap->read, $collection->get_id()), 'A subscriber user cannot read Collections');
|
||||
$this->assertTrue(user_can($user_id, 'subscriber'));
|
||||
$this->assertFalse(user_can($user_id, $collection->cap->edit_post, $collection->get_id()), 'A subscriber user can edit a Collections?');
|
||||
|
||||
|
||||
|
||||
|
||||
$new_admin_user = $this->factory()->user->create(array( 'role' => 'administrator' ));
|
||||
wp_set_current_user($new_admin_user);
|
||||
$user_id = get_current_user_id();
|
||||
$this->assertTrue(user_can($user_id, 'administrator'));
|
||||
$this->assertTrue(user_can($user_id, $collection->cap->edit_post, $collection->get_id()), 'A administrator user cannot edit a Collections?');
|
||||
//TODO test all roles and check the capabilities
|
||||
|
||||
|
||||
$new_contributor_user = $this->factory()->user->create(array( 'role' => 'contributor' ));
|
||||
wp_set_current_user($new_contributor_user);
|
||||
$this->assertTrue($collection->can_read());
|
||||
$this->assertFalse($collection->can_publish());
|
||||
|
||||
|
||||
|
||||
|
||||
$this->assertTrue(user_can($new_admin_user, $collection->get_items_capabilities()->edit_posts, $collection->get_id()), 'admin should be able to edit items in the collection');
|
||||
|
||||
|
||||
$privateCollection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
|
@ -63,14 +63,14 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$this->assertTrue(user_can($new_admin_user, $collection->cap->read_post, $privateCollection->get_id()), 'admin should be able read private collection');
|
||||
|
||||
|
||||
// subsciber should not be able to
|
||||
$x = user_can($new_user, $collection->cap->read_post, $collection->get_id());
|
||||
$this->assertFalse(user_can($new_user, $collection->cap->read_post, $privateCollection->get_id()), 'subscriber should not be able read private collection');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group serialize_permission
|
||||
*/
|
||||
|
@ -83,19 +83,19 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$ser = base64_encode( maybe_serialize($collection));
|
||||
$u2 = $this->factory()->user->create(array( 'role' => 'subscriber' ));
|
||||
wp_set_current_user($u2);
|
||||
$collection_unser = maybe_unserialize( base64_decode($ser));
|
||||
$this->assertFalse(user_can($u2, $collection_unser->cap->edit_post, $collection_unser->get_id()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group permission_others_collections
|
||||
*/
|
||||
function test_edit_others_collections() {
|
||||
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
|
@ -104,7 +104,7 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$item = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
array(
|
||||
|
@ -113,10 +113,10 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$new_author_user = $this->factory()->user->create(array( 'role' => 'author' ));
|
||||
wp_set_current_user($new_author_user);
|
||||
|
||||
|
||||
$collection2 = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
|
@ -125,7 +125,7 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$item2 = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
array(
|
||||
|
@ -134,26 +134,26 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// Once we had a bug that items of all collections shared the same capability type. they should not.
|
||||
// This test avoid it to happen
|
||||
$this->assertNotEquals($item2->get_capabilities()->edit_posts, $item->get_capabilities()->edit_posts);
|
||||
|
||||
|
||||
$this->assertTrue(current_user_can( $item2->get_capabilities()->edit_post, $item2->get_id() ), 'author should be able to edit items in his collection');
|
||||
$this->assertFalse(current_user_can( $item->get_capabilities()->edit_post, $item->get_id() ), 'author should not be able to edit items in admins collection');
|
||||
|
||||
|
||||
$this->assertTrue($item2->can_edit(), 'author should be able to edit items in his collection');
|
||||
$this->assertFalse($item->can_edit(), 'author should not be able to edit items in admins collection');
|
||||
|
||||
|
||||
$this->assertNotEquals($item->get_capabilities()->edit_posts, $item2->get_capabilities()->edit_posts);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group permission_others_collections
|
||||
*/
|
||||
function test_edit_others_collections_tainacan_role() {
|
||||
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
|
@ -162,7 +162,7 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$item = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
array(
|
||||
|
@ -171,10 +171,10 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$new_author_user = $this->factory()->user->create(array( 'role' => 'tainacan-author' ));
|
||||
wp_set_current_user($new_author_user);
|
||||
|
||||
|
||||
$collection2 = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
|
@ -183,7 +183,7 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$item2 = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
array(
|
||||
|
@ -192,26 +192,26 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// Once we had a bug that items of all collections shared the same capability type. they should not.
|
||||
// This test avoid it to happen
|
||||
$this->assertNotEquals($item2->get_capabilities()->edit_posts, $item->get_capabilities()->edit_posts);
|
||||
|
||||
|
||||
$this->assertTrue(current_user_can( $item2->get_capabilities()->edit_post, $item2->get_id() ), 'author should be able to edit items in his collection');
|
||||
$this->assertFalse(current_user_can( $item->get_capabilities()->edit_post, $item->get_id() ), 'author should not be able to edit items in admins collection');
|
||||
|
||||
|
||||
$this->assertTrue($item2->can_edit(), 'author should be able to edit items in his collection');
|
||||
$this->assertFalse($item->can_edit(), 'author should not be able to edit items in admins collection');
|
||||
|
||||
|
||||
$this->assertNotEquals($item->get_capabilities()->edit_posts, $item2->get_capabilities()->edit_posts);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function test_read_item() {
|
||||
|
||||
|
||||
$ItemRepo = \Tainacan\Repositories\Items::get_instance();
|
||||
$ColRepo = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
|
@ -221,7 +221,7 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$item = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
array(
|
||||
|
@ -231,33 +231,36 @@ class Permissions extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$subscriber = $this->factory()->user->create(array( 'role' => 'subscriber' ));
|
||||
wp_set_current_user($subscriber);
|
||||
|
||||
|
||||
wp_logout();
|
||||
|
||||
|
||||
$this->assertTrue($item->can_read());
|
||||
|
||||
|
||||
$item->set_status('private');
|
||||
$item->validate();
|
||||
$item = $ItemRepo->insert($item);
|
||||
|
||||
|
||||
$this->assertFalse($item->can_read());
|
||||
|
||||
|
||||
$item->set_status('publish');
|
||||
$item->validate();
|
||||
$item = $ItemRepo->insert($item);
|
||||
|
||||
|
||||
$this->assertTrue($item->can_read());
|
||||
|
||||
|
||||
$collection->set_status('private');
|
||||
$collection->validate();
|
||||
$collection = $ColRepo->insert($collection);
|
||||
|
||||
|
||||
// refresh item
|
||||
$item = new \Tainacan\Entities\Item($item->get_id());
|
||||
|
||||
$this->assertFalse($item->can_read());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue