<commit_before>require 'spec_helper'

describe ItemRequestsController do

  let(:mock_item_request) { mock_model(ItemRequest).as_null_object }
  let(:mock_item) { mock_model(Item).as_null_object }
  let(:mock_person) { mock_model(Person).as_null_object }
  let(:signedin_user) { generate_mock_user_with_person }

  it_should_require_signed_in_user_for_actions :all

  def as_the_requester
    mock_item_request.stub(:requester?).and_return(true)
    mock_item_request.stub(:gifter?).and_return(false)
  end

  def as_the_gifter
    mock_item_request.stub(:requester?).and_return(false)
    mock_item_request.stub(:gifter?).and_return(true)
  end

  def as_other_person
    mock_item_request.stub(:requester?).and_return(false)
    mock_item_request.stub(:gifter?).and_return(false)
  end

  describe "as signed in user" do

    before do
      sign_in_as_user(signedin_user)

      mock_item.stub(:deleted?).and_return(false)
    end

    describe "GET new" do

      before do<commit_msg>Rspec controller action<commit_after>require 'spec_helper'

describe ItemRequestsController do

  let(:mock_item_request) { mock_model(ItemRequest).as_null_object }
  let(:mock_item) { mock_model(Item).as_null_object }
  let(:mock_person) { mock_model(Person).as_null_object }
  let(:signedin_user) { generate_mock_user_with_person }

  it_should_require_signed_in_user_for_actions :all

  def as_the_requester
    mock_item_request.stub(:requester?).and_return(true)
    mock_item_request.stub(:gifter?).and_return(false)
  end

  def as_the_gifter
    mock_item_request.stub(:requester?).and_return(false)
    mock_item_request.stub(:gifter?).and_return(true)
  end

  def as_other_person
    mock_item_request.stub(:requester?).and_return(false)
    mock_item_request.stub(:gifter?).and_return(false)
  end

  describe 'test actions' do

      it "show action should require signed in user" do
          get :show, :id => '1'
          response.should redirect_to(root_path)
          flash[:alert].should eql(I18n.t('messages.must_be_signed_in'))
        end
  end

  describe "as signed in user" do

    before do
      sign_in_as_user(signedin_user)

      mock_item.stub(:deleted?).and_return(false)
    end

    describe "GET new" do

      before do
{'fraction_non_alphanumeric': 0.09790832220738763, 'fraction_numerical': 0.0013351134846461949, 'mean_word_length': 4.605985037406484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7314179', 'n_tokens_mistral': 791, 'n_tokens_neox': 769, 'n_words': 118}