Skip to content

Commit

Permalink
No use database for holidays storage
Browse files Browse the repository at this point in the history
  • Loading branch information
javierav committed Jan 22, 2024
1 parent 9221257 commit 56b7ba3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 104 deletions.
19 changes: 19 additions & 0 deletions app/lib/holiday.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Holiday
def self.all
@all ||= new.all
end

def all
(year2023 + year2024).map { |date| Date.parse(date) }
end

private

def year2023
%w[2023-01-06 2023-05-01 2023-08-15 2023-10-12 2023-11-01 2023-12-06 2023-12-08 2023-12-25]
end

def year2024
%w[2024-01-01 2024-01-06 2024-05-01 2024-08-15 2024-10-12 2024-11-01 2024-12-06 2024-12-25]
end
end
4 changes: 0 additions & 4 deletions app/models/holiday.rb

This file was deleted.

9 changes: 0 additions & 9 deletions db/migrate/20240106173348_create_holidays.rb

This file was deleted.

8 changes: 0 additions & 8 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 0 additions & 53 deletions test/fixtures/holidays.yml

This file was deleted.

15 changes: 15 additions & 0 deletions test/lib/holiday_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "test_helper"

class HolidayTest < ActiveSupport::TestCase
test "2022-11-22 is not holiday" do
assert_not Holiday.all.include?(Date.parse("2022-11-22"))
end

test "2023-01-06 is holiday" do
assert_includes Holiday.all, Date.parse("2023-01-06")
end

test "2024-01-01 is holiday" do
assert_includes Holiday.all, Date.parse("2024-01-01")
end
end
30 changes: 0 additions & 30 deletions test/models/holiday_test.rb

This file was deleted.

0 comments on commit 56b7ba3

Please sign in to comment.