discourse/spec/components/avatar_lookup_spec.rb

27 lines
548 B
Ruby
Raw Normal View History

# encoding: utf-8
require 'rails_helper'
require_dependency 'avatar_lookup'
describe AvatarLookup do
2017-07-28 09:20:09 +08:00
let!(:user) { Fabricate(:user) }
describe '#[]' do
before do
2013-07-13 05:07:54 +08:00
@avatar_lookup = AvatarLookup.new([user.id, nil])
end
it 'returns nil if user_id does not exists' do
2015-01-10 00:34:37 +08:00
expect(@avatar_lookup[0]).to eq(nil)
end
it 'returns nil if user_id is nil' do
2015-01-10 00:34:37 +08:00
expect(@avatar_lookup[nil]).to eq(nil)
end
it 'returns user if user_id exists' do
2015-01-10 00:34:37 +08:00
expect(@avatar_lookup[user.id]).to eq(user)
end
end
end