docbrown/spec/models/timeframe_spec.rb
Mac Siri 842e6880b8
Routine rubocop fix on /spec (#19217)
* Softrun rubocop

* Hardrun rubocop (-A)

* Change a rubocop rule

* Add missing cops

* Undo & redo rubocop -A
2023-03-21 09:55:26 -04:00

31 lines
837 B
Ruby

require "rails_helper"
RSpec.describe Timeframe do
it "sets timeframe for week to 1 week ago" do
Timecop.freeze(Time.current) do
timeframe = described_class.datetime("week")
expect(timeframe).to eq(1.week.ago)
end
end
it "sets timeframe for month to 1 month ago" do
Timecop.freeze(Time.current) do
timeframe = described_class.datetime("month")
expect(timeframe).to eq(1.month.ago)
end
end
it "sets timeframe for year to 1 year ago" do
Timecop.freeze(Time.current) do
timeframe = described_class.datetime("year")
expect(timeframe).to eq(1.year.ago)
end
end
it "sets timeframe for infinity to 5 years ago" do
Timecop.freeze(Time.current) do
timeframe = described_class.datetime("infinity")
expect(timeframe).to eq(5.years.ago)
end
end
end