mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Jobs::UpdateGravatar do
|
|
fab!(:user) { Fabricate(:user) }
|
|
let(:temp) { Tempfile.new('test') }
|
|
fab!(:upload) { Fabricate(:upload, user: user) }
|
|
let(:avatar) { user.create_user_avatar! }
|
|
|
|
it "picks gravatar if system avatar is picked and gravatar was just downloaded" do
|
|
temp.binmode
|
|
# tiny valid png
|
|
temp.write(Base64.decode64("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="))
|
|
temp.rewind
|
|
FileHelper.expects(:download).returns(temp)
|
|
|
|
Jobs.run_immediately!
|
|
|
|
expect(user.uploaded_avatar_id).to eq(nil)
|
|
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
|
|
|
SiteSetting.automatically_download_gravatars = true
|
|
|
|
user.refresh_avatar
|
|
user.reload
|
|
|
|
expect(user.uploaded_avatar_id).to_not eq(nil)
|
|
expect(user.uploaded_avatar_id).to eq(user.user_avatar.gravatar_upload_id)
|
|
|
|
temp.unlink
|
|
end
|
|
|
|
it "does not enqueue a job when user is missing their email" do
|
|
user.primary_email.destroy
|
|
user.reload
|
|
|
|
expect(user.uploaded_avatar_id).to eq(nil)
|
|
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
|
|
|
SiteSetting.automatically_download_gravatars = true
|
|
|
|
expect { user.refresh_avatar }
|
|
.not_to change { Jobs::UpdateGravatar.jobs.count }
|
|
user.reload
|
|
|
|
expect(user.uploaded_avatar_id).to eq(nil)
|
|
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
|
end
|
|
end
|