From 6694eb2ece245efc013f2d5b65e816691212821a Mon Sep 17 00:00:00 2001 From: carolyncole <1599081+carolyncole@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:44:35 -0400 Subject: [PATCH] Updating communities based on feedback (#1973) fixes #1970 --- app/models/group.rb | 5 +++-- db/migrate/20241021194327_deparment_community.rb | 9 +++++++++ db/schema.rb | 2 +- spec/models/group_spec.rb | 2 +- spec/system/work_edit_spec.rb | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20241021194327_deparment_community.rb diff --git a/app/models/group.rb b/app/models/group.rb index 4b50b836b..1f6db8e84 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -159,9 +159,10 @@ def communities if code == "PPPL" ["Princeton Plasma Physics Laboratory"] else - ["Princeton Neuroscience Institute", "Department of Geosciences", "Mechanical and Aerospace Engineering", + ["Princeton Neuroscience Institute", "Geosciences", "Mechanical and Aerospace Engineering", "Astrophysical Sciences", "Civil and Environmental Engineering", "Chemical and Biological Engineering", - "Digital Humanities", "Music and Arts", "Princeton School of Public and International Affairs"].sort + "Digital Humanities", "Music and Arts", "Princeton School of Public and International Affairs", + "Chemistry", "Lewis Seigler Genomics", "Architecture", "Ecology and Evolutionary Biology", "Economics"].sort end end diff --git a/db/migrate/20241021194327_deparment_community.rb b/db/migrate/20241021194327_deparment_community.rb new file mode 100644 index 000000000..3cab3cfec --- /dev/null +++ b/db/migrate/20241021194327_deparment_community.rb @@ -0,0 +1,9 @@ +class DeparmentCommunity < ActiveRecord::Migration[7.2] + def change + Work.where("metadata @> ?", JSON.dump(communities: ["Department of Geosciences"])).each do |work| + communities = work.resource.communities + work.resource.communities = communities.map {|community| community == "Department of Geosciences" ? "Geosciences" : community } + work.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ce3f622d6..558418c57 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_07_05_120614) do +ActiveRecord::Schema[7.2].define(version: 2024_10_21_194327) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 007b641d6..6cb0a924b 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -30,7 +30,7 @@ it "sorts alphabetically communities and subcommunities" do described_class.create_defaults group_rd = described_class.where(code: "RD").first - expect(group_rd.communities.first).to eq "Astrophysical Sciences" + expect(group_rd.communities.first).to eq "Architecture" expect(group_rd.communities.last).to eq "Princeton School of Public and International Affairs" group_pppl = described_class.where(code: "PPPL").first diff --git a/spec/system/work_edit_spec.rb b/spec/system/work_edit_spec.rb index d1b931ea1..633aefb21 100644 --- a/spec/system/work_edit_spec.rb +++ b/spec/system/work_edit_spec.rb @@ -205,10 +205,10 @@ sign_in user visit edit_work_path(work) click_on "Additional Metadata" - select "Department of Geosciences", from: "communities" + select "Geosciences", from: "communities" expect(page).to_not have_content("Subcommunities") click_on "Save Work" - expect(page).to have_content("Department of Geosciences") + expect(page).to have_content("Geosciences") end end