@@ -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 } , sort : nil , user_id : @random_users [ 0 ] [ :id ] )
308304 expect ( response [ 'channels' ] . length ) . to eq 1
309305 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
310306
@@ -313,11 +309,32 @@ def loop_times(times)
313309 expect ( response [ 'channel_member' ] ) . not_to have_key ( 'pinned_at' )
314310
315311 # Query for unpinned channel
316- response = @client . query_channels (
317- { 'pinned' => false , 'cid' => @channel . cid } ,
318- nil ,
319- { 'user_id' => @random_users [ 0 ] [ :id ] }
320- )
312+ response = @client . query_channels ( { 'pinned' => false , 'cid' => @channel . cid } , sort : nil , user_id : @random_users [ 0 ] [ :id ] )
313+ expect ( response [ 'channels' ] . length ) . to eq 1
314+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
315+ end
316+
317+ it 'can archive and unarchive a channel' do
318+ @channel . add_members ( [ @random_users [ 0 ] [ :id ] ] )
319+ @channel . add_members ( [ @random_users [ 1 ] [ :id ] ] )
320+
321+ # Pin the channel
322+ now = Time . now
323+ response = @channel . archive ( @random_users [ 0 ] [ :id ] )
324+ expect ( response [ 'channel_member' ] [ 'archived_at' ] ) . not_to be_nil
325+ expect ( Time . parse ( response [ 'channel_member' ] [ 'archived_at' ] ) . to_i ) . to be >= now . to_i
326+
327+ # Query for archived channel
328+ response = @client . query_channels ( { 'archived' => true , 'cid' => @channel . cid } , sort : nil , user_id : @random_users [ 0 ] [ :id ] )
329+ expect ( response [ 'channels' ] . length ) . to eq 1
330+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
331+
332+ # Unarchive the channel
333+ response = @channel . unarchive ( @random_users [ 0 ] [ :id ] )
334+ expect ( response [ 'channel_member' ] ) . not_to have_key ( 'archived_at' )
335+
336+ # Query for unarchived channel
337+ response = @client . query_channels ( { 'archived' => false , 'cid' => @channel . cid } , sort : nil , user_id : @random_users [ 0 ] [ :id ] )
321338 expect ( response [ 'channels' ] . length ) . to eq 1
322339 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
323340 end
0 commit comments