<commit_before>require 'spec_helper'

ActiveRecord::Migration.verbose = false
ActiveRecord::Base.logger = Logger.new(nil)
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')

ActiveRecord::Base.connection.instance_eval do
  create_table :notifs do |t|
    t.references :target, polymorphic: true, index: true
    t.belongs_to :user, index: true
    t.boolean :unread, index: true, default: true
    t.string :type
    t.timestamps null: false
  end
end

describe UserNotif::Notif do
  it 'raises an exception with an invalid target' do
    expect { UserNotif::Notif.new(target: nil) }.to raise_error ModelExceptions::BadTypeNotification
  end
end<commit_msg>[C] Notif spec<commit_after>require 'spec_helper'

ActiveRecord::Migration.verbose = false
ActiveRecord::Base.logger = Logger.new(nil)
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')

ActiveRecord::Base.connection.instance_eval do
  create_table :notifs do |t|
    t.references :target, polymorphic: true, index: true
    t.belongs_to :user, index: true
    t.boolean :unread, index: true, default: true
    t.string :type
    t.timestamps null: false
  end
end

describe UserNotif::Notif do
  let(:notif) { UserNotif::Notif.new }

  it 'raises an exception with an invalid target' do
    expect { UserNotif::Notif.new(target: nil) }.to raise_error ModelExceptions::BadTypeNotification
  end

  describe '#email?' do
    it 'returns true' do
      expect(notif.email?).to eq true
    end
  end

  describe '#email_template' do
    it 'returns generic_notif' do
      expect(notif.email_template).to eq 'generic_notif'
    end
  end

  describe '#subject_email' do
    it 'returns subject_email' do
      expect(notif.subject_email).to eq I18n.t('notif.generic.subject')
    end
  end
end
{'fraction_non_alphanumeric': 0.10613598673300166, 'fraction_numerical': 0.002211166390270868, 'mean_word_length': 4.468277945619335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6175376', 'n_tokens_mistral': 596, 'n_tokens_neox': 578, 'n_words': 157}