Skip to content

Commit

Permalink
persist time zone for user
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Dec 5, 2024
1 parent 5722697 commit 5a35543
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def set_attributes(_attributes)

set_default_attributes(params) if model.new_record?

# move the timezone from the user
model.change_by_system do
model.time_zone = model.user.time_zone.name
end

# Always set the logging user as logged_by
set_logged_by
end

Check notice on line 51 in modules/costs/app/services/time_entries/set_attributes_service.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/costs/app/services/time_entries/set_attributes_service.rb#L33-L51 <Metrics/AbcSize>

Assignment Branch Condition size for set_attributes is too high. [<3, 22, 3> 22.41/17]
Raw output
modules/costs/app/services/time_entries/set_attributes_service.rb:33:5: C: Metrics/AbcSize: Assignment Branch Condition size for set_attributes is too high. [<3, 22, 3> 22.41/17]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@
end
end

context "with a user with a defined timezone" do
it "extracts the current timezone from the user and stores it in the time entry" do
user.pref[:time_zone] = "America/Los_Angeles"
subject

expect(time_entry_instance.time_zone).to eq "America/Los_Angeles"
end
end

context "with hours == 0" do
let(:params) do
{
Expand Down

0 comments on commit 5a35543

Please sign in to comment.