Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/APPEALS-35707-29633-29632 (prodtest) #21485

Merged
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ group :test, :development, :demo do
gem "capybara"
gem "capybara-screenshot"
gem "danger", "~> 6.2.2"
gem "database_cleaner"
gem "database_cleaner-active_record", "2.0.0"
gem "factory_bot_rails", "~> 5.2"
gem "faker"
gem "guard-rspec"
Expand Down
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ GEM
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
database_cleaner (1.7.0)
database_cleaner-active_record (2.0.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.3)
ddtrace (0.34.1)
msgpack
Expand Down Expand Up @@ -771,7 +774,7 @@ DEPENDENCIES
console_tree_renderer!
countries
danger (~> 6.2.2)
database_cleaner
database_cleaner-active_record (= 2.0.0)
ddtrace
debase
derailed_benchmarks
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/organizations/task_summary_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def index
format.json do
render json: {
members: json_users(organization.users),
task_counts: result.to_hash.to_json
task_counts: result.to_a.to_json
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/vacols/case_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def exists_for_appeals(vacols_ids)
conn.exec_query(sanitize_sql_array([query, vacols_ids]))
end

result.to_hash.reduce({}) do |memo, row|
result.to_a.reduce({}) do |memo, row|
memo[(row["bfkey"]).to_s] = (row["n"] > 0)
memo
end
Expand Down
24 changes: 12 additions & 12 deletions app/models/vacols/case_docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def self.counts_by_priority_and_readiness
group by PRIORITY, READY
SQL

connection.exec_query(query).to_hash
connection.exec_query(query).to_a
end
# rubocop:enable Metrics/MethodLength

Expand All @@ -220,7 +220,7 @@ def self.genpop_priority_count
where VLJ is null or #{ineligible_judges_sattyid_cache}
SQL

connection.exec_query(query).to_hash.count
connection.exec_query(query).to_a.size
end

def self.not_genpop_priority_count
Expand All @@ -229,7 +229,7 @@ def self.not_genpop_priority_count
where VLJ is not null
SQL

connection.exec_query(query).to_hash.count
connection.exec_query(query).to_a.size
end

def self.nod_count
Expand Down Expand Up @@ -311,7 +311,7 @@ def self.age_of_n_oldest_genpop_priority_appeals(num)

fmtd_query = sanitize_sql_array([query, num])

appeals = conn.exec_query(fmtd_query).to_hash
appeals = conn.exec_query(fmtd_query).to_a
appeals.map { |appeal| appeal["bfdloout"] }
end

Expand All @@ -330,7 +330,7 @@ def self.age_of_n_oldest_priority_appeals_available_to_judge(judge, num)
num
])

appeals = conn.exec_query(fmtd_query).to_hash
appeals = conn.exec_query(fmtd_query).to_a
appeals.map { |appeal| appeal["bfd19"] }
end

Expand All @@ -349,7 +349,7 @@ def self.age_of_n_oldest_nonpriority_appeals_available_to_judge(judge, num)
num
])

appeals = conn.exec_query(fmtd_query).to_hash
appeals = conn.exec_query(fmtd_query).to_a
appeals.map { |appeal| appeal["bfd19"] }
end

Expand All @@ -361,7 +361,7 @@ def self.age_of_oldest_priority_appeal

fmtd_query = sanitize_sql_array([query, 1])

connection.exec_query(fmtd_query).to_hash.first&.fetch("bfdloout")
connection.exec_query(fmtd_query).to_a.first&.fetch("bfdloout")
end

def self.age_of_oldest_priority_appeal_by_docket_date
Expand All @@ -372,7 +372,7 @@ def self.age_of_oldest_priority_appeal_by_docket_date

fmtd_query = sanitize_sql_array([query, 1])

connection.exec_query(fmtd_query).to_hash.first&.fetch("bfd19")
connection.exec_query(fmtd_query).to_a.first&.fetch("bfd19")
end

def self.nonpriority_decisions_per_year
Expand Down Expand Up @@ -411,7 +411,7 @@ def self.nonpriority_hearing_cases_for_judge_count(judge)
end

def self.priority_ready_appeal_vacols_ids
connection.exec_query(SELECT_PRIORITY_APPEALS).to_hash.map { |appeal| appeal["bfkey"] }
connection.exec_query(SELECT_PRIORITY_APPEALS).to_a.map { |appeal| appeal["bfkey"] }
end

def self.ready_to_distribute_appeals
Expand All @@ -420,7 +420,7 @@ def self.ready_to_distribute_appeals
SQL

fmtd_query = sanitize_sql_array([query])
connection.exec_query(fmtd_query).to_hash
connection.exec_query(fmtd_query).to_a
end

# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Metrics/MethodLength
Expand Down Expand Up @@ -504,11 +504,11 @@ def self.distribute_appeals(query, judge, dry_run)

conn.transaction do
if dry_run
conn.exec_query(query).to_hash
conn.exec_query(query).to_a
else
conn.execute(LOCK_READY_APPEALS) unless FeatureToggle.enabled?(:acd_disable_legacy_lock_ready_appeals)

