@@ -37,7 +37,7 @@ module('Acceptance | /me/pending-invites', function (hooks) {
37
37
38
38
context . authenticateAs ( user ) ;
39
39
40
- return { nanomsg } ;
40
+ return { nanomsg, user } ;
41
41
}
42
42
43
43
test ( 'redirects to / when not logged in' , async function ( assert ) {
@@ -81,19 +81,11 @@ module('Acceptance | /me/pending-invites', function (hooks) {
81
81
} ) ;
82
82
83
83
test ( 'invites can be declined' , async function ( assert ) {
84
- assert . expect ( 9 ) ;
84
+ let { nanomsg , user } = prepare ( this ) ;
85
85
86
- let { nanomsg } = prepare ( this ) ;
87
-
88
- this . server . put ( '/api/v1/me/crate_owner_invitations/:crate_id' , ( schema , request ) => {
89
- assert . deepEqual ( request . params , { crate_id : nanomsg . id } ) ;
90
-
91
- let body = JSON . parse ( request . requestBody ) ;
92
- assert . strictEqual ( body . crate_owner_invite . accepted , false ) ;
93
- assert . strictEqual ( body . crate_owner_invite . crate_id , nanomsg . id ) ;
94
-
95
- return { crate_owner_invitation : { crate_id : 42 , accepted : false } } ;
96
- } ) ;
86
+ let { crateOwnerInvitations, crateOwnerships } = this . server . schema ;
87
+ assert . equal ( crateOwnerInvitations . where ( { crateId : nanomsg . id , inviteeId : user . id } ) . length , 1 ) ;
88
+ assert . equal ( crateOwnerships . where ( { crateId : nanomsg . id , userId : user . id } ) . length , 0 ) ;
97
89
98
90
await visit ( '/me/pending-invites' ) ;
99
91
assert . equal ( currentURL ( ) , '/me/pending-invites' ) ;
@@ -106,6 +98,9 @@ module('Acceptance | /me/pending-invites', function (hooks) {
106
98
. hasText ( 'Declined. You have not been added as an owner of crate nanomsg.' ) ;
107
99
assert . dom ( '[data-test-invite="nanomsg"] [data-test-crate-link]' ) . doesNotExist ( ) ;
108
100
assert . dom ( '[data-test-invite="nanomsg"] [data-test-inviter-link]' ) . doesNotExist ( ) ;
101
+
102
+ assert . equal ( crateOwnerInvitations . where ( { crateId : nanomsg . id , inviteeId : user . id } ) . length , 0 ) ;
103
+ assert . equal ( crateOwnerships . where ( { crateId : nanomsg . id , userId : user . id } ) . length , 0 ) ;
109
104
} ) ;
110
105
111
106
test ( 'error message is shown if decline request fails' , async function ( assert ) {
@@ -123,19 +118,11 @@ module('Acceptance | /me/pending-invites', function (hooks) {
123
118
} ) ;
124
119
125
120
test ( 'invites can be accepted' , async function ( assert ) {
126
- assert . expect ( 9 ) ;
121
+ let { nanomsg , user } = prepare ( this ) ;
127
122
128
- let { nanomsg } = prepare ( this ) ;
129
-
130
- this . server . put ( '/api/v1/me/crate_owner_invitations/:crate_id' , ( schema , request ) => {
131
- assert . deepEqual ( request . params , { crate_id : nanomsg . id } ) ;
132
-
133
- let body = JSON . parse ( request . requestBody ) ;
134
- assert . strictEqual ( body . crate_owner_invite . accepted , true ) ;
135
- assert . strictEqual ( body . crate_owner_invite . crate_id , nanomsg . id ) ;
136
-
137
- return { crate_owner_invitation : { crate_id : 42 , accepted : true } } ;
138
- } ) ;
123
+ let { crateOwnerInvitations, crateOwnerships } = this . server . schema ;
124
+ assert . equal ( crateOwnerInvitations . where ( { crateId : nanomsg . id , inviteeId : user . id } ) . length , 1 ) ;
125
+ assert . equal ( crateOwnerships . where ( { crateId : nanomsg . id , userId : user . id } ) . length , 0 ) ;
139
126
140
127
await visit ( '/me/pending-invites' ) ;
141
128
assert . equal ( currentURL ( ) , '/me/pending-invites' ) ;
@@ -150,6 +137,9 @@ module('Acceptance | /me/pending-invites', function (hooks) {
150
137
assert . dom ( '[data-test-invite="nanomsg"] [data-test-inviter-link]' ) . doesNotExist ( ) ;
151
138
152
139
await percySnapshot ( assert ) ;
140
+
141
+ assert . equal ( crateOwnerInvitations . where ( { crateId : nanomsg . id , inviteeId : user . id } ) . length , 0 ) ;
142
+ assert . equal ( crateOwnerships . where ( { crateId : nanomsg . id , userId : user . id } ) . length , 1 ) ;
153
143
} ) ;
154
144
155
145
test ( 'error message is shown if accept request fails' , async function ( assert ) {
0 commit comments