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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions app/controllers/state_file/faq_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ class StateFile::FaqController < ApplicationController
layout "state_file"

def index
years_to_show = filing_years_to_show # calculate once per request
visible_state_code_names = StateFile::StateInformationService.state_code_to_name_map
.filter { |state_code, _| (years_to_show - StateFile::StateInformationService.filing_years(state_code)).empty? }
.transform_values { |state_name| { state_name: } }
visible_state_code_names.slice!(params[:us_state]) unless params[:us_state] == "us"
product_types = visible_state_code_names.keys.map do |code|
Expand All @@ -20,10 +18,6 @@ def index
end

def show
if params[:us_state] == 'ny'
redirect_to state_landing_page_path(us_state: "ny")
return
end
@section_key = params[:section_key]
@faq_category = FaqCategory.find_by(slug: @section_key, product_type: FaqCategory.state_to_product_type(params[:us_state]))

Expand All @@ -32,6 +26,7 @@ def show

private

# @deprecated FYST is retired now, show all categories all the time!
def filing_years_to_show
faq_show_start = Rails.configuration.state_file_show_faq_date_start
faq_show_end = Rails.configuration.state_file_show_faq_date_end
Expand All @@ -48,12 +43,10 @@ def filing_years_to_show
# show states that were open this year and will open next year
[tax_year, tax_year + 1]
end
elsif app_time > faq_show_end
[tax_year + 1]
else
if app_time > faq_show_end
[tax_year + 1]
else
[tax_year]
end
[tax_year]
end
end
end
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Application < Rails::Application
config.state_file_end_of_new_intakes = et.parse('2025-10-22 23:59:59')
config.state_file_end_of_in_progress_intakes = et.parse('2025-10-31 23:59:59')
config.state_file_show_faq_date_start = pt.parse('2024-12-10 00:00:00')
config.state_file_show_faq_date_end = pt.parse('2025-11-18 23:59:59')
config.state_file_show_faq_date_end = pt.parse('2025-11-15 23:59:59')

config.allow_magic_verification_code = (Rails.env.demo? || Rails.env.development? || Rails.env.heroku? || Rails.env.staging?)
config.allow_magic_ssn = (Rails.env.demo? || Rails.env.development? || Rails.env.heroku? || Rails.env.staging?)
Expand Down
141 changes: 1 addition & 140 deletions spec/controllers/state_file/faq_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,135 +15,6 @@

expect(response).to be_ok
end

context "showing the right states" do
let(:last_year_state_name) { "state that was open last year but not this year" }
let(:continuing_state_name) { "state that was open last year and open this year" }
let(:new_this_year_state_name) { "new state that will open this year" }
let(:new_next_year_state_name) { "new state that will open next year" }
before do
allow(StateFile::StateInformationService).to receive(:filing_years).with(:last_year_state).and_return([tax_year - 1])
allow(StateFile::StateInformationService).to receive(:filing_years).with(:continuing_state).and_return([tax_year + 1, tax_year, tax_year - 1])
allow(StateFile::StateInformationService).to receive(:filing_years).with(:new_this_year_state).and_return([tax_year, tax_year + 1])
allow(StateFile::StateInformationService).to receive(:filing_years).with(:new_next_year_state).and_return([tax_year + 1])

allow(StateFile::StateInformationService).to receive(:state_code_to_name_map).and_return(
{
last_year_state: last_year_state_name,
continuing_state: continuing_state_name,
new_this_year_state: new_this_year_state_name,
new_next_year_state: new_next_year_state_name,
}
)
end

context "when FYST has not opened yet for the year" do
around do |example|
Timecop.freeze(Rails.configuration.state_file_show_faq_date_start - 1.hour) do
example.run
end
end

context "in production" do
before do
allow(Rails).to receive(:env).and_return("production".inquiry)
end

it "shows only states that were open before and will reopen" do
get :index, params: { us_state: "us" }

expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: last_year_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: continuing_state_name)
expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: new_this_year_state_name)
expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: new_next_year_state_name)
end
end

context "in any other environment" do
["demo", "heroku", "development"].each do |environment|
before do
allow(Rails).to receive(:env).and_return(environment.inquiry)
end

it "shows states that will open this season" do
get :index, params: { us_state: "us" }

expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: last_year_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: continuing_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: new_this_year_state_name)
expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: new_next_year_state_name)
end
end
end
end

context "when FYST is either open or has closed for the year" do
context "open" do
around do |example|
Timecop.freeze(Rails.configuration.state_file_show_faq_date_end - 1.day) do
example.run
end
end

context "in any environment" do
["production", "demo", "heroku", "development"].each do |environment|
before do
allow(Rails).to receive(:env).and_return(environment.inquiry)
end

it "shows states that are currently open" do
get :index, params: { us_state: "us" }

expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: last_year_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: continuing_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: new_this_year_state_name)
expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: new_next_year_state_name)
end
end
end
end

context "after close" do
around do |example|
Timecop.freeze(Rails.configuration.state_file_end_of_in_progress_intakes + 1.day) do
example.run
end
end

context "in production" do
before do
allow(Rails).to receive(:env).and_return("production".inquiry)
end

it "shows only states that were open before and will reopen" do
get :index, params: { us_state: "us" }

expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: last_year_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: continuing_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: new_this_year_state_name)
expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: new_next_year_state_name)
end
end

context "in any other environment" do
["demo", "heroku", "development"].each do |environment|
before do
allow(Rails).to receive(:env).and_return(environment.inquiry)
end

it "shows states that will open next season" do
get :index, params: { us_state: "us" }

expect(response.body).not_to have_text I18n.t("state_file.faq.index.title", state: last_year_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: continuing_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: new_this_year_state_name)
expect(response.body).to have_text I18n.t("state_file.faq.index.title", state: new_next_year_state_name)
end
end
end
end
end
end
end

describe "#show" do
Expand All @@ -155,15 +26,5 @@

expect(response.body).to have_text faq_category.description_en
end

context "for new york" do
let!(:faq_category) { create :faq_category, slug: section_key, product_type: "state_file_ny" }

it "redirects to the ny landing page" do
get :show, params: { section_key: section_key, us_state: "ny" }

expect(response).to redirect_to state_landing_page_path(us_state: "ny")
end
end
end
end
end
Loading