Skip to content

Commit

Permalink
[ci] Create tests for gravatar_image in User model
Browse files Browse the repository at this point in the history
Co-authored-by: Dany Marcoux <dmarcoux@suse.com>
  • Loading branch information
eduardoj and Dany Marcoux committed Jul 9, 2018
1 parent 0afa99a commit 6a43187
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/api/spec/models/user_spec.rb
Expand Up @@ -551,4 +551,30 @@
expect(user.can_create_project?('foo:bar')).to be true
end
end

describe '#gravatar_image' do
context 'gravatar configuration disabled' do
before do
allow(Configuration).to receive(:gravatar).and_return(false)
end

it { expect(user.gravatar_image(0)).to eq(:none) }
end

context 'gravatar configuration enabled' do
context 'problems loading the image' do
before do
allow(ActiveXML.backend).to receive(:load_external_url).and_raise(ActiveXML::Transport::Error)
end

it { expect(user.gravatar_image(0)).to eq(:none) }
end

before do
allow(ActiveXML.backend).to receive(:load_external_url).with(anything).and_return('some_content')
end

it { expect(user.gravatar_image(0)).to eq('some_content') }
end
end
end

0 comments on commit 6a43187

Please sign in to comment.