|
|
|
@ -149,7 +149,7 @@ describe Synchronization::Member do
|
|
|
|
|
@user1.reload
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'now works with tables with views' do
|
|
|
|
|
it 'fails to overwrite tables with views by replacement' do
|
|
|
|
|
url = 'https://wadus.com/guess_country.csv'
|
|
|
|
|
|
|
|
|
|
path = fake_data_path('guess_country.csv')
|
|
|
|
@ -169,6 +169,31 @@ describe Synchronization::Member do
|
|
|
|
|
|
|
|
|
|
@user2.in_database.execute('CREATE VIEW wadus AS SELECT * FROM guess_country')
|
|
|
|
|
|
|
|
|
|
member.run
|
|
|
|
|
expect(member.state).to eq 'failure'
|
|
|
|
|
expect(member.error_code).to eq 2013
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'it can overwrite tables with views by sync' do
|
|
|
|
|
url = 'https://wadus.com/guess_country_geocoded.csv'
|
|
|
|
|
|
|
|
|
|
path = fake_data_path('guess_country_geocoded.csv')
|
|
|
|
|
stub_download(url: url, filepath: path, content_disposition: false)
|
|
|
|
|
|
|
|
|
|
attrs = random_attributes(user_id: @user2.id).merge(service_item_id: url, url: url, name: 'guess_country_geocoded')
|
|
|
|
|
member = Synchronization::Member.new(attrs).store
|
|
|
|
|
|
|
|
|
|
DataImport.create(
|
|
|
|
|
user_id: @user2.id,
|
|
|
|
|
data_source: path,
|
|
|
|
|
synchronization_id: member.id,
|
|
|
|
|
service_name: 'public_url',
|
|
|
|
|
service_item_id: url,
|
|
|
|
|
updated_at: Time.now
|
|
|
|
|
).run_import!
|
|
|
|
|
|
|
|
|
|
@user2.in_database.execute('CREATE VIEW wadus_geocoded AS SELECT * FROM guess_country_geocoded')
|
|
|
|
|
|
|
|
|
|
member.run
|
|
|
|
|
expect(member.state).to eq 'success'
|
|
|
|
|
end
|
|
|
|
|