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) public function sendNotification(User $user, Invoice $invoice, $notificationType, Payment $payment = null)
{ {
if (!$user->email) { if (! $user->email || $user->cannot('view', $invoice)) {
return; return;
} }
$entityType = $invoice->getEntityType(); $entityType = $invoice->getEntityType();
$view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}"; $view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}";
$account = $user->account; $account = $user->account;
@ -64,7 +64,7 @@ class UserMailer extends Mailer
'invoice' => $invoice->invoice_number, 'invoice' => $invoice->invoice_number,
'client' => $client->getDisplayName() 'client' => $client->getDisplayName()
]); ]);
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); $this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
} }
@ -88,7 +88,7 @@ class UserMailer extends Mailer
'contactName' => $invitation->contact->getDisplayName(), 'contactName' => $invitation->contact->getDisplayName(),
'invoiceNumber' => $invoice->invoice_number, 'invoiceNumber' => $invoice->invoice_number,
]; ];
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); $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(); $faker = Faker\Factory::create();
$company = Company::create(); $company = Company::create();
$account = Account::create([ $account = Account::create([
'name' => $faker->name, 'name' => $faker->name,
'address1' => $faker->streetAddress, 'address1' => $faker->streetAddress,
@ -28,7 +28,7 @@ class UserTableSeeder extends Seeder
'city' => $faker->city, 'city' => $faker->city,
'state' => $faker->state, 'state' => $faker->state,
'postal_code' => $faker->postcode, 'postal_code' => $faker->postcode,
'country_id' => Country::all()->random()->id, 'country_id' => Country::all()->random()->id,
'account_key' => str_random(RANDOM_KEY_LENGTH), 'account_key' => str_random(RANDOM_KEY_LENGTH),
'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)),
'work_phone' => $faker->phoneNumber, 'work_phone' => $faker->phoneNumber,
@ -50,12 +50,13 @@ class UserTableSeeder extends Seeder
'confirmed' => true, 'confirmed' => true,
'notify_sent' => false, 'notify_sent' => false,
'notify_paid' => false, 'notify_paid' => false,
'is_admin' => 1,
]); ]);
Affiliate::create([ Affiliate::create([
'affiliate_key' => SELF_HOST_AFFILIATE_KEY 'affiliate_key' => SELF_HOST_AFFILIATE_KEY
]); ]);
} }
} }