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.

74 lines
2.1 KiB

7 years ago
7 years ago
7 years ago
  1. require 'rails_helper'
  2. RSpec.describe AccountsController, type: :controller do
  3. render_views
  4. let(:alice) { Fabricate(:account, username: 'alice') }
  5. describe 'GET #show' do
  6. let!(:status1) { Status.create!(account: alice, text: 'Hello world') }
  7. let!(:status2) { Status.create!(account: alice, text: 'Boop', thread: status1) }
  8. let!(:status3) { Status.create!(account: alice, text: 'Picture!') }
  9. let!(:status4) { Status.create!(account: alice, text: 'Mentioning @alice') }
  10. before do
  11. status3.media_attachments.create!(account: alice, file: fixture_file_upload('files/attachment.jpg', 'image/jpeg'))
  12. end
  13. context 'atom' do
  14. before do
  15. get :show, params: { username: alice.username, max_id: status4.stream_entry.id, since_id: status1.stream_entry.id }, format: 'atom'
  16. end
  17. it 'assigns @account' do
  18. expect(assigns(:account)).to eq alice
  19. end
  20. it 'assigns @entries' do
  21. entries = assigns(:entries).to_a
  22. expect(entries.size).to eq 2
  23. expect(entries[0].status).to eq status3
  24. expect(entries[1].status).to eq status2
  25. end
  26. it 'returns http success with Atom' do
  27. expect(response).to have_http_status(:success)
  28. end
  29. end
  30. context 'activitystreams2' do
  31. before do
  32. get :show, params: { username: alice.username }, format: 'json'
  33. end
  34. it 'assigns @account' do
  35. expect(assigns(:account)).to eq alice
  36. end
  37. it 'returns http success with Activity Streams 2.0' do
  38. expect(response).to have_http_status(:success)
  39. end
  40. end
  41. context 'html' do
  42. before do
  43. get :show, params: { username: alice.username, max_id: status4.id, since_id: status1.id }
  44. end
  45. it 'assigns @account' do
  46. expect(assigns(:account)).to eq alice
  47. end
  48. it 'assigns @statuses' do
  49. statuses = assigns(:statuses).to_a
  50. expect(statuses.size).to eq 2
  51. expect(statuses[0]).to eq status3
  52. expect(statuses[1]).to eq status2
  53. end
  54. it 'returns http success' do
  55. expect(response).to have_http_status(:success)
  56. end
  57. end
  58. end
  59. end