-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default activity log retention time at app startup and seeds
- Loading branch information
1 parent
b193a82
commit 4835dd2
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule Trento.ReleaseTest do | ||
@moduledoc false | ||
use ExUnit.Case | ||
use Trento.DataCase | ||
|
||
import Trento.Factory | ||
|
||
require Trento.ActivityLog.RetentionPeriodUnit, as: RetentionPeriodUnit | ||
|
||
alias Trento.ActivityLog.RetentionTime | ||
alias Trento.ActivityLog.Settings, as: ActivityLogSettings | ||
|
||
describe "Activity Log settings initiation" do | ||
test "should init default activity log retention time" do | ||
Trento.Release.init_default_activity_log_retention_time() | ||
|
||
assert %ActivityLogSettings{ | ||
retention_time: %RetentionTime{ | ||
retention_period: 1, | ||
retention_period_unit: RetentionPeriodUnit.months() | ||
} | ||
} = Trento.Repo.one(ActivityLogSettings.base_query()) | ||
end | ||
|
||
test "should not change previously saved retention time" do | ||
retention_period = 3 | ||
retention_period_unit = RetentionPeriodUnit.weeks() | ||
|
||
insert(:activity_log_settings, | ||
retention_time: %{ | ||
retention_period: retention_period, | ||
retention_period_unit: retention_period_unit | ||
} | ||
) | ||
|
||
Trento.Release.init_default_activity_log_retention_time() | ||
|
||
assert %ActivityLogSettings{ | ||
retention_time: %RetentionTime{ | ||
retention_period: ^retention_period, | ||
retention_period_unit: ^retention_period_unit | ||
} | ||
} = Trento.Repo.one(ActivityLogSettings.base_query()) | ||
end | ||
end | ||
end |