Browse Source

fixes based on review

pull/661/head
Dushan Despotovic 3 years ago
parent
commit
120b7dde9a
  1. 2
      app/components/primary_navigation_component.rb
  2. 6
      app/models/case_log.rb
  3. 2
      config/forms/2021_2022.json
  4. 2
      config/forms/2022_2023.json
  5. 8
      config/initializers/feature_toggle.rb
  6. 10
      spec/models/case_log_spec.rb

2
app/components/primary_navigation_component.rb

@ -3,7 +3,7 @@ class PrimaryNavigationComponent < ViewComponent::Base
def initialize(items:)
@items = items
FeatureToggle.show_schemes_button? ? @items = @items.reject { |nav_item| nav_item.text.include?("Supported housing") } : @items
FeatureToggle.supported_housing_schemes_enabled? ? @items : @items.reject! { |nav_item| nav_item.text.include?("Supported housing") }
super
end

6
app/models/case_log.rb

@ -112,8 +112,8 @@ class CaseLog < ApplicationRecord
status == "in_progress"
end
def needs_question_enabled?
FeatureToggle.needs_question_enabled?
def supported_housing_schemes_enabled?
FeatureToggle.supported_housing_schemes_enabled?
end
def weekly_net_income
@ -524,7 +524,7 @@ private
def set_derived_fields!
# TODO: Remove once we support supported housing logs
self.needstype = 1 unless needs_question_enabled?
self.needstype = 1 unless FeatureToggle.supported_housing_schemes_enabled?
if rsnvac.present?
self.newprop = has_first_let_vacancy_reason? ? 1 : 2
end

2
config/forms/2021_2022.json

@ -30,7 +30,7 @@
},
"depends_on": [
{
"needs_question_enabled?" : true
"supported_housing_schemes_enabled?" : true
}
]
},

2
config/forms/2022_2023.json

@ -30,7 +30,7 @@
},
"depends_on": [
{
"needs_question_enabled?" : true
"supported_housing_schemes_enabled?" : true
}
]
},

8
config/initializers/feature_toggle.rb

@ -1,9 +1,7 @@
class FeatureToggle
def self.needs_question_enabled?
!Rails.env.production?
end
def self.supported_housing_schemes_enabled?
return true unless Rails.env.production?
def self.show_schemes_button?
Rails.env.production?
false
end
end

10
spec/models/case_log_spec.rb

@ -2105,10 +2105,10 @@ RSpec.describe CaseLog do
end
end
describe "needs_question_enabled?" do
it "returns false for the case log if the environment is not production" do
describe "supported_housing_schemes_enabled?" do
it "returns true for the case log if the environment is not production" do
case_log = FactoryBot.create(:case_log)
expect(case_log.needs_question_enabled?).to eq(false)
expect(case_log.supported_housing_schemes_enabled?).to eq(true)
end
context "when in the production environment" do
@ -2116,9 +2116,9 @@ RSpec.describe CaseLog do
allow(Rails.env).to receive(:production?).and_return(true)
end
it "returns true for a case log" do
it "returns false for a case log" do
case_log = FactoryBot.create(:case_log)
expect(case_log.needs_question_enabled?).to eq(true)
expect(case_log.supported_housing_schemes_enabled?).to eq(false)
end
end
end

Loading…
Cancel
Save