@@ -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,10 +300,11 @@ 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+ user_id = @random_users [ 0 ] [ :id ]
303304 response = @client . query_channels (
304305 { 'pinned' => true , 'cid' => @channel . cid } ,
305306 nil ,
306- { ' user_id' => @random_users [ 0 ] [ :id ] }
307+ user_id
307308 )
308309 expect ( response [ 'channels' ] . length ) . to eq 1
309310 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
@@ -316,7 +317,41 @@ def loop_times(times)
316317 response = @client . query_channels (
317318 { 'pinned' => false , 'cid' => @channel . cid } ,
318319 nil ,
319- { 'user_id' => @random_users [ 0 ] [ :id ] }
320+ user_id
321+ )
322+ expect ( response [ 'channels' ] . length ) . to eq 1
323+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
324+ end
325+
326+ it 'can archive and unarchive a channel' do
327+ @channel . add_members ( [ @random_users [ 0 ] [ :id ] ] )
328+ @channel . add_members ( [ @random_users [ 1 ] [ :id ] ] )
329+
330+ # Pin the channel
331+ now = Time . now
332+ response = @channel . archive ( @random_users [ 0 ] [ :id ] )
333+ expect ( response [ 'channel_member' ] [ 'archived_at' ] ) . not_to be_nil
334+ expect ( Time . parse ( response [ 'channel_member' ] [ 'archived_at' ] ) . to_i ) . to be >= now . to_i
335+
336+ # Query for archived channel
337+ user_id = @random_users [ 0 ] [ :id ]
338+ response = @client . query_channels (
339+ { 'archived' => true , 'cid' => @channel . cid } ,
340+ nil ,
341+ user_id
342+ )
343+ expect ( response [ 'channels' ] . length ) . to eq 1
344+ expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
345+
346+ # Unarchive the channel
347+ response = @channel . unarchive ( @random_users [ 0 ] [ :id ] )
348+ expect ( response [ 'channel_member' ] ) . not_to have_key ( 'archived_at' )
349+
350+ # Query for unarchived channel
351+ response = @client . query_channels (
352+ { 'archived' => false , 'cid' => @channel . cid } ,
353+ nil ,
354+ user_id
320355 )
321356 expect ( response [ 'channels' ] . length ) . to eq 1
322357 expect ( response [ 'channels' ] [ 0 ] [ 'channel' ] [ 'cid' ] ) . to eq @channel . cid
0 commit comments