Fix name resolving error on export (#2612)
* Fix name resolving error on export * Fix exporter service spec
This commit is contained in:
parent
af83bab2d0
commit
2ea6accec1
2 changed files with 12 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue