Skip to content

Commit

Permalink
skip ActiveFedora specs if disable_wings is on
Browse files Browse the repository at this point in the history
if we're flagging `disable_wings`, there's no FCRepo backend for this
system. don't run any tests that are focused on ensuring FCRepo related or
ActiveFedora related behavior.

Anything tested in this way should eventually be deprecated and removed.
  • Loading branch information
tamsin johnson authored and tamsin johnson committed Aug 23, 2023
1 parent e285a4a commit 4720476
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 15 deletions.
8 changes: 7 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ def clean_active_fedora_repository

config.profile_examples = 10

config.before(:example, :active_fedora) do
skip("Don't test Wings") if Hyrax.config.disable_wings
end

config.before(:example, :clean_repo) do
clean_active_fedora_repository unless Hyrax.config.disable_wings
Hyrax::RedisEventStore.instance.then(&:flushdb)
Expand Down Expand Up @@ -331,7 +335,9 @@ def clean_active_fedora_repository
.to receive(:metadata_adapter)
.and_return(Valkyrie::MetadataAdapter.find(adapter_name))

if adapter_name != :wings_adapter
if adapter_name == :wings_adapter
skip("Don't test Wings when it is dasabled") if Hyrax.config.disable_wings
else
allow(Hyrax.config).to receive(:disable_wings).and_return(true)
hide_const("Wings") # disable_wings=true removes the Wings constant
end
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/active_fedora_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'wings'
require 'wings/active_fedora_converter'

RSpec.describe Wings::ActiveFedoraConverter, :clean_repo do
RSpec.describe Wings::ActiveFedoraConverter, :active_fedora, :clean_repo do
subject(:converter) { described_class.new(resource: resource) }
let(:attributes) { { id: id } }
let(:id) { 'moomin_id' }
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/attribute_transformer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'wings/attribute_transformer'

RSpec.describe Wings::AttributeTransformer do
RSpec.describe Wings::AttributeTransformer, :active_fedora do
let(:id) { 'moomin123' }
let(:work) { GenericWork.new(id: id, **attributes) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'wings_helper'
require 'wings/hydra/works/services/add_file_to_file_set'

RSpec.describe Wings::Works::AddFileToFileSet, :clean_repo do
RSpec.describe Wings::Works::AddFileToFileSet, :active_fedora, :clean_repo do
let(:af_file_set) { create(:file_set, id: 'fileset_id') }
let!(:file_set) { af_file_set.valkyrie_resource }

Expand Down
2 changes: 1 addition & 1 deletion spec/wings/model_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'wings_helper'
require 'wings/model_transformer'

RSpec.describe Wings::ModelTransformer, :clean_repo do
RSpec.describe Wings::ModelTransformer, :active_fedora, :clean_repo do
subject(:factory) { described_class.new(pcdm_object: pcdm_object) }
let(:pcdm_object) { work }
let(:adapter) { Valkyrie::MetadataAdapter.find(:memory) }
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/orm_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'wings_helper'
require 'wings/orm_converter'

RSpec.describe Wings::OrmConverter do
RSpec.describe Wings::OrmConverter, :active_fedora do
describe '.to_valkyrie_resource_class' do
context 'when given a ActiveFedora class (eg. a constant that responds to #properties)' do
context 'for the returned object (e.g. a class)' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'wings_helper'
require 'wings/services/custom_queries/find_access_control'

RSpec.describe Wings::CustomQueries::FindAccessControl do
RSpec.describe Wings::CustomQueries::FindAccessControl, :active_fedora do
subject(:query_handler) { described_class.new(query_service: query_service) }
let(:adapter) { Valkyrie::MetadataAdapter.find(:wings_adapter) }
let(:persister) { adapter.persister }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'wings_helper'
require 'wings/services/custom_queries/find_collections_by_type'

RSpec.describe Wings::CustomQueries::FindCollectionsByType, :clean_repo do
RSpec.describe Wings::CustomQueries::FindCollectionsByType, :active_fedora, :clean_repo do
subject(:query_handler) { described_class.new(query_service: query_service) }
let(:collection_type) { FactoryBot.create(:collection_type) }
let(:type_gid) { collection_type.to_global_id }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'wings/hydra/works/services/add_file_to_file_set'
require 'wings/services/custom_queries/find_file_metadata'

RSpec.describe Wings::CustomQueries::FindFileMetadata, :clean_repo do
RSpec.describe Wings::CustomQueries::FindFileMetadata, :active_fedora, :clean_repo do
subject(:query_handler) { described_class.new(query_service: query_service) }
let(:query_service) { Hyrax.query_service }
let(:af_file_id1) { 'file1' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'wings_helper'
require 'wings/services/custom_queries/find_many_by_alternate_ids'

RSpec.describe Wings::CustomQueries::FindManyByAlternateIds do
RSpec.describe Wings::CustomQueries::FindManyByAlternateIds, :active_fedora do
let(:query_service) { Hyrax.query_service }

let(:work1) { create(:public_work) }
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/transformer_value_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'spec_helper'
require 'wings/transformer_value_mapper'

RSpec.describe Wings::TransformerValueMapper do
RSpec.describe Wings::TransformerValueMapper, :active_fedora do
subject(:mapper) { described_class.for(value) }
let(:value) { 'a value' }
let(:uri) { RDF::URI('http://example.com/moomin') }
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/valkyrie/persister_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'valkyrie/specs/shared_specs'
require 'wings'

RSpec.describe Wings::Valkyrie::Persister do
RSpec.describe Wings::Valkyrie::Persister, :active_fedora do
subject(:persister) { described_class.new(adapter: adapter) }
let(:adapter) { Wings::Valkyrie::MetadataAdapter.new }
let(:query_service) { adapter.query_service }
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/valkyrie/query_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'valkyrie/specs/shared_specs'
require 'wings'

RSpec.describe Wings::Valkyrie::QueryService, :clean_repo do
RSpec.describe Wings::Valkyrie::QueryService, :active_fedora, :clean_repo do
before do
module Hyrax::Test
module QueryService
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/valkyrie/resource_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'spec_helper'
require 'wings'

RSpec.describe Wings::Valkyrie::ResourceFactory do
RSpec.describe Wings::Valkyrie::ResourceFactory, :active_fedora do
subject(:factory) { described_class.new(adapter: adapter) }
let(:adapter) { Valkyrie::Persistence::Memory::MetadataAdapter.new }
let(:work) { GenericWork.new }
Expand Down
2 changes: 1 addition & 1 deletion spec/wings/valkyrie/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'hyrax/specs/shared_specs/valkyrie_storage_versions'
require 'valkyrie/specs/shared_specs'

RSpec.describe Wings::Valkyrie::Storage, :clean_repo do
RSpec.describe Wings::Valkyrie::Storage, :active_fedora, :clean_repo do
subject(:storage_adapter) { described_class.new }
let(:file) { fixture_file_upload('/world.png', 'image/png') }

Expand Down

0 comments on commit 4720476

Please sign in to comment.