<commit_before>require 'rails_helper'


RSpec.describe "student flow" do
  
  before do
    @student = Fabricate(:user, class_groups: [
      Fabricate(:class_group, question_sets: [
        Fabricate(:question_set)
      ]), 
      Fabricate(:class_group)
    ])
  end

  let(:session) do
    { user_id: @student.id }
  end  

  it 'directs them to the sign in page' do
    get '/'
    expect(response).to render_template(:index)
  end

  describe 'github' do
    it "should login with github", :js => true do
      get "/test_sign_in/#{@student.id}"
      get '/'
      expect(response).to redirect_to('/class_groups')
    end
  end

  context 'when user is not signed in' do
    it 'allows a student to sign in with github and redirects to their list of classes' do
      get "/"
      expect(response).to render_template("welcome/index")
      #signs in
      get "/test_sign_in/#{@student.id}"
      get '/'
      expect(response).to redirect_to('/class_groups')
      
      #allow(response).to receive(:create).and_return(session[:user_id] = @student.id)
      # expect().to receive().with()
      # expect(response).to redirect_to(class_groups_path)
    end
  end

  context 'when user is previously signed in' do
    xit 'redirects signed in student to their list of classes' do
      session = {user_id: @student.uid}
      OmniAuth.config.add_mock(:github, {:uid => @student.uid})
      get "/"
      binding.pry
      expect(response).to render_template("class_groups/index")

    end
  end

end<commit_msg>3 working tests (through class groups show page)<commit_after>require 'rails_helper'


RSpec.describe "student flow" do
  
  before do
    @student = Fabricate(:user, class_groups: [
      Fabricate(:class_group, question_sets: [
        Fabricate(:question_set)
      ]), 
      Fabricate(:class_group)
    ])
  end

  let(:session) do
    { user_id: @student.id }
  end  

  it 'directs them to the sign in page' do
    get '/'
    expect(response).to render_template(:index)
  end

  describe 'github' do
    it "should login with github", :js => true do
      get "/test_sign_in/#{@student.id}"
      get '/'
      expect(response).to redirect_to('/class_groups')
    end
  end

  context 'when student accesses site' do
    it 'allows a student to sign in with github and redirects to their list of classes then individual class' do
      #accesses site
      get "/"
      expect(response).to render_template("welcome/index")
      
      #logs in & redirects to class_groups_index
      get "/test_sign_in/#{@student.id}"
      get '/'
      expect(response).to redirect_to('/class_groups')
      follow_redirect!
      expect(response.body).to include(@student.class_groups.first.name)
      expect(response.body).to include(@student.class_groups[1].name)

      #student views 1 class group on show page
      get "/class_groups/#{@student.class_groups.first.id}"
      expect(response).to render_template('class_groups/show')
      expect(response.body).to include(@student.class_groups.first.name)
      expect(response.body).to_not include(@student.class_groups[1].name)
    end
  end

end
{'fraction_non_alphanumeric': 0.11570512820512821, 'fraction_numerical': 0.001282051282051282, 'mean_word_length': 2.9606598984771573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '650851', 'n_tokens_mistral': 990, 'n_tokens_neox': 958, 'n_words': 251}