custom_emojis_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Custom Emojis' do
  4. let(:user) { Fabricate(:user) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
  6. let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
  7. describe 'GET /api/v1/custom_emojis' do
  8. before do
  9. Fabricate(:custom_emoji, domain: nil, disabled: false, visible_in_picker: true, shortcode: 'coolcat')
  10. end
  11. context 'when logged out' do
  12. it 'returns http success and json' do
  13. get api_v1_custom_emojis_path
  14. expect(response)
  15. .to have_http_status(200)
  16. expect(response.content_type)
  17. .to start_with('application/json')
  18. expect(response.parsed_body)
  19. .to be_present
  20. .and have_attributes(
  21. first: include(shortcode: 'coolcat')
  22. )
  23. end
  24. end
  25. context 'when logged in' do
  26. it 'returns http success and json' do
  27. get api_v1_custom_emojis_path, headers: headers
  28. expect(response)
  29. .to have_http_status(200)
  30. expect(response.content_type)
  31. .to start_with('application/json')
  32. expect(response.parsed_body)
  33. .to be_present
  34. .and have_attributes(
  35. first: include(shortcode: 'coolcat')
  36. )
  37. end
  38. end
  39. end
  40. end