Skip to content

Commit

Permalink
Merge pull request rubyonjets#519 from choilive/support-time-zone-config
Browse files Browse the repository at this point in the history
Add config for Time.zone
  • Loading branch information
tongueroo authored Dec 4, 2020
2 parents 48c2baa + f24bc87 commit 928a240
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/jets/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def configs!
load_environments_config
load_db_config
set_iam_policy # relies on dependent values, must be called afterwards
set_time_zone
normalize_env_vars!
end

Expand Down Expand Up @@ -179,6 +180,10 @@ def set_iam_policy
config.managed_policy_definitions ||= [] # default empty
end

def set_time_zone
Time.zone_default = Time.find_zone!(config.time_zone)
end

# It is pretty easy to attempt to set environment variables without
# the correct AWS Environment.Variables path struture.
# Auto-fix it for convenience.
Expand Down
1 change: 1 addition & 0 deletions lib/jets/application/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def default_config
config.autoload_paths = [] # allows for customization
config.ignore_paths = [] # allows for customization
config.logger = Jets::Logger.new($stderr)
config.time_zone = "UTC"

# function properties defaults
config.function = ActiveSupport::OrderedOptions.new
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/jets/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
expect(config.function.memory_size).to eq 1536
end

it "should have a default time zone defined" do
expect(config.time_zone).to eq "UTC"
expect(Time.zone).to eq Time.find_zone!("UTC")
end

it "routes should be loaded" do
router = app.routes
expect(router).to be_a(Jets::Router)
Expand Down

0 comments on commit 928a240

Please sign in to comment.