DEV: clean up dependencies in spec

Follow up on zeitwork we needed to be a bit more explicit about a few
dependencies internally.

On certain orders the test suite could fail.
This commit is contained in:
Sam Saffron 2019-10-02 14:50:54 +10:00
parent 3f6af54fe1
commit 55ee9abecb
7 changed files with 11 additions and 14 deletions

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "import_export/importer" require "import_export/importer"
require "import_export/base_exporter"
require "import_export/category_structure_exporter" require "import_export/category_structure_exporter"
require "import_export/category_exporter" require "import_export/category_exporter"
require "import_export/topic_exporter" require "import_export/topic_exporter"

View File

@ -2,7 +2,6 @@
module ImportExport module ImportExport
class BaseExporter class BaseExporter
attr_reader :export_data, :categories attr_reader :export_data, :categories
CATEGORY_ATTRS = [:id, :name, :color, :created_at, :user_id, :slug, :description, :text_color, CATEGORY_ATTRS = [:id, :name, :color, :created_at, :user_id, :slug, :description, :text_color,

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require "import_export/base_exporter"
module ImportExport module ImportExport
class CategoryStructureExporter < BaseExporter class CategoryStructureExporter < BaseExporter

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "import_export/category_exporter" require "import_export"
describe ImportExport::CategoryExporter do describe ImportExport::CategoryExporter do
@ -24,7 +24,7 @@ describe ImportExport::CategoryExporter do
end end
it 'export the category with permission groups' do it 'export the category with permission groups' do
category_group = Fabricate(:category_group, category: category, group: group) _category_group = Fabricate(:category_group, category: category, group: group)
data = ImportExport::CategoryExporter.new([category.id]).perform.export_data data = ImportExport::CategoryExporter.new([category.id]).perform.export_data
expect(data[:categories].count).to eq(1) expect(data[:categories].count).to eq(1)
@ -33,7 +33,7 @@ describe ImportExport::CategoryExporter do
it 'export multiple categories' do it 'export multiple categories' do
category2 = Fabricate(:category) category2 = Fabricate(:category)
category_group = Fabricate(:category_group, category: category, group: group) _category_group = Fabricate(:category_group, category: category, group: group)
data = ImportExport::CategoryExporter.new([category.id, category2.id]).perform.export_data data = ImportExport::CategoryExporter.new([category.id, category2.id]).perform.export_data
expect(data[:categories].count).to eq(2) expect(data[:categories].count).to eq(2)
@ -45,8 +45,8 @@ describe ImportExport::CategoryExporter do
Fabricate(:post, topic: topic1, user: User.find(-1), post_number: 1) Fabricate(:post, topic: topic1, user: User.find(-1), post_number: 1)
topic2 = Fabricate(:topic, category: category, user: user) topic2 = Fabricate(:topic, category: category, user: user)
Fabricate(:post, topic: topic2, user: user, post_number: 1) Fabricate(:post, topic: topic2, user: user, post_number: 1)
reply1 = Fabricate(:post, topic: topic2, user: user2, post_number: 2) _reply1 = Fabricate(:post, topic: topic2, user: user2, post_number: 2)
reply2 = Fabricate(:post, topic: topic2, user: user3, post_number: 3) _reply2 = Fabricate(:post, topic: topic2, user: user3, post_number: 3)
data = ImportExport::CategoryExporter.new([category.id]).perform.export_data data = ImportExport::CategoryExporter.new([category.id]).perform.export_data
expect(data[:categories].count).to eq(1) expect(data[:categories].count).to eq(1)

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "import_export/category_exporter" require "import_export"
require "import_export/category_structure_exporter"
require "import_export/importer"
describe ImportExport::Importer do describe ImportExport::Importer do
@ -13,7 +11,7 @@ describe ImportExport::Importer do
let(:import_data) do let(:import_data) do
import_file = Rack::Test::UploadedFile.new(file_from_fixtures("import-export.json", "json")) import_file = Rack::Test::UploadedFile.new(file_from_fixtures("import-export.json", "json"))
data = ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(import_file.read)) ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(import_file.read))
end end
def import(data) def import(data)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "rails_helper" require "rails_helper"
require "import_export/topic_exporter" require "import_export"
describe ImportExport::TopicExporter do describe ImportExport::TopicExporter do
@ -25,7 +25,7 @@ describe ImportExport::TopicExporter do
it 'export multiple topics' do it 'export multiple topics' do
topic2 = Fabricate(:topic, user: user) topic2 = Fabricate(:topic, user: user)
post2 = Fabricate(:post, user: user, topic: topic2) _post2 = Fabricate(:post, user: user, topic: topic2)
data = ImportExport::TopicExporter.new([topic.id, topic2.id]).perform.export_data data = ImportExport::TopicExporter.new([topic.id, topic2.id]).perform.export_data
expect(data[:categories].blank?).to eq(true) expect(data[:categories].blank?).to eq(true)

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 's3_helper'
require 'backup_restore/s3_backup_store' require 'backup_restore/s3_backup_store'
require_relative 'shared_examples_for_backup_store' require_relative 'shared_examples_for_backup_store'