Fix for tests

This commit is contained in:
Hillel Coren 2016-06-07 14:40:54 +03:00
parent 1eb334f3b4
commit 5489ade5ff
2 changed files with 9 additions and 8 deletions

View File

@ -36,10 +36,10 @@ class UserMailer extends Mailer
public function sendNotification(User $user, Invoice $invoice, $notificationType, Payment $payment = null)
{
if (!$user->email) {
if (! $user->email || $user->cannot('view', $invoice)) {
return;
}
$entityType = $invoice->getEntityType();
$view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}";
$account = $user->account;
@ -64,7 +64,7 @@ class UserMailer extends Mailer
'invoice' => $invoice->invoice_number,
'client' => $client->getDisplayName()
]);
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
@ -88,7 +88,7 @@ class UserMailer extends Mailer
'contactName' => $invitation->contact->getDisplayName(),
'invoiceNumber' => $invoice->invoice_number,
];
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
}

View File

@ -20,7 +20,7 @@ class UserTableSeeder extends Seeder
$faker = Faker\Factory::create();
$company = Company::create();
$account = Account::create([
'name' => $faker->name,
'address1' => $faker->streetAddress,
@ -28,7 +28,7 @@ class UserTableSeeder extends Seeder
'city' => $faker->city,
'state' => $faker->state,
'postal_code' => $faker->postcode,
'country_id' => Country::all()->random()->id,
'country_id' => Country::all()->random()->id,
'account_key' => str_random(RANDOM_KEY_LENGTH),
'invoice_terms' => $faker->text($faker->numberBetween(50, 300)),
'work_phone' => $faker->phoneNumber,
@ -50,12 +50,13 @@ class UserTableSeeder extends Seeder
'confirmed' => true,
'notify_sent' => false,
'notify_paid' => false,
'is_admin' => 1,
]);
Affiliate::create([
'affiliate_key' => SELF_HOST_AFFILIATE_KEY
]);
}
}
}