<commit_before>require  File.expand_path(File.dirname(__FILE__)) + "/../mailing_spec_helper"

describe CampaignsController do

  reset_domain_tables :market_campaigns, :market_segments, :end_users, :market_campaign_messages, :site_versions, :site_nodes, :market_links, :market_campaign_queues, :mail_templates, :market_link_entries

  def create_ready_to_send_campaign
    @user1 = EndUser.push_target('<EMAIL>')
    @user2 = EndUser.push_target('<EMAIL>')
    @campaign = MarketCampaign.create_custom_campaign('campaign', [@user1.id, @user2.id])
    html = '<p>Please visit us at <a href="http://test.dev/">test.dev</a></p>'
    text = 'Please visit us at http://test.dev/'
    @campaign.create_mail_template :name => 'test', :body_type => 'html,text', :subject => 'test subject', :language => 'en', :template_type => 'campaign', :body_html => html, :body_text => text
    @message = MarketCampaignMessage.create :market_campaign_id => @campaign.id
    @campaign.status = 'setup'
    @campaign.save
    @campaign
  end

  def create_members_segment
    @user1 = EndUser.push_target('<EMAIL>')
    @user1.tag('new')
    @user2 = EndUser.push_target('<EMAIL>')
    @user2.tag('new')
    @user_segment = UserSegment.create :name => 'test', :segment_type => 'filtered', :segment_options_text => 'email.like("<EMAIL>")'
    @segment = @user_segment.market_segment
  end

  def create_mail_template
    @mail_template = MailTemplate.create :name => 'Test Template', :subject => 'Test Subject', :language => 'en', :template_type => 'campaign', :body_text => 'Test email body', :body_type => 'text'
  end

  def fake_net_http(response)
    @http = mock
    @http.should_receive(:request_head).and_yield(response)<commit_msg>Fix spec, need to mock out setting read timeout.<commit_after>require  File.expand_path(File.dirname(__FILE__)) + "/../mailing_spec_helper"

describe CampaignsController do

  reset_domain_tables :market_campaigns, :market_segments, :end_users, :market_campaign_messages, :site_versions, :site_nodes, :market_links, :market_campaign_queues, :mail_templates, :market_link_entries

  def create_ready_to_send_campaign
    @user1 = EndUser.push_target('<EMAIL>')
    @user2 = EndUser.push_target('<EMAIL>')
    @campaign = MarketCampaign.create_custom_campaign('campaign', [@user1.id, @user2.id])
    html = '<p>Please visit us at <a href="http://test.dev/">test.dev</a></p>'
    text = 'Please visit us at http://test.dev/'
    @campaign.create_mail_template :name => 'test', :body_type => 'html,text', :subject => 'test subject', :language => 'en', :template_type => 'campaign', :body_html => html, :body_text => text
    @message = MarketCampaignMessage.create :market_campaign_id => @campaign.id
    @campaign.status = 'setup'
    @campaign.save
    @campaign
  end

  def create_members_segment
    @user1 = EndUser.push_target('<EMAIL>')
    @user1.tag('new')
    @user2 = EndUser.push_target('<EMAIL>')
    @user2.tag('new')
    @user_segment = UserSegment.create :name => 'test', :segment_type => 'filtered', :segment_options_text => 'email.like("<EMAIL>")'
    @segment = @user_segment.market_segment
  end

  def create_mail_template
    @mail_template = MailTemplate.create :name => 'Test Template', :subject => 'Test Subject', :language => 'en', :template_type => 'campaign', :body_text => 'Test email body', :body_type => 'text'
  end

  def fake_net_http(response)
    @http = mock
    @http.should_receive(:read_timeout=).any_number_of_times
    @http.should_receive(:request_head).and_yield(response)
{'fraction_non_alphanumeric': 0.1526912181303116, 'fraction_numerical': 0.004532577903682719, 'mean_word_length': 5.205623901581722, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 55, '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': '405157', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1135, 'n_words': 228}