Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-02-26 20:11:26 +0300
committerRémy Coutable <remy@rymai.me>2019-03-07 10:13:37 +0300
commitf5e80ed6b24f5aacda2868a836ffe7b741cb422d (patch)
tree01f6a5e0e0334d9b92355b0707dcaf48c6312e28 /spec
parent68b7f99fa4ec7fe8ab0ef08508899ce4dff9ef13 (diff)
Reduce differences in spec/support/helpers/javascript_fixtures_helpers.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/fixtures/static_fixtures.rb22
-rw-r--r--spec/support/helpers/javascript_fixtures_helpers.rb27
2 files changed, 27 insertions, 22 deletions
diff --git a/spec/javascripts/fixtures/static_fixtures.rb b/spec/javascripts/fixtures/static_fixtures.rb
index 4569f16f0ca..852a82587b9 100644
--- a/spec/javascripts/fixtures/static_fixtures.rb
+++ b/spec/javascripts/fixtures/static_fixtures.rb
@@ -7,23 +7,23 @@ describe ApplicationController, '(Static JavaScript fixtures)', type: :controlle
clean_frontend_fixtures('static/')
end
- fixtures_path = File.expand_path(JavaScriptFixturesHelpers::FIXTURE_PATH, Rails.root)
- haml_fixtures = Dir.glob(File.expand_path('**/*.haml', fixtures_path)).map do |file_path|
- file_path.sub(/\A#{fixtures_path}#{File::SEPARATOR}/, '')
- end
+ JavaScriptFixturesHelpers::FIXTURE_PATHS.each do |fixture_path|
+ fixtures_path = File.expand_path(fixture_path, Rails.root)
+
+ Dir.glob(File.expand_path('**/*.haml', fixtures_path)).map do |file_path|
+ template_file_name = file_path.sub(/\A#{fixtures_path}#{File::SEPARATOR}/, '')
- haml_fixtures.each do |template_file_name|
- it "static/#{template_file_name.sub(/\.haml\z/, '.raw')}" do |example|
- fixture_file_name = example.description
- rendered = render_template(template_file_name)
- store_frontend_fixture(rendered, fixture_file_name)
+ it "static/#{template_file_name.sub(/\.haml\z/, '.raw')}" do |example|
+ fixture_file_name = example.description
+ rendered = render_template(fixture_path, template_file_name)
+ store_frontend_fixture(rendered, fixture_file_name)
+ end
end
end
private
- def render_template(template_file_name)
- fixture_path = JavaScriptFixturesHelpers::FIXTURE_PATH
+ def render_template(fixture_path, template_file_name)
controller = ApplicationController.new
controller.prepend_view_path(fixture_path)
controller.render_to_string(template: template_file_name, layout: false)
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)