Skip to content

Commit

Permalink
Restore TimeEntry patch with test
Browse files Browse the repository at this point in the history
  • Loading branch information
jigarius committed May 21, 2024
1 parent a1f3b6c commit c54a2ca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
{ controller: 't2r_import', action: 'index' },
caption: 'Toggl'
end

# Patches.
require_relative 'lib/patches/time_entry'
end
34 changes: 34 additions & 0 deletions test/integration/models/toggl_mapping_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

require_relative '../../test_helper'

class TogglMappingTest < T2r::IntegrationTest
fixtures :all

def setup
@user = users(:jsmith)
end

test 'deleting time entry deletes relevant toggl mappings' do
time_entry = time_entries(:entry_001)

mapping_1 = TogglMapping.create(
toggl_id: 201,
time_entry_id: time_entry.id,
created_at: DateTime.strptime('2024-02-22T15:30:04+00:00')
)
mapping_2 = TogglMapping.create(
toggl_id: 202,
time_entry_id: time_entry.id,
created_at: DateTime.strptime('2024-02-22T15:30:04+00:00')
)

assert time_entry.toggl_mapping_ids.include? mapping_1.id
assert time_entry.toggl_mapping_ids.include? mapping_2.id

assert time_entry.destroy

refute TogglMapping.exists? mapping_1.id
refute TogglMapping.exists? mapping_2.id
end
end

0 comments on commit c54a2ca

Please sign in to comment.