Add PushNotification#to
This commit is contained in:
@ -3,4 +3,8 @@ class PushNotification < ActiveRecord::Base
|
||||
belongs_to :device_token, foreign_key: 'device_token_id'
|
||||
|
||||
validates :event, :device_token, presence: true
|
||||
|
||||
def to
|
||||
device_token.token
|
||||
end
|
||||
end
|
||||
|
||||
@ -13,4 +13,13 @@ RSpec.describe PushNotification do
|
||||
it { is_expected.to have_db_column(:event_id) }
|
||||
it { is_expected.to have_db_column(:device_token_id) }
|
||||
end
|
||||
|
||||
describe "#to" do
|
||||
let(:device_token) { Fabricate.build(:device_token, token: 'token') }
|
||||
let(:push_notification) { described_class.new(device_token: device_token) }
|
||||
|
||||
it 'returns the associated DeviceToken\'s token' do
|
||||
expect(push_notification.to).to eq('token')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user