2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-05-22 15:37:02 +08:00
|
|
|
|
|
|
|
describe UserAvatar do
|
|
|
|
let(:avatar){
|
|
|
|
user = Fabricate(:user)
|
|
|
|
user.create_user_avatar!
|
|
|
|
}
|
|
|
|
|
|
|
|
it 'can update gravatars' do
|
|
|
|
temp = Tempfile.new('test')
|
2014-05-26 19:17:20 +08:00
|
|
|
temp.binmode
|
|
|
|
# tiny valid png
|
|
|
|
temp.write(Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw=="))
|
|
|
|
temp.rewind
|
2014-05-22 15:37:02 +08:00
|
|
|
FileHelper.expects(:download).returns(temp)
|
|
|
|
avatar.update_gravatar!
|
|
|
|
temp.unlink
|
2014-12-31 22:55:03 +08:00
|
|
|
expect(avatar.gravatar_upload).not_to eq(nil)
|
2014-05-22 15:37:02 +08:00
|
|
|
end
|
|
|
|
end
|