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

describe PostStream::PageRenderer, :type => :controller do
  controller_name :page
  integrate_views

  reset_domain_tables :post_stream_post, :post_stream_post_comments, :post_stream_targets, :post_stream_post_targets, :end_users

  renderer_builder '/post_stream/page/stream'

  it "should render the stream paragraph even when not setup" do
    @rnd = stream_renderer
    @rnd.should_receive(:render_paragraph)
    PostStreamPoster.should_receive(:new).exactly(0).times
    renderer_get @rnd
  end

  it "should render the stream for a user" do
    @user = EndUser.push_target('<EMAIL>')
    @rnd = stream_renderer({}, :target => [:target, @user])
    @rnd.should_receive(:render_paragraph)
    renderer_get @rnd
  end

  it "should post to the stream" do
    @myself = EndUser.new
    @target = EndUser.push_target('<EMAIL>')
    @rnd = stream_renderer({}, :target => [:target, @myself], :post_permission => [:target, @target])
    @rnd.should_receive(:redirect_paragraph)
    assert_difference 'PostStreamPost.count', 1 do
      renderer_post @rnd, :stream_post => {:body => 'My first post'}
    end

    @post = PostStreamPost.find(:last)
    @post.should_not be_nil
    @post.body.should == 'My first post'
    @post.body_html.should include('My first post')
    @post.posted_by.should be_nil
    @post.end_user.should be_nil<commit_msg>Fixed test for anonymous post<commit_after>require  File.expand_path(File.dirname(__FILE__)) + '/../../post_stream_spec_helper'

describe PostStream::PageRenderer, :type => :controller do
  controller_name :page
  integrate_views

  reset_domain_tables :post_stream_post, :post_stream_post_comments, :post_stream_targets, :post_stream_post_targets, :end_users

  renderer_builder '/post_stream/page/stream'

  it "should render the stream paragraph even when not setup" do
    @rnd = stream_renderer
    @rnd.should_receive(:render_paragraph)
    PostStreamPoster.should_receive(:new).exactly(0).times
    renderer_get @rnd
  end

  it "should render the stream for a user" do
    @user = EndUser.push_target('<EMAIL>')
    @rnd = stream_renderer({}, :target => [:target, @user])
    @rnd.should_receive(:render_paragraph)
    renderer_get @rnd
  end

  it "should post to the stream" do
    @myself = EndUser.new
    @target = EndUser.push_target('<EMAIL>')
    @rnd = stream_renderer({}, :target => [:target, @target], :post_permission => [:target, @target])
    @rnd.should_receive(:redirect_paragraph)
    assert_difference 'PostStreamPost.count', 1 do
      renderer_post @rnd, :stream_post => {:body => 'My first post'}
    end

    @post = PostStreamPost.find(:last)
    @post.should_not be_nil
    @post.body.should == 'My first post'
    @post.body_html.should include('My first post')
    @post.posted_by.should be_nil
    @post.end_user.should be_nil
{'fraction_non_alphanumeric': 0.12250516173434274, 'fraction_numerical': 0.0013764624913971094, 'mean_word_length': 4.47457627118644, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '2135363', 'n_tokens_mistral': 976, 'n_tokens_neox': 949, 'n_words': 213}