spec/grocer_spec.rb in notifiable-apns-grocer-0.4.0 vs spec/grocer_spec.rb in notifiable-apns-grocer-0.5.0

- old
+ new

@@ -1,48 +1,52 @@ require 'spec_helper' describe Notifiable::Apns::Grocer::Stream do - + + let(:a) { Notifiable::App.create } let(:g) { Notifiable::Apns::Grocer::Stream.new } - let(:n) { Notifiable::Notification.create(:message => "Test message") } - let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :apns) } + let(:n) { Notifiable::Notification.create(:message => "Test message", :app => a) } + let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :apns, :app => a) } let(:u) { User.new(d) } it "sends a single grocer notification" do g.env = "test" g.send_notification(n, d) Timeout.timeout(2) { notification = @grocer.notifications.pop notification.alert.should eql "Test message" + notification.custom[:notification_id].should == n.id } end it "sends a single grocer notification in a batch" do - Notifiable.batch do |b| - b.add(n, u) + Notifiable.batch(a) do |b| + b.add_notifiable(n, u) end Notifiable::NotificationStatus.count.should == 1 Notifiable::NotificationStatus.first.status.should == 0 Timeout.timeout(2) { notification = @grocer.notifications.pop notification.alert.should eql "Test message" + notification.custom[:notification_id].should == n.id } end it "supports custom properties" do n.params = {:flag => true} - Notifiable.batch do |b| - b.add(n, u) + Notifiable.batch(a) do |b| + b.add_notifiable(n, u) end Notifiable::NotificationStatus.count.should == 1 Notifiable::NotificationStatus.first.status.should == 0 Timeout.timeout(2) { notification = @grocer.notifications.pop + notification.custom[:notification_id].should == n.id notification.custom[:flag].should == true } end end \ No newline at end of file