appeals = conn.exec_query(query).to_hash
appeals = conn.exec_query(query).to_a
return appeals if appeals.empty?

vacols_ids = appeals.map { |appeal| appeal["bfkey"] }
Expand Down
2 changes: 1 addition & 1 deletion app/models/vacols/case_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def self.descriptions(vacols_ids)
conn.exec_query(sanitize_sql_array([query, vacols_ids]))
end

issues_result.to_hash.reduce({}) do |memo, result|
issues_result.to_a.reduce({}) do |memo, result|
issue_key = result["isskey"].to_s
memo[issue_key] = (memo[issue_key] || []) << result
memo
Expand Down
2 changes: 1 addition & 1 deletion app/models/vacols/correspondent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.extract(last_extract)

fmtd_query = sanitize_sql_array([query, last_extract])

connection.exec_query(fmtd_query).to_hash
connection.exec_query(fmtd_query).to_a
end

# Take in a collection and return a csv friendly format
Expand Down
6 changes: 5 additions & 1 deletion app/services/deprecation_warnings/disallowed_deprecations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class ::DisallowedDeprecationError < StandardError; end

# Regular expressions for Rails 6.1 deprecation warnings that we have addressed in the codebase
RAILS_6_1_FIXED_DEPRECATION_WARNING_REGEXES = [
/update_attributes is deprecated and will be removed from Rails 6\.1/
/update_attributes is deprecated and will be removed from Rails 6\.1/,
/ActionView::Base instances should be constructed with a lookup context, assignments, and a controller./,
/ActionView::Base instances must implement `compiled_method_container`/,
/render file: should be given the absolute path to a file/,
/`ActiveRecord::Result#to_hash` has been renamed to `to_a`/
].freeze

# Regular expressions for deprecation warnings that should raise an exception on detection
Expand Down
16 changes: 9 additions & 7 deletions app/services/hearings/calendar_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# emails.

class Hearings::CalendarService
class CalendarEventView < ActionView::Base
include Hearings::CalendarTemplateHelper
include Hearings::AppellantNameHelper
end

class << self
# Sent when first switching a video hearing to a virtual hearing,
# and also when the scheduled time for an existing virtual hearing
Expand Down Expand Up @@ -95,11 +100,8 @@ def create_calendar_event(hearing)
end

def render_virtual_hearing_calendar_event_template(email_recipient_info, event_type, locals)
template = ActionView::Base.new(ActionMailer::Base.view_paths, {})
template.class_eval do
include Hearings::CalendarTemplateHelper
include Hearings::AppellantNameHelper
end
lookup_context = ActionView::Base.build_lookup_context(ActionController::Base.view_paths)
context = CalendarEventView.new(lookup_context)

