Commit ae20dcc5 authored by Alexis Reigel's avatar Alexis Reigel Committed by Douwe Maan

find assets in test for CI and local test

Due to the change in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14583/diffs we
can't use the same method to access assets in a CI and the local test
environment anymore.
parent 62375744
......@@ -2,6 +2,7 @@ require 'spec_helper'
describe JiraService do
include Gitlab::Routing
include AssetsHelpers
describe '#options' do
let(:service) do
......@@ -164,7 +165,7 @@ describe JiraService do
it "creates Remote Link reference in JIRA for comment" do
@jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
favicon_path = "http://localhost/assets/#{Rails.application.assets.find_asset('favicon.png').digest_path}"
favicon_path = "http://localhost/assets/#{find_asset('favicon.png').digest_path}"
# Creates comment
expect(WebMock).to have_requested(:post, @comment_url)
......
......@@ -4,6 +4,7 @@ describe SystemNoteService do
include ProjectForksHelper
include Gitlab::Routing
include RepoHelpers
include AssetsHelpers
set(:group) { create(:group) }
let(:project) { create(:project, :repository, group: group) }
......@@ -771,7 +772,7 @@ describe SystemNoteService do
end
describe "new reference" do
let(:favicon_path) { "http://localhost/assets/#{Rails.application.assets.find_asset('favicon.png').digest_path}" }
let(:favicon_path) { "http://localhost/assets/#{find_asset('favicon.png').digest_path}" }
before do
allow(JIRA::Resource::Remotelink).to receive(:all).and_return([])
......
module AssetsHelpers
# In a CI environment the assets are not compiled, as there is a CI job
# `compile-assets` that compiles them in the prepare stage for all following
# specs.
# Locally the assets are precompiled dynamically.
#
# Sprockets doesn't provide one method to access an asset for both cases.
def find_asset(asset_name)
if ENV['CI']
Sprockets::Railtie.build_environment(Rails.application, true)[asset_name]
else
Rails.application.assets.find_asset(asset_name)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment