diff options
Diffstat (limited to 'spec/helpers/avatars_helper_spec.rb')
-rw-r--r-- | spec/helpers/avatars_helper_spec.rb | 142 |
1 files changed, 83 insertions, 59 deletions
diff --git a/spec/helpers/avatars_helper_spec.rb b/spec/helpers/avatars_helper_spec.rb index cef72d24c43..6eb97a99264 100644 --- a/spec/helpers/avatars_helper_spec.rb +++ b/spec/helpers/avatars_helper_spec.rb @@ -297,22 +297,26 @@ RSpec.describe AvatarsHelper do subject { helper.user_avatar_without_link(options) } it 'displays user avatar' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, 16), - data: { container: 'body' }, - class: 'avatar s16 has-tooltip', - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, 16), + data: { container: 'body' }, + class: 'avatar s16 has-tooltip', + title: user.name + ) end context 'with css_class parameter' do let(:options) { { user: user, css_class: '.cat-pics' } } it 'uses provided css_class' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, 16), - data: { container: 'body' }, - class: "avatar s16 #{options[:css_class]} has-tooltip", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, 16), + data: { container: 'body' }, + class: "avatar s16 #{options[:css_class]} has-tooltip", + title: user.name + ) end end @@ -320,11 +324,13 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user, size: 99 } } it 'uses provided size' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, options[:size]), - data: { container: 'body' }, - class: "avatar s#{options[:size]} has-tooltip", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, options[:size]), + data: { container: 'body' }, + class: "avatar s#{options[:size]} has-tooltip", + title: user.name + ) end end @@ -332,11 +338,13 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user, url: '/over/the/rainbow.png' } } it 'uses provided url' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: options[:url], - data: { container: 'body' }, - class: "avatar s16 has-tooltip", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: options[:url], + data: { container: 'body' }, + class: "avatar s16 has-tooltip", + title: user.name + ) end end @@ -344,11 +352,13 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user, lazy: true } } it 'adds `lazy` class to class list, sets `data-src` with avatar URL and `src` with placeholder image' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: LazyImageTagHelper.placeholder_image, - data: { container: 'body', src: avatar_icon_for_user(user, 16) }, - class: "avatar s16 has-tooltip lazy", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: LazyImageTagHelper.placeholder_image, + data: { container: 'body', src: avatar_icon_for_user(user, 16) }, + class: "avatar s16 has-tooltip lazy", + title: user.name + ) end end @@ -357,11 +367,13 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user, has_tooltip: true } } it 'adds has-tooltip' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, 16), - data: { container: 'body' }, - class: "avatar s16 has-tooltip", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, 16), + data: { container: 'body' }, + class: "avatar s16 has-tooltip", + title: user.name + ) end end @@ -369,10 +381,12 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user, has_tooltip: false } } it 'does not add has-tooltip or data container' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, 16), - class: "avatar s16", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, 16), + class: "avatar s16", + title: user.name + ) end end end @@ -384,20 +398,24 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user, user_name: 'Tinky Winky' } } it 'prefers user parameter' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, 16), - data: { container: 'body' }, - class: "avatar s16 has-tooltip", - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, 16), + data: { container: 'body' }, + class: "avatar s16 has-tooltip", + title: user.name + ) end end it 'uses user_name and user_email parameter if user is not present' do - is_expected.to eq tag.img(alt: "#{options[:user_name]}'s avatar", - src: helper.avatar_icon_for_email(options[:user_email], 16), - data: { container: 'body' }, - class: "avatar s16 has-tooltip", - title: options[:user_name]) + is_expected.to eq tag.img( + alt: "#{options[:user_name]}'s avatar", + src: helper.avatar_icon_for_email(options[:user_email], 16), + data: { container: 'body' }, + class: "avatar s16 has-tooltip", + title: options[:user_name] + ) end end @@ -408,11 +426,13 @@ RSpec.describe AvatarsHelper do let(:options) { { user: user_with_avatar, only_path: false } } it 'will return avatar with a full path' do - is_expected.to eq tag.img(alt: "#{user_with_avatar.name}'s avatar", - src: avatar_icon_for_user(user_with_avatar, 16, only_path: false), - data: { container: 'body' }, - class: "avatar s16 has-tooltip", - title: user_with_avatar.name) + is_expected.to eq tag.img( + alt: "#{user_with_avatar.name}'s avatar", + src: avatar_icon_for_user(user_with_avatar, 16, only_path: false), + data: { container: 'body' }, + class: "avatar s16 has-tooltip", + title: user_with_avatar.name + ) end end @@ -420,11 +440,13 @@ RSpec.describe AvatarsHelper do let(:options) { { user_email: user_with_avatar.email, user_name: user_with_avatar.username, only_path: false } } it 'will return avatar with a full path' do - is_expected.to eq tag.img(alt: "#{user_with_avatar.username}'s avatar", - src: helper.avatar_icon_for_email(user_with_avatar.email, 16, only_path: false), - data: { container: 'body' }, - class: "avatar s16 has-tooltip", - title: user_with_avatar.username) + is_expected.to eq tag.img( + alt: "#{user_with_avatar.username}'s avatar", + src: helper.avatar_icon_for_email(user_with_avatar.email, 16, only_path: false), + data: { container: 'body' }, + class: "avatar s16 has-tooltip", + title: user_with_avatar.username + ) end end end @@ -447,11 +469,13 @@ RSpec.describe AvatarsHelper do let(:resource) { user.namespace } it 'displays user avatar' do - is_expected.to eq tag.img(alt: "#{user.name}'s avatar", - src: avatar_icon_for_user(user, 32), - data: { container: 'body' }, - class: 'avatar s32 has-tooltip', - title: user.name) + is_expected.to eq tag.img( + alt: "#{user.name}'s avatar", + src: avatar_icon_for_user(user, 32), + data: { container: 'body' }, + class: 'avatar s32 has-tooltip', + title: user.name + ) end end |