From 2ea6accec12b86f4ba1d5c692660f3255859e560 Mon Sep 17 00:00:00 2001 From: Anna Buianova Date: Mon, 29 Apr 2019 22:37:50 +0300 Subject: [PATCH] Fix name resolving error on export (#2612) * Fix name resolving error on export * Fix exporter service spec --- app/services/exporter/service.rb | 6 +++--- spec/services/exporter/service_spec.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/services/exporter/service.rb b/app/services/exporter/service.rb index 44058710f..29b8de068 100644 --- a/app/services/exporter/service.rb +++ b/app/services/exporter/service.rb @@ -5,8 +5,8 @@ module Exporter attr_reader :user EXPORTERS = [ - Articles, - Comments, + Exporter::Articles, + Exporter::Comments, ].freeze def initialize(user) @@ -18,7 +18,7 @@ module Exporter # export content with filenames EXPORTERS.each do |exporter| - files = exporter.new(user).export(config.fetch(exporter.name.to_sym, {})) + files = exporter.new(user).export(config.fetch(exporter.name.demodulize.downcase.to_sym, {})) files.each do |name, content| exports[name] = content end diff --git a/spec/services/exporter/service_spec.rb b/spec/services/exporter/service_spec.rb index d0aef4827..f4efb5b61 100644 --- a/spec/services/exporter/service_spec.rb +++ b/spec/services/exporter/service_spec.rb @@ -59,6 +59,15 @@ RSpec.describe Exporter::Service do expect(exports.length).to eq(described_class::EXPORTERS.size) end + it "fetches the passed config" do + service = valid_instance(article.user) + config = double + allow(config).to receive(:fetch).with(:articles, {}).and_return(slug: article.slug) + allow(config).to receive(:fetch).with(:comments, {}).and_return({}) + service.export(config: config) + expect(config).to have_received(:fetch).with(:articles, {}) + end + context "when emailing the user" do it "delivers one email" do service = valid_instance(article.user)