Skip to content

Commit 07270f5

Browse files
committed
feat: use given short_label in reaction (#2970)
1 parent 3606132 commit 07270f5

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

app/models/reaction.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ def cleanup_array_fields
289289
end
290290

291291
def auto_set_short_label
292+
return if short_label.present?
293+
292294
prefix = creator.reaction_name_prefix
293295
counter = creator.counters['reactions'].succ
294296
self.short_label = "#{creator.initials}-#{prefix}#{counter}"
@@ -299,9 +301,10 @@ def update_counter
299301
end
300302

301303
def scrub
302-
if temperature&.fetch('userText', nil).present?
303-
self.temperature = temperature.merge('userText' => scrubber(temperature['userText']))
304-
end
304+
return if temperature&.fetch('userText', nil).blank?
305+
306+
self.temperature = temperature.merge('userText' => scrubber(temperature['userText']))
307+
305308
# Conditions are not scrubbed: plain text may contain "<" or ">" (e.g. "pH < 7");
306309
# scrub_xml would strip them. Conditions are escaped at display time.
307310
end

spec/lib/import/import_collections_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
expect(reaction.temperature.to_s).to eq('{"data"=>[], "userText"=>"30", "valueUnit"=>"°C"}')
8888
expect(reaction.status).to eq('Done')
8989
expect(reaction.solvent).to eq('')
90-
expect(reaction.short_label).to eq('UU-R1')
90+
expect(reaction.short_label).to eq('FM-R2')
9191
expect(reaction.role).to eq('gp')
9292
expect(reaction.duration).to eq('1 Day(s)')
9393
expect(reaction.conditions).to eq('')

0 commit comments

Comments
 (0)