Skip to content

Commit 1eb0b08

Browse files
committed
Allow specifying companies in messages
1 parent 0733c44 commit 1eb0b08

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/userlist/push/message.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Message < Resource
44
include Operations::Push
55

66
has_one :user, type: 'Userlist::Push::User'
7+
has_one :company, type: 'Userlist::Push::Company'
78

89
def initialize(payload = {}, config = Userlist.config)
910
raise Userlist::ArgumentError, 'Missing required payload' unless payload

spec/userlist/push/message_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{
66
template: 'template-identifier',
77
user: 'user-identifier',
8+
company: 'company-identifier',
89
properties: {
910
value: '$100.00'
1011
}
@@ -39,4 +40,23 @@
3940
expect(subject.push?).to be_truthy
4041
end
4142
end
43+
44+
context 'when a company hash is given' do
45+
let(:payload) do
46+
super().merge(
47+
company: {
48+
identifier: 'company-identifier',
49+
name: 'Example Company'
50+
}
51+
)
52+
end
53+
54+
it 'should convert it into a company object' do
55+
expect(subject.company).to be_kind_of(Userlist::Push::Company)
56+
end
57+
58+
it 'should be pushable' do
59+
expect(subject.push?).to be_truthy
60+
end
61+
end
4262
end

0 commit comments

Comments
 (0)