spec/jobs/ping_job_spec.rb in rhosync-2.1.2 vs spec/jobs/ping_job_spec.rb in rhosync-2.1.3

- old
+ new

@@ -39,7 +39,22 @@ @c.device_type = 'blackberry' @c.device_pin = nil PingJob.should_receive(:log).once.with("Skipping ping for non-registered client_id '#{@c.id}'...") lambda { PingJob.perform(params) }.should_not raise_error end + + it "should drop ping if it's already in user's device pin list" do + params = {"user_id" => @u.id, "api_token" => @api_token, + "sources" => [@s.name], "message" => 'hello world', + "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'} + + # another client with the same device pin ... + @c1 = Client.create(@c_fields,{:source_name => @s_fields[:name]}) + # and yet another one ... + @c2 = Client.create(@c_fields,{:source_name => @s_fields[:name]}) + + Apple.should_receive(:ping).with({'device_pin' => @c.device_pin, 'device_port' => @c.device_port}.merge!(params)) + PingJob.should_receive(:log).twice.with(/Dropping ping request for client/) + lambda { PingJob.perform(params) }.should_not raise_error + end end \ No newline at end of file