# Some *~ magic ~* here. The recipient title is used to determine which template to load:
#
Expand All @@ -112,8 +114,8 @@ def render_virtual_hearing_calendar_event_template(email_recipient_info, event_t

template_name = "#{email_recipient_info.title.downcase}_#{event_type}_event_description"

template.render(
file: "hearing_mailer/calendar_events/#{template_name}",
context.render(
template: "hearing_mailer/calendar_events/#{template_name}",
locals: locals
)
end
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "database_cleaner"
require "database_cleaner-active_record"

# because db/seeds is not in the autoload path, we must load them explicitly here
# base.rb needs to be loaded first because the other seeds inherit from it
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/doc.rake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace :doc do
end

def exec_sql(sql)
db_connection.exec_query(sql).to_hash
db_connection.exec_query(sql).to_a
end

def db_connection
Expand Down
68 changes: 68 additions & 0 deletions spec/services/hearings/calendar_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# frozen_string_literal: true

describe Hearings::CalendarService do
describe ".confirmation_calendar_invite" do
subject(:confirmation_calendar_invite) do
described_class.confirmation_calendar_invite(virtual_hearing, email_recipient_info, link)
end

let(:regional_office) { "RO06" } # nyc_ro_eastern
let(:appeal) { create(:appeal, :hearing_docket) }
let(:hearing_day) do
create(:hearing_day, scheduled_for: Date.parse("January 1, 1970"),
request_type: HearingDay::REQUEST_TYPES[:video],
regional_office: regional_office)
end
let(:hearing) do
create(:hearing, appeal: appeal,
scheduled_time: "8:30AM",
hearing_day: hearing_day,
regional_office: regional_office)
end
let(:virtual_hearing) do
create(:virtual_hearing, hearing: hearing, appellant_tz: nil, representative_tz: nil)
end
let(:email_recipient_info) do
EmailRecipientInfo.new(name: "LastName",
title: "appellant",
hearing_email_recipient: hearing_email_recipient)
end
let(:hearing_email_recipient) { virtual_hearing.hearing.appellant_recipient }
let(:link) { virtual_hearing.guest_link }

it "returns appropriate iCalendar event" do
expected_description = <<~TEXT
You're scheduled for a virtual hearing with a Veterans Law Judge of the Board of Veterans' Appeals.

Date and Time
Thursday, 1 January 1970 at 8:30am EST

How to Join
We recommend joining 15 minutes before your hearing start time. Click on the link below, or copy and paste the link into the address field of your web browser:
https://care.evn.va.gov/bva-app/?join=1&media=&escalate=1&[email protected]&pin=&role=guest

Help Desk
If you are experiencing technical difficulties, call the VA Video Connect Helpdesk at 855-519-7116 and press 4 for Board of Veterans' Appeals support.

Rescheduling or Canceling Your Hearing
If you need to reschedule or cancel your virtual hearing, contact us by email at [email protected]
TEXT

aggregate_failures do
expect(confirmation_calendar_invite).to be_a(String)

ical_event = Icalendar::Calendar.parse(confirmation_calendar_invite).first.events.first

expect(ical_event.url.to_s).to eq(
"https://care.evn.va.gov/bva-app/?join=1&media=&escalate=1&[email protected]&pin=&role=guest"
)
expect(ical_event.location).to eq(
"https://care.evn.va.gov/bva-app/?join=1&media=&escalate=1&[email protected]&pin=&role=guest"
)
expect(ical_event.status).to eq("CONFIRMED")
expect(ical_event.summary).to be_nil
expect(ical_event.description).to eq(expected_description)
end
end
end
end
36 changes: 18 additions & 18 deletions spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
# IMPORTANT that in all these hook defs, the "caseflow" connection comes last.

config.before(:suite) do
DatabaseCleaner[:active_record, { connection: etl }].clean_with(:truncation)
DatabaseCleaner[:active_record, { connection: vacols }]
.clean_with(:deletion, { except: vacols_tables_to_preserve })
DatabaseCleaner[:active_record, { connection: caseflow }].clean_with(:truncation)
DatabaseCleaner[:active_record, { db: etl }].clean_with(:truncation)
DatabaseCleaner[:active_record, { db: vacols }]
.clean_with(:deletion, except: vacols_tables_to_preserve)
DatabaseCleaner[:active_record, { db: caseflow }].clean_with(:truncation)
end

config.before(:each) do |example|
# Allows seeded data to persist for use across threads
# You will need to manually clean the data once the threads under test close.
unless example.metadata[:bypass_cleaner]
DatabaseCleaner[:active_record, { connection: vacols }].strategy = :transaction
DatabaseCleaner[:active_record, { connection: caseflow }].strategy = :transaction
DatabaseCleaner[:active_record, { db: vacols }].strategy = :transaction
DatabaseCleaner[:active_record, { db: caseflow }].strategy = :transaction
end
end

config.before(:each, db_clean: :truncation) do |example|
unless example.metadata[:bypass_cleaner]
DatabaseCleaner[:active_record, { connection: vacols }].strategy =
DatabaseCleaner[:active_record, { db: vacols }].strategy =
:deletion, { except: vacols_tables_to_preserve }
DatabaseCleaner[:active_record, { connection: caseflow }].strategy = :truncation
DatabaseCleaner[:active_record, { db: caseflow }].strategy = :truncation
end
end

Expand All @@ -46,42 +46,42 @@
# Driver is probably for an external browser with an app
# under test that does *not* share a database connection with the
# specs, so use truncation strategy.
DatabaseCleaner[:active_record, { connection: vacols }].strategy =
DatabaseCleaner[:active_record, { db: vacols }].strategy =
:deletion, { except: vacols_tables_to_preserve }
DatabaseCleaner[:active_record, { connection: caseflow }].strategy = :truncation
DatabaseCleaner[:active_record, { db: caseflow }].strategy = :truncation
end
end

config.before(:each) do |example|
unless example.metadata[:bypass_cleaner]
DatabaseCleaner[:active_record, { connection: vacols }].start
DatabaseCleaner[:active_record, { connection: caseflow }].start
DatabaseCleaner[:active_record, { db: vacols }].start
DatabaseCleaner[:active_record, { db: caseflow }].start
end
end

config.append_after(:each) do
DatabaseCleaner[:active_record, { connection: vacols }].clean
DatabaseCleaner[:active_record, { connection: caseflow }].clean
DatabaseCleaner[:active_record, { db: vacols }].clean
DatabaseCleaner[:active_record, { db: caseflow }].clean
clean_application!
end

# ETL is never used in feature tests and there are only a few, so we tag those with :etl
# ETL db uses deletion strategy everywhere because syncing runs in a transaction.
config.before(:each, :etl) do
DatabaseCleaner[:active_record, { connection: etl }].strategy = :deletion
DatabaseCleaner[:active_record, { db: etl }].strategy = :deletion
end

config.before(:each, :etl, db_clean: :truncation) do
DatabaseCleaner[:active_record, { connection: etl }].strategy = :truncation
DatabaseCleaner[:active_record, { db: etl }].strategy = :truncation
end

config.before(:each, :etl) do
Rails.logger.info("DatabaseCleaner.start ETL")
DatabaseCleaner[:active_record, { connection: etl }].start
DatabaseCleaner[:active_record, { db: etl }].start
end

config.append_after(:each, :etl) do
DatabaseCleaner[:active_record, { connection: etl }].clean
DatabaseCleaner[:active_record, { db: etl }].clean
Rails.logger.info("DatabaseCleaner.clean ETL")
end
end
Loading