<commit_before>require 'spec_helper'

describe NotifyUser::Apns do
  let(:user) { User.create({email: '<EMAIL>' })}
  let(:notification) { NewPostNotification.create({target: user}) }

  before :each do
    allow_any_instance_of(NotifyUser::BaseNotification).to receive(:mobile_message).and_return('New Notification')
    allow_any_instance_of(NotifyUser::Gcm).to receive(:device_tokens).and_return('a_token')
  end

  describe "initialisation" do
    it "should initialise the correct push options" do
      @apns = NotifyUser::Apns.new([notification], [], {})

      expect(@apns.push_options[:alert]).to eq 'New Notification'
      expect(@apns.push_options[:badge]).to eq 1
      expect(@apns.push_options[:category]).to eq 'NewPostNotification'
      expect(@apns.push_options[:custom_data]).to be_empty
      expect(@apns.push_options[:sound]).to eq 'default'
    end

    it 'should access the notification targets list of devices' do
      expect(user).to receive(:devices)

      @apns = NotifyUser::Apns.new([notification], [], {})
    end

    it 'should use the sound specified in the options' do
      @apns = NotifyUser::Apns.new([notification], [], { sound: 'special.wav' })

      expect(@apns.push_options[:sound]).to eq 'special.wav'
    end

    it 'should remove the badge key for silent notifications' do<commit_msg>Removes the spec for fetching devices within the push notification class itself.<commit_after>require 'spec_helper'

describe NotifyUser::Apns do
  let(:user) { User.create({email: '<EMAIL>' })}
  let(:notification) { NewPostNotification.create({target: user}) }

  before :each do
    allow_any_instance_of(NotifyUser::BaseNotification).to receive(:mobile_message).and_return('New Notification')
    allow_any_instance_of(NotifyUser::Gcm).to receive(:device_tokens).and_return('a_token')
  end

  describe "initialisation" do
    it "should initialise the correct push options" do
      @apns = NotifyUser::Apns.new([notification], [], {})

      expect(@apns.push_options[:alert]).to eq 'New Notification'
      expect(@apns.push_options[:badge]).to eq 1
      expect(@apns.push_options[:category]).to eq 'NewPostNotification'
      expect(@apns.push_options[:custom_data]).to be_empty
      expect(@apns.push_options[:sound]).to eq 'default'
    end

    it 'should use the sound specified in the options' do
      @apns = NotifyUser::Apns.new([notification], [], { sound: 'special.wav' })

      expect(@apns.push_options[:sound]).to eq 'special.wav'
    end

    it 'should remove the badge key for silent notifications' do
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.0007797270955165692, 'mean_word_length': 4.59041394335512, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2960541', 'n_tokens_mistral': 781, 'n_tokens_neox': 757, 'n_words': 179}