@@ -289,7 +289,7 @@ def loop_times(times)
289289 expect ( response [ 'members' ] . length ) . to eq 2
290290 end
291291
292- it 'can pin and unpin channel' do
292+ it 'can pin and unpin a channel' do
293293 @channel . add_members ( [ @random_users [ 0 ] [ :id ] ] )
294294 @channel . add_members ( [ @random_users [ 1 ] [ :id ] ] )
295295
@@ -303,7 +303,7 @@ def loop_times(times)
303303 response = @client . query_channels (
304304 { 'pinned' => true , 'cid' => @channel . cid } ,
305305 nil ,
306- { ' user_id' => @random_users [ 0 ] [ :id ] }
306+ user_id = @random_users [ 0 ] [ :id ]
307307 )
308308 expect ( response [ 'channels' ] . length ) . to eq 1
309309 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
@@ -316,7 +316,40 @@ def loop_times(times)
316316 response = @client . query_channels (
317317 { 'pinned' => false , 'cid' => @channel . cid } ,
318318 nil ,
319- { 'user_id' => @random_users [ 0 ] [ :id ] }
319+ user_id = @random_users [ 0 ] [ :id ]
320+ )
321+ expect ( response [ 'channels' ] . length ) . to eq 1
322+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
323+ end
324+
325+ it 'can archive and unarchive a channel' do
326+ @channel . add_members ( [ @random_users [ 0 ] [ :id ] ] )
327+ @channel . add_members ( [ @random_users [ 1 ] [ :id ] ] )
328+
329+ # Pin the channel
330+ now = Time . now
331+ response = @channel . archive ( @random_users [ 0 ] [ :id ] )
332+ expect ( response [ 'channel_member' ] [ 'archived_at' ] ) . not_to be_nil
333+ expect ( Time . parse ( response [ 'channel_member' ] [ 'archived_at' ] ) . to_i ) . to be >= now . to_i
334+
335+ # Query for archived channel
336+ response = @client . query_channels (
337+ { 'archived' => true , 'cid' => @channel . cid } ,
338+ nil ,
339+ user_id = @random_users [ 0 ] [ :id ]
340+ )
341+ expect ( response [ 'channels' ] . length ) . to eq 1
342+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
343+
344+ # Unarchive the channel
345+ response = @channel . unarchive ( @random_users [ 0 ] [ :id ] )
346+ expect ( response [ 'channel_member' ] ) . not_to have_key ( 'archived_at' )
347+
348+ # Query for unarchived channel
349+ response = @client . query_channels (
350+ { 'archived' => false , 'cid' => @channel . cid } ,
351+ nil ,
352+ user_id = @random_users [ 0 ] [ :id ]
320353 )
321354 expect ( response [ 'channels' ] . length ) . to eq 1
322355 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
0 commit comments