Skip to content

Commit

Permalink
Fixes issue with default value being lost for resource_type_general
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea committed Dec 13, 2022
1 parent 1bc5647 commit 516891b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/form_to_resource_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def process_curator_controlled(params:, work:)
resource.version_number = params["version_number"] if params["version_number"].present?
resource.collection_tags = params["collection_tags"].split(",").map(&:strip) if params["collection_tags"]
resource.resource_type = params["resource_type"] if params["resource_type"]
resource.resource_type_general = params["resource_type_general"]&.to_sym
resource.resource_type_general = params["resource_type_general"]&.to_sym if params["resource_type_general"]
resource
end

Expand Down
15 changes: 15 additions & 0 deletions spec/system/work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
stub_s3
end

it "Defaults correct values for resource_type and resource_type_general", js: true do
sign_in user
visit user_path(user)
click_on "Submit New"
fill_in "title_main", with: "Supreme"
within("#creator_row_1") do
fill_in "given_name_1", with: "Sonia"
fill_in "family_name_1", with: "Sotomayor"
end
click_on "Create New"
work = Work.last
expect(work.resource.resource_type).to eq "Dataset"
expect(work.resource.resource_type_general).to eq :DATASET
end

it "Prevents empty title", js: true do
sign_in user
visit user_path(user)
Expand Down

0 comments on commit 516891b

Please sign in to comment.