You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
783 B

  1. require 'rails_helper'
  2. RSpec.describe Follow, type: :model do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. let(:bob) { Fabricate(:account, username: 'bob') }
  5. subject { Follow.new(account: alice, target_account: bob) }
  6. describe 'validations' do
  7. it 'has a valid fabricator' do
  8. follow = Fabricate.build(:follow)
  9. expect(follow).to be_valid
  10. end
  11. it 'is invalid without an account' do
  12. follow = Fabricate.build(:follow, account: nil)
  13. follow.valid?
  14. expect(follow).to model_have_error_on_field(:account)
  15. end
  16. it 'is invalid without a target_account' do
  17. follow = Fabricate.build(:follow, target_account: nil)
  18. follow.valid?
  19. expect(follow).to model_have_error_on_field(:target_account)
  20. end
  21. end
  22. end