We've moved discussions to Discord

User factory failing on Terms of Services

Matt Bjornson
I'm working on a system spec that is failing with the error

  1) ExistingUserLogins existing user login and see their dashboard
     Failure/Error: @user = FactoryBot.create(:user)

     ActiveRecord::RecordInvalid:
       Validation failed: Terms of service can't be blank

My users factory is:
require 'faker'

FactoryBot.define do
  factory :user, class: 'User' do
   email { Faker::Internet.email }
   password { "password" }
   name { Faker::Movies::Lebowski.character } 
   accepted_terms_at { Time.current }
   accepted_privacy_at { Time.current }
   time_zone { "America/Chicago" }
  end
end

My system spec is pretty basic too

require 'rails_helper'

RSpec.describe "ExistingUserLogins", type: :system do
  before do
    driven_by(:rack_test)
    @user = FactoryBot.create(:user)
  end

  scenario "existing user login and see their dashboard" do
    login_as(@user)
    visit "/"
    expect(page).to have_content "dashboard"
  end 
end

What am I doing wrong? Any pointers appreciated :)
Matt Bjornson
Solved, I modified the FactoryBot to read:

FactoryBot.define do
  factory :user, class: 'User' do
   email { Faker::Internet.email }
   password { "password" }
   name { Faker::Movies::Lebowski.character } 
   terms_of_service { true }
   time_zone { "America/Chicago" }
  end
end
Notifications
You’re not receiving notifications from this thread.