diff options
author | Maxim Rydkin <maks.rydkin@gmail.com> | 2017-09-01 00:43:13 +0300 |
---|---|---|
committer | Maxim Rydkin <maks.rydkin@gmail.com> | 2017-09-07 13:16:14 +0300 |
commit | db3bc89792c5450cb93e674d621d5ea996ee01f6 (patch) | |
tree | 48120717ce854b618c38f796ba2b6c3dcf5f0737 | |
parent | d441b5e7b52ccfadf9adb3b7fc73f5e33f5da6bf (diff) |
refactor `app/helpers/projects_helper.rb:21:3`
-rw-r--r-- | .rubocop.yml | 2 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 4 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 10 |
3 files changed, 12 insertions, 4 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 16f2e4484fc..4640681379a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -643,7 +643,7 @@ Metrics/ClassLength: # of test cases needed to validate a method. Metrics/CyclomaticComplexity: Enabled: true - Max: 15 + Max: 14 # Limit lines to 80 characters. Metrics/LineLength: diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 86665ea2aec..7e5b214b1c7 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -17,7 +17,7 @@ module ProjectsHelper def link_to_member_avatar(author, opts = {}) default_opts = { avatar: true, name: true, size: 16, author_class: 'author', title: ":name" } opts = default_opts.merge(opts) - image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: "avatar avatar-inline #{"s#{opts[:size]}" if opts[:size]}", alt: '') if opts[:avatar] + image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: ['avatar', 'avatar-inline', "#{"s#{opts[:size]}" if opts[:size]}", opts[:avatar_class]].reject(&:blank?), alt: '') if opts[:avatar] end def link_to_member(project, author, opts = {}, &block) @@ -29,7 +29,7 @@ module ProjectsHelper author_html = "" # Build avatar image tag - author_html << image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: "avatar avatar-inline #{"s#{opts[:size]}" if opts[:size]} #{opts[:avatar_class] if opts[:avatar_class]}", alt: '') if opts[:avatar] + author_html << link_to_member_avatar(author, opts) if opts[:avatar] # Build name span tag if opts[:by_username] diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index d1efa318d14..93a5b55e4d0 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -191,7 +191,15 @@ describe ProjectsHelper do end end - describe 'link_to_member' do + describe '#link_to_member_avatar' do + let(:user) { create(:user) } + + it 'returns image tag for member avatar' do + expect(helper.link_to_member_avatar(user)).to eq("<img width=\"16\" class=\"avatar avatar-inline s16 lazy\" alt=\"\" data-src=\"http://www.gravatar.com/avatar/a763e4acc6bc22cbabeae2638cfd4db4?s=32&d=identicon\" src=\"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" />") + end + end + + describe '#link_to_member' do let(:group) { create(:group) } let(:project) { create(:project, group: group) } let(:user) { create(:user) } |