Address PR review remarks [MAILPOET-1721]

This commit is contained in:
wxa
2019-01-22 12:25:59 +03:00
parent a4ff9822ad
commit 5bf968fbc6
4 changed files with 7 additions and 7 deletions

View File

@ -108,7 +108,7 @@ const itemActions = [
); );
}, },
display: function display(segment) { display: function display(segment) {
return isWPUsersSegment(segment); return !isSpecialSegment(segment);
}, },
}, },
{ {

View File

@ -144,10 +144,10 @@ class API {
$found_segments_ids = array(); $found_segments_ids = array();
foreach($found_segments as $segment) { foreach($found_segments as $segment) {
if($segment->type === Segment::TYPE_WP_USERS) { if($segment->type === Segment::TYPE_WP_USERS) {
throw new \Exception(__(sprintf("Can't subscribe to a WordPress Users list with ID %d.", $segment->id), 'mailpoet')); throw new \Exception(__(sprintf("Can't unsubscribe from a WordPress Users list with ID %d.", $segment->id), 'mailpoet'));
} }
if($segment->type === Segment::TYPE_WC_USERS) { if($segment->type === Segment::TYPE_WC_USERS) {
throw new \Exception(__(sprintf("Can't subscribe to a WooCommerce Customers list with ID %d.", $segment->id), 'mailpoet')); throw new \Exception(__(sprintf("Can't unsubscribe from a WooCommerce Customers list with ID %d.", $segment->id), 'mailpoet'));
} }
$found_segments_ids[] = $segment->id; $found_segments_ids[] = $segment->id;
} }
@ -168,7 +168,7 @@ class API {
function getLists() { function getLists() {
return Segment::whereNotIn('type', [Segment::TYPE_WP_USERS, Segment::TYPE_WC_USERS]) return Segment::whereNotIn('type', [Segment::TYPE_WP_USERS, Segment::TYPE_WC_USERS])
->findArray(); ->findArray();
} }
function addSubscriber(array $subscriber, $segments = array(), $options = array()) { function addSubscriber(array $subscriber, $segments = array(), $options = array()) {

View File

@ -80,7 +80,7 @@ class Subscriber extends Model {
} }
function isWooCommerceUser() { function isWooCommerceUser() {
return $this->is_woocommerce_user == true; return (bool)$this->is_woocommerce_user;
} }
static function getCurrentWPUser() { static function getCurrentWPUser() {

View File

@ -621,7 +621,7 @@ class APITest extends \MailPoetTest {
$this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id)); $this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id));
$this->fail('WP Users segment exception should have been thrown.'); $this->fail('WP Users segment exception should have been thrown.');
} catch(\Exception $e) { } catch(\Exception $e) {
expect($e->getMessage())->equals("Can't subscribe to a WordPress Users list with ID {$segment->id}."); expect($e->getMessage())->equals("Can't unsubscribe from a WordPress Users list with ID {$segment->id}.");
} }
} }
@ -639,7 +639,7 @@ class APITest extends \MailPoetTest {
$this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id)); $this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id));
$this->fail('WooCommerce Customers segment exception should have been thrown.'); $this->fail('WooCommerce Customers segment exception should have been thrown.');
} catch(\Exception $e) { } catch(\Exception $e) {
expect($e->getMessage())->equals("Can't subscribe to a WooCommerce Customers list with ID {$segment->id}."); expect($e->getMessage())->equals("Can't unsubscribe from a WooCommerce Customers list with ID {$segment->id}.");
} }
} }