mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-12 16:14:58 +08:00
Fix empty file name on protocols.io
Closes SCI-3650
This commit is contained in:
parent
e965866d57
commit
8866d98512
4 changed files with 21 additions and 4 deletions
|
@ -51,9 +51,12 @@ module ProtocolImporters
|
||||||
|
|
||||||
def self.attachments(components)
|
def self.attachments(components)
|
||||||
components.select { |c| c[:type_id] == 23 }.map do |cc|
|
components.select { |c| c[:type_id] == 23 }.map do |cc|
|
||||||
|
# Original name can be empty, so just use source
|
||||||
|
name = cc[:source][:original_name] || cc[:source][:source].split('/')[-1]
|
||||||
|
|
||||||
{
|
{
|
||||||
url: cc[:source][:source],
|
url: cc[:source][:source],
|
||||||
name: cc[:source][:name]
|
name: name
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -110,6 +110,10 @@
|
||||||
{
|
{
|
||||||
"url": "http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg",
|
"url": "http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg",
|
||||||
"name": "Second file"
|
"name": "Second file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg",
|
||||||
|
"name": "14506718045_5b3e71dacd_o.jpg"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": 0
|
"position": 0
|
||||||
|
|
|
@ -579,7 +579,7 @@
|
||||||
"type_id": 23,
|
"type_id": 23,
|
||||||
"title": "file",
|
"title": "file",
|
||||||
"source": {
|
"source": {
|
||||||
"name": "First file",
|
"original_name": "First file",
|
||||||
"source": "https://pbs.twimg.com/media/Cwu3zrZWQAA7axs.jpg"
|
"source": "https://pbs.twimg.com/media/Cwu3zrZWQAA7axs.jpg"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -590,7 +590,17 @@
|
||||||
"type_id": 23,
|
"type_id": 23,
|
||||||
"title": "file",
|
"title": "file",
|
||||||
"source": {
|
"source": {
|
||||||
"name": "Second file",
|
"original_name": "Second file",
|
||||||
|
"source": "http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1054723,
|
||||||
|
"guid": "A85D4EBC0F394B38A4C8D65D5CB6877F",
|
||||||
|
"order_id": 4,
|
||||||
|
"type_id": 23,
|
||||||
|
"title": "file",
|
||||||
|
"source": {
|
||||||
"source": "http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg"
|
"source": "http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe ProtocolImporters::ProtocolIntermediateObject do
|
||||||
context 'when have valid object' do
|
context 'when have valid object' do
|
||||||
it { expect { pio.import }.to change { Protocol.all.count }.by(1) }
|
it { expect { pio.import }.to change { Protocol.all.count }.by(1) }
|
||||||
it { expect { pio.import }.to change { Step.all.count }.by(2) }
|
it { expect { pio.import }.to change { Step.all.count }.by(2) }
|
||||||
it { expect { pio.import }.to change { Asset.all.count }.by(2) }
|
it { expect { pio.import }.to change { Asset.all.count }.by(3) }
|
||||||
it { expect(pio.import).to be_valid }
|
it { expect(pio.import).to be_valid }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue