<commit_before>require 'rails_helper'

RSpec.describe 'Teacher Flow' do

  before do
    @teacher = Fabricate(:verified_user, class_groups: [Fabricate(:class_group)])
    @question_set = Fabricate(:question_set)
  end

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

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

  it "allows a teacher to sign in with github and directs them to the class page", :js => true do
    
    # sign in teacher with github
    get "/test_sign_in/#{@teacher.id}"
    get '/'
    expect(response).to redirect_to('/class_groups')
 
    # takes teacher to show page when they click on a class group
    get "/class_groups/#{@teacher.class_groups[0].id}"
    expect(response).to render_template('class_groups/show')

    #takes teacher to question set show page after they create a question set
    get "/class_groups/#{@teacher.class_groups[0].id}/question_sets/#{@question_set.id}"
    expect(response).to render_template('question_sets/show')

    #teacher creates a question
    

  end


end<commit_msg>added post question route test<commit_after>require 'rails_helper'

RSpec.describe 'Teacher Flow' do

  before do
    @teacher = Fabricate(:verified_user, class_groups: [Fabricate(:class_group)])
    @question_set = Fabricate(:question_set)
  end

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

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

  it "allows a teacher to sign in with github and directs them to the class page", :js => true do
    
    # sign in teacher with github
    get "/test_sign_in/#{@teacher.id}"
    get '/'
    expect(response).to redirect_to('/class_groups')
 
    # takes teacher to show page when they click on a class group
    get "/class_groups/#{@teacher.class_groups[0].id}"
    expect(response).to render_template('class_groups/show')

    #takes teacher to question set show page after they create a question set
    get "/class_groups/#{@teacher.class_groups[0].id}/question_sets/#{@question_set.id}"
    expect(response).to render_template('question_sets/show')
    
    #make question sets, and questions for question sets. make sure database is lined up.
    post "/question_sets/#{@question_set.id}/questions.json", :question => {
      question_set_id: @question_set.id, content: {question: "Blah", answer: "D", choices: [{"A" => "La"}, {"B" => "De"}, {"C" => "Da"}, {"D" => "Fa"}]}}
    post "/question_sets/#{@question_set.id}/questions.json", :question => {
      question_set_id: @question_set.id, content: {question: "Woo", answer: "A", choices: [{"A" => "La"}, {"B" => "De"}, {"C" => "Da"}, {"D" => "Fa"}]}}
    # binding.pry
    questions = Question.where(question_set_id: @question_set.id)
    expect(questions.count).to eq(2)
  end


end
{'fraction_non_alphanumeric': 0.13951866062085805, 'fraction_numerical': 0.0017439832577607255, 'mean_word_length': 3.8120805369127515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3849247', 'n_tokens_mistral': 957, 'n_tokens_neox': 917, 'n_words': 261}