|
|
|
|
@ -76,4 +76,52 @@ RSpec.describe QuestionViewHelper do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#example_date_in_tax_year_of" do |
|
|
|
|
subject(:result) { example_date_in_tax_year_of(input) } |
|
|
|
|
|
|
|
|
|
context "when called with nil" do |
|
|
|
|
let(:input) { nil } |
|
|
|
|
|
|
|
|
|
it "returns the current date" do |
|
|
|
|
expect(result).to eq(Time.zone.today) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when called with a date after April" do |
|
|
|
|
calendar_year = 2030 |
|
|
|
|
let(:input) { Date.new(calendar_year, 7, 7) } |
|
|
|
|
|
|
|
|
|
it "returns the first of September from that year" do |
|
|
|
|
expect(result).to eq(Date.new(calendar_year, 9, 1)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when called with a date before April" do |
|
|
|
|
calendar_year = 2040 |
|
|
|
|
let(:input) { Date.new(calendar_year, 2, 7) } |
|
|
|
|
|
|
|
|
|
it "returns the first of September from the previous year" do |
|
|
|
|
expect(result).to eq(Date.new(calendar_year - 1, 9, 1)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when called with a date in April after the fifth" do |
|
|
|
|
calendar_year = 2050 |
|
|
|
|
let(:input) { Date.new(calendar_year, 4, 7) } |
|
|
|
|
|
|
|
|
|
it "returns the first of September from that year" do |
|
|
|
|
expect(result).to eq(Date.new(calendar_year, 9, 1)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when called with a date in April before the sixth" do |
|
|
|
|
calendar_year = 2060 |
|
|
|
|
let(:input) { Date.new(calendar_year, 4, 4) } |
|
|
|
|
|
|
|
|
|
it "returns the first of September from the previous year" do |
|
|
|
|
expect(result).to eq(Date.new(calendar_year - 1, 9, 1)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|