Skip to content

Commit

Permalink
DEV: clean up dependencies in spec
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SamSaffron committed Oct 2, 2019
1 parent 3f6af54 commit 55ee9ab
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/import_export.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "import_export/importer"
require "import_export/base_exporter"
require "import_export/category_structure_exporter"
require "import_export/category_exporter"
require "import_export/topic_exporter"
Expand Down
1 change: 0 additions & 1 deletion lib/import_export/base_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module ImportExport
class BaseExporter

attr_reader :export_data, :categories

CATEGORY_ATTRS = [:id, :name, :color, :created_at, :user_id, :slug, :description, :text_color,
Expand Down
2 changes: 0 additions & 2 deletions lib/import_export/category_structure_exporter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "import_export/base_exporter"

module ImportExport
class CategoryStructureExporter < BaseExporter

Expand Down
10 changes: 5 additions & 5 deletions spec/import_export/category_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "rails_helper"
require "import_export/category_exporter"
require "import_export"

describe ImportExport::CategoryExporter do

Expand All @@ -24,7 +24,7 @@
end

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

expect(data[:categories].count).to eq(1)
Expand All @@ -33,7 +33,7 @@

it 'export multiple categories' do
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

expect(data[:categories].count).to eq(2)
Expand All @@ -45,8 +45,8 @@
Fabricate(:post, topic: topic1, user: User.find(-1), post_number: 1)
topic2 = Fabricate(:topic, category: category, user: user)
Fabricate(:post, topic: topic2, user: user, post_number: 1)
reply1 = Fabricate(:post, topic: topic2, user: user2, post_number: 2)
reply2 = Fabricate(:post, topic: topic2, user: user3, post_number: 3)
_reply1 = Fabricate(:post, topic: topic2, user: user2, post_number: 2)
_reply2 = Fabricate(:post, topic: topic2, user: user3, post_number: 3)
data = ImportExport::CategoryExporter.new([category.id]).perform.export_data

expect(data[:categories].count).to eq(1)
Expand Down
6 changes: 2 additions & 4 deletions spec/import_export/importer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "rails_helper"
require "import_export/category_exporter"
require "import_export/category_structure_exporter"
require "import_export/importer"
require "import_export"

describe ImportExport::Importer do

Expand All @@ -13,7 +11,7 @@

let(:import_data) do
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

def import(data)
Expand Down
4 changes: 2 additions & 2 deletions spec/import_export/topic_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "rails_helper"
require "import_export/topic_exporter"
require "import_export"

describe ImportExport::TopicExporter do

Expand All @@ -25,7 +25,7 @@

it 'export multiple topics' do
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

expect(data[:categories].blank?).to eq(true)
Expand Down
1 change: 1 addition & 0 deletions spec/lib/backup_restore/s3_backup_store_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
require 's3_helper'
require 'backup_restore/s3_backup_store'
require_relative 'shared_examples_for_backup_store'

Expand Down

0 comments on commit 55ee9ab

Please sign in to comment.