summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2017-10-02 15:44:58 +0200
committerTim Zallmann <tzallmann@gitlab.com>2017-10-04 14:27:09 +0200
commit1b752968757873434404a2bf82ea360ce829ec87 (patch)
treebc48ee35c12bfa0f01cc9a0cc6dcdc21d27176d7
parent892b02e890be539a95e6b52feb14f5d188513700 (diff)
downloadgitlab-ce-1b752968757873434404a2bf82ea360ce829ec87.tar.gz
Fixed Linting errors + tests
-rw-r--r--app/helpers/lazy_image_tag_helper.rb2
-rw-r--r--app/models/concerns/avatarable.rb6
-rw-r--r--spec/helpers/application_helper_spec.rb6
-rw-r--r--spec/helpers/groups_helper_spec.rb13
4 files changed, 13 insertions, 14 deletions
diff --git a/app/helpers/lazy_image_tag_helper.rb b/app/helpers/lazy_image_tag_helper.rb
index aea1fcc7e91..60df16b3373 100644
--- a/app/helpers/lazy_image_tag_helper.rb
+++ b/app/helpers/lazy_image_tag_helper.rb
@@ -9,7 +9,7 @@ module LazyImageTagHelper
unless options.delete(:lazy) == false
options[:data] ||= {}
- unless options.delete(:use_original_source) == true
+ unless options.delete(:use_original_source)
options[:data][:src] = path_to_image(source)
else
options[:data][:src] = source
diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb
index ddaa15e6a0d..6ed57dea858 100644
--- a/app/models/concerns/avatarable.rb
+++ b/app/models/concerns/avatarable.rb
@@ -13,10 +13,8 @@ module Avatarable
# If asset_host is set then it is expected that assets are handled by a standalone host.
# That means we do not want to get GitLab's relative_url_root option anymore.
host = asset_host.present? ? asset_host : gitlab_host
-
- [host, avatar.url].join
- else
- [host, avatar.url].join
end
+
+ [host, avatar.url].join
end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 10bc5f2ecd2..6dafd73d337 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -57,6 +57,8 @@ describe ApplicationHelper do
end
describe 'project_icon' do
+ let(:asset_host) { 'http://assets' }
+
it 'returns an url for the avatar' do
project = create(:project, avatar: File.open(uploaded_image_temp_path))
avatar_url = "/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
@@ -64,8 +66,8 @@ describe ApplicationHelper do
expect(helper.project_icon(project.full_path).to_s)
.to eq "<img data-src=\"#{avatar_url}\" class=\" lazy\" src=\"#{LazyImageTagHelper.placeholder_image}\" />"
- allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host)
- avatar_url = "#{gitlab_host}/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
+ allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
+ avatar_url = "#{asset_host}/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
expect(helper.project_icon(project.full_path).to_s)
.to eq "<img data-src=\"#{avatar_url}\" class=\" lazy\" src=\"#{LazyImageTagHelper.placeholder_image}\" />"
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 40c26b6e1d5..55de03c8ed2 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
describe GroupsHelper do
include ApplicationHelper
+ let(:asset_host) { 'http://assets' }
describe 'group_icon' do
avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
@@ -17,16 +18,14 @@ describe GroupsHelper do
expect(group_icon(group).to_s)
.to eq "<img data-src=\"#{avatar_url}\" class=\" lazy\" src=\"#{LazyImageTagHelper.placeholder_image}\" />"
- allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host)
- avatar_url = "#{gitlab_host}/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif"
+ allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
+ avatar_url = "#{asset_host}/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif"
expect(group_icon(group).to_s)
.to eq "<img data-src=\"#{avatar_url}\" class=\" lazy\" src=\"#{LazyImageTagHelper.placeholder_image}\" />"
end
end
-
-
describe 'group_icon_url' do
avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
@@ -39,16 +38,16 @@ describe GroupsHelper do
end
it 'returns an CDN url for the avatar' do
- allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host)
+ allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
group = create(:group)
group.avatar = fixture_file_upload(avatar_file_path)
group.save!
expect(group_icon_url(group.path).to_s)
- .to match("#{gitlab_host}/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif")
+ .to match("#{asset_host}/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif")
end
it 'returns an based url for the avatar if private' do
- allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host)
+ allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
group = create(:group)
group.avatar = fixture_file_upload(avatar_file_path)
group.private = true