1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- require 'rails_helper'
- RSpec.describe Issue1905ExchangeLoginFromRemoteId, type: :db_migration do
- let(:backend) { ::Import::Exchange }
- it 'removes :item_id from attributes' do
- invalid_config = {
- attributes: {
- item_id: 'login',
- some: 'other',
- }
- }
- valid_config = ActiveSupport::HashWithIndifferentAccess.new(
- attributes: {
- some: 'other',
- }
- )
- expect(backend).to receive(:config).and_return(invalid_config) # rubocop:disable RSpec/StubbedMock
- allow(backend).to receive(:config).and_call_original
- migrate
- expect(backend.config).to eq(valid_config)
- end
- context 'no changes' do
- it 'performs no action for new systems', system_init_done: false do
- expect(backend).not_to receive(:config)
- migrate
- end
- shared_examples 'irrelevant config' do
- it 'does not change the config' do
- allow(backend).to receive(:config).and_return(config)
- expect(backend).not_to receive(:config=)
- migrate
- end
- end
- context 'blank config' do
- let(:config) { nil }
- it_behaves_like 'irrelevant config'
- end
- context 'blank attributes' do
- let(:config) do
- {
- some: 'config'
- }
- end
- it_behaves_like 'irrelevant config'
- end
- context 'blank attribute :item_id' do
- let(:config) do
- {
- attributes: {
- some: 'mapping'
- }
- }
- end
- it_behaves_like 'irrelevant config'
- end
- context 'attribute :item_id not mapping to login' do
- let(:config) do
- {
- attributes: {
- item_id: 'other_local_attribute'
- }
- }
- end
- it_behaves_like 'irrelevant config'
- end
- end
- end
|