2013-05-25 01:50:39 -05:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2015-10-11 04:41:23 -05:00
|
|
|
require 'rails_helper'
|
2013-06-28 12:55:34 -05:00
|
|
|
require_dependency 'avatar_lookup'
|
2013-05-25 01:50:39 -05:00
|
|
|
|
|
|
|
describe AvatarLookup do
|
|
|
|
let!(:user){ Fabricate(:user) }
|
|
|
|
|
|
|
|
describe '#[]' do
|
|
|
|
before do
|
2013-07-12 16:07:54 -05:00
|
|
|
@avatar_lookup = AvatarLookup.new([user.id, nil])
|
2013-05-25 01:50:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil if user_id does not exists' do
|
2015-01-09 10:34:37 -06:00
|
|
|
expect(@avatar_lookup[0]).to eq(nil)
|
2013-05-25 01:50:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil if user_id is nil' do
|
2015-01-09 10:34:37 -06:00
|
|
|
expect(@avatar_lookup[nil]).to eq(nil)
|
2013-05-25 01:50:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns user if user_id exists' do
|
2015-01-09 10:34:37 -06:00
|
|
|
expect(@avatar_lookup[user.id]).to eq(user)
|
2013-05-25 01:50:39 -05:00
|
|
|
end
|
|
|
|
end
|
2014-09-25 10:44:48 -05:00
|
|
|
end
|