diff options
author | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2018-05-22 19:37:35 +0300 |
---|---|---|
committer | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2018-06-06 12:28:13 +0300 |
commit | 29598f6e6d8ebbe9c1b64018fcb925655ccceb67 (patch) | |
tree | 8b5dbd23ad73bceff2dde81ee7125799b54690ac /spec | |
parent | d2256300e559e836884fea57210266dae764f13e (diff) |
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.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_services/jira_service_spec.rb | 3 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 3 | ||||
-rw-r--r-- | spec/support/helpers/assets_helpers.rb | 15 |
3 files changed, 19 insertions, 2 deletions
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index 50bdb80ff92..c3b4eb17a5c 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -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) diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index e2ee421921c..57d081cffb3 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe SystemNoteService do include Gitlab::Routing include RepoHelpers + include AssetsHelpers set(:group) { create(:group) } set(:project) { create(:project, :repository, group: group) } @@ -769,7 +770,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([]) diff --git a/spec/support/helpers/assets_helpers.rb b/spec/support/helpers/assets_helpers.rb new file mode 100644 index 00000000000..09bbf451671 --- /dev/null +++ b/spec/support/helpers/assets_helpers.rb @@ -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 |