<commit_before>require File.dirname(__FILE__) + '/../test_helper'
require 'account_controller'
require 'exception_notification.rb'
ActionController::Base.send :include, ExceptionNotifiable
ExceptionNotifier.exception_recipients = ['<EMAIL>', '<EMAIL>']

class ExceptionNotificationTest < ActionController::IntegrationTest
  def setup
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []
    AccountController.any_instance.stubs(:signup).raises(RuntimeError)
    AccountController.any_instance.stubs(:local_request?).returns(false)
    AccountController.any_instance.stubs(:consider_all_requests_local).returns(false)
  end

  should 'deliver mail notification about exceptions' do
    assert_difference ActionMailer::Base.deliveries, :size do
      get '/account/signup'
    end
  end

  should 'deliver mails to addresses listed in Noosfero configuration noosfero.yml' do
    get '/account/signup'
    assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, '<EMAIL>'
    assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, '<EMAIL>'
  end

  should 'render not found when try to access invalid url' do
    get '/profile/ze/tag/notexists'
    assert_template 'not_found.rhtml'
  end<commit_msg>Fixed 1 exception_notification integration test that was failing<commit_after>require File.dirname(__FILE__) + '/../test_helper'
require 'account_controller'
require 'exception_notification.rb'
ActionController::Base.send :include, ExceptionNotifiable
ExceptionNotifier.exception_recipients = ['<EMAIL>', '<EMAIL>']

class ExceptionNotificationTest < ActionController::IntegrationTest
  def setup
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []
    [ProfileController, AccountController].each{|klass| klass.any_instance.stubs(:signup).raises(RuntimeError)}
    [ProfileController, AccountController].each{|klass| klass.any_instance.stubs(:local_request?).returns(false)}
    [ProfileController, AccountController].each{|klass| klass.any_instance.stubs(:consider_all_requests_local).returns(false)}
  end

  should 'deliver mail notification about exceptions' do
    assert_difference ActionMailer::Base.deliveries, :size do
      get '/account/signup'
    end
  end

  should 'deliver mails to addresses listed in Noosfero configuration noosfero.yml' do
    get '/account/signup'
    assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, '<EMAIL>'
    assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, '<EMAIL>'
  end

  should 'render not found when try to access invalid url' do
    get '/profile/ze/tag/notexists'
    assert_template 'not_found.rhtml'
  end
{'fraction_non_alphanumeric': 0.10678210678210678, 'fraction_numerical': 0.00036075036075036075, 'mean_word_length': 5.6819277108433734, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '6073674', 'n_tokens_mistral': 818, 'n_tokens_neox': 805, 'n_words': 168}