2013-05-25 14:50:39 +08:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'spec_helper'
|
2013-06-29 01:55:34 +08:00
|
|
|
require_dependency 'avatar_lookup'
|
2013-05-25 14:50:39 +08:00
|
|
|
|
|
|
|
describe AvatarLookup do
|
|
|
|
let!(:user){ Fabricate(:user) }
|
|
|
|
|
|
|
|
describe '#[]' do
|
|
|
|
before do
|
2013-07-13 05:07:54 +08:00
|
|
|
@avatar_lookup = AvatarLookup.new([user.id, nil])
|
2013-05-25 14:50:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil if user_id does not exists' do
|
|
|
|
@avatar_lookup[0].should be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil if user_id is nil' do
|
|
|
|
@avatar_lookup[nil].should be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns user if user_id exists' do
|
|
|
|
@avatar_lookup[user.id].should eq(user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|