diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-08-26 04:42:46 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-08-26 04:42:46 +0300 |
commit | 046b28312704f3131e72dcd2dbdacc5264d4aa62 (patch) | |
tree | a8c2b14a6e1db3b662fee2c79af70d9fcb643c2e /spec/ci/helpers/user_helper_spec.rb | |
parent | e449426a4e7d15cdd582d4f136add52cbfb5e04e (diff) |
Groundwork for merging CI into CE
Diffstat (limited to 'spec/ci/helpers/user_helper_spec.rb')
-rw-r--r-- | spec/ci/helpers/user_helper_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/ci/helpers/user_helper_spec.rb b/spec/ci/helpers/user_helper_spec.rb new file mode 100644 index 00000000000..7215dc41a85 --- /dev/null +++ b/spec/ci/helpers/user_helper_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe UserHelper do + describe :user_avatar_url do + let (:user) { User.new({'avatar_url' => avatar_url}) } + + context 'no avatar' do + let (:avatar_url) { nil } + + it 'should return a generic avatar' do + user_avatar_url(user).should == 'ci/no_avatar.png' + end + end + + context 'plain gravatar' do + let (:base_url) { 'http://www.gravatar.com/avatar/abcdefgh' } + let (:avatar_url) { "#{base_url}?s=40&d=mm" } + + it 'should return gravatar with default size' do + user_avatar_url(user).should == "#{base_url}?s=40&d=identicon" + end + + it 'should return gravatar with custom size' do + user_avatar_url(user, 120).should == "#{base_url}?s=120&d=identicon" + end + end + + context 'secure gravatar' do + let (:base_url) { 'https://secure.gravatar.com/avatar/abcdefgh' } + let (:avatar_url) { "#{base_url}?s=40&d=mm" } + + it 'should return gravatar with default size' do + user_avatar_url(user).should == "#{base_url}?s=40&d=identicon" + end + + it 'should return gravatar with custom size' do + user_avatar_url(user, 120).should == "#{base_url}?s=120&d=identicon" + end + end + + context 'custom avatar' do + let (:avatar_url) { 'http://example.local/avatar.png' } + + it 'should return custom avatar' do + user_avatar_url(user).should == avatar_url + end + end + end +end |