diff options
Diffstat (limited to 'spec/support/helpers/javascript_fixtures_helpers.rb')
-rw-r--r-- | spec/support/helpers/javascript_fixtures_helpers.rb | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb index 89c5ec7a718..f525b2f945e 100644 --- a/spec/support/helpers/javascript_fixtures_helpers.rb +++ b/spec/support/helpers/javascript_fixtures_helpers.rb @@ -2,11 +2,12 @@ require 'action_dispatch/testing/test_request' require 'fileutils' module JavaScriptFixturesHelpers + extend ActiveSupport::Concern include Gitlab::Popen - FIXTURE_PATH = 'spec/javascripts/fixtures'.freeze + FIXTURE_PATHS = %w[spec/javascripts/fixtures ee/spec/javascripts/fixtures].freeze - def self.included(base) + included do |base| base.around do |example| # pick an arbitrary date from the past, so tests are not time dependent Timecop.freeze(Time.utc(2015, 7, 3, 10)) { example.run } @@ -15,26 +16,30 @@ module JavaScriptFixturesHelpers # Public: Removes all fixture files from given directory # - # directory_name - directory of the fixtures (relative to FIXTURE_PATH) + # directory_name - directory of the fixtures (relative to FIXTURE_PATHS) # def clean_frontend_fixtures(directory_name) - directory_name = File.expand_path(directory_name, FIXTURE_PATH) - Dir[File.expand_path('*.html.raw', directory_name)].each do |file_name| - FileUtils.rm(file_name) + FIXTURE_PATHS.each do |fixture_path| + directory_name = File.expand_path(directory_name, fixture_path) + Dir[File.expand_path('*.html.raw', directory_name)].each do |file_name| + FileUtils.rm(file_name) + end end end # Public: Store a response object as fixture file # # response - string or response object to store - # fixture_file_name - file name to store the fixture in (relative to FIXTURE_PATH) + # fixture_file_name - file name to store the fixture in (relative to FIXTURE_PATHS) # def store_frontend_fixture(response, fixture_file_name) - fixture_file_name = File.expand_path(fixture_file_name, FIXTURE_PATH) - fixture = response.respond_to?(:body) ? parse_response(response) : response + FIXTURE_PATHS.each do |fixture_path| + fixture_file_name = File.expand_path(fixture_file_name, fixture_path) + fixture = response.respond_to?(:body) ? parse_response(response) : response - FileUtils.mkdir_p(File.dirname(fixture_file_name)) - File.write(fixture_file_name, fixture) + FileUtils.mkdir_p(File.dirname(fixture_file_name)) + File.write(fixture_file_name, fixture) + end end def remove_repository(project) |