@ -7,17 +7,17 @@ RSpec.describe Api::Activitypub::OutboxController, type: :controller do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				  describe  'GET #show'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    before  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      @request . env[ 'HTTP_  ACCEPT']  =  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      @request . headers[ '  ACCEPT']  =  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    describe  ' small number of statuses' do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    describe  ' collection with  small number of statuses' do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      public_status  =  nil 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      before  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        public_status  =  Status. create! (  account :  user . account ,  text :  'Hello world' ,  visibility :  :public ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Status. create! (  account :  user . account ,  text :  'Hello world' ,  visibility :  :private ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Status. create! (  account :  user . account ,  text :  'Hello world' ,  visibility :  :unlisted ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Status. create! (  account :  user . account ,  text :  'Hello world' ,  visibility :  :direct ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        public_status  =  Fabricate( :status ,   account :  user . account ,  text :  'Hello world' ,  visibility :  :public ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate( :status ,   account :  user . account ,  text :  'Hello world' ,  visibility :  :private ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate( :status ,   account :  user . account ,  text :  'Hello world' ,  visibility :  :unlisted ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate( :status ,   account :  user . account ,  text :  'Hello world' ,  visibility :  :direct ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        get  :show ,  params :  {  id :  user . account . id  } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -30,62 +30,126 @@ RSpec.describe Api::Activitypub::OutboxController, type: :controller do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response . header [ 'Content-Type' ] ) . to  include  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'sets Access-Control-Allow-Origin header to *'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response . header [ 'Access-Control-Allow-Origin' ] ) . to  eq  '*' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns AS2 JSON body'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        json_data  =  JSON . parse ( response . body ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( '@context'  = >  'https://www.w3.org/ns/activitystreams' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'id'  = >  @request . url ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'type'  = >  'OrderedCollection' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'totalItems'  = >  1 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( ' items ') 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data [ 'items' ] . count ) . to  eq ( 1 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data [ 'items' ] ) . to  include ( api_activitypub_status_url ( public_status ) ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( ' current ') 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'first' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'last' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    describe  ' large number of statuses' do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    describe  ' collection with  large number of statuses' do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      before  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        30 . times  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          Status. create! (  account :  user . account ,  text :  'Hello world' ,  visibility :  :public ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          Fabricate( :status ,   account :  user . account ,  text :  'Hello world' ,  visibility :  :public ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Status . create! ( account :  user . account ,  text :  'Hello world' ,  visibility :  :private ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Status . create! ( account :  user . account ,  text :  'Hello world' ,  visibility :  :unlisted ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Status . create! ( account :  user . account ,  text :  'Hello world' ,  visibility :  :direct ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :private ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :unlisted ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :direct ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        get  :show ,  params :  {  id :  user . account . id  } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      describe  'first page'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        before  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          get  :show ,  params :  {  id :  user . account . id  } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns http success'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response ) . to  have_http_status ( :success ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        it  'returns http success  ' do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( response ) . to  have_http_status ( :success )  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'sets Content-Type header to AS2  ' do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response . header [ 'Content-Type' ] ) . to  include  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        it  'sets Content-Type header to AS2'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( response . header [ 'Content-Type' ] ) . to  include  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns AS2 JSON body'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        json_data  =  JSON . parse ( response . body ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( '@context'  = >  'https://www.w3.org/ns/activitystreams' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'id'  = >  @request . url ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'type'  = >  'OrderedCollection' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'totalItems'  = >  30 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'current' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'first' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'last' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    describe  'page with small number of statuses'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      statuses  =  [ ] 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        it  'sets Access-Control-Allow-Origin header to *'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( response . header [ 'Access-Control-Allow-Origin' ] ) . to  eq  '*' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      before  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        5 . times  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          statuses  <<  Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :public ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        it  'returns AS2 JSON body'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          json_data  =  JSON . parse ( response . body ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( '@context'  = >  'https://www.w3.org/ns/activitystreams' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( 'id'  = >  @request . url ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( 'type'  = >  'OrderedCollectionPage' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( 'totalItems'  = >  20 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( 'items' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data [ 'items' ] . count ) . to  eq ( 20 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( 'current'  = >  @request . url ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to  include ( 'next' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          expect ( json_data ) . to_not  include ( 'prev' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :private ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :unlisted ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :direct ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        get  :show ,  params :  {  id :  user . account . id ,  max_id :  statuses . last . id  +  1  } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns http success'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response ) . to  have_http_status ( :success ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'sets Content-Type header to AS2'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response . header [ 'Content-Type' ] ) . to  include  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns AS2 JSON body'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        json_data  =  JSON . parse ( response . body ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( '@context'  = >  'https://www.w3.org/ns/activitystreams' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'id'  = >  @request . url ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'type'  = >  'OrderedCollectionPage' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'partOf' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'items' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data [ 'items' ] . length ) . to  eq ( 5 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'prev' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'next' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'current' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'first' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'last' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    describe  'page with large number of statuses'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      statuses  =  [ ] 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      before  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        30 . times  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				          statuses  <<  Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :public ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :private ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :unlisted ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        Fabricate ( :status ,  account :  user . account ,  text :  'Hello world' ,  visibility :  :direct ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        get  :show ,  params :  {  id :  user . account . id ,  max_id :  statuses . last . id  +  1  } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns http success'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response ) . to  have_http_status ( :success ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'sets Content-Type header to AS2'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( response . header [ 'Content-Type' ] ) . to  include  'application/activity+json' 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      it  'returns AS2 JSON body'  do 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        json_data  =  JSON . parse ( response . body ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( '@context'  = >  'https://www.w3.org/ns/activitystreams' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'id'  = >  @request . url ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'type'  = >  'OrderedCollectionPage' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'partOf' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'items' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data [ 'items' ] . length ) . to  eq ( 20 ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'prev' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'next' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'current' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'first' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        expect ( json_data ) . to  include ( 'last' ) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    end 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				  end