<commit_before>require 'rails_helper'
# include Devise::TestHelpers # this should work without this

RSpec.describe OffspringsController, type: :controller do
  context "When not authenticated," do
    let(:user) { FactoryGirl.build_stubbed(:user) }
    let(:off) { FactoryGirl.build_stubbed(:offspring, user: user) }

    it "does not allow to create" do
      post :create, offspring: {first_name: "pepe", last_name: "kata", grade: :primary_first}
      expect(response).to redirect_to('/users/sign_in')
    end

    it "does not allow access new" do
      get :new, {}
      expect(response).to redirect_to('/users/sign_in')
    end

    it "does not allow to destroy" do
      expect do
        delete :destroy, id: off.id
      end.to change(user.offsprings, :count).by(0)
      expect(response).to redirect_to('/users/sign_in')
    end

    pending "does not allow to see the index of offsprings"
    pending "visitor can't see offpsring@show"
    pending "visitor can't see other users"
  end

  context "When authenticated," do
    let(:user) { FactoryGirl.create(:user) } # Necessary creat to sign in
    before(:each) do
      sign_in user
    end

    describe "#create" do
      it "allows creation of primary_first children" do
        expect do
          post :create, offspring: {first_name: "pepe", last_name: "kata", grade: :primary_first}
        end.to change(user.offsprings, :count).by(1)<commit_msg>Fix in redirect of specs<commit_after>require 'rails_helper'
# include Devise::TestHelpers # this should work without this

RSpec.describe OffspringsController, type: :controller do
  context "When not authenticated," do
    let(:user) { FactoryGirl.build_stubbed(:user) }
    let(:off) { FactoryGirl.build_stubbed(:offspring, user: user) }

    it "does not allow to create" do
      post :create, offspring: {first_name: "pepe", last_name: "kata", grade: :primary_first}
      expect(response).to redirect_to(new_user_session_path)
    end

    it "does not allow access new" do
      get :new, {}
      expect(response).to redirect_to(new_user_session_path)
    end

    it "does not allow to destroy" do
      expect do
        delete :destroy, id: off.id
      end.to change(user.offsprings, :count).by(0)
      expect(response).to redirect_to(new_user_session_path)
    end

    pending "does not allow to see the index of offsprings"
    pending "visitor can't see offpsring@show"
    pending "visitor can't see other users"
  end

  context "When authenticated," do
    let(:user) { FactoryGirl.create(:user) } # Necessary creat to sign in
    before(:each) do
      sign_in user
    end

    describe "#create" do
      it "allows creation of primary_first children" do
        expect do
          post :create, offspring: {first_name: "pepe", last_name: "kata", grade: :primary_first}
        end.to change(user.offsprings, :count).by(1)
{'fraction_non_alphanumeric': 0.10390516039051603, 'fraction_numerical': 0.001394700139470014, 'mean_word_length': 3.3935681470137826, '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': '5928203', 'n_tokens_mistral': 914, 'n_tokens_neox': 879, 'n_words': 277}