Browse Source

Add incref column (#87)

* Add incref column

* Rubocop

* update migration version
pull/88/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
7942dec5c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/models/case_log.rb
  2. 8
      db/migrate/20211112105348_add_incref_field.rb
  3. 3
      db/schema.rb
  4. 8
      spec/controllers/case_logs_controller_spec.rb

14
app/models/case_log.rb

@ -164,9 +164,7 @@ class CaseLog < ApplicationRecord
end end
def hhmemb def hhmemb
if other_hhmemb.present? other_hhmemb.presence
other_hhmemb
end
end end
def applicable_income_range def applicable_income_range
@ -193,7 +191,11 @@ class CaseLog < ApplicationRecord
end end
end end
def incref
if net_income_known == "Prefer not to say"
1
end
end
private private
@ -253,6 +255,10 @@ private
dynamically_not_required << "ecstat#{n}" dynamically_not_required << "ecstat#{n}"
end end
if net_income_known != "Prefer not to say"
dynamically_not_required << "incref"
end
required.delete_if { |key, _value| dynamically_not_required.include?(key) } required.delete_if { |key, _value| dynamically_not_required.include?(key) }
end end
end end

8
db/migrate/20211112105348_add_incref_field.rb

@ -0,0 +1,8 @@
class AddIncrefField < ActiveRecord::Migration[6.1]
def change
change_table :case_logs, bulk: true do |t|
t.column :incref, :integer
end
end
end

3
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_11_11_143319) do ActiveRecord::Schema.define(version: 2021_11_12_105348) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -153,6 +153,7 @@ ActiveRecord::Schema.define(version: 2021_11_11_143319) do
t.integer "mrcmonth" t.integer "mrcmonth"
t.integer "mrcyear" t.integer "mrcyear"
t.integer "other_hhmemb" t.integer "other_hhmemb"
t.integer "incref"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end end

8
spec/controllers/case_logs_controller_spec.rb

@ -181,10 +181,10 @@ RSpec.describe CaseLogsController, type: :controller do
context "partition date" do context "partition date" do
let(:case_log_with_date) do let(:case_log_with_date) do
{ {
:"mrcdate(1i)" => "2021", "mrcdate(1i)": "2021",
:"mrcdate(2i)" => "05", "mrcdate(2i)": "05",
:"mrcdate(3i)" => "04", "mrcdate(3i)": "04",
:page => "major_repairs_date", page: "major_repairs_date",
} }
end end
it "saves full and partial dates" do it "saves full and partial dates" do

Loading…
Cancel
Save