~cytrogen/masto-fe

ref: ec59166844b04ec416bdbc2612fd8a4364f9dd67 masto-fe/spec/controllers/concerns/cache_concern_spec.rb -rw-r--r-- 868 bytes
ec591668 — Claire Fix ArgumentError when loading newer Private Mentions (#25399) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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
    context 'when given an empty array' do
      it 'returns an empty array' do
        get :empty_array
        expect(response.body).to eq '0'
      end
    end

    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