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.
This commit is contained in:
parent
d2256300e5
commit
29598f6e6d
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe JiraService do
|
describe JiraService do
|
||||||
include Gitlab::Routing
|
include Gitlab::Routing
|
||||||
|
include AssetsHelpers
|
||||||
|
|
||||||
describe '#options' do
|
describe '#options' do
|
||||||
let(:service) do
|
let(:service) do
|
||||||
|
|
@ -164,7 +165,7 @@ describe JiraService do
|
||||||
it "creates Remote Link reference in JIRA for comment" do
|
it "creates Remote Link reference in JIRA for comment" do
|
||||||
@jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
|
@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
|
# Creates comment
|
||||||
expect(WebMock).to have_requested(:post, @comment_url)
|
expect(WebMock).to have_requested(:post, @comment_url)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
||||||
describe SystemNoteService do
|
describe SystemNoteService do
|
||||||
include Gitlab::Routing
|
include Gitlab::Routing
|
||||||
include RepoHelpers
|
include RepoHelpers
|
||||||
|
include AssetsHelpers
|
||||||
|
|
||||||
set(:group) { create(:group) }
|
set(:group) { create(:group) }
|
||||||
set(:project) { create(:project, :repository, group: group) }
|
set(:project) { create(:project, :repository, group: group) }
|
||||||
|
|
@ -769,7 +770,7 @@ describe SystemNoteService do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "new reference" do
|
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
|
before do
|
||||||
allow(JIRA::Resource::Remotelink).to receive(:all).and_return([])
|
allow(JIRA::Resource::Remotelink).to receive(:all).and_return([])
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
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
|
||||||
Loading…
Reference in New Issue