summaryrefslogtreecommitdiff
path: root/spec/javascripts/fixtures/static_fixtures.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/fixtures/static_fixtures.rb')
-rw-r--r--spec/javascripts/fixtures/static_fixtures.rb24
1 files changed, 6 insertions, 18 deletions
diff --git a/spec/javascripts/fixtures/static_fixtures.rb b/spec/javascripts/fixtures/static_fixtures.rb
index 852a82587b9..cb4b90cdca5 100644
--- a/spec/javascripts/fixtures/static_fixtures.rb
+++ b/spec/javascripts/fixtures/static_fixtures.rb
@@ -3,29 +3,17 @@ require 'spec_helper'
describe ApplicationController, '(Static JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
- before(:all) do
- clean_frontend_fixtures('static/')
- 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}/, '')
-
- 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
+ Dir.glob('{,ee/}spec/javascripts/fixtures/**/*.haml').map do |file_path|
+ it "static/#{file_path.sub(%r{\A(ee/)?spec/javascripts/fixtures/}, '').sub(/\.haml\z/, '')}" do |example|
+ store_frontend_fixture(render_template(file_path), example.description)
end
end
private
- def render_template(fixture_path, template_file_name)
+ def render_template(template_file_name)
controller = ApplicationController.new
- controller.prepend_view_path(fixture_path)
- controller.render_to_string(template: template_file_name, layout: false)
+ controller.prepend_view_path(File.dirname(template_file_name))
+ controller.render_to_string(template: File.basename(template_file_name), layout: false)
end
end