9 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/lib/generators/screen/templates/form_view.template:
--------------------------------------------------------------------------------
1 | <%% content_for :card_title, "Template" %>
2 |
3 | <%% content_for :card_help, "Here's what you do" %>
4 |
5 | <%% content_for :card_body do %>
6 | <%%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
7 | <%% end %>
8 | <%% end %>
9 |
--------------------------------------------------------------------------------
/app/forms/anyone_tribe_form.rb:
--------------------------------------------------------------------------------
1 | class AnyoneTribeForm < Form
2 | set_attributes_for :interview, :anyone_tribe
3 |
4 | validates_inclusion_of :anyone_tribe, { in: %w{yes no}, message: "Make sure to choose an option." }
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/forms/stopped_work_details_form.rb:
--------------------------------------------------------------------------------
1 | class StoppedWorkDetailsForm < Form
2 | set_attributes_for :interview, :stopped_work_details
3 |
4 | validates_presence_of :stopped_work_details, message: "Please include an answer."
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/views/anyone_convicted_drug_felony/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Has anyone on the #{application_or_renewal} been convicted of a drug-related felony?".html_safe %>
2 |
3 | <% content_for :card_body, "People with drug-related felonies can still be eligible if they meet certain conditions." %>
4 |
--------------------------------------------------------------------------------
/app/forms/any_not_listed_names_form.rb:
--------------------------------------------------------------------------------
1 | class AnyNotListedNamesForm < Form
2 | set_attributes_for :interview, :any_not_listed_names
3 |
4 | validates_presence_of :any_not_listed_names, message: "Make sure to include an answer."
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/generators/screen/anyone/templates/details/form_view.template:
--------------------------------------------------------------------------------
1 | <%% content_for :card_title, "Template" %>
2 |
3 | <%% content_for :card_help, "Here's what you do" %>
4 |
5 | <%% content_for :card_body do %>
6 | <%%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
7 | <%% end %>
8 | <%% end %>
9 |
--------------------------------------------------------------------------------
/spec/support/shared_examples/forms_controller_always_shows.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.shared_examples_for "form controller always shows" do
4 | describe "show?" do
5 | it "is always true" do
6 | show_form = subject.class.show?(nil)
7 | expect(show_form).to eq(true)
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/app/forms/citizen_form.rb:
--------------------------------------------------------------------------------
1 | class CitizenForm < Form
2 | set_attributes_for :navigator, :citizen
3 |
4 | def save
5 | interview.navigator.update(attributes_for(:navigator))
6 | end
7 |
8 | def self.existing_attributes(interview)
9 | HashWithIndifferentAccess.new(interview.navigator.attributes)
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/forms/pregnant_form.rb:
--------------------------------------------------------------------------------
1 | class PregnantForm < Form
2 | set_attributes_for :navigator, :pregnant
3 |
4 | def save
5 | interview.navigator.update(attributes_for(:navigator))
6 | end
7 |
8 | def self.existing_attributes(interview)
9 | HashWithIndifferentAccess.new(interview.navigator.attributes)
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/views/needed_documents_signpost/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Great! Now let's go through a few questions to see what other documents are needed." %>
2 |
3 | <% content_for :card_illustration do %>
4 | <% render partial: "components/molecules/progress_step_bar", locals: { current_step: 2, step_count: 3 } %>
5 | <% end %>
6 |
--------------------------------------------------------------------------------
/app/views/parent_not_in_home/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Are there any parents who do not live in the home?".html_safe %>
2 |
3 | <% content_for :card_help, "If so, the applicant will have to fill out a Child Support Information form (Appendix D) for each parent not in the home.".html_safe %>
4 |
--------------------------------------------------------------------------------
/db/migrate/20181121224900_add_fee_agent_fields_to_interview.rb:
--------------------------------------------------------------------------------
1 | class AddFeeAgentFieldsToInterview < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :interviews, :fee_agent_name, :string
4 | add_column :interviews, :fee_agent_email, :string
5 | add_column :interviews, :fee_agent_phone_number, :string
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/forms/any_away_from_home_names_form.rb:
--------------------------------------------------------------------------------
1 | class AnyAwayFromHomeNamesForm < Form
2 | set_attributes_for :interview, :any_away_from_home_names
3 |
4 | validates_presence_of :any_away_from_home_names, message: "Make sure to include an answer."
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/forms/anyone_stopped_work_form.rb:
--------------------------------------------------------------------------------
1 | class AnyoneStoppedWorkForm < Form
2 | set_attributes_for :interview, :anyone_stopped_work
3 |
4 | validates_inclusion_of :anyone_stopped_work, { in: %w{yes no}, message: "Make sure to choose an option." }
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/forms/expenses_payment_details_form.rb:
--------------------------------------------------------------------------------
1 | class ExpensesPaymentDetailsForm < Form
2 | set_attributes_for :interview, :expenses_payment_details
3 |
4 | validates_presence_of :expenses_payment_details, message: "Make sure to include an answer."
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/forms/quest_card_form.rb:
--------------------------------------------------------------------------------
1 | class QuestCardForm < Form
2 | set_attributes_for :interview, :has_quest_card
3 |
4 | validates :has_quest_card, inclusion: {
5 | in: %w(yes no),
6 | message: "Make sure to select yes or no.",
7 | }
8 |
9 | def save
10 | interview.update(attributes_for(:interview))
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20181206222204_add_residency_fields.rb:
--------------------------------------------------------------------------------
1 | class AddResidencyFields < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :navigators, :lived_outside_alaska, :integer, default: 0
4 | add_column :interviews, :arrival_in_alaska, :string
5 | add_column :interviews, :intend_to_stay, :integer, default: 0
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/forms/any_not_listed_form.rb:
--------------------------------------------------------------------------------
1 | class AnyNotListedForm < Form
2 | set_attributes_for :interview, :any_not_listed
3 |
4 | validates :any_not_listed, inclusion: {
5 | in: %w(yes no),
6 | message: "Please answer this question",
7 | }
8 |
9 | def save
10 | interview.update(attributes_for(:interview))
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/app/forms/filing_tax_return_details_form.rb:
--------------------------------------------------------------------------------
1 | class FilingTaxReturnDetailsForm < Form
2 | set_attributes_for :interview, :filing_tax_return_details
3 |
4 | validates_presence_of :filing_tax_return_details, message: "Make sure to include an answer."
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/validators/ten_digit_phone_number_validator.rb:
--------------------------------------------------------------------------------
1 | class TenDigitPhoneNumberValidator < ActiveModel::EachValidator
2 | def validate_each(record, attribute, value)
3 | if value.blank? || !value.match?(/\A\d{10}\z/)
4 | record.errors[attribute] <<
5 | "Make sure to enter a valid 10-digit phone number."
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/views/shared/_how_it_works_step3.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
Hit send!
3 |
4 | The <%= current_interview&.navigator&.interview_type || "application or renewal" %>, fee agent interview form, and attached verifications will be securely sent to the DPA office within seconds.
5 |
--------------------------------------------------------------------------------
/app/controllers/pregnant_controller.rb:
--------------------------------------------------------------------------------
1 | class PregnantController < YesNoFormsController
2 | def self.show_rule_sets(interview)
3 | super << interview.selected_atap?
4 | end
5 |
6 | def yes_no_method_name
7 | :pregnant
8 | end
9 |
10 | def yes_value
11 | true
12 | end
13 |
14 | def no_value
15 | false
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/yarn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_ROOT = File.expand_path('..', __dir__)
3 | Dir.chdir(APP_ROOT) do
4 | begin
5 | exec "yarnpkg", *ARGV
6 | rescue Errno::ENOENT
7 | $stderr.puts "Yarn executable was not detected in the system."
8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9 | exit 1
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20181214234524_add_important_confirmations_to_interview.rb:
--------------------------------------------------------------------------------
1 | class AddImportantConfirmationsToInterview < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :interviews, :client_sign_and_date, :boolean
4 | add_column :interviews, :fa_sign_and_date, :boolean
5 | add_column :interviews, :all_ssns_included, :boolean
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/controllers/other_information_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe OtherInformationController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | other_info: "Best E. Person",
7 | }
8 | it_behaves_like "form controller always shows"
9 | end
10 |
--------------------------------------------------------------------------------
/app/forms/any_away_from_home_form.rb:
--------------------------------------------------------------------------------
1 | class AnyAwayFromHomeForm < Form
2 | set_attributes_for :interview, :any_away_from_home
3 |
4 | validates :any_away_from_home, inclusion: {
5 | in: %w(yes no),
6 | message: "Please answer this question",
7 | }
8 |
9 | def save
10 | interview.update(attributes_for(:interview))
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/app/forms/anyone_filing_tax_return_form.rb:
--------------------------------------------------------------------------------
1 | class AnyoneFilingTaxReturnForm < Form
2 | set_attributes_for :interview, :anyone_filing_tax_return
3 |
4 | validates_inclusion_of :anyone_filing_tax_return, { in: %w{yes no}, message: "Make sure to choose an option." }
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/forms/approved_for_disability_form.rb:
--------------------------------------------------------------------------------
1 | class ApprovedForDisabilityForm < Form
2 | set_attributes_for :interview, :approved_for_disability
3 |
4 | validates_inclusion_of :approved_for_disability, { in: %w{yes no}, message: "Make sure to choose an option." }
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/forms/children_in_home_form.rb:
--------------------------------------------------------------------------------
1 | class ChildrenInHomeForm < Form
2 | set_attributes_for :navigator, :children_in_home
3 |
4 | def save
5 | interview.navigator.update(attributes_for(:navigator))
6 | end
7 |
8 | def self.existing_attributes(interview)
9 | HashWithIndifferentAccess.new(interview.navigator.attributes)
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/forms/interim_assistance_form.rb:
--------------------------------------------------------------------------------
1 | class InterimAssistanceForm < Form
2 | set_attributes_for :navigator, :interim_assistance
3 |
4 | def save
5 | interview.navigator.update(attributes_for(:navigator))
6 | end
7 |
8 | def self.existing_attributes(interview)
9 | HashWithIndifferentAccess.new(interview.navigator.attributes)
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/forms/parent_not_in_home_form.rb:
--------------------------------------------------------------------------------
1 | class ParentNotInHomeForm < Form
2 | set_attributes_for :navigator, :parent_not_in_home
3 |
4 | def save
5 | interview.navigator.update(attributes_for(:navigator))
6 | end
7 |
8 | def self.existing_attributes(interview)
9 | HashWithIndifferentAccess.new(interview.navigator.attributes)
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/overrides.scss:
--------------------------------------------------------------------------------
1 | .template--homepage .slab--hero h1 {
2 | font-size: 3.6rem;
3 | line-height: 1.3em;
4 | font-weight: 600;
5 | margin-top: 1.5em;
6 | margin-bottom: .5em;
7 | }
8 |
9 | .card {
10 | max-width: 72rem;
11 | margin-left: auto;
12 | margin-right: auto;
13 | }
14 |
15 | .vertical-steps h3 {
16 | font-weight: 600;
17 | }
--------------------------------------------------------------------------------
/app/forms/anyone_convicted_drug_felony_form.rb:
--------------------------------------------------------------------------------
1 | class AnyoneConvictedDrugFelonyForm < Form
2 | set_attributes_for :interview, :anyone_convicted_drug_felony
3 |
4 | validates_inclusion_of :anyone_convicted_drug_felony, { in: %w{yes no}, message: "Make sure to choose an option." }
5 |
6 | def save
7 | interview.update(attributes_for(:interview))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/controllers/static_pages_controller.rb:
--------------------------------------------------------------------------------
1 | class StaticPagesController < ApplicationController
2 | before_action :clear_interview_from_session
3 |
4 | helper_method :current_interview
5 |
6 | def index; end
7 |
8 | private
9 |
10 | def current_interview; end
11 |
12 | def clear_interview_from_session
13 | session[:current_interview_id] = nil
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/factories/interview.rb:
--------------------------------------------------------------------------------
1 | FactoryBot.define do
2 | factory :interview do
3 | trait :with_navigator do
4 | transient do
5 | interview_type { nil }
6 | end
7 |
8 | after(:create) do |interview, evaluator|
9 | create(:navigator, interview: interview, interview_type: evaluator.interview_type)
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/controllers/citizen_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe CitizenController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | citizen: true,
7 | }
8 | it_behaves_like "form controller always shows"
9 | it_behaves_like "yes no forms controller with boolean values"
10 | end
11 |
--------------------------------------------------------------------------------
/app/controllers/parent_not_in_home_controller.rb:
--------------------------------------------------------------------------------
1 | class ParentNotInHomeController < YesNoFormsController
2 | def self.show_rule_sets(interview)
3 | super << interview.navigator.children_in_home?
4 | end
5 |
6 | def yes_no_method_name
7 | :parent_not_in_home
8 | end
9 |
10 | def yes_value
11 | true
12 | end
13 |
14 | def no_value
15 | false
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/views/approved_for_disability/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Has the #{applicant_or_client} been approved for Social Security Disability or SSI?".html_safe %>
2 |
3 | <% content_for :card_help, "In order to be eligible for Adult Public Assistance, the #{applicant_or_client} needs to have at least applied for Social Security Disability or SSI." %>
4 |
5 |
--------------------------------------------------------------------------------
/spec/controllers/anyone_tribe_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyoneTribeController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | anyone_tribe: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/spec/controllers/quest_card_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe QuestCardController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | has_quest_card: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/app/controllers/interim_assistance_controller.rb:
--------------------------------------------------------------------------------
1 | class InterimAssistanceController < YesNoFormsController
2 | def self.show_rule_sets(interview)
3 | super << interview.approved_for_disability_no?
4 | end
5 |
6 | def yes_no_method_name
7 | :interim_assistance
8 | end
9 |
10 | def yes_value
11 | true
12 | end
13 |
14 | def no_value
15 | false
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 | # Character.create(name: 'Luke', movie: movies.first)
8 |
--------------------------------------------------------------------------------
/spec/controllers/any_not_listed_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyNotListedController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | any_not_listed: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/app/views/other_information/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Any other information that would be helpful for the case worker to know?" %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :other_info, "Enter any other information or comments.", options: {rows: "4"} %>
6 | <% end %>
7 | <% end %>
8 |
--------------------------------------------------------------------------------
/lib/tasks/bundler_audit.rake:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | if Rails.env.development? || Rails.env.test?
4 | require "bundler/audit/cli"
5 |
6 | namespace :bundler do
7 | desc "Updates the ruby-advisory-db and runs audit"
8 | task :audit do
9 | %w[update check].each do |command|
10 | Bundler::Audit::CLI.start [command]
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/db/migrate/20181122004152_add_client_details_to_interview.rb:
--------------------------------------------------------------------------------
1 | class AddClientDetailsToInterview < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :interviews, :client_name, :string
4 | add_column :interviews, :encrypted_client_last_four_ssn, :string
5 | add_column :interviews, :encrypted_client_last_four_ssn_iv, :string
6 | add_column :interviews, :attendee_names, :text
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/spec/controllers/any_away_from_home_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyAwayFromHomeController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | any_away_from_home: "no",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/app/controllers/want_direct_deposit_controller.rb:
--------------------------------------------------------------------------------
1 | class WantDirectDepositController < YesNoFormsController
2 | def self.show_rule_sets(interview)
3 | super << (interview.selected_apa? || interview.selected_atap?)
4 | end
5 |
6 | def yes_no_method_name
7 | :want_direct_deposit
8 | end
9 |
10 | def yes_value
11 | true
12 | end
13 |
14 | def no_value
15 | false
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/controllers/anyone_stopped_work_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyoneStoppedWorkController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | anyone_stopped_work: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/app/views/shared/_how_it_works_vertical.html.erb:
--------------------------------------------------------------------------------
1 |
Attach the <%= current_interview&.navigator&.interview_type || "application or renewal form"%> and verification docs.
3 |
4 | We'll help snap photos or upload the <%= current_interview&.navigator&.interview_type || "forms" %> and any relevant proof. The documents will not be saved on your device.
5 |
--------------------------------------------------------------------------------
/lib/generators/screen/templates/form_controller_spec.template:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe <%= model.camelcase %>Controller do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | signature: "Best E. Person",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/spec/controllers/anyone_filing_tax_return_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyoneFilingTaxReturnController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | anyone_filing_tax_return: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/spec/controllers/rights_and_responsibilities_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe RightsAndResponsibilitiesController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | explained_rights: "1",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/lib/generators/screen/templates/form_controller.template:
--------------------------------------------------------------------------------
1 | class <%= model.camelcase %>Controller < FormsController
2 | layout "left_aligned"
3 | <%- if options.doc? -%>
4 | # Specify under what conditions controller should be accessible:
5 | # (By default it will always be shown
6 | <%- end -%>
7 | # def self.show_rule_sets(interview)
8 | # super << ShowRules.must_have_supported_county(interview)
9 | # end
10 | end
11 |
--------------------------------------------------------------------------------
/app/assets/javascripts/cable.js:
--------------------------------------------------------------------------------
1 | // Action Cable provides the framework to deal with WebSockets in Rails.
2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3 | //
4 | //= require action_cable
5 | //= require_self
6 | //= require_tree ./channels
7 |
8 | (function() {
9 | this.App || (this.App = {});
10 |
11 | App.cable = ActionCable.createConsumer();
12 |
13 | }).call(this);
14 |
--------------------------------------------------------------------------------
/lib/generators/screen/anyone/templates/details/form_controller.template:
--------------------------------------------------------------------------------
1 | class <%= details_class_name %>Controller < FormsController
2 | layout "left_aligned"
3 | <%- if options.doc? -%>
4 | # Specify under what conditions controller should be accessible:
5 | # (By default it will always be shown)
6 | <%- end -%>
7 | def self.show_rule_sets(interview)
8 | super << interview.<%= anyone_model_method %>_yes?
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/controllers/anyone_convicted_drug_felony_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyoneConvictedDrugFelonyController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | anyone_convicted_drug_felony: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/spec/controllers/expenses_payment_details_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ExpensesPaymentDetailsController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | expenses_payment_details: "supporting details",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20181120172602_create_interviews_and_navigators.rb:
--------------------------------------------------------------------------------
1 | class CreateInterviewsAndNavigators < ActiveRecord::Migration[5.2]
2 | def change
3 | create_table :interviews, &:timestamps
4 |
5 | create_table :navigators do |t|
6 | t.references :interview
7 | t.integer :interview_type
8 | t.timestamps
9 | end
10 |
11 | change_column_default :navigators, :interview_type, from: nil, to: 0
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/generators/screen/anyone/templates/anyone/form_controller_spec.template:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe <%= anyone_class_name %>Controller do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | <%= anyone_model_method %>: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 | it_behaves_like "form controller always shows"
10 | end
11 |
--------------------------------------------------------------------------------
/app/views/cama_details/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "If applying for CAMA, please list the specific medical need." %>
2 |
3 |
4 | <% content_for :card_body do %>
5 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
6 | <%= f.cfa_textarea :cama_details,
7 | "List the need and make sure to include the doctor's name and phone number.",
8 | options: {rows: "4"} %>
9 | <% end %>
10 | <% end %>
11 |
--------------------------------------------------------------------------------
/spec/support/shared_examples/yes_no_forms_controller_with_enum_values.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.shared_examples_for "yes no forms controller with enum values" do
4 | describe "yes_value" do
5 | it "returns 'yes'" do
6 | expect(controller.yes_value).to eq("yes")
7 | end
8 | end
9 |
10 | describe "no_value" do
11 | it "returns 'no'" do
12 | expect(controller.no_value).to eq("no")
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/app/views/any_away_from_home_names/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Tell us about the people who live in the house but are away from home." %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :any_away_from_home_names, "List their name(s), why they are away, and the expected date to return home.", options: {rows: "4"} %>
6 | <% end %>
7 | <% end %>
8 |
--------------------------------------------------------------------------------
/app/views/any_not_listed_names/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Tell us about the people who live in the home but are not on the #{application_or_renewal}" %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :any_not_listed_names, "List their name(s) and relationship to the #{applicant_or_client}.", options: {rows: "4"} %>
6 | <% end %>
7 | <% end %>
8 |
--------------------------------------------------------------------------------
/app/views/filing_tax_return_details/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Tell us about the tax return." %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :filing_tax_return_details,
6 | "Who in the household will be filing and will there be any tax dependent(s)? If so, who?",
7 | options: {rows: "4"} %>
8 | <% end %>
9 | <% end %>
10 |
--------------------------------------------------------------------------------
/app/views/lets_start/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Let's start with the interview." %>
2 |
3 | <% content_for :card_illustration do %>
4 | <% render partial: "components/molecules/progress_step_bar", locals: { current_step: 1, step_count: 3 } %>
5 | <% end %>
6 |
7 | <% content_for :card_body do %>
8 |
9 | We'll guide you through step-by-step and automatically fill out a digital fee agent interview form.
10 |
11 | <% end %>
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/spec/support/shared_examples/yes_no_forms_controller_with_boolean_values.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.shared_examples_for "yes no forms controller with boolean values" do
4 | describe "yes_value" do
5 | it "returns 'true'" do
6 | expect(controller.yes_value).to eq(true)
7 | end
8 | end
9 |
10 | describe "no_value" do
11 | it "returns 'false'" do
12 | expect(controller.no_value).to eq(false)
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/app/views/want_direct_deposit/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Does the #{applicant_or_client} want to get benefits through direct deposit?".html_safe %>
2 |
3 | <% content_for :card_help do %>
4 |
5 | This is for Alaska Temporary Assistance and Adult Public Assistance benefits.
6 |
7 |
8 | If yes, please have the <%= applicant_or_client %> fill out the Direct Deposit form.
9 |
10 | <% end %>
11 |
--------------------------------------------------------------------------------
/spec/controllers/residency_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ResidencyController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | lived_outside_alaska: "yes",
7 | arrival_in_alaska: "Last year",
8 | intend_to_stay: "yes",
9 | }
10 | it_behaves_like "form controller unsuccessful update"
11 | it_behaves_like "form controller always shows"
12 | end
13 |
--------------------------------------------------------------------------------
/app/views/any_away_from_home/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Is there anyone on the #{application_or_renewal} who usually lives in the house but is away from home?".html_safe %>
2 |
3 | <% content_for :card_body do %>
4 |
5 |
For example:
6 |
Going to college
7 |
On military duty
8 |
Doing remote work
9 |
Serving prison time
10 |
11 | <% end %>
12 |
--------------------------------------------------------------------------------
/app/views/tribe_details/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Tell us about the people who are in a federally recognized tribe." %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :tribe_details, "List the names of anyone on the #{application_or_renewal} who is in a federally recognized tribe and what tribe they are a part of.", options: {rows: "4"} %>
6 | <% end %>
7 | <% end %>
8 |
--------------------------------------------------------------------------------
/spec/controllers/important_confirmations_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ImportantConfirmationsController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | client_sign_and_date: "1",
7 | fa_sign_and_date: "1",
8 | all_ssns_included: "1",
9 | }
10 | it_behaves_like "form controller unsuccessful update"
11 | it_behaves_like "form controller always shows"
12 | end
13 |
--------------------------------------------------------------------------------
/app/controllers/children_in_home_controller.rb:
--------------------------------------------------------------------------------
1 | class ChildrenInHomeController < YesNoFormsController
2 | def self.show_rule_sets(interview)
3 | [
4 | interview.navigator.interview_type_application?,
5 | (interview.selected_medicaid || interview.selected_atap),
6 | ] + super
7 | end
8 |
9 | def yes_no_method_name
10 | :children_in_home
11 | end
12 |
13 | def yes_value
14 | true
15 | end
16 |
17 | def no_value
18 | false
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/controllers/client_details_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ClientDetailsController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | client_name: "Best E. Person",
7 | client_last_four_ssn: "1234",
8 | attendee_names: "Anne Dog, Best E. Person",
9 | }
10 | it_behaves_like "form controller unsuccessful update"
11 | it_behaves_like "form controller always shows"
12 | end
13 |
--------------------------------------------------------------------------------
/lib/generators/screen/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Create files for adding a new screen to the application.
3 |
4 | Example:
5 | rails generate screen FoodAssistance
6 |
7 | This will create:
8 | app/forms/food_assistance_form.rb
9 | app/controllers/food_assistance_controller.rb
10 | app/views/food_assistance/edit.html.erb
11 | spec/forms/food_assistance_form_spec.rb
12 | spec/controllers/food_assistance_controller_spec.rb
13 |
14 | This will add:
15 | * TBD
--------------------------------------------------------------------------------
/spec/controllers/fee_agent_details_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe FeeAgentDetailsController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | fee_agent_name: "Best E. Person",
7 | fee_agent_email: "feeagent@example.com",
8 | fee_agent_phone_number: "555-555-5555",
9 | }
10 | it_behaves_like "form controller unsuccessful update"
11 | it_behaves_like "form controller always shows"
12 | end
13 |
--------------------------------------------------------------------------------
/spec/support/pdf_helper.rb:
--------------------------------------------------------------------------------
1 | module PdfHelper
2 | def filled_in_values(file_path)
3 | filled_in_fields = pdftk.get_fields(file_path)
4 |
5 | filled_in_fields.each_with_object({}) do |field, hash|
6 | hash[field.name] = field.value
7 | end
8 | end
9 |
10 | def pdftk
11 | @_pdftk ||= PdfForms.new
12 | end
13 |
14 | def write_raw_pdf_to_temp_file(source:)
15 | temp_pdf = Tempfile.new("pdf", encoding: "ascii-8bit")
16 | temp_pdf << source
17 | temp_pdf
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require_relative "config/application"
4 |
5 | namespace :lint do
6 | task :autocorrect do
7 | require "rubocop/rake_task"
8 | RuboCop::RakeTask.new
9 | Rake::Task["rubocop:auto_correct"].execute
10 | end
11 | end
12 |
13 | task :brakeman do
14 | sh "brakeman --no-pager"
15 | end
16 |
17 | task default: %w[lint:autocorrect bundler:audit brakeman spec]
18 |
19 | Rails.application.load_tasks
20 |
21 | task "db:schema:dump": "db:schema:alphabetize_columns"
22 |
--------------------------------------------------------------------------------
/app/forms/rights_and_responsibilities_form.rb:
--------------------------------------------------------------------------------
1 | class RightsAndResponsibilitiesForm < Form
2 | set_attributes_for :interview, :explained_rights
3 |
4 | validates :explained_rights, inclusion: {
5 | in: ["1"],
6 | message: "Make sure to agree before continuing.",
7 | }
8 |
9 | def save
10 | interview.update(attributes_for(:interview))
11 | end
12 |
13 | def self.existing_attributes(interview)
14 | {
15 | explained_rights: checkbox_value(interview.explained_rights),
16 | }
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/app/views/success/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_illustration do %>
2 |
3 | <% end %>
4 | <% content_for :card_title, "This #{application_or_renewal} has been successfully submitted to the DPA office." %>
5 |
6 | <% content_for :card_body do %>
7 |
8 | <%= "Let the client know to expect a call within a few days or mail from the DPA office within the next two weeks to finalize the #{application_or_renewal} process." %>
9 |
10 | <% end %>
11 |
--------------------------------------------------------------------------------
/spec/helpers/application_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ApplicationHelper, type: :helper do
4 | describe "#format_phone_number" do
5 | context "phone number present" do
6 | it "formats a phone number" do
7 | expect(helper.format_phone_number("2024561111")).to eq("(202) 456-1111")
8 | end
9 | end
10 |
11 | context "blank value" do
12 | it "returns nil" do
13 | expect(helper.format_phone_number("")).to be_nil
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/controllers/which_program_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe WhichProgramController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | selected_snap: "1",
7 | selected_medicaid: "1",
8 | selected_general_relief: "1",
9 | selected_atap: "0",
10 | selected_apa: "0",
11 | selected_cama: "0",
12 | }
13 | it_behaves_like "form controller unsuccessful update"
14 | it_behaves_like "form controller always shows"
15 | end
16 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/db/migrate/20181207183301_add_anyone_convicted_details_to_interview.rb:
--------------------------------------------------------------------------------
1 | class AddAnyoneConvictedDetailsToInterview < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :interviews, :convicted_drug_felony_name, :string
4 | add_column :interviews, :completed_probation_or_parole, :integer, default: 0
5 | add_column :interviews, :completed_treatment_program, :integer, default: 0
6 | add_column :interviews, :taken_action_towards_rehabilitation, :integer, default: 0
7 | add_column :interviews, :complied_with_reentry, :integer, default: 0
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/controllers/static_pages_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe StaticPagesController, type: :controller do
4 | describe "#index" do
5 | it "renders the homepage" do
6 | get :index
7 |
8 | expect(response).to render_template(:index)
9 | end
10 |
11 | context "with a current interview " do
12 | it "sets the current interview id to nil" do
13 | session[:current_interview_id] = 1
14 |
15 | get :index
16 |
17 | expect(session[:current_interview_id]).to be_nil
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/app/views/anyone_stopped_work/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Does anyone on this #{application_or_renewal} have work that was stopped or reduced within the last 60 days?".html_safe %>
2 |
3 | <% content_for :card_help, "Please check carefully. This can hold up cases if DPA income checks show higher income than reported." %>
4 |
5 | <% content_for :card_body do %>
6 |
13 |
14 | <%= f.cfa_checkbox_set(:explained_rights,
15 | [{ label: "Yes", method: :explained_rights }],
16 | label_text: "Did you explain the rights and responsibilities and provide a copy to the #{applicant_or_client}?") %>
17 | <% end %>
18 | <% end %>
19 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6 | * vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
17 | @import 'cfa_styleguide_main';
18 |
19 | @import 'molecules/show-more';
20 |
21 | @import 'overrides';
22 | @import 'custom';
--------------------------------------------------------------------------------
/spec/support/shared_examples/forms_controller_successful_update.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.shared_examples_for "form controller successful update" do |valid_params|
4 | describe "#update" do
5 | context "without interview" do
6 | it "redirects to homepage" do
7 | put :update, params: { form: valid_params }
8 |
9 | expect(response).to redirect_to(root_path)
10 | end
11 | end
12 |
13 | context "with interview" do
14 | let(:current_interview) { create(:interview, :with_navigator) }
15 |
16 | before do
17 | session[:current_interview_id] = current_interview.id
18 | end
19 |
20 | context "on successful update" do
21 | it "redirects to next path" do
22 | put :update, params: { form: valid_params }
23 |
24 | expect(response).to redirect_to(subject.next_path)
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/app/forms/residency_form.rb:
--------------------------------------------------------------------------------
1 | class ResidencyForm < Form
2 | set_attributes_for :interview, :arrival_in_alaska, :intend_to_stay
3 | set_attributes_for :navigator, :lived_outside_alaska
4 |
5 | validates_presence_of :lived_outside_alaska, message: "Make sure to select an answer"
6 | validate :arrival_in_alaska_validation
7 | validates_presence_of :intend_to_stay, message: "Make sure to select an answer"
8 |
9 | def save
10 | interview.update(attributes_for(:interview))
11 | interview.navigator.update(attributes_for(:navigator))
12 | end
13 |
14 | def self.existing_attributes(interview)
15 | HashWithIndifferentAccess.new(interview.attributes.merge(interview.navigator.attributes))
16 | end
17 |
18 | def arrival_in_alaska_validation
19 | if lived_outside_alaska == "yes" && arrival_in_alaska.blank?
20 | errors.add(:arrival_in_alaska, "Make sure to include an answer")
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/forms/children_in_home_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ChildrenInHomeForm do
4 | describe "#save" do
5 | let(:interview) { create :interview, :with_navigator }
6 |
7 | let(:valid_params) do
8 | {
9 | children_in_home: "true",
10 | }
11 | end
12 |
13 | it "persists the values to the correct models" do
14 | form = ChildrenInHomeForm.new(interview, valid_params)
15 | form.valid?
16 | form.save
17 |
18 | interview.reload
19 |
20 | expect(interview.navigator.children_in_home).to eq true
21 | end
22 | end
23 |
24 | describe ".from_interview" do
25 | it "assigns values from interview" do
26 | interview = create(:interview, navigator: build(:navigator, children_in_home: true))
27 |
28 | form = ChildrenInHomeForm.from_interview(interview)
29 |
30 | expect(form.children_in_home).to eq true
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/app/views/stopped_work_details/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Tell us about work that has stopped or has been reduced in the last 60 days." %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :stopped_work_details,
6 | "
List the person, the job, when and why the job ended or was reduced, and the name and phone number of the employer.
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | The more details you can provide, the more likely the #{applicant_or_client} can be approved without issues.
15 |
16 |
",
17 | options: {rows: "4"} %>
18 | <% end %>
19 | <% end %>
20 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'fileutils'
3 | include FileUtils
4 |
5 | # path to your application root.
6 | APP_ROOT = File.expand_path('..', __dir__)
7 |
8 | def system!(*args)
9 | system(*args) || abort("\n== Command #{args} failed ==")
10 | end
11 |
12 | chdir APP_ROOT do
13 | # This script is a way to update your development environment automatically.
14 | # Add necessary update steps to this file.
15 |
16 | puts '== Installing dependencies =='
17 | system! 'gem install bundler --conservative'
18 | system('bundle check') || system!('bundle install')
19 |
20 | # Install JavaScript dependencies if using Yarn
21 | # system('bin/yarn')
22 |
23 | puts "\n== Updating database =="
24 | system! 'bin/rails db:migrate'
25 |
26 | puts "\n== Removing old logs and tempfiles =="
27 | system! 'bin/rails log:clear tmp:clear'
28 |
29 | puts "\n== Restarting application server =="
30 | system! 'bin/rails restart'
31 | end
32 |
--------------------------------------------------------------------------------
/spec/controllers/tribe_details_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe TribeDetailsController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | tribe_details: "yes",
7 | }
8 | it_behaves_like "form controller unsuccessful update"
9 |
10 | describe "#show?" do
11 | context "when someone in household is tribe" do
12 | it "returns true" do
13 | application = create(:interview, anyone_tribe: "yes")
14 |
15 | show = TribeDetailsController.show?(application)
16 | expect(show).to eq(true)
17 | end
18 | end
19 |
20 | context "when no one in household is tribe" do
21 | it "returns false" do
22 | application = create(:interview, anyone_tribe: "no")
23 |
24 | show = TribeDetailsController.show?(application)
25 | expect(show).to eq(false)
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/spec/forms/parent_not_in_home_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ParentNotInHomeForm do
4 | describe "#save" do
5 | let(:interview) { create :interview, :with_navigator }
6 |
7 | let(:valid_params) do
8 | {
9 | parent_not_in_home: "true",
10 | }
11 | end
12 |
13 | it "persists the values to the correct models" do
14 | form = ParentNotInHomeForm.new(interview, valid_params)
15 | form.valid?
16 | form.save
17 |
18 | interview.reload
19 |
20 | expect(interview.navigator.parent_not_in_home).to eq true
21 | end
22 | end
23 |
24 | describe ".from_interview" do
25 | it "assigns values from interview" do
26 | interview = create(:interview, navigator: build(:navigator, parent_not_in_home: true))
27 |
28 | form = ParentNotInHomeForm.from_interview(interview)
29 |
30 | expect(form.parent_not_in_home).to eq true
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/spec/forms/want_direct_deposit_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe WantDirectDepositForm do
4 | describe "validations" do
5 | context "when want_direct_deposit is provided" do
6 | it "is valid" do
7 | form = WantDirectDepositForm.new(
8 | nil,
9 | want_direct_deposit: false,
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 | end
16 |
17 | describe "#save" do
18 | let(:interview) { create :interview, :with_navigator }
19 |
20 | let(:valid_params) do
21 | {
22 | want_direct_deposit: true,
23 | }
24 | end
25 |
26 | it "persists the values to the correct models" do
27 | form = WantDirectDepositForm.new(interview, valid_params)
28 | form.valid?
29 | form.save
30 |
31 | interview.reload
32 |
33 | expect(interview.navigator.want_direct_deposit).to be_truthy
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/app/views/attach_documents_signpost/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Lastly, let's attach the #{application_or_renewal} and any required documents." %>
2 |
3 | <% content_for :card_illustration do %>
4 | <% render partial: "components/molecules/progress_step_bar", locals: { current_step: 3, step_count: 3 } %>
5 | <% end %>
6 |
7 | <% content_for :card_body do %>
8 |
9 |
10 | If you are doing this on a computer, you can scan documents to your computer and upload them in the follow section.
11 |
12 |
13 |
14 |
15 |
16 | If you are doing this on a smartphone or tablet device, you can use the camera on the back of the device to take a picture of any documents.
17 |
18 |
19 |
20 |
21 | Photos will not be saved to your device.
22 |
23 |
24 |
25 | <% end %>
26 |
--------------------------------------------------------------------------------
/spec/controllers/approved_for_disability_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ApprovedForDisabilityController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | approved_for_disability: "yes",
7 | }
8 | it_behaves_like "yes no forms controller with enum values"
9 |
10 | describe "#show" do
11 | context "selected APA" do
12 | it "shows" do
13 | application = create(:interview, selected_apa: true)
14 |
15 | show = ApprovedForDisabilityController.show?(application)
16 | expect(show).to eq(true)
17 | end
18 | end
19 |
20 | context "did not select APA" do
21 | it "does not show" do
22 | application = create(:interview, selected_apa: false)
23 |
24 | show = ApprovedForDisabilityController.show?(application)
25 | expect(show).to eq(false)
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/app/views/important_confirmations/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Let's review a few important parts of the #{application_or_renewal}." %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 |
6 | <%= f.cfa_checkbox_set(:client_sign_and_date,
7 | [{ label: "Yes", method: :client_sign_and_date }],
8 | label_text: "Did the #{applicant_or_client} sign and date the #{application_or_renewal} and all other forms needing signature?") %>
9 |
10 | <%= f.cfa_checkbox_set(:fa_sign_and_date,
11 | [{ label: "Yes", method: :fa_sign_and_date }],
12 | label_text: "Did you, as Fee Agent, sign and date the #{application_or_renewal}?") %>
13 |
14 | <%= f.cfa_checkbox_set(:all_ssns_included,
15 | [{ label: "Yes", method: :all_ssns_included }],
16 | label_text: "Are all the household members' social security numbers listed on the #{application_or_renewal}?") %>
17 | <% end %>
18 | <% end %>
19 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/app/views/interim_assistance/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Does the #{applicant_or_client} want to apply for interim assistance?".html_safe %>
2 |
3 | <% content_for :card_body do %>
4 |
Interim Assistance is a state program paying up to $280 per month to people who are waiting for final decisions about whether they are eligible for disability benefits from the SSA.
If yes, the <%= applicant_or_client %> will need to fill out and return a Preliminary Examination for Interim Assistance Form (AD2) and a Authorization for Reimbursement of Interim Assistance form (GEN 142- IAR).
18 | <%= "SNAP ".html_safe if current_interview.selected_snap %>
19 | <%= "Medicaid ".html_safe if current_interview.selected_medicaid %>
20 | <%= "General Relief ".html_safe if current_interview.selected_general_relief %>
21 | <%= "Alaska Temporary Assistance ".html_safe if current_interview.selected_atap %>
22 | <%= "Adult Public Assistance ".html_safe if current_interview.selected_apa %>
23 | <%= "CAMA" if current_interview.selected_cama %>
24 |
25 |
26 | <% end %>
27 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 |
4 | ruby "2.5.3"
5 |
6 | gem "rails", "~> 5.2.1"
7 |
8 | gem "administrate"
9 | gem "administrate-field-enum"
10 | gem "attr_encrypted"
11 | gem "bootsnap", ">= 1.1.0", require: false
12 | gem "cfa-styleguide", git: "https://github.com/codeforamerica/cfa-styleguide-gem"
13 | gem "handlebars_assets"
14 | gem "jbuilder", "~> 2.5"
15 | gem "lograge"
16 | gem "pdf-forms"
17 | gem "pg", ">= 0.18", "< 2.0"
18 | gem "puma", "~> 3.11"
19 | gem "sass-rails", "~> 5.0"
20 |
21 | group :development, :test do
22 | gem "brakeman", require: false
23 | gem "bundler-audit", require: false
24 | gem "byebug", platforms: %i[mri mingw x64_mingw]
25 | gem "factory_bot_rails"
26 | gem "pry-byebug"
27 | gem "rails-controller-testing"
28 | gem "rspec-rails"
29 | end
30 |
31 | group :development do
32 | gem "listen", ">= 3.0.5", "< 3.2"
33 | gem "rubocop", require: false
34 | gem "rubocop-rspec", require: false
35 | gem "spring"
36 | gem "spring-watcher-listen", "~> 2.0.0"
37 | gem "web-console", ">= 3.3.0"
38 | end
39 |
40 | group :test do
41 | gem "capybara"
42 | gem "capybara-selenium"
43 | gem "chromedriver-helper"
44 | gem "rspec_junit_formatter"
45 | end
46 |
47 | gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
48 |
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5 | // vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file. JavaScript code in this file should be added after the last require_* statement.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require cfa_styleguide_main
14 | //= require activestorage
15 | //= require handlebars.runtime
16 | //= require_tree ./templates
17 | //= require_tree .
18 |
19 | var showMore = (function() {
20 | return {
21 | init: function() {
22 | $('.show-more').each(function(index, showmore) {
23 | $(showmore).find('.show-more__button').click(function(e) {
24 | e.preventDefault();
25 | $(showmore).addClass('is-open');
26 | })
27 | });
28 | }
29 | }
30 | })();
31 |
32 | $(document).ready(function() {
33 | showMore.init();
34 | });
35 |
--------------------------------------------------------------------------------
/spec/features/admin/admin_dashboard_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.feature "Admin viewing dashboard" do
4 | include PdfHelper
5 |
6 | context "logged in admin" do
7 | def basic_auth!
8 | encoded_login = ["admin:password"].pack("m*")
9 | page.driver.header "Authorization", "Basic #{encoded_login}"
10 | end
11 |
12 | before do
13 | basic_auth!
14 | end
15 |
16 | scenario "viewing details for an interview" do
17 | interview = create(:interview)
18 |
19 | visit admin_root_path
20 |
21 | expect(page).to have_content("Interview")
22 |
23 | click_on interview.id
24 |
25 | expect(page).to have_content("Interview ##{interview.id}")
26 | end
27 |
28 | scenario "searching isn't broken" do
29 | visit admin_root_path(search: "asdf")
30 |
31 | expect(page).to have_content("Interview")
32 | end
33 |
34 | scenario "viewing a pdf" do
35 | create(:interview, fee_agent_name: "Jessie Tester")
36 |
37 | visit admin_root_path
38 |
39 | click_on "Download"
40 |
41 | temp_file = write_raw_pdf_to_temp_file(source: page.source)
42 | pdf_values = filled_in_values(temp_file.path)
43 |
44 | # Minimal testing to make sure PDF isn't corrupted
45 | expect(pdf_values["fa_name"]).to include("Jessie Tester")
46 | end
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/app/forms/convicted_drug_felony_details_form.rb:
--------------------------------------------------------------------------------
1 | class ConvictedDrugFelonyDetailsForm < Form
2 | set_attributes_for :interview,
3 | :convicted_drug_felony_name,
4 | :completed_probation_or_parole,
5 | :completed_treatment_program,
6 | :taken_action_towards_rehabilitation,
7 | :complied_with_reentry,
8 | :none
9 |
10 | validates_presence_of :convicted_drug_felony_name, message: "Make sure to include their name."
11 | validate :at_least_one_drug_felony_or_none_selected
12 |
13 | def save
14 | enum_keys = %i[
15 | completed_probation_or_parole
16 | completed_treatment_program
17 | taken_action_towards_rehabilitation
18 | complied_with_reentry
19 | ]
20 | enum_values = attributes_for(:interview).slice(*enum_keys)
21 | enum_values.update(enum_values) { |_, val| val == "1" ? "yes" : "no" }
22 | interview.update(enum_values.merge(attributes_for(:interview).except(*enum_keys).except(:none)))
23 | end
24 |
25 | private
26 |
27 | def at_least_one_drug_felony_or_none_selected
28 | return true if attributes_for(:interview).except(:convicted_drug_felony_name).values.any? { |value| value == "1" }
29 |
30 | errors.add(:convicted_drug_felony_details, "Please select at least one option or 'none of the above.'")
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/forms/what_living_expenses_form.rb:
--------------------------------------------------------------------------------
1 | class WhatLivingExpensesForm < Form
2 | set_attributes_for :interview,
3 | :has_rent_mortgage_expense,
4 | :has_space_rent_expense,
5 | :has_property_tax_expense,
6 | :has_child_support_expense,
7 | :has_home_insurance_expense,
8 | :has_child_care_expense,
9 | :has_medical_care_medicine_expense,
10 | :has_wood_coal_expense,
11 | :has_telephone_expense,
12 | :has_water_sewage_expense,
13 | :has_electricity_expense,
14 | :has_propane_gas_expense,
15 | :has_oil_expense,
16 | :none
17 |
18 | validate :at_least_one_expense_or_none_selected
19 |
20 | def save
21 | interview.update(attributes_for(:interview).except(:none))
22 | end
23 |
24 | def self.existing_attributes(interview)
25 | attributes_to_checkbox_values(interview, attribute_names.reject { |name| name == :none })
26 | end
27 |
28 | private
29 |
30 | def at_least_one_expense_or_none_selected
31 | return true if attributes_for(:interview).values.any? { |value| value == "1" }
32 |
33 | errors.add(:living_expenses, "Please select at least one option or 'none of the above.'")
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/spec/controllers/verification_guidance_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe VerificationGuidanceController do
4 | it_behaves_like "form controller always shows"
5 |
6 | context "with session" do
7 | let(:current_interview) { create(:interview, :with_navigator) }
8 |
9 | before do
10 | session[:current_interview_id] = current_interview.id
11 | end
12 |
13 | describe "#current_interview" do
14 | it "returns the Interview from the id in the session" do
15 | expect(controller.current_interview).to eq current_interview
16 | end
17 | end
18 |
19 | describe "#edit" do
20 | it "sets the form and renders the template" do
21 | get :edit
22 |
23 | expect(response).to render_template(:edit)
24 | expect(assigns[:interview]).to be_a VerificationGuidanceInterviewDecorator
25 | end
26 | end
27 |
28 | describe "#current_path" do
29 | it "returns the path for this route" do
30 | expect(controller.current_path).to eq "/screens/#{controller.class.to_param}"
31 | end
32 | end
33 |
34 | describe "#next_path" do
35 | it "returns the next path from this controller" do
36 | form_navigation = FormNavigation.new(controller)
37 |
38 | expect(controller.next_path).to eq "/screens/#{form_navigation.next.to_param}"
39 | end
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/lib/generators/screen/screen_generator.rb:
--------------------------------------------------------------------------------
1 | class ScreenGenerator < Rails::Generators::NamedBase
2 | source_root File.expand_path("templates", __dir__)
3 | class_option :doc, type: :boolean, default: false, desc: "Include documentation."
4 |
5 | def generate_model
6 | generate_form_model
7 | generate_form_controller
8 | generate_form_view
9 | generate_form_model_spec
10 | generate_form_controller_spec
11 |
12 | puts "\nDone generating the #{model} screen!"
13 | puts "Be sure to add #{model}Controller in the desired application order in `form_navigation.rb`"
14 | end
15 |
16 | private
17 |
18 | alias_method :model, :name
19 |
20 | def generate_form_model
21 | template "form_model.template", "app/forms/#{model.underscore}_form.rb"
22 | end
23 |
24 | def generate_form_model_spec
25 | template "form_model_spec.template",
26 | "spec/forms/#{model.underscore}_form_spec.rb"
27 | end
28 |
29 | def generate_form_controller
30 | template "form_controller.template",
31 | "app/controllers/#{model.underscore}_controller.rb"
32 | end
33 |
34 | def generate_form_controller_spec
35 | template "form_controller_spec.template",
36 | "spec/controllers/#{model.underscore}_controller_spec.rb"
37 | end
38 |
39 | def generate_form_view
40 | template "form_view.template",
41 | "app/views/#{model.underscore}/edit.html.erb"
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/app/views/expenses_payment_details/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Explain how the household has been supporting itself before applying for assistance." %>
2 |
3 | <% content_for :card_body do %>
4 | <%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaFormBuilder) do |f| %>
5 | <%= f.cfa_textarea :expenses_payment_details,
6 | "
If the #{applicant_or_client} claimed \"no income,\" explain how the expenses have been paid, or note that they are due or unpaid.
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | The more details you can provide, the more likely the #{applicant_or_client} can be approved without issues.
15 |
16 |
",
17 | options: {
18 | rows: "4",
19 | placeholder: "E.g., lives with brother - doesn’t pay rent. Gets PFD of $1600, monthly SSA payments of $500, monthly food box from food bank, relies on subsistence fishing and hunting.",
20 | } %>
21 | <% end %>
22 | <% end %>
23 |
--------------------------------------------------------------------------------
/spec/controllers/want_direct_deposit_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe WantDirectDepositController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller successful update", {
6 | want_direct_deposit: true,
7 | }
8 | it_behaves_like "yes no forms controller with boolean values"
9 |
10 | describe "#show?" do
11 | context "when applicant is applying for Alaska Temporary Assistance" do
12 | it "returns true" do
13 | application = create(:interview, :with_navigator, selected_atap: true)
14 |
15 | show = WantDirectDepositController.show?(application)
16 | expect(show).to eq(true)
17 | end
18 | end
19 |
20 | context "when applicant is applying for Adult Public Assistance" do
21 | it "returns true" do
22 | application = create(:interview, :with_navigator, selected_apa: true)
23 |
24 | show = WantDirectDepositController.show?(application)
25 | expect(show).to eq(true)
26 | end
27 | end
28 |
29 | context "when applicant is not applying for Adult Public Assistance or Alaska Temporary Assistance" do
30 | it "returns false" do
31 | application = create(:interview, selected_apa: false, selected_atap: false)
32 |
33 | skip_step = WantDirectDepositController.show?(application)
34 | expect(skip_step).to eq(false)
35 | end
36 | end
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/spec/support/shared_examples/forms_controller_base_behavior.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.shared_examples_for "form controller base behavior" do |is_last_section|
4 | context "with session" do
5 | let(:current_interview) { create(:interview, :with_navigator) }
6 |
7 | before do
8 | session[:current_interview_id] = current_interview.id
9 | end
10 |
11 | describe "#current_interview" do
12 | it "returns the Interview from the id in the session" do
13 | expect(controller.current_interview).to eq current_interview
14 | end
15 | end
16 |
17 | describe "#edit" do
18 | it "sets the form and renders the template" do
19 | get :edit
20 |
21 | expect(response).to render_template(:edit)
22 | expect(assigns[:form]).to be_a Form
23 | end
24 | end
25 |
26 | describe "#current_path" do
27 | it "returns the path for this route" do
28 | expect(controller.current_path).to eq "/screens/#{controller.class.to_param}"
29 | end
30 | end
31 |
32 | describe "#next_path" do
33 | it "returns the next path from this controller" do
34 | form_navigation = FormNavigation.new(controller)
35 |
36 | if is_last_section
37 | expect(controller.next_path).to eq "/"
38 | else
39 | expect(controller.next_path).to eq "/screens/#{form_navigation.next.to_param}"
40 | end
41 | end
42 | end
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/spec/forms/other_information_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe OtherInformationForm do
4 | describe "validations" do
5 | context "when other_info is provided" do
6 | it "is valid" do
7 | form = OtherInformationForm.new(
8 | nil,
9 | other_info: "best attribute",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when other_info is not provided" do
17 | it "is still valid" do
18 | form = OtherInformationForm.new(
19 | nil,
20 | other_info: nil,
21 | )
22 |
23 | expect(form).to be_valid
24 | end
25 | end
26 | end
27 |
28 | describe "#save" do
29 | let(:interview) { create :interview }
30 |
31 | let(:valid_params) do
32 | {
33 | other_info: "I'm hungry",
34 | }
35 | end
36 |
37 | it "persists the values to the correct models" do
38 | form = OtherInformationForm.new(interview, valid_params)
39 | form.valid?
40 | form.save
41 |
42 | interview.reload
43 |
44 | expect(interview.other_info).to eq "I'm hungry"
45 | end
46 | end
47 |
48 | describe ".from_interview" do
49 | it "assigns values from interview" do
50 | interview = create(:interview, other_info: "What up")
51 |
52 | form = OtherInformationForm.from_interview(interview)
53 |
54 | expect(form.other_info).to eq "What up"
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/spec/forms/cama_details_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe CamaDetailsForm do
4 | describe "validations" do
5 | context "when cama_details is provided" do
6 | it "is valid" do
7 | form = CamaDetailsForm.new(
8 | nil,
9 | cama_details: "best attribute",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when some_attribute is not provided" do
17 | it "is still valid" do
18 | form = CamaDetailsForm.new(
19 | nil,
20 | cama_details: nil,
21 | )
22 |
23 | expect(form).to be_valid
24 | end
25 | end
26 | end
27 |
28 | describe "#save" do
29 | let(:interview) { create :interview }
30 |
31 | let(:valid_params) do
32 | {
33 | cama_details: "Lots of medical problems to report.",
34 | }
35 | end
36 |
37 | it "persists the values to the correct models" do
38 | form = CamaDetailsForm.new(interview, valid_params)
39 | form.valid?
40 | form.save
41 |
42 | interview.reload
43 |
44 | expect(interview.cama_details).to eq "Lots of medical problems to report."
45 | end
46 | end
47 |
48 | describe ".from_interview" do
49 | it "assigns values from interview" do
50 | interview = create(:interview, cama_details: "SOMETHING")
51 |
52 | form = CamaDetailsForm.from_interview(interview)
53 |
54 | expect(form.cama_details).to eq "SOMETHING"
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory.
30 | #
31 | # preload_app!
32 |
33 | # Allow puma to be restarted by `rails restart` command.
34 | plugin :tmp_restart
35 |
--------------------------------------------------------------------------------
/app/views/any_not_listed/edit.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :card_title, "Is there anyone who is living in the home but is not listed on the #{application_or_renewal}?".html_safe %>
2 |
3 | <% content_for :card_help, "The context helps DPA in case there are other people in the home who need to be included." %>
4 |
5 | <% content_for :card_body do %>
6 |
If you live with them: you must include children under 22, spouses, and parents.
11 |
Roommates: Do not include roommates unless you buy and prepare more than half of your meals together.
12 |
60+/disabled: People who are 60+/disabled and live with others can choose to apply separately.
13 |
Immigrants: Any immigrant can choose to opt-out and will not be asked about their immigration status. They still need to be included on this application.
14 |
Separation/divorce: In cases of separation or divorce, only include the other person if they live with you. Include your children if they eat most of their meals with you. Children cannot be on multiple cases at once.
15 |
Pregnant mothers: Do not include unborn children on this application.
16 |
17 |
18 |
19 | <% end %>
20 |
--------------------------------------------------------------------------------
/lib/generators/screen/templates/form_model.template:
--------------------------------------------------------------------------------
1 | class <%= model.camelcase %>Form < Form
2 | <%- if options.doc? -%>
3 | # Whitelist top-level parameter names for Interview, e.g.
4 | #
5 | # given params: { form: { living_situation: "stable_housing" } }
6 | #
7 | # set_attributes_for :interview, :living_situation
8 | #
9 | # Delete the method if you aren't updating the Interview.
10 | <%- end -%>
11 | set_attributes_for :interview, :foo
12 |
13 | <%- if options.doc? -%>
14 | # Whitelist top-level parameter names for InterviewNavigator, e.g.
15 | #
16 | # given params: { form: { anyone_requesting_food: "yes" } }
17 | #
18 | # set_attributes_for :navigator, :anyone_requesting_food
19 | #
20 | # These attributes should be used for application flow, and not to fill out
21 | # the application PDF.
22 | #
23 | # Delete the method if you aren't updating the InterviewNavigator.
24 | <%- end -%>
25 | set_attributes_for :navigator, :street_address, :city, :zip_code
26 |
27 | <%- if options.doc? -%>
28 | # Add any validations below. Be sure to include helpful error messages.
29 | <%- end -%>
30 | validates_presence_of :street_address, message: "Please add your street address"
31 | validates_presence_of :city, message: "Please add the city you live in"
32 | validates :zip_code, length: { is: 5, message: "Please add a five digit ZIP code" }
33 |
34 | def save
35 | interview.update(attributes_for(:interview))
36 | interview.navigator.update(attributes_for(:navigator))
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/lib/generators/screen/anyone/templates/details/form_model_spec.template:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe <%= details_class_name %>Form do
4 | describe "validations" do
5 | context "when some_attribute is provided" do
6 | it "is valid" do
7 | form = <%= details_class_name %>Form.new(
8 | nil,
9 | some_attribute: "best attribute",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when some_attribute is not provided" do
17 | it "is invalid" do
18 | form = <%= details_class_name %>Form.new(
19 | nil,
20 | some_attribute: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:some_attribute]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | # some attributes
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = <%= details_class_name %>Form.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | # expectations
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, :with_navigator)
52 |
53 | form = <%= details_class_name %>Form.from_interview(interview)
54 |
55 | # expectation
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/spec/support/shared_examples/anyone_form.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.shared_examples_for "anyone form" do |method_name|
4 | describe "validations" do
5 | context "when #{method_name} is provided" do
6 | it "is valid" do
7 | form = described_class.new(
8 | nil,
9 | method_name => "yes",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when #{method_name} is not provided" do
17 | it "is invalid" do
18 | form = described_class.new(
19 | nil,
20 | method_name => "unfilled",
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[method_name.to_sym]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:valid_params) do
31 | {
32 | method_name => "yes",
33 | }
34 | end
35 |
36 | it "persists the values to the correct models" do
37 | interview = create(:interview)
38 | form = described_class.new(interview, valid_params)
39 | form.valid?
40 | form.save
41 |
42 | interview.reload
43 |
44 | expect(form.public_send(method_name)).to eq("yes")
45 | end
46 | end
47 |
48 | describe ".from_interview" do
49 | it "assigns values from interview" do
50 | interview = create(:interview, method_name => "no")
51 |
52 | form = described_class.from_interview(interview)
53 |
54 | expect(form.public_send(method_name)).to eq("no")
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/spec/forms/tribe_details_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe TribeDetailsForm do
4 | describe "validations" do
5 | context "when tribe_details is provided" do
6 | it "is valid" do
7 | form = TribeDetailsForm.new(
8 | nil,
9 | tribe_details: "best attribute",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when tribe_details is not provided" do
17 | it "is invalid" do
18 | form = TribeDetailsForm.new(
19 | nil,
20 | tribe_details: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:tribe_details]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | tribe_details: "WHATEVER THOUGH",
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = TribeDetailsForm.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | expect(interview.tribe_details).to eq "WHATEVER THOUGH"
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, tribe_details: "SOMETHING SOMETHING")
52 |
53 | form = TribeDetailsForm.from_interview(interview)
54 |
55 | expect(form.tribe_details).to eq "SOMETHING SOMETHING"
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/molecules/_show-more.scss:
--------------------------------------------------------------------------------
1 | // Original implementation (with specs):
2 | // https://github.com/codeforamerica/gcf-backend/commit/410a93ee58b69c88919a2a59d73a9320fc952004
3 |
4 | .show-more {
5 | text-align: left;
6 | margin-bottom: 3em;
7 | position: relative;
8 |
9 | &:after {
10 | content: '';
11 | display: block;
12 | position: absolute;
13 | bottom: 0em;
14 | left: 0;
15 | right: 0;
16 | background-image: linear-gradient(-180deg, rgba(255,255,255,0.00) 0%, #FFFFFF 75%);
17 | height: 7em;
18 | border-bottom: 2px solid #EAEAE9; // $color-light-grey
19 | }
20 |
21 | &.is-open {
22 | border-bottom: 0;
23 |
24 | &:after {
25 | display: none;
26 | }
27 | .show-more__content {
28 | max-height: none;
29 | }
30 | .show-more__button {
31 | display: none;
32 | }
33 | }
34 | }
35 |
36 | .show-more--long {
37 | .show-more__content {
38 | max-height: 30rem;
39 | }
40 | }
41 |
42 | .show-more__button {
43 | font-size: 1.6rem; // $font-size-small
44 | display: inline-block;
45 | padding: .2em .4em;
46 | border-radius: 30px;
47 | border: 2px solid #EAEAE9; // $color-light-grey
48 | text-decoration: none;
49 | position: absolute;
50 | bottom: -1.3em;
51 | left: 50%;
52 | z-index: 2;
53 | width: 8em;
54 | margin-left: -4em;
55 | text-align: center;
56 | background-color: #FFF;
57 | &:hover {
58 | background-color: #FAFAF9; // $color-background
59 | }
60 | }
61 |
62 | .show-more__content {
63 | max-height: 15rem;
64 | overflow: hidden;
65 | }
66 |
--------------------------------------------------------------------------------
/lib/generators/screen/templates/form_model_spec.template:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe <%= model.camelcase %>Form do
4 | describe "validations" do
5 | context "when some_attribute is provided" do
6 | it "is valid" do
7 | form = <%= "#{model.camelcase}Form".classify %>.new(
8 | nil,
9 | some_attribute: "best attribute",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when some_attribute is not provided" do
17 | it "is invalid" do
18 | form = <%= "#{model.camelcase}Form".classify %>.new(
19 | nil,
20 | some_attribute: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:some_attribute]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | # some attributes
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = <%= "#{model.camelcase}Form".classify %>.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | # expectations
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, :with_navigator)
52 |
53 | form = <%= "#{model.camelcase}Form".classify %>.from_interview(interview)
54 |
55 | # expectation
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/app/models/interview.rb:
--------------------------------------------------------------------------------
1 | class Interview < ApplicationRecord
2 | has_one :navigator,
3 | dependent: :destroy
4 |
5 | has_many_attached :id_verifications
6 |
7 | attr_encrypted :client_last_four_ssn, key: CredentialsHelper.secret_key_for_ssn_encryption
8 |
9 | enum any_not_listed: { unfilled: 0, yes: 1, no: 2 }, _prefix: :any_not_listed
10 | enum any_away_from_home: { unfilled: 0, yes: 1, no: 2 }, _prefix: :any_away_from_home
11 | enum anyone_convicted_drug_felony: { unfilled: 0, yes: 1, no: 2 }, _prefix: :anyone_convicted_drug_felony
12 | enum completed_probation_or_parole: { unfilled: 0, yes: 1, no: 2 }, _prefix: :completed_probation_or_parole
13 | enum completed_treatment_program: { unfilled: 0, yes: 1, no: 2 }, _prefix: :completed_treatment_program
14 | enum taken_action_towards_rehabilitation: { unfilled: 0, yes: 1, no: 2 },
15 | _prefix: :taken_action_towards_rehabilitation
16 | enum complied_with_reentry: { unfilled: 0, yes: 1, no: 2 }, _prefix: :complied_with_reentry
17 | enum anyone_tribe: { unfilled: 0, yes: 1, no: 2 }, _prefix: :anyone_tribe
18 | enum anyone_stopped_work: { unfilled: 0, yes: 1, no: 2 }, _prefix: :anyone_stopped_work
19 | enum has_quest_card: { unfilled: 0, yes: 1, no: 2 }, _prefix: :has_quest_card
20 | enum anyone_filing_tax_return: { unfilled: 0, yes: 1, no: 2 }, _prefix: :anyone_filing_tax_return
21 | # Generated enums added above
22 | enum approved_for_disability: { unfilled: 0, yes: 1, no: 2 }, _prefix: :approved_for_disability
23 | enum intend_to_stay: { unfilled: 0, yes: 1, no: 2 }, _prefix: :intend_to_stay
24 | end
25 |
--------------------------------------------------------------------------------
/spec/forms/rights_and_responsibilities_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe RightsAndResponsibilitiesForm do
4 | describe "validations" do
5 | context "when rights_and_responsibilities is provided" do
6 | it "is valid" do
7 | form = RightsAndResponsibilitiesForm.new(
8 | nil,
9 | explained_rights: "1",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when rights_and_responsibilities is false" do
17 | it "is invalid" do
18 | form = RightsAndResponsibilitiesForm.new(
19 | nil,
20 | explained_rights: "0",
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:explained_rights]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | explained_rights: "1",
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = RightsAndResponsibilitiesForm.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | expect(interview.explained_rights).to be(true)
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, :with_navigator)
52 |
53 | form = RightsAndResponsibilitiesForm.from_interview(interview)
54 |
55 | expect(form.explained_rights).to eq("0")
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/spec/forms/any_not_listed_names_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AnyNotListedNamesForm do
4 | describe "validations" do
5 | context "when any_not_listed_names is provided" do
6 | it "is valid" do
7 | form = AnyNotListedNamesForm.new(
8 | nil,
9 | any_not_listed_names: "yada yada",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when any_not_listed_names is not provided" do
17 | it "is invalid" do
18 | form = AnyNotListedNamesForm.new(
19 | nil,
20 | any_not_listed_names: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:any_not_listed_names]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | any_not_listed_names: "Sean Carter",
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = AnyNotListedNamesForm.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | expect(interview.any_not_listed_names).to eq "Sean Carter"
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, any_not_listed_names: "Beyonce Knowles")
52 |
53 | form = AnyNotListedNamesForm.from_interview(interview)
54 |
55 | expect(form.any_not_listed_names).to eq "Beyonce Knowles"
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/spec/forms/approved_for_disability_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe ApprovedForDisabilityForm do
4 | describe "validations" do
5 | context "when approved_for_disability is provided" do
6 | it "is valid" do
7 | form = ApprovedForDisabilityForm.new(
8 | nil,
9 | approved_for_disability: "yes",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when approved_for_disability is not provided" do
17 | it "is invalid" do
18 | form = ApprovedForDisabilityForm.new(
19 | nil,
20 | approved_for_disability: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:approved_for_disability]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | approved_for_disability: "yes",
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = ApprovedForDisabilityForm.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | expect(interview.approved_for_disability).to eq("yes")
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, approved_for_disability: "yes")
52 |
53 | form = ApprovedForDisabilityForm.from_interview(interview)
54 |
55 | expect(form.approved_for_disability).to eq("yes")
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/spec/forms/filing_tax_return_details_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe FilingTaxReturnDetailsForm do
4 | describe "validations" do
5 | context "when filing_tax_return_details is provided" do
6 | it "is valid" do
7 | form = FilingTaxReturnDetailsForm.new(
8 | nil,
9 | filing_tax_return_details: "a bunch of details",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when filing_tax_return_details is not provided" do
17 | it "is invalid" do
18 | form = FilingTaxReturnDetailsForm.new(
19 | nil,
20 | filing_tax_return_details: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:filing_tax_return_details]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | filing_tax_return_details: "YES YES YES",
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = FilingTaxReturnDetailsForm.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | expect(interview.filing_tax_return_details).to eq "YES YES YES"
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, filing_tax_return_details: "OKAY OKAY OKAY")
52 |
53 | form = FilingTaxReturnDetailsForm.from_interview(interview)
54 |
55 | expect(form.filing_tax_return_details).to eq "OKAY OKAY OKAY"
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/spec/forms/stopped_work_details_form_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe StoppedWorkDetailsForm do
4 | describe "validations" do
5 | context "when stopped_work_details is provided" do
6 | it "is valid" do
7 | form = StoppedWorkDetailsForm.new(
8 | nil,
9 | stopped_work_details: "Travelling circus act is closed for the winter.",
10 | )
11 |
12 | expect(form).to be_valid
13 | end
14 | end
15 |
16 | context "when stopped_work_details is not provided" do
17 | it "is invalid" do
18 | form = StoppedWorkDetailsForm.new(
19 | nil,
20 | stopped_work_details: nil,
21 | )
22 |
23 | expect(form).not_to be_valid
24 | expect(form.errors[:stopped_work_details]).to be_present
25 | end
26 | end
27 | end
28 |
29 | describe "#save" do
30 | let(:interview) { create :interview }
31 |
32 | let(:valid_params) do
33 | {
34 | stopped_work_details: "Laser tattoo removal only opened weekends now.",
35 | }
36 | end
37 |
38 | it "persists the values to the correct models" do
39 | form = StoppedWorkDetailsForm.new(interview, valid_params)
40 | form.valid?
41 | form.save
42 |
43 | interview.reload
44 |
45 | expect(interview.stopped_work_details).to eq "Laser tattoo removal only opened weekends now."
46 | end
47 | end
48 |
49 | describe ".from_interview" do
50 | it "assigns values from interview" do
51 | interview = create(:interview, stopped_work_details: "OKAY OKAY")
52 |
53 | form = StoppedWorkDetailsForm.from_interview(interview)
54 |
55 | expect(form.stopped_work_details).to eq "OKAY OKAY"
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/spec/controllers/add_id_verification_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe AddIdVerificationController do
4 | it_behaves_like "form controller base behavior"
5 | it_behaves_like "form controller always shows"
6 |
7 | describe "#update" do
8 | context "without interview" do
9 | it "redirects to homepage" do
10 | put :update, params: { form: {} }
11 |
12 | expect(response).to redirect_to(root_path)
13 | end
14 | end
15 |
16 | context "with interview" do
17 | let(:interview) do
18 | create(:interview, :with_navigator)
19 | end
20 |
21 | let(:active_storage_blob) do
22 | ActiveStorage::Blob.create_after_upload!(
23 | io: File.open(Rails.root.join("spec", "fixtures", "image.jpg")),
24 | filename: "image.jpg",
25 | content_type: "image/jpg",
26 | )
27 | end
28 |
29 | before do
30 | session[:current_interview_id] = interview.id
31 | end
32 |
33 | context "with documents" do
34 | let(:valid_params) do
35 | {
36 | documents: ["", active_storage_blob.signed_id],
37 | }
38 | end
39 |
40 | it "redirects to next path" do
41 | put :update, params: { form: valid_params }
42 |
43 | expect(response).to redirect_to(subject.next_path)
44 | end
45 | end
46 |
47 | context "without documents (ie: Safari)" do
48 | let(:valid_params) do
49 | {}
50 | end
51 |
52 | it "redirects to next path" do
53 | put :update, params: { form: valid_params }
54 |
55 | expect(response).to redirect_to(subject.next_path)
56 | end
57 | end
58 | end
59 | end
60 | end
61 |
--------------------------------------------------------------------------------