diff options
author | Rémy Coutable <remy@rymai.me> | 2019-03-12 20:20:46 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-03-19 10:46:22 +0300 |
commit | b789bfaeefd9838c33f13c028893424025ade1ad (patch) | |
tree | 3fcd3267fc58c5330ddc0a408b42fb2f34adaebd /spec/javascripts/fixtures | |
parent | 68aacd65ae3c53f3c1d2cf081adc89e3758c52de (diff) |
Simplify the JavaScriptFixturesHelpers module
- Only storing fixtures in one place
- This place changes whether we are in CE or EE
We discovered with @winh that only fixtures located under
spec/javascripts/fixtures are used, even in EE so there's no need to
clean/create fixtures in ee/spec/javascripts/fixtures.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/javascripts/fixtures')
-rw-r--r-- | spec/javascripts/fixtures/emojis.rb | 20 | ||||
-rw-r--r-- | spec/javascripts/fixtures/static_fixtures.rb | 20 |
2 files changed, 6 insertions, 34 deletions
diff --git a/spec/javascripts/fixtures/emojis.rb b/spec/javascripts/fixtures/emojis.rb deleted file mode 100644 index 4dab697e5e2..00000000000 --- a/spec/javascripts/fixtures/emojis.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'Emojis (JavaScript fixtures)' do - include JavaScriptFixturesHelpers - - before(:all) do - clean_frontend_fixtures('emojis/') - end - - it 'emojis/emojis.json' do |example| - JavaScriptFixturesHelpers::FIXTURE_PATHS.each do |fixture_path| - next unless File.directory?(fixture_path) - - # Copying the emojis.json from the public folder - fixture_file_name = File.expand_path('emojis/emojis.json', fixture_path) - FileUtils.mkdir_p(File.dirname(fixture_file_name)) - FileUtils.cp(Rails.root.join('public/-/emojis/1/emojis.json'), fixture_file_name) - end - end -end diff --git a/spec/javascripts/fixtures/static_fixtures.rb b/spec/javascripts/fixtures/static_fixtures.rb index 852a82587b9..78224471ea9 100644 --- a/spec/javascripts/fixtures/static_fixtures.rb +++ b/spec/javascripts/fixtures/static_fixtures.rb @@ -7,25 +7,17 @@ describe ApplicationController, '(Static JavaScript fixtures)', type: :controlle 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/, '.raw')}" 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 |