mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 13:39:36 -06:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
38 lines
1.0 KiB
Ruby
38 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "import_export"
|
|
|
|
describe ImportExport::TopicExporter do
|
|
|
|
before do
|
|
STDOUT.stubs(:write)
|
|
end
|
|
|
|
fab!(:user) { Fabricate(:user) }
|
|
fab!(:topic) { Fabricate(:topic, user: user) }
|
|
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
|
|
|
|
context '.perform' do
|
|
it 'export a single topic' do
|
|
data = ImportExport::TopicExporter.new([topic.id]).perform.export_data
|
|
|
|
expect(data[:categories].blank?).to eq(true)
|
|
expect(data[:groups].blank?).to eq(true)
|
|
expect(data[:topics].count).to eq(1)
|
|
expect(data[:users].count).to eq(1)
|
|
end
|
|
|
|
it 'export multiple topics' do
|
|
topic2 = Fabricate(:topic, user: user)
|
|
_post2 = Fabricate(:post, user: user, topic: topic2)
|
|
data = ImportExport::TopicExporter.new([topic.id, topic2.id]).perform.export_data
|
|
|
|
expect(data[:categories].blank?).to eq(true)
|
|
expect(data[:groups].blank?).to eq(true)
|
|
expect(data[:topics].count).to eq(2)
|
|
expect(data[:users].map { |u| u[:id] }).to match_array([user.id])
|
|
end
|
|
end
|
|
|
|
end
|