Skip to content

Commit bdc37fb

Browse files
committed
Updating to use time_ago_in_words method to make this a little cleaner to read
1 parent 6704d85 commit bdc37fb

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

app/services/cms/models/collections/email_template.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ def merge_content(text, user)
4949
achievements = user.sorted_completed_cpd_achievements_by(programme: @programme)
5050
if achievements.any?
5151
achievement = achievements.last
52-
last_cpd_completed_ago = distance_of_time_in_words(achievement.updated_at, DateTime.now)
5352

5453
merges += [
55-
["{last_cpd_completed_ago}", last_cpd_completed_ago],
54+
["{last_cpd_completed_ago}", time_ago_in_words(achievement.updated_at)],
5655
["{last_cpd_completed_year}", "in #{achievement.updated_at.year}"],
5756
["{last_cpd_title}", achievement.activity.title]
5857
]

spec/services/cms/models/collections/email_template_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
travel_back
9393
end
9494

95-
it "should replace achievement placeholders using distance_of_time_in_words" do
95+
it "should replace achievement placeholders using time_ago_in_words" do
9696
content = @model.process_blocks(text_content, user)
9797
text = content.dig(2, :children, 0, :text)
9898
expect(text).to eq("You completed Past activity about 1 month ago.")

0 commit comments

Comments
 (0)