Renamed 'ip' column to 'subscribed_ip'

- updated code based on PR review
This commit is contained in:
Jonathan Labreuille
2016-11-09 11:43:08 +01:00
parent 1a6b032943
commit c22d3c8957
4 changed files with 22 additions and 18 deletions

View File

@@ -361,26 +361,34 @@ class SubscribersTest extends MailPoetTest {
expect($response->errors[0]['message'])->contains('has no method');
}
function testItCanSubscribeAUser() {
// set ip address
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
function testItCannotSubscribeWithoutSegments() {
$router = new Subscribers();
// missing segment
$response = $router->subscribe(array(
'email' => 'toto@mailpoet.com'
// no segments specified
));
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('Please select a list.');
}
// proper subscription
function testItCanSubscribe() {
$router = new Subscribers();
$response = $router->subscribe(array(
'email' => 'toto@mailpoet.com',
'segments' => array($this->segment_1->id, $this->segment_2->id)
));
expect($response->status)->equals(APIResponse::STATUS_OK);
}
function testItCannotMassSubscribe() {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$router = new Subscribers();
$response = $router->subscribe(array(
'email' => 'toto@mailpoet.com',
'segments' => array($this->segment_1->id, $this->segment_2->id)
));
try {
$response = $router->subscribe(array(