1
0
mirror of https://github.com/whippyshou/mastodon synced 2024-12-25 03:58:24 +09:00
whippy-edition/spec/controllers/concerns/cache_concern_spec.rb

41 lines
868 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe CacheConcern do
controller(ApplicationController) do
include CacheConcern
def empty_array
render plain: cache_collection([], Status).size
end
def empty_relation
render plain: cache_collection(Status.none, Status).size
end
end
before do
routes.draw do
get 'empty_array' => 'anonymous#empty_array'
post 'empty_relation' => 'anonymous#empty_relation'
end
end
describe '#cache_collection' do
2023-05-04 12:49:08 +09:00
context 'when given an empty array' do
it 'returns an empty array' do
get :empty_array
expect(response.body).to eq '0'
end
end
2023-05-04 12:49:08 +09:00
context 'when given an empty relation' do
it 'returns an empty array' do
get :empty_relation
expect(response.body).to eq '0'
end
end
end
end