account_serializer_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe REST::AccountSerializer do
  4. subject { serialized_record_json(account, described_class) }
  5. let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
  6. let(:user) { Fabricate(:user, role: role) }
  7. let(:account) { user.account }
  8. context 'when the account is suspended' do
  9. before do
  10. account.suspend!
  11. end
  12. it 'returns empty roles' do
  13. expect(subject['roles']).to eq []
  14. end
  15. end
  16. context 'when the account has a highlighted role' do
  17. let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
  18. it 'returns the expected role' do
  19. expect(subject['roles'].first).to include({ 'name' => 'Role' })
  20. end
  21. end
  22. context 'when the account has a non-highlighted role' do
  23. let(:role) { Fabricate(:user_role, name: 'Role', highlighted: false) }
  24. it 'returns empty roles' do
  25. expect(subject['roles']).to eq []
  26. end
  27. end
  28. context 'when the account is memorialized' do
  29. before do
  30. account.memorialize!
  31. end
  32. it 'marks it as such' do
  33. expect(subject['memorial']).to be true
  34. end
  35. end
  36. end