@@ -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
@@ -300,11 +300,7 @@ def loop_times(times)
300300 expect ( Time . parse ( response [ 'channel_member' ] [ 'pinned_at' ] ) . to_i ) . to be >= now . to_i
301301
302302 # Query for pinned channel
303- response = @client . query_channels (
304- { 'pinned' => true , 'cid' => @channel . cid } ,
305- nil ,
306- { 'user_id' => @random_users [ 0 ] [ :id ] }
307- )
303+ response = @client . query_channels ( { 'pinned' => true , 'cid' => @channel . cid } )
308304 expect ( response [ 'channels' ] . length ) . to eq 1
309305 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
310306
@@ -316,7 +312,36 @@ def loop_times(times)
316312 response = @client . query_channels (
317313 { 'pinned' => false , 'cid' => @channel . cid } ,
318314 nil ,
319- { 'user_id' => @random_users [ 0 ] [ :id ] }
315+ user_id : @random_users [ 0 ] [ :id ]
316+ )
317+ expect ( response [ 'channels' ] . length ) . to eq 1
318+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
319+ end
320+
321+ it 'can archive and unarchive a channel' do
322+ @channel . add_members ( [ @random_users [ 0 ] [ :id ] ] )
323+ @channel . add_members ( [ @random_users [ 1 ] [ :id ] ] )
324+
325+ # Pin the channel
326+ now = Time . now
327+ response = @channel . archive ( @random_users [ 0 ] [ :id ] )
328+ expect ( response [ 'channel_member' ] [ 'archived_at' ] ) . not_to be_nil
329+ expect ( Time . parse ( response [ 'channel_member' ] [ 'archived_at' ] ) . to_i ) . to be >= now . to_i
330+
331+ # Query for archived channel
332+ response = @client . query_channels ( { 'archived' => true , 'cid' => @channel . cid } , nil , user_id : @random_users [ 0 ] [ :id ] )
333+ expect ( response [ 'channels' ] . length ) . to eq 1
334+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
335+
336+ # Unarchive the channel
337+ response = @channel . unarchive ( @random_users [ 0 ] [ :id ] )
338+ expect ( response [ 'channel_member' ] ) . not_to have_key ( 'archived_at' )
339+
340+ # Query for unarchived channel
341+ response = @client . query_channels (
342+ { 'archived' => false , 'cid' => @channel . cid } ,
343+ nil ,
344+ user_id : @random_users [ 0 ] [ :id ]
320345 )
321346 expect ( response [ 'channels' ] . length ) . to eq 1
322347 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
0 commit comments