diff --git a/app/assets/stylesheets/pages/casa_cases.scss b/app/assets/stylesheets/pages/casa_cases.scss
index 544409c430..34ad221b4f 100644
--- a/app/assets/stylesheets/pages/casa_cases.scss
+++ b/app/assets/stylesheets/pages/casa_cases.scss
@@ -169,4 +169,4 @@ body.casa_cases-show {
flex-direction: column;
gap: .2rem;
}
-}
+}
\ No newline at end of file
diff --git a/app/controllers/placements_controller.rb b/app/controllers/placements_controller.rb
index fe24ffa4e4..0bc7490e61 100644
--- a/app/controllers/placements_controller.rb
+++ b/app/controllers/placements_controller.rb
@@ -3,25 +3,52 @@ class PlacementsController < ApplicationController
before_action :set_placement, only: %i[edit show generate update destroy]
before_action :require_organization!
- rescue_from ActiveRecord::RecordNotFound, with: -> { head :not_found }
+ def index
+ @placements = policy_scope(@casa_case.placements).includes(:placement_type).order(placement_started_at: :desc)
+ end
def show
- authorize @casa_case
+ authorize @placement
end
def new
+ @placement = Placement.new(casa_case: @casa_case)
+ authorize @placement
end
def edit
+ authorize @placement
end
def create
+ @placement = Placement.new(placement_params)
+ authorize @placement
+
+ if @placement.save
+ redirect_to casa_case_placements_path(@casa_case), notice: "Placement was successfully created."
+ else
+ render :new, status: :unprocessable_entity
+ end
end
def update
+ authorize @placement
+
+ if @placement.update(placement_params)
+ redirect_to casa_case_placements_path(@casa_case), notice: "Placement was successfully updated."
+ else
+ render :edit, status: :unprocessable_entity
+ end
end
def destroy
+ authorize @placement
+
+ if @placement.destroy
+ redirect_to casa_case_placements_path(@casa_case), notice: "Placement was successfully deleted."
+ else
+ render :edit, status: :unprocessable_entity
+ end
end
private
@@ -33,4 +60,11 @@ def set_casa_case
def set_placement
@placement = @casa_case.placements.find(params[:id])
end
+
+ def placement_params
+ params.require(:placement).permit(
+ :placement_started_at,
+ :placement_type_id
+ ).merge({creator_id: current_user.id, casa_case_id: @casa_case.id})
+ end
end
diff --git a/app/models/casa_org.rb b/app/models/casa_org.rb
index b5b9c7461c..7aed3f2ab1 100644
--- a/app/models/casa_org.rb
+++ b/app/models/casa_org.rb
@@ -28,6 +28,7 @@ class CasaOrg < ApplicationRecord
has_many :contact_topics
has_one_attached :logo
has_one_attached :court_report_template
+ has_many :placement_types, dependent: :destroy
def casa_admins
CasaAdmin.in_organization(self)
diff --git a/app/models/placement.rb b/app/models/placement.rb
index f1f4c71b30..f0ef8c102c 100644
--- a/app/models/placement.rb
+++ b/app/models/placement.rb
@@ -2,6 +2,7 @@ class Placement < ApplicationRecord
belongs_to :casa_case
belongs_to :placement_type
belongs_to :creator, class_name: "User"
+ has_one :casa_org, through: :casa_case
validates :placement_started_at, comparison: {
greater_than_or_equal_to: "1989-01-01".to_date,
diff --git a/app/models/placement_type.rb b/app/models/placement_type.rb
index 49ffd47054..f4515c325f 100644
--- a/app/models/placement_type.rb
+++ b/app/models/placement_type.rb
@@ -1,6 +1,9 @@
class PlacementType < ApplicationRecord
belongs_to :casa_org
+
validates :name, presence: true
+ scope :for_organization, ->(org) { where(casa_org: org) }
+ scope :order_alphabetically, -> { order(:name) }
end
# == Schema Information
diff --git a/app/policies/placement_policy.rb b/app/policies/placement_policy.rb
new file mode 100644
index 0000000000..da622c4b0d
--- /dev/null
+++ b/app/policies/placement_policy.rb
@@ -0,0 +1,26 @@
+class PlacementPolicy < ApplicationPolicy
+ class Scope < ApplicationPolicy::Scope
+ def resolve
+ return scope.none unless @user&.casa_org
+
+ scope.joins(:casa_case).where(casa_cases: {casa_org: @user.casa_org})
+ end
+ end
+
+ def allowed_to_edit_casa_case?
+ casa_case_policy.edit?
+ end
+
+ alias_method :show?, :allowed_to_edit_casa_case?
+ alias_method :edit?, :allowed_to_edit_casa_case?
+ alias_method :update?, :allowed_to_edit_casa_case?
+ alias_method :new?, :allowed_to_edit_casa_case?
+ alias_method :create?, :allowed_to_edit_casa_case?
+ alias_method :destroy?, :admin_or_supervisor?
+
+ private
+
+ def casa_case_policy
+ CasaCasePolicy.new(user, record.casa_case)
+ end
+end
diff --git a/app/views/casa_cases/_placements.html.erb b/app/views/casa_cases/_placements.html.erb
index ce7a5aa30d..be1545446c 100644
--- a/app/views/casa_cases/_placements.html.erb
+++ b/app/views/casa_cases/_placements.html.erb
@@ -1,13 +1,18 @@
-<% placements = casa_case.placements %>
-
-<% if placements.empty? %>
- No Placements
-<% else %>
-
<%= link_to "See All Placements", casa_case_placements_path(casa_case), class: 'text-primary hover-underline' %>
+<% elsif casa_case.casa_org.placement_types.present? %>
+ <%= link_to "See All Placements", casa_case_placements_path(casa_case), class: 'text-primary hover-underline' %>
<% end %>
diff --git a/app/views/placements/_fields.html.erb b/app/views/placements/_fields.html.erb
new file mode 100644
index 0000000000..79922aafc3
--- /dev/null
+++ b/app/views/placements/_fields.html.erb
@@ -0,0 +1,18 @@
+
+ <%= form.label :placement_started_at, "Placement Started At" %>
+ <%= form.date_field :placement_started_at,
+ value: placement.placement_started_at&.to_date || Time.zone.now,
+ class: "form-control" %>
+
+
- <%= link_to '#', class: "btn-sm main-btn primary-btn btn-hover" do %>
+ <%= link_to edit_casa_case_placement_path(@casa_case, @placement), class: "btn-sm main-btn primary-btn btn-hover" do %>
Edit
<% end %>
diff --git a/config/environments/test.rb b/config/environments/test.rb
index e7388b07af..ac1618269c 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -9,7 +9,6 @@
# Settings specified here will take precedence over those in config/application.rb.
config.action_mailer.default_url_options = {host: "localhost", port: 3000} # for devise authentication
# While tests run files are not watched, reloading is not necessary.
- config.enable_reloading = false
# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.action_view.cache_template_loading = true
@@ -20,7 +19,6 @@
config.eager_load = ENV["CI"].present?
# cache classes on CI, but enable reloading for local work (bin/rspec)
config.enable_reloading = ENV["CI"].blank?
-
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
diff --git a/config/routes.rb b/config/routes.rb
index 4352a14943..ac967a6435 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -65,7 +65,7 @@
resources :court_dates, only: %i[create edit new show update destroy]
- resources :placements, only: %i[create edit new show update destroy]
+ resources :placements
member do
patch :deactivate
diff --git a/spec/factories/casa_orgs.rb b/spec/factories/casa_orgs.rb
index bfdcb99331..7017f88bf8 100644
--- a/spec/factories/casa_orgs.rb
+++ b/spec/factories/casa_orgs.rb
@@ -12,5 +12,15 @@
trait :with_logo do
logo { Rack::Test::UploadedFile.new(Rails.root.join("spec", "fixtures", "org_logo.jpeg")) }
end
+
+ trait :with_placement_types do
+ transient { placement_names { ["Reunification", "Adoption", "Foster Care", "Kinship"] } }
+
+ after(:create) do |org, evaluator|
+ evaluator.placement_names.each do |name|
+ org.placement_types.create!(name: name)
+ end
+ end
+ end
end
end
diff --git a/spec/factories/placements.rb b/spec/factories/placements.rb
index 1d95506def..478f67d7e8 100644
--- a/spec/factories/placements.rb
+++ b/spec/factories/placements.rb
@@ -1,8 +1,8 @@
FactoryBot.define do
factory :placement do
+ association :creator, factory: :user
casa_case
placement_type
placement_started_at { DateTime.now }
- creator { association :user }
end
end
diff --git a/spec/policies/placement_policy_spec.rb b/spec/policies/placement_policy_spec.rb
new file mode 100644
index 0000000000..abe5f6a8c8
--- /dev/null
+++ b/spec/policies/placement_policy_spec.rb
@@ -0,0 +1,48 @@
+require "rails_helper"
+
+RSpec.describe PlacementPolicy do
+ subject { described_class }
+
+ let(:casa_org) { create(:casa_org) }
+ let(:diff_org) { create(:casa_org) }
+
+ let(:casa_case) { create(:casa_case, casa_org:) }
+ let(:placement) { create(:placement, casa_case:) }
+
+ let(:casa_admin) { build(:casa_admin, casa_org:) }
+ let(:supervisor) { build(:supervisor, casa_org:) }
+ let(:volunteer) { build(:volunteer, casa_org:) }
+ let(:casa_admin_diff_org) { build(:casa_admin, casa_org: diff_org) }
+ let(:supervisor_diff_org) { build(:supervisor, casa_org: diff_org) }
+ let(:volunteer_diff_org) { build(:volunteer, casa_org: diff_org) }
+
+ permissions :create?, :edit?, :update?, :show?, :new? do
+ it { is_expected.to permit(casa_admin, placement) }
+
+ context "when a supervisor belongs to the same org as the case" do
+ it { expect(subject).to permit(supervisor, placement) }
+ end
+
+ context "when a supervisor does not belong to the same org as the case" do
+ let(:casa_case) { create(:casa_case, casa_org: diff_org) }
+
+ it { expect(subject).not_to permit(supervisor, placement) }
+ end
+
+ context "when volunteer is assigned" do
+ before { create(:case_assignment, volunteer:, casa_case:, active: true) }
+
+ it { is_expected.to permit(volunteer, placement) }
+ end
+
+ context "when volunteer is not assigned" do
+ it { is_expected.not_to permit(volunteer, placement) }
+ end
+ end
+
+ permissions :destroy? do
+ it { is_expected.to permit(casa_admin, placement) }
+ it { is_expected.to permit(supervisor, placement) }
+ it { is_expected.not_to permit(volunteer, placement) }
+ end
+end
diff --git a/spec/system/placements/destroy_spec.rb b/spec/system/placements/destroy_spec.rb
new file mode 100644
index 0000000000..5ff11fa5b2
--- /dev/null
+++ b/spec/system/placements/destroy_spec.rb
@@ -0,0 +1,34 @@
+require "rails_helper"
+
+RSpec.describe "placements/destroy", type: :system do
+ let(:now) { Date.new(2025, 1, 2) }
+ let(:casa_org) { create(:casa_org, :with_placement_types) }
+ let(:admin) { create(:casa_admin, casa_org:) }
+ let(:casa_case) { create(:casa_case, casa_org:, case_number: "123") }
+ let(:placement_type) { create(:placement_type, name: "Reunification", casa_org:) }
+ let(:placement) { create(:placement, placement_started_at: "2024-08-15 20:40:44 UTC", casa_case:, placement_type:) }
+
+ before do
+ travel_to now
+ sign_in admin
+ visit casa_case_placements_path(casa_case, placement)
+ click_on "Delete"
+ end
+
+ it "does not delete on modal close" do
+ expect(page).to have_text("Delete Placement?")
+ click_on "Close"
+
+ expect(page).to have_text("Reunification")
+ expect(page).to have_text("August 15, 2024 - Present")
+ end
+
+ it "deletes placement" do
+ expect(page).to have_text("Delete Placement?")
+ click_on "Confirm"
+
+ expect(page).to have_text("Placement was successfully deleted.")
+ expect(page).not_to have_text("Reunification")
+ expect(page).not_to have_text("August 15, 2024 - Present")
+ end
+end
diff --git a/spec/system/placements/edit_spec.rb b/spec/system/placements/edit_spec.rb
new file mode 100644
index 0000000000..e7e9609ba0
--- /dev/null
+++ b/spec/system/placements/edit_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe "placements/edit", type: :system do
+ let(:now) { Date.new(2025, 1, 2) }
+ let(:casa_org) { create(:casa_org, :with_placement_types) }
+ let(:admin) { create(:casa_admin, casa_org:) }
+ let(:casa_case) { create(:casa_case, casa_org:, case_number: "123") }
+ let(:placement_type) { create(:placement_type, name: "Reunification", casa_org:) }
+ let(:placement) { create(:placement, placement_started_at: "2024-08-15 20:40:44 UTC", casa_case:, placement_type:) }
+
+ before do
+ travel_to now
+ sign_in admin
+ visit casa_case_placement_path(casa_case, placement)
+ click_link("Edit")
+ end
+
+ it "updates placement with valid form data", js: true do
+ expect(page).to have_content("123")
+
+ fill_in "Placement Started At", with: now - 5.years
+ select "Kinship", from: "Placement Type"
+
+ click_on "Update"
+
+ expect(page).to have_content("Placement was successfully updated.")
+ expect(page).to have_content("123")
+ expect(page).to have_content("January 2, 2020")
+ expect(page).to have_content("Kinship")
+ end
+
+ it "rejects placement update with invalid form data" do
+ fill_in "Placement Started At", with: 1000.years.ago
+ click_on "Update"
+
+ expect(page).to have_content("1 error prohibited this Placement from being saved:\nPlacement started at cannot be prior to 1/1/1989.")
+ end
+end
diff --git a/spec/system/placements/index_spec.rb b/spec/system/placements/index_spec.rb
new file mode 100644
index 0000000000..007296f39a
--- /dev/null
+++ b/spec/system/placements/index_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe "placements", type: :system do
+ let(:now) { Date.new(2025, 1, 2) }
+ let(:casa_org) { create(:casa_org, :with_placement_types) }
+ let(:admin) { create(:casa_admin, casa_org:) }
+ let(:casa_case) { create(:casa_case, casa_org:, case_number: "123") }
+ let(:placement_current) { create(:placement_type, name: "Reunification", casa_org:) }
+ let(:placement_prev) { create(:placement_type, name: "Kinship", casa_org:) }
+ let(:placement_first) { create(:placement_type, name: "Adoption", casa_org:) }
+ let(:placements) do
+ [
+ create(:placement, placement_started_at: "2024-08-15 20:40:44 UTC", casa_case:, placement_type: placement_current),
+ create(:placement, placement_started_at: "2023-06-02 00:00:00 UTC", casa_case:, placement_type: placement_prev),
+ create(:placement, placement_started_at: "2021-12-25 10:10:10 UTC", casa_case:, placement_type: placement_first)
+ ]
+ end
+
+ before do
+ travel_to now
+ sign_in admin
+ visit casa_case_placements_path(casa_case, placements)
+ end
+
+ it "displays all placements for org" do
+ expect(page).to have_text("Reunification")
+ expect(page).to have_text("August 15, 2024 - Present")
+ expect(page).to have_text("Kinship")
+ expect(page).to have_text("June 2, 2023 - August 15, 2024")
+ expect(page).to have_text("Adoption")
+ expect(page).to have_text("December 25, 2021 - June 2, 2023")
+ end
+end
diff --git a/spec/system/placements/new_spec.rb b/spec/system/placements/new_spec.rb
new file mode 100644
index 0000000000..05a559e553
--- /dev/null
+++ b/spec/system/placements/new_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe "placements/new", type: :system do
+ let(:now) { Date.new(2025, 1, 2) }
+ let(:casa_org) { create(:casa_org, :with_placement_types) }
+ let(:admin) { create(:casa_admin, casa_org:) }
+ let(:casa_case) { create(:casa_case, casa_org:, case_number: "123") }
+ let(:placement_type) { create(:placement_type, name: "Reunification", casa_org:) }
+ let(:placement) { create(:placement, placement_started_at: "2024-08-15 20:40:44 UTC", casa_case:, placement_type:) }
+
+ before do
+ travel_to now
+ sign_in admin
+ visit casa_case_placements_path(casa_case)
+ click_link("New Placement")
+ end
+
+ it "creates placement with valid form data", js: true do
+ expect(page).to have_content("123")
+
+ fill_in "Placement Started At", with: now
+ select placement_type.name, from: "Placement Type"
+
+ click_on "Create"
+
+ expect(page).to have_content("Placement was successfully created.")
+ expect(page).to have_content("123")
+ expect(page).to have_content("January 2, 2025")
+ expect(page).to have_content("Reunification")
+ end
+
+ it "rejects placement with invalid form data" do
+ fill_in "Placement Started At", with: 1000.years.ago
+ click_on "Create"
+
+ expect(page).to have_content("2 errors prohibited this Placement from being saved:\nPlacement type must exist Placement started at cannot be prior to 1/1/1989.")
+ end
+end
diff --git a/spec/views/casa_cases/show.html.erb_spec.rb b/spec/views/casa_cases/show.html.erb_spec.rb
index a6ffdec3ab..9e9d6b5836 100644
--- a/spec/views/casa_cases/show.html.erb_spec.rb
+++ b/spec/views/casa_cases/show.html.erb_spec.rb
@@ -61,19 +61,37 @@
render
expect(rendered).to match("111")
- expect(rendered).to match("May 6, 2023")
+ expect(rendered).to match("Current Placement:")
+ expect(rendered).to match(/Placement Type/)
+ expect(rendered).to match("Placed since: May 6, 2023")
+ expect(rendered).to match("See All Placements")
end
end
- context "where there is no placement" do
+ context "when there is no placement" do
it "renders casa case without placements" do
+ casa_org = create(:casa_org, :with_placement_types)
+ casa_case = create(:casa_case, casa_org:)
+ assign(:casa_case, casa_case)
+
+ render
+
+ expect(rendered).to match(casa_case.case_number)
+ expect(rendered).to have_content("Current Placement:")
+ expect(rendered).to have_content("Unknown")
+ expect(rendered).to have_content("See All Placements")
+ end
+
+ it "renders nothing about placements when org has no placement types" do
casa_case = create(:casa_case)
assign(:casa_case, casa_case)
render
expect(rendered).to match(casa_case.case_number)
- expect(rendered).to have_content("No Placements")
+ expect(rendered).not_to have_content("Current Placement:")
+ expect(rendered).not_to have_content("Unknown")
+ expect(rendered).not_to have_content("See All Placements")
end
end
end
diff --git a/spec/views/notifications/index.html.erb_spec.rb b/spec/views/notifications/index.html.erb_spec.rb
index 8a2a71b587..97666b0455 100644
--- a/spec/views/notifications/index.html.erb_spec.rb
+++ b/spec/views/notifications/index.html.erb_spec.rb
@@ -1,6 +1,7 @@
require "rails_helper"
RSpec.describe "notifications/index", type: :view do
+ let(:base_time) { Date.new(2025, 1, 2) }
let(:notification_1_hour_ago) { create(:notification, :followup_with_note) }
let(:notification_1_day_ago) { create(:notification, :emancipation_checklist_reminder) }
let(:notification_2_days_ago) { create(:notification, :youth_birthday) }
@@ -20,7 +21,7 @@
end
context "when there is a deploy date" do
- let(:deploy_time) { 2.days.ago }
+ let(:deploy_time) { base_time - 2.days }
before do
Health.instance.update_attribute(:latest_deploy_time, deploy_time)
@@ -28,10 +29,10 @@
context "when there are notifications" do
before do
- notification_1_hour_ago.update_attribute(:created_at, 1.hour.ago)
- notification_1_day_ago.update_attribute(:created_at, 1.day.ago)
- notification_2_days_ago.update_attribute(:created_at, 2.days.ago)
- notification_3_days_ago.update_attribute(:created_at, 3.days.ago)
+ notification_1_hour_ago.update_attribute(:created_at, base_time - 1.hour)
+ notification_1_day_ago.update_attribute(:created_at, base_time - 1.day)
+ notification_2_days_ago.update_attribute(:created_at, base_time - 2.days)
+ notification_3_days_ago.update_attribute(:created_at, base_time - 3.days)
patch_note_1.update_attribute(:patch_note_group, patch_note_group_all_users)
end
diff --git a/spec/views/placements/edit.html.erb_spec.rb b/spec/views/placements/edit.html.erb_spec.rb
new file mode 100644
index 0000000000..8e433c767d
--- /dev/null
+++ b/spec/views/placements/edit.html.erb_spec.rb
@@ -0,0 +1,31 @@
+require "rails_helper"
+
+RSpec.describe "placements/edit", type: :view do
+ subject { render template: "placements/edit" }
+
+ let(:organization) { create(:casa_org) }
+ let(:user) { build_stubbed(:casa_admin, casa_org: organization) }
+ let(:casa_case) { create(:casa_case, casa_org: organization, case_number: "123") }
+ let(:placement_type) { create(:placement_type, name: "Reunification") }
+ let(:placement) { create(:placement, placement_started_at: "2024-08-15 12:39:00 UTC", placement_type:, casa_case:) }
+
+ before do
+ assign :casa_case, casa_case
+ assign :placement, placement
+
+ enable_pundit(view, user)
+ allow(view).to receive(:current_user).and_return(user)
+ allow(view).to receive(:current_organization).and_return(user.casa_org)
+ render
+ end
+
+ it { is_expected.to have_selector("h1", text: "Editing Placement") }
+
+ it "has a date input for placement started at with the correct value" do
+ expect(rendered).to have_field("placement[placement_started_at]", with: "2024-08-15")
+ end
+
+ it "has a select input for placement type with the correct placeholder" do
+ expect(rendered).to have_select("placement[placement_type_id]", with_options: ["-Select Placement Type-"])
+ end
+end
diff --git a/spec/views/placements/index.html.erb_spec.rb b/spec/views/placements/index.html.erb_spec.rb
new file mode 100644
index 0000000000..3142b68396
--- /dev/null
+++ b/spec/views/placements/index.html.erb_spec.rb
@@ -0,0 +1,66 @@
+require "rails_helper"
+
+RSpec.describe "placements/index", type: :view do
+ let(:casa_org) { create(:casa_org, :with_placement_types) }
+ let(:casa_case) { create(:casa_case, casa_org:, case_number: "CINA-12345") }
+ let(:placement_current) { create(:placement_type, name: "Reunification", casa_org:) }
+ let(:placement_prev) { create(:placement_type, name: "Kinship", casa_org:) }
+ let(:placement_first) { create(:placement_type, name: "Adoption", casa_org:) }
+
+ let(:placements) do
+ [
+ create(:placement, placement_started_at: "2024-08-15 20:40:44 UTC", casa_case:, placement_type: placement_current),
+ create(:placement, placement_started_at: "2023-06-02 00:00:00 UTC", casa_case:, placement_type: placement_prev),
+ create(:placement, placement_started_at: "2021-12-25 10:10:10 UTC", casa_case:, placement_type: placement_first)
+ ]
+ end
+
+ before do
+ assign(:casa_case, casa_case)
+ assign(:placements, placements.sort_by(&:placement_started_at).reverse)
+
+ render
+ end
+
+ it "displays the case number in the header" do
+ expect(rendered).to have_selector("h1", text: "CINA-12345")
+ end
+
+ it "has a link to create a new placement" do
+ expect(rendered).to have_link("New Placement", href: new_casa_case_placement_path(casa_case))
+ end
+
+ it "displays placement information for each placement" do
+ expect(rendered).to have_content("Reunification")
+ expect(rendered).to have_content(/August 15, 2024/)
+ expect(rendered).to have_content(/Present/)
+
+ expect(rendered).to have_content("Kinship")
+ expect(rendered).to have_content(/June 2, 2023/)
+
+ expect(rendered).to have_content("Adoption")
+ expect(rendered).to have_content(/December 25, 2021/)
+ end
+
+ it "has edit links for each placement" do
+ placements.each do |placement|
+ expect(rendered).to have_link("Edit", href: edit_casa_case_placement_path(casa_case, placement))
+ end
+ end
+
+ it "has delete buttons for each placement" do
+ placements.each do |placement|
+ expect(rendered).to have_selector("a[data-bs-target='##{placement.id}']", text: "Delete")
+ end
+ end
+
+ it "renders delete confirmation modals for each placement" do
+ placements.each do |placement|
+ expect(rendered).to have_selector("##{placement.id}.modal")
+ within "##{placement.id}" do
+ expect(rendered).to have_content("Delete Placement?")
+ expect(rendered).to have_link("Delete Placement", href: casa_case_placement_path(casa_case, placement))
+ end
+ end
+ end
+end
diff --git a/spec/views/placements/new.html.erb_spec.rb b/spec/views/placements/new.html.erb_spec.rb
new file mode 100644
index 0000000000..8df99f6312
--- /dev/null
+++ b/spec/views/placements/new.html.erb_spec.rb
@@ -0,0 +1,20 @@
+require "rails_helper"
+
+RSpec.describe "placements/new", type: :view do
+ subject { render template: "placements/new" }
+
+ before do
+ assign :casa_case, casa_case
+ assign :placement, Placement.new
+
+ allow(view).to receive(:current_organization).and_return(user.casa_org)
+ end
+
+ let(:user) { build_stubbed(:casa_admin) }
+ let(:casa_case) { create(:casa_case) }
+
+ it { is_expected.to have_selector("h1", text: "New Placement") }
+ it { is_expected.to have_selector("h6", text: casa_case.case_number) }
+ it { is_expected.to have_link(casa_case.case_number, href: "/casa_cases/#{casa_case.case_number.parameterize}") }
+ it { is_expected.to have_selector(".primary-btn") }
+end