Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
89bfd2b
composer update
djaiss Mar 4, 2018
2692ec5
wip
djaiss Mar 4, 2018
5aa5143
wip
djaiss Mar 4, 2018
c0a3215
wip
djaiss Mar 5, 2018
f2d6ac8
wip
djaiss Mar 14, 2018
e28d17b
wip
djaiss Mar 15, 2018
1d05bb2
wip
djaiss Mar 16, 2018
ea24eff
wip
djaiss Mar 16, 2018
8feb259
merge master
djaiss Mar 16, 2018
63b2c78
wip
djaiss Mar 17, 2018
a616fea
wip
djaiss Mar 18, 2018
e9658ef
wip
djaiss Mar 18, 2018
4a772a9
wip
djaiss Mar 19, 2018
3480bb3
wip
djaiss Mar 20, 2018
3cb1e73
wip
djaiss Mar 20, 2018
cc9b3fa
wip
djaiss Mar 21, 2018
a167d84
Merge branch 'replace-relationships' of github.com:monicahq/monica in…
djaiss Mar 22, 2018
e6d6a85
wip
djaiss Mar 22, 2018
1f03697
far from being over... depressing
djaiss Mar 22, 2018
7fb1f20
fix stupid mistake I made while freaking tired
djaiss Mar 22, 2018
4ade29d
wip
djaiss Mar 23, 2018
dd7622b
wip
djaiss Mar 23, 2018
99f8f3a
Add better design for displaying a relationship
djaiss Mar 24, 2018
4cf1c10
wip
djaiss Mar 25, 2018
15bc1dd
tests
djaiss Mar 25, 2018
91a6501
final test
djaiss Mar 25, 2018
941f5ee
api
djaiss Mar 26, 2018
1671a86
wip
djaiss Mar 26, 2018
f9d4595
merge master
djaiss Mar 26, 2018
55aae4b
styleci
djaiss Mar 26, 2018
a2edbeb
styleci
djaiss Mar 26, 2018
0b128cc
bump files
djaiss Mar 26, 2018
beb7ecc
tests
djaiss Mar 27, 2018
f855158
merge master
djaiss Mar 27, 2018
a405ea3
fix styleci
djaiss Mar 27, 2018
7f5b09b
wip api
djaiss Mar 28, 2018
eae3fb1
wip api
djaiss Mar 28, 2018
82da42a
wip
djaiss Mar 30, 2018
c558111
wip
djaiss Mar 30, 2018
5f8a665
wip
djaiss Mar 30, 2018
f5e899a
wip
djaiss Mar 30, 2018
2727011
wip
djaiss Mar 30, 2018
bf0dd02
fix tests
djaiss Mar 30, 2018
91ec824
styleci
djaiss Mar 30, 2018
1c63734
merge master
djaiss Mar 31, 2018
1ad5764
fix bug
djaiss Mar 31, 2018
d7ffd47
fix test
djaiss Mar 31, 2018
b9ee161
remove useless test
djaiss Apr 1, 2018
df2e51a
Merge branch 'master' into replace-relationships
djaiss Apr 1, 2018
d0d5441
optimization
djaiss Apr 1, 2018
66b1965
Merge branch 'master' into replace-relationships
djaiss Apr 1, 2018
e7a7087
fix stuff
djaiss Apr 1, 2018
35020f1
Merge branch 'replace-relationships' of github.com:monicahq/monica in…
djaiss Apr 1, 2018
afaae90
fix dashboard
djaiss Apr 2, 2018
4e49981
merge mastr
djaiss Apr 2, 2018
916107c
styleci
djaiss Apr 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
djaiss committed Mar 30, 2018
commit bf0dd02d1711cfa1ffd784fc91eed3cc0746fad3
16 changes: 8 additions & 8 deletions app/Http/Resources/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ public function toArray($request)
'information' => [
'relationships' => $this->when(! $this->is_partial, [
'love' => [
'total' => $this->getRelationshipsByRelationshipTypeGroup('love')->count(),
'contacts' => Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('love')),
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('love')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('love')->count()),
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('love')) ? null : Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('love'))),
],
'family' => [
'total' => $this->getRelationshipsByRelationshipTypeGroup('family')->count(),
'contacts' => Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('family')),
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('family')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('family')->count()),
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('family')) ? null : Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('family'))),
],
'friend' => [
'total' => $this->getRelationshipsByRelationshipTypeGroup('friend')->count(),
'contacts' => Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('friend')),
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('friend')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('friend')->count()),
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('friend')) ? null : Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('friend'))),
],
'work' => [
'total' => $this->getRelationshipsByRelationshipTypeGroup('work')->count(),
'contacts' => Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('work')),
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('work')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('work')->count()),
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('work')) ? null : Contact::translateForAPI($this->getRelationshipsByRelationshipTypeGroup('work'))),
],
]),
'dates' => [
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public function boot()
Contact::findOrFail($route->parameter('contact')->id);

Relationship::where('account_id', auth()->user()->account_id)
->where('contact_id_main', $route->parameter('contact')->id)
->where('contact_id_secondary', $value)
->where('contact_is', $route->parameter('contact')->id)
->where('of_contact', $value)
->firstOrFail();

return Contact::findOrFail($value);
Expand Down
10 changes: 5 additions & 5 deletions tests/Api/Contact/ApiContactControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function test_it_gets_a_list_of_contacts()
{
$user = $this->signin();

$contact = factory(Contact::class, 10)->create([
$contact = factory('App\Contact', 10)->create([
'account_id' => $user->account_id,
]);

Expand All @@ -32,7 +32,7 @@ public function test_it_gets_a_list_of_contacts_with_pagination_everytime()
{
$user = $this->signin();

$contact = factory(Contact::class, 10)->create([
$contact = factory('App\Contact', 10)->create([
'account_id' => $user->account_id,
]);

Expand All @@ -48,7 +48,7 @@ public function test_it_applies_the_limit_parameter_in_search()
{
$user = $this->signin();

$contact = factory(Contact::class, 10)->create([
$contact = factory('App\Contact', 10)->create([
'account_id' => $user->account_id,
]);

Expand All @@ -75,13 +75,13 @@ public function test_it_is_possible_to_search_for_a_specific_contact()
{
$user = $this->signin();

$contact = factory(Contact::class)->create([
$contact = factory('App\Contact')->create([
'account_id' => $user->account_id,
'first_name' => 'roger',
]);

// create 10 other contacts named Bob (to avoid random conflicts if we took a random name)
$contact = factory(Contact::class, 10)->create([
$contact = factory('App\Contact', 10)->create([
'account_id' => $user->account_id,
'first_name' => 'bob',
]);
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature;

use App\Contact;
use Tests\FeatureTestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;

Expand All @@ -19,7 +18,7 @@ private function fetchUser()
{
$user = $this->signIn();

$contact = factory(Contact::class)->create([
$contact = factory('App\Contact')->create([
'account_id' => $user->account_id,
]);

Expand Down
3 changes: 3 additions & 0 deletions tests/Traits/SignIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function signIn($user = null)

$this->be($user);

$user->account->populateRelationshipTypeGroupsTable();
$user->account->populateRelationshipTypesTable();

return $user;
}
}
8 changes: 4 additions & 4 deletions tests/Unit/RelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_it_belongs_to_a_contact()
'contact_is' => $contact->id,
]);

$this->assertTrue($relationship->contact()->exists());
$this->assertTrue($relationship->contactIs()->exists());
}

public function test_it_belongs_to_another_contact()
Expand All @@ -36,7 +36,7 @@ public function test_it_belongs_to_another_contact()
'of_contact' => $contact->id,
]);

$this->assertTrue($relationship->withContact()->exists());
$this->assertTrue($relationship->ofContact()->exists());
}

public function test_it_belongs_to_a_relationship_type()
Expand All @@ -57,9 +57,9 @@ public function test_it_belongs_to_a_contact_through_with_contact_field()
{
$contact = factory('App\Contact')->create([]);
$relationship = factory('App\Relationship')->create([
'contact_id_secondary' => $contact->id,
'of_contact' => $contact->id,
]);

$this->assertTrue($relationship->withContact()->exists());
$this->assertTrue($relationship->ofContact()->exists());
}
}