Skip to content

Commit

Permalink
Merge branch 'herbarium_accession_number_observation_form' into autoc…
Browse files Browse the repository at this point in the history
…ompleters-refactor-js
  • Loading branch information
nimmolo committed Jun 22, 2024
2 parents 16a17b3 + 107a172 commit 6c9ebb9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions app/controllers/observations_controller/form_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def init_specimen_vars
@collectors_name = @user.legal_name
@collectors_number = ""
@herbarium_name = @user.preferred_herbarium_name
@herbarium_id = ""
@accession_number = ""
end

def init_specimen_vars_for_reload
Expand All @@ -74,8 +74,8 @@ def init_specimen_vars_for_reload
end
return unless params[:herbarium_record]

@herbarium_name = params[:herbarium_record][:herbarium_name]
@herbarium_id = params[:herbarium_record][:herbarium_id]
@herbarium_name = params[:herbarium_record][:herbarium_name]
@accession_number = params[:herbarium_record][:accession_number]
end

def init_project_vars
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/observations_controller/new_and_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def normalize_herbarium_record_params(obs, params)
herbarium = params2[:herbarium_name].to_s.strip_html.strip_squeeze
herbarium = lookup_herbarium(herbarium)
init_det = initial_determination(obs)
accession = params2[:herbarium_id].to_s.strip_html.strip_squeeze
accession = params2[:accession_number].to_s.strip_html.strip_squeeze
accession = default_accession_number(obs, params) if accession.blank?
notes = params2[:herbarium_record_notes]
[herbarium, init_det, accession, notes]
Expand Down Expand Up @@ -297,7 +297,7 @@ def not_creating_record?(obs, herbarium, accession_number)
# If user checks specimen box and nothing else, do not create record.
obs.collection_numbers.empty? &&
herbarium == @user.preferred_herbarium &&
params[:herbarium_record][:herbarium_id].blank?
params[:herbarium_record][:accession_number].blank?
end

def redirect_to_next_page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
) %>
<%= text_field_with_label(
form: fhr, field: :herbarium_id, value: @herbarium_id,
form: fhr, field: :accession_number, value: @accession_number,
label: "#{:herbarium_record_accession_number.t}:",
data: { action: "specimen#checkCheckbox" }
) %>
Expand Down
25 changes: 12 additions & 13 deletions test/controllers/observations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def default_collection_number_fields
end

def default_herbarium_record_fields
{ herbarium_name: "", herbarium_id: "" }
{ herbarium_name: "", accession_number: "" }
end

def location_exists_or_place_name_blank(params)
Expand Down Expand Up @@ -1436,7 +1436,7 @@ def test_create_new_observation
assert_input_value(:collection_number_number, "")
assert_input_value(:herbarium_record_herbarium_name,
users(:rolf).preferred_herbarium_name)
assert_input_value(:herbarium_record_herbarium_id, "")
assert_input_value(:herbarium_record_accession_number, "")
assert_true(@response.body.include?("Albion, Mendocino Co., California"))
users(:rolf).update(location_format: "scientific")
get(:new)
Expand Down Expand Up @@ -1577,7 +1577,7 @@ def test_create_observation_with_herbarium_record
{ observation: { specimen: "1" },
herbarium_record: {
herbarium_name: herbaria(:nybg_herbarium).auto_complete_name,
herbarium_id: "1234"
accession_number: "1234"
},
naming: { name: "Coprinus comatus" } },
1, 1, 0
Expand All @@ -1592,14 +1592,14 @@ def test_create_observation_with_herbarium_duplicate_label
{ observation: { specimen: "1" },
herbarium_record: {
herbarium_name: herbaria(:nybg_herbarium).auto_complete_name,
herbarium_id: "1234"
accession_number: "1234"
},
naming: { name: "Cortinarius sp." } },
0, 0, 0
)
assert_input_value(:herbarium_record_herbarium_name,
"NY - The New York Botanical Garden")
assert_input_value(:herbarium_record_herbarium_id, "1234")
assert_input_value(:herbarium_record_accession_number, "1234")
end

def test_create_observation_with_herbarium_no_id
Expand All @@ -1608,7 +1608,7 @@ def test_create_observation_with_herbarium_no_id
{ observation: { specimen: "1" },
herbarium_record: {
herbarium_name: herbaria(:nybg_herbarium).auto_complete_name,
herbarium_id: ""
accession_number: ""
},
naming: { name: name } },
1, 1, 0
Expand All @@ -1620,11 +1620,10 @@ def test_create_observation_with_herbarium_no_id

def test_create_observation_with_herbarium_but_no_specimen
generic_construct_observation(
{ herbarium_record:
{ herbarium_name: herbaria(
:nybg_herbarium
).auto_complete_name,
herbarium_id: "1234" },
{ herbarium_record: {
herbarium_name: herbaria(:nybg_herbarium).auto_complete_name,
accession_number: "1234"
},
naming: { name: "Coprinus comatus" } },
1, 1, 0
)
Expand All @@ -1637,7 +1636,7 @@ def test_create_observation_with_new_nonpersonal_herbarium
generic_construct_observation(
{ observation: { specimen: "1" },
herbarium_record: { herbarium_name: "A Brand New Herbarium",
herbarium_id: "" },
accession_number: "" },
naming: { name: "Coprinus comatus" } },
1, 1, 0
)
Expand All @@ -1650,7 +1649,7 @@ def test_create_observation_with_new_personal_herbarium
generic_construct_observation(
{ observation: { specimen: "1" },
herbarium_record: { herbarium_name: katrina.personal_herbarium_name,
herbarium_id: "12345" },
accession_number: "12345" },
naming: { name: "Coprinus comatus" } },
1, 1, 0, katrina
)
Expand Down

0 comments on commit 6c9ebb9

Please sign in to comment.