<commit_before>require 'spec_helper'

describe "Smart Redirect" do
    #create a course with content
    #instead of courses_path, we should
    #go to the course we just created
  subject { page }

  let!(:course){ FactoryGirl.create(:course, is_active: true) }
  let!(:section){ FactoryGirl.create(:section, course_id: course.id) }
  let!(:lesson){ FactoryGirl.create(:lesson, section_id: section.id) }

  describe "Redirect back after sign up" do
    context 'From the home page' do
      before { sign_up_user }

      it { should have_selector('h1', text: "This is Your Path to Learning Web Development" ) }

    end
    context 'From a specific lesson page' do
      before do
        visit lesson_path(lesson.course.title_url, lesson.title_url)
        sign_up_user
      end

      it { should have_selector('div', text: lesson.title ) }

    end

    context 'From signup path' do
      before do
        visit signup_path
        sign_up_user
      end

      it { should have_selector('h1', text: "This is Your Path to Learning Web Development" ) }

    end
  end

  describe "Redirect back after sign in" do
    # Create a user here to login with
    # after visiting couress path:
    # 1. click login
    # 2. sign in with a valid user
    # 3. redirect back to courses path

    let!(:new_user){ FactoryGirl.create(:user) }

    context 'From a specific lesson page' do
      before do
        visit lesson_path(course.title_url, lesson.title_url)
        sign_in(new_user)
      end

      it 'should redirect the registered user to last viewed lesson page' do
        should have_selector('div', text: lesson.title )
      end
    end
<commit_msg>Test different sign up paths<commit_after>require 'spec_helper'

describe "Smart Redirect" do
    #create a course with content
    #instead of courses_path, we should
    #go to the course we just created
  subject { page }

  let!(:course){ FactoryGirl.create(:course, is_active: true) }
  let!(:section){ FactoryGirl.create(:section, course_id: course.id) }
  let!(:lesson){ FactoryGirl.create(:lesson, section_id: section.id) }

  describe "Redirect back after sign up" do
    context 'From the home page' do
      before { sign_up_user }

      it { should have_selector('h1', text: "This is Your Path to Learning Web Development" ) }

    end
    context 'From a specific lesson page' do
      before do
        visit lesson_path(lesson.course.title_url, lesson.title_url)
        sign_up_user
      end

      it { should have_selector('div', text: lesson.title ) }

    end

    context 'From signup path' do
      before do
        visit '/signup'
        sign_up_user
      end

      it { should have_selector('h1', text: "This is Your Path to Learning Web Development" ) }

    end

    context 'From signup path' do
      before do
        visit '/sign_up'
        sign_up_user
      end

      it { should have_selector('h1', text: "This is Your Path to Learning Web Development" ) }

    end
  end

  describe "Redirect back after sign in" do
    # Create a user here to login with
    # after visiting couress path:
    # 1. click login
    # 2. sign in with a valid user
    # 3. redirect back to courses path

    let!(:new_user){ FactoryGirl.create(:user) }

    context 'From a specific lesson page' do
      before do
        visit lesson_path(course.title_url, lesson.title_url)
        sign_in(new_user)
      end

      it 'should redirect the registered user to last viewed lesson page' do
        should have_selector('div', text: lesson.title )
      end
    end

{'fraction_non_alphanumeric': 0.08103545301069218, 'fraction_numerical': 0.0030951041080472708, 'mean_word_length': 2.6992715920915713, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4099548', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1021, 'n_words': 384}