<commit_before>require File.dirname(__FILE__) + '/../spec_helper'

describe OutgoingMessage, " when making an outgoing message" do
    before do
        @outgoing_message = OutgoingMessage.new({
            :status => 'ready',
            :message_type => 'initial_request',
            :body => 'This request contains a <EMAIL> email address',
            :last_sent_at => Time.now(),
            :what_doing => 'normal_sort'
        })
    end

    it "should not index the email addresses" do
        # also used for track emails
        @outgoing_message.get_text_for_indexing.should_not include("<EMAIL>")
    end 

    it "should not display email addresses on page" do
        @outgoing_message.get_body_for_html_display.should_not include("<EMAIL>")
    end

    it "should link to help page where email address was" do
        @outgoing_message.get_body_for_html_display.should have_tag('a[href="/help/about#mobiles"]', :text => 'email address')
    end

    it "should include email addresses in outgoing messages" do
        @outgoing_message.body.should include("<EMAIL>")
    end
end


describe IncomingMessage, " when censoring data" do
    fixtures :outgoing_messages

    before do
        @om = outgoing_messages(:useless_outgoing_message)

        @censor_rule = CensorRule.new()
        @censor_rule.text = "dog"<commit_msg>Simpler check works on new Rails, when the other doesn't<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

describe OutgoingMessage, " when making an outgoing message" do
    before do
        @outgoing_message = OutgoingMessage.new({
            :status => 'ready',
            :message_type => 'initial_request',
            :body => 'This request contains a <EMAIL> email address',
            :last_sent_at => Time.now(),
            :what_doing => 'normal_sort'
        })
    end

    it "should not index the email addresses" do
        # also used for track emails
        @outgoing_message.get_text_for_indexing.should_not include("<EMAIL>")
    end 

    it "should not display email addresses on page" do
        @outgoing_message.get_body_for_html_display.should_not include("<EMAIL>")
    end

    it "should link to help page where email address was" do
        @outgoing_message.get_body_for_html_display.should include('<a href="/help/about#mobiles">')
    end

    it "should include email addresses in outgoing messages" do
        @outgoing_message.body.should include("<EMAIL>")
    end
end


describe IncomingMessage, " when censoring data" do
    fixtures :outgoing_messages

    before do
        @om = outgoing_messages(:useless_outgoing_message)

        @censor_rule = CensorRule.new()
        @censor_rule.text = "dog"
{'fraction_non_alphanumeric': 0.09544950055493896, 'fraction_numerical': 0.0, 'mean_word_length': 2.970631424375918, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 23, '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': '3852068', 'n_tokens_mistral': 791, 'n_tokens_neox': 764, 'n_words': 218}