Skip to content

Commit

Permalink
Fix a typo in the event’s occurred_at attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt committed Nov 30, 2023
1 parent e399459 commit 612c8cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/userlist/push/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def initialize(payload = {}, config = Userlist.config)
super
end

def occured_at
payload[:occured_at] || Time.now
def occurred_at
payload[:occurred_at] || payload[:occured_at] || Time.now
end

def push?
Expand Down
18 changes: 15 additions & 3 deletions spec/userlist/push/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
expect(subject.push?).to be_truthy
end

it 'should set the occured_at property' do
payload.delete(:occured_at)
it 'should set the occurred_at property' do
payload.delete(:occurred_at)
event = described_class.new(payload)

expect(event.occured_at).to be_an_instance_of(Time)
expect(event.occurred_at).to be_an_instance_of(Time)
end

context 'when a user hash is given' do
Expand Down Expand Up @@ -110,4 +110,16 @@
expect(subject.push?).to be_falsey
end
end

context 'when there is a legacy occured_at property' do
let(:payload) do
super().merge(occured_at: timestamp )
end

let(:timestamp) { Time.parse('2018-01-01T00:00:00Z') }

it 'should set the occurred_at property' do
expect(subject.occurred_at).to eq(timestamp)
end
end
end
4 changes: 2 additions & 2 deletions spec/userlist/push/serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
user: user,
company: company,
name: 'example_event',
occured_at: Time.now,
occurred_at: Time.now,
properties: {
null: nil,
empty: [],
Expand Down Expand Up @@ -223,7 +223,7 @@
it 'should return the correct payload' do
expect(payload).to eq(
name: 'example_event',
occured_at: event.occured_at,
occurred_at: event.occurred_at,
user: {
identifier: 'user-identifier',
email: '[email protected]',
Expand Down

0 comments on commit 612c8cb

Please sign in to comment.