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