<commit_before>require 'rails_helper'


RSpec.describe RequestsController, type: :controller do

  describe 'GET #requests' do
    before(:each) do
      @user = FactoryGirl.create(:user)
      @chair = FactoryGirl.create(:chair)
      @representative = FactoryGirl.create(:user)
      ChairWimi.create(user_id: @representative.id, chair_id: @chair.id, representative: true)
    end

    it 'does not show requests for users' do
      sign_in @user
      get :requests, {id: @chair}
      expect(response).to have_http_status(302)
    end

    it 'shows request page for chairs representative' do
      sign_in @representative
      get :requests, {id: @chair}
      expect(response).to have_http_status(:success)
    end

    it 'does not show request page for another chair' do
      chair1 = FactoryGirl.create(:chair)
      sign_in @representative
      get :requests, {id: chair1}
      expect(response).to have_http_status(302)
    end

    it 'show all requests of chair' do
      FactoryGirl.create(:holiday, user_id: @representative.id, status: 1)
      FactoryGirl.create(:trip, user_id: @representative.id, status: 1)
      FactoryGirl.create(:expense, user_id: @representative.id, status: 1)
      FactoryGirl.create(:holiday, user_id: @user.id, status: 1)
      sign_in @representative
      get :requests, {id: @chair}
      expect(response).to render_template('requests')
    end
  end<commit_msg>test for filtered requests<commit_after>require 'rails_helper'


RSpec.describe RequestsController, type: :controller do

  describe 'GET #requests' do
    before(:each) do
      @user = FactoryGirl.create(:user)
      @chair = FactoryGirl.create(:chair)
      @representative = FactoryGirl.create(:user)
      ChairWimi.create(user_id: @representative.id, chair_id: @chair.id, representative: true)
    end

    it 'does not show requests for users' do
      sign_in @user
      get :requests, {id: @chair}
      expect(response).to have_http_status(302)
    end

    it 'shows request page for chairs representative' do
      sign_in @representative
      get :requests, {id: @chair}
      expect(response).to have_http_status(:success)
    end

    it 'does not show request page for another chair' do
      chair1 = FactoryGirl.create(:chair)
      sign_in @representative
      get :requests, {id: chair1}
      expect(response).to have_http_status(302)
    end

    it 'show all requests of chair' do
      FactoryGirl.create(:holiday, user_id: @representative.id, status: 1)
      FactoryGirl.create(:trip, user_id: @representative.id, status: 1)
      FactoryGirl.create(:expense, user_id: @representative.id, status: 1)
      FactoryGirl.create(:holiday, user_id: @user.id, status: 1)
      sign_in @representative
      get :requests, {id: @chair}
      expect(response).to render_template('requests')
    end

    it 'shows filtered requests' do
      sign_in @representative
      post :requests_filtered, {id: @chair}
      expect(response).to have_http_status(:success)
    end
  end
{'fraction_non_alphanumeric': 0.10335659687603856, 'fraction_numerical': 0.007976071784646061, 'mean_word_length': 3.4134897360703813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3390871', 'n_tokens_mistral': 971, 'n_tokens_neox': 903, 'n_words': 252}