Skip to content

Commit

Permalink
Singularize Activity Log retention period unit
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonkopliku committed Jun 24, 2024
1 parent e3db6a0 commit 3ad5d8f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/trento/activity_logging/retention_period_unit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ defmodule Trento.ActivityLog.RetentionPeriodUnit do
Type that represents the possible retention period units.
"""

use Trento.Support.Enum, values: [:days, :weeks, :months, :years]
use Trento.Support.Enum, values: [:day, :week, :month, :year]
end
2 changes: 1 addition & 1 deletion lib/trento/activity_logging/retention_time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Trento.ActivityLog.RetentionTime do
def default do
%RetentionTime{
value: 1,
unit: RetentionPeriodUnit.months()
unit: RetentionPeriodUnit.month()
}
end
end
14 changes: 7 additions & 7 deletions test/trento/activity_log_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule Trento.ActivityLogTest do
describe "changing activity log settings" do
test "should not be able to change retention time if no activity log settings were previously saved" do
assert {:error, :activity_log_settings_not_configured} ==
ActivityLog.change_retention_period(42, RetentionPeriodUnit.days())
ActivityLog.change_retention_period(42, RetentionPeriodUnit.day())
end

@validation_scenarios [
Expand Down Expand Up @@ -104,22 +104,22 @@ defmodule Trento.ActivityLogTest do
%{
name: "days",
value: 1,
unit: RetentionPeriodUnit.days()
unit: RetentionPeriodUnit.day()
},
%{
name: "weeks",
value: 3,
unit: RetentionPeriodUnit.weeks()
unit: RetentionPeriodUnit.week()
},
%{
name: "months",
value: 5,
unit: RetentionPeriodUnit.months()
unit: RetentionPeriodUnit.month()
},
%{
name: "years",
value: 7,
unit: RetentionPeriodUnit.years()
unit: RetentionPeriodUnit.year()
}
]

Expand All @@ -130,7 +130,7 @@ defmodule Trento.ActivityLogTest do
insert(:activity_log_settings,
retention_time: %{
value: 92,
unit: RetentionPeriodUnit.years()
unit: RetentionPeriodUnit.year()
}
)

Expand All @@ -155,7 +155,7 @@ defmodule Trento.ActivityLogTest do

test "should successfully handle unchanging retention periods" do
initial_retention_period = 42
initial_retention_period_unit = RetentionPeriodUnit.days()
initial_retention_period_unit = RetentionPeriodUnit.day()

insert(:activity_log_settings,
retention_time: %{
Expand Down
4 changes: 2 additions & 2 deletions test/trento/release_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ defmodule Trento.ReleaseTest do
assert %ActivityLogSettings{
retention_time: %RetentionTime{
value: 1,
unit: RetentionPeriodUnit.months()
unit: RetentionPeriodUnit.month()
}
} = Trento.Repo.one(ActivityLogSettings.base_query())
end

test "should not change previously saved retention time" do
value = 3
unit = RetentionPeriodUnit.weeks()
unit = RetentionPeriodUnit.week()

insert(:activity_log_settings,
retention_time: %{
Expand Down

0 comments on commit 3ad5d8f

Please sign in to comment.