rpush/rpush — pull request #60 by jmnsf (2014-08-08 17:03:43+00:00)
Title: Improves notif validation to work better with ActiveRecord.

Validating Notifications against app_id prevents the App (if it exists) to be saved before the validation occurs. An example:

pry(main)> notif = Rpush::Client::ActiveRecord::Notification.new
pry(main)> notif.app = Rpush::Client::ActiveRecord::App.new(name: "wut")
pry(main)> notif.app.tap(&:valid?).errors
=> @messages={} # valid
pry(main)> notif.valid?
=> false
pry(main)> notif.errors
=> @messages={:app_id=>["can't be blank"]}

This forces us to save the App before the Notification. So, **why is this important?** Mostly for testing. When we're testing notifications we just do a FactoryGirl.create(:rpush_apns_notif) and expect the associations to do the rest. The way it is, we are required to include extra code for saving the App as well.