summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2017-01-06 16:12:59 +0000
committerAlfredo Sumaran <alfredo@gitlab.com>2017-01-06 16:12:59 +0000
commit57652bf58482dd1b4ac26b5f804d3d4ece6591d8 (patch)
tree01b907268b022696d33b1d64471e53c20e87a974 /spec/support
parent729636bdc6eda769ad5e8eda48a6ed722e854cd7 (diff)
parentf19330e4fbef7f893af86c6e9b06d3378c3ef936 (diff)
downloadgitlab-ce-57652bf58482dd1b4ac26b5f804d3d4ece6591d8.tar.gz
Merge branch '26226-generate-all-haml-fixtures-within-teaspoon-fixtures-task' into 'master'
Precompile all frontend test fixtures Closes #26226 See merge request !8384
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/javascript_fixtures_helpers.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/support/javascript_fixtures_helpers.rb b/spec/support/javascript_fixtures_helpers.rb
index d15aac61b18..0b8729db0f9 100644
--- a/spec/support/javascript_fixtures_helpers.rb
+++ b/spec/support/javascript_fixtures_helpers.rb
@@ -20,11 +20,24 @@ module JavaScriptFixturesHelpers
# Public: Store a response object as fixture file
#
- # response - response object to store
+ # response - string or response object to store
# fixture_file_name - file name to store the fixture in (relative to FIXTURE_PATH)
#
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
+
+ FileUtils.mkdir_p(File.dirname(fixture_file_name))
+ File.write(fixture_file_name, fixture)
+ end
+
+ private
+
+ # Private: Prepare a response object for use as a frontend fixture
+ #
+ # response - response object to prepare
+ #
+ def parse_response(response)
fixture = response.body
fixture.force_encoding("utf-8")
@@ -45,7 +58,6 @@ module JavaScriptFixturesHelpers
fixture.gsub!(%r{="/}, "=\"http://#{test_host}/")
end
- FileUtils.mkdir_p(File.dirname(fixture_file_name))
- File.write(fixture_file_name, fixture)
+ fixture
end
end