diff options
author | Mike Greiling <mike@pixelcog.com> | 2016-12-30 14:47:12 -0600 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-01-03 10:56:39 -0600 |
commit | 2373082eb0d6b2f8eff9632a7b96febd9dd794c5 (patch) | |
tree | a94530969424238e45f633e149188c67acc64ad9 /spec/javascripts/fixtures | |
parent | 4cd962ec6ec2b037983c1a0d7c1097e8b1f70f52 (diff) | |
download | gitlab-ce-2373082eb0d6b2f8eff9632a7b96febd9dd794c5.tar.gz |
create catch-all fixture generator for all static fixtures
Diffstat (limited to 'spec/javascripts/fixtures')
-rw-r--r-- | spec/javascripts/fixtures/static_fixtures.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/javascripts/fixtures/static_fixtures.rb b/spec/javascripts/fixtures/static_fixtures.rb new file mode 100644 index 00000000000..4569f16f0ca --- /dev/null +++ b/spec/javascripts/fixtures/static_fixtures.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe ApplicationController, '(Static JavaScript fixtures)', type: :controller do + include JavaScriptFixturesHelpers + + before(:all) do + 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 + + 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) + end + end + + private + + def render_template(template_file_name) + fixture_path = JavaScriptFixturesHelpers::FIXTURE_PATH + controller = ApplicationController.new + controller.prepend_view_path(fixture_path) + controller.render_to_string(template: template_file_name, layout: false) + end +end |