Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ GEM
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.7)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
image_processing (1.14.0)
mini_magick (>= 4.9.5, < 6)
Expand Down Expand Up @@ -334,7 +334,8 @@ GEM
logger
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.27.0)
minitest (6.0.1)
prism (~> 1.5)
multi_xml (0.8.1)
bigdecimal (>= 3.1, < 5)
multipart-post (2.4.1)
Expand Down Expand Up @@ -403,7 +404,7 @@ GEM
parallel
paranoia (3.0.1)
activerecord (>= 6, < 8.1)
parser (3.3.10.0)
parser (3.3.10.1)
ast (~> 2.4.1)
racc
pdf-forms (1.5.2)
Expand All @@ -420,7 +421,7 @@ GEM
pretender (0.6.0)
actionpack (>= 7.1)
prettyprint (0.2.0)
prism (1.7.0)
prism (1.9.0)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -558,12 +559,12 @@ GEM
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.47.1, < 2.0)
rubocop-rails (2.31.0)
rubocop-rails (2.34.3)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rspec (3.7.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
Expand Down Expand Up @@ -637,9 +638,9 @@ GEM
standard-performance (1.9.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.26.0)
standard-rails (1.4.0)
standard-rails (1.6.0)
lint_roller (~> 1.0)
rubocop-rails (~> 2.31.0)
rubocop-rails (~> 2.34.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.9)
Expand Down
36 changes: 18 additions & 18 deletions spec/datatables/case_contact_datatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,68 +173,68 @@
let(:search_term) { "John" }

it "returns matching case contacts" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].map { |d| d[:id] }).not_to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).not_to include(jane_contact.id.to_s)
end
end

context "searching by creator email" do
let(:search_term) { "jane@example.com" }

it "returns matching case contacts" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].map { |d| d[:id] }).not_to include(john_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).not_to include(john_contact.id.to_s)
end
end

context "searching by case number" do
let(:search_term) { "2024-001" }

it "returns matching case contacts" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].map { |d| d[:id] }).not_to include(john_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).not_to include(john_contact.id.to_s)
end
end

context "searching by notes" do
let(:search_term) { "Meeting" }

it "returns matching case contacts" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].map { |d| d[:id] }).not_to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).not_to include(jane_contact.id.to_s)
end
end

context "searching by contact_type name" do
let(:search_term) { "Family" }

it "returns matching case contacts" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].map { |d| d[:id] }).not_to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).not_to include(jane_contact.id.to_s)
end
end

context "with case-insensitive search" do
let(:search_term) { "JOHN" }

it "returns matching case contacts regardless of case" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(john_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(john_contact.id.to_s)
end
end

context "with partial search term" do
let(:search_term) { "Smi" }

it "returns matching case contacts with partial match" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(jane_contact.id.to_s)
end
end

context "with blank search term" do
let(:search_term) { "" }

it "returns all case contacts" do
expect(datatable.as_json[:data].map { |d| d[:id] }).to include(john_contact.id.to_s, jane_contact.id.to_s)
expect(datatable.as_json[:data].pluck(:id)).to include(john_contact.id.to_s, jane_contact.id.to_s)
end
end

Expand Down Expand Up @@ -275,7 +275,7 @@
let(:order_direction) { "desc" }

it "orders contacts by occurred_at descending" do
ids = datatable.as_json[:data].map { |d| d[:id] }
ids = datatable.as_json[:data].pluck(:id)
expect(ids).to eq([recent_contact.id.to_s, old_contact.id.to_s])
end
end
Expand All @@ -284,7 +284,7 @@
let(:order_direction) { "asc" }

it "orders contacts by occurred_at ascending" do
ids = datatable.as_json[:data].map { |d| d[:id] }
ids = datatable.as_json[:data].pluck(:id)
expect(ids).to eq([old_contact.id.to_s, recent_contact.id.to_s])
end
end
Expand All @@ -295,7 +295,7 @@
let(:order_direction) { "desc" }

it "orders contacts by contact_made" do
ids = datatable.as_json[:data].map { |d| d[:id] }
ids = datatable.as_json[:data].pluck(:id)
expect(ids.first).to eq(recent_contact.id.to_s)
end
end
Expand All @@ -305,7 +305,7 @@
let(:order_direction) { "asc" }

it "orders contacts by medium_type" do
ids = datatable.as_json[:data].map { |d| d[:id] }
ids = datatable.as_json[:data].pluck(:id)
expect(ids.first).to eq(recent_contact.id.to_s)
end
end
Expand All @@ -315,7 +315,7 @@
let(:order_direction) { "desc" }

it "orders contacts by duration_minutes" do
ids = datatable.as_json[:data].map { |d| d[:id] }
ids = datatable.as_json[:data].pluck(:id)
expect(ids).to eq([recent_contact.id.to_s, old_contact.id.to_s])
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/datatables/supervisor_datatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
it "brings only active supervisors", :aggregate_failures do
expect(subject[:recordsTotal]).to eq(2)
expect(subject[:recordsFiltered]).to eq(1)
expect(subject[:data].map { |d| d[:display_name] }).to include(CGI.escapeHTML(active_supervisor.display_name))
expect(subject[:data].map { |d| d[:display_name] }).not_to include(CGI.escapeHTML(inactive_supervisor.display_name))
expect(subject[:data].pluck(:display_name)).to include(CGI.escapeHTML(active_supervisor.display_name))
expect(subject[:data].pluck(:display_name)).not_to include(CGI.escapeHTML(inactive_supervisor.display_name))
end
end

Expand All @@ -30,8 +30,8 @@
it "brings only inactive supervisors", :aggregate_failures do
expect(subject[:recordsTotal]).to eq(2)
expect(subject[:recordsFiltered]).to eq(1)
expect(subject[:data].map { |d| d[:display_name] }).to include(CGI.escapeHTML(inactive_supervisor.display_name))
expect(subject[:data].map { |d| d[:display_name] }).not_to include(CGI.escapeHTML(active_supervisor.display_name))
expect(subject[:data].pluck(:display_name)).to include(CGI.escapeHTML(inactive_supervisor.display_name))
expect(subject[:data].pluck(:display_name)).not_to include(CGI.escapeHTML(active_supervisor.display_name))
end
end

Expand All @@ -42,8 +42,8 @@
it "brings only all supervisors", :aggregate_failures do
expect(subject[:recordsTotal]).to eq(2)
expect(subject[:recordsFiltered]).to eq(2)
expect(subject[:data].map { |d| d[:display_name] }).to include(CGI.escapeHTML(active_supervisor.display_name))
expect(subject[:data].map { |d| d[:display_name] }).to include(CGI.escapeHTML(inactive_supervisor.display_name))
expect(subject[:data].pluck(:display_name)).to include(CGI.escapeHTML(active_supervisor.display_name))
expect(subject[:data].pluck(:display_name)).to include(CGI.escapeHTML(inactive_supervisor.display_name))
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/datatables/volunteer_datatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@

context "when ascending" do
it "is successful" do
expect(values.map { |h| h[:contacts_made_in_past_days] }).to eq ["2", "3", "", "", "", ""]
expect(values.pluck(:contacts_made_in_past_days)).to eq ["2", "3", "", "", "", ""]
end
end

Expand All @@ -293,7 +293,7 @@
end

it "is successful" do
expect(values.map { |h| h[:contacts_made_in_past_days] }).to eq ["3", "2", "", "", "", ""]
expect(values.pluck(:contacts_made_in_past_days)).to eq ["3", "2", "", "", "", ""]
end

it "moves blanks to the end" do
Expand Down Expand Up @@ -342,7 +342,7 @@

it "is successful" do
expect(subject[:data].length).to eq volunteers.count
expect(subject[:data].map { |d| d[:id] }.sort).to eq volunteers.map { |v| v.id.to_s }.sort
expect(subject[:data].pluck(:id).sort).to eq volunteers.map { |v| v.id.to_s }.sort
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/casa_org_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
let(:contact_topics) { ContactTopic.where(casa_org: org).map(&:question) }

it "matches default contact topics" do
expected = fake_topics.map { |topic| topic["question"] }
expected = fake_topics.pluck("question")
expect(contact_topics).to include(*expected)
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/models/case_court_report_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,18 @@
court_topics = build(:case_court_report_context, casa_case: casa_case).court_topics

expect(court_topics.keys).to match_array(["Question 1", "Question 2", "Question 3"])
expect(court_topics["Question 1"][:answers].map { |a| a[:value] }).to match_array(
expect(court_topics["Question 1"][:answers].pluck(:value)).to match_array(
["Answer From One Year Ago", "Answer 1", "Answer 3", "Answer From One Day Ago"]
)
expect(court_topics["Question 2"][:answers].map { |a| a[:value] }).to match_array(["Answer 2", "Answer 5"])
expect(court_topics["Question 3"][:answers].map { |a| a[:value] }).to match_array(["No Answer Provided", "No Answer Provided"])
expect(court_topics["Question 2"][:answers].pluck(:value)).to match_array(["Answer 2", "Answer 5"])
expect(court_topics["Question 3"][:answers].pluck(:value)).to match_array(["No Answer Provided", "No Answer Provided"])
end

it "filters by date range" do
court_topics = build(:case_court_report_context, start_date: 45.day.ago.to_s, end_date: 5.day.ago.to_s, casa_case: casa_case).court_topics

expect(court_topics.keys).to match_array(["Question 1", "Question 2", "Question 3"])
expect(court_topics["Question 1"][:answers].map { |a| a[:value] }).to match_array(["Answer 1", "Answer 3"])
expect(court_topics["Question 1"][:answers].pluck(:value)).to match_array(["Answer 1", "Answer 3"])
end

it "filters answers from topics set be excluded from court report" do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/contact_topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

questions = org.contact_topics.map(&:question)
details = org.contact_topics.map(&:details)
expect(questions).to match_array(topics.map { |t| t["question"] })
expect(details).to match_array(topics.map { |t| t["details"] })
expect(questions).to match_array(topics.pluck("question"))
expect(details).to match_array(topics.pluck("details"))
end

it "fails if not all required attrs are present" do
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/all_casa_admins/casa_orgs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
expect { post_create }.to change(ContactTopic, :count).by(2)

casa_org = CasaOrg.last
expect(casa_org.contact_topics.map(&:question)).to match_array(contact_topics.map { |t| t["question"] })
expect(casa_org.contact_topics.map(&:details)).to match_array(contact_topics.map { |t| t["details"] })
expect(casa_org.contact_topics.map(&:question)).to match_array(contact_topics.pluck("question"))
expect(casa_org.contact_topics.map(&:details)).to match_array(contact_topics.pluck("details"))
expect(casa_org.contact_topics.pluck(:active)).to be_all true
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
post datatable_case_contacts_new_design_path, params: search_params, as: :json

json = JSON.parse(response.body, symbolize_names: true)
ids = json[:data].map { |d| d[:id] }
ids = json[:data].pluck(:id)
expect(ids).to include(searchable_contact.id.to_s)
end
end
Expand All @@ -135,7 +135,7 @@
post datatable_case_contacts_new_design_path, params: datatable_params, as: :json

json = JSON.parse(response.body, symbolize_names: true)
ids = json[:data].map { |d| d[:id] }
ids = json[:data].pluck(:id)

expect(ids).to include(volunteer_contact.id.to_s)
expect(ids).not_to include(other_volunteer_contact.id.to_s)
Expand All @@ -162,7 +162,7 @@
post datatable_case_contacts_new_design_path, params: datatable_params, as: :json

json = JSON.parse(response.body, symbolize_names: true)
ids = json[:data].map { |d| d[:id] }
ids = json[:data].pluck(:id)

expect(ids).to include(contact1.id.to_s, contact2.id.to_s)
end
Expand Down
Loading