2016-02-29 13:42:08 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe AccountsController, type: :controller do
|
2016-09-07 18:33:07 -04:00
|
|
|
render_views
|
|
|
|
|
2016-02-29 13:42:08 -05:00
|
|
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
2017-05-22 20:53:01 -04:00
|
|
|
let!(:status1) { Status.create!(account: alice, text: 'Hello world') }
|
|
|
|
let!(:status2) { Status.create!(account: alice, text: 'Boop', thread: status1) }
|
|
|
|
let!(:status3) { Status.create!(account: alice, text: 'Picture!') }
|
|
|
|
let!(:status4) { Status.create!(account: alice, text: 'Mentioning @alice') }
|
2017-08-25 12:50:52 -04:00
|
|
|
let!(:status5) { Status.create!(account: alice, text: 'Kitsune') }
|
|
|
|
let!(:status6) { Status.create!(account: alice, text: 'Neko') }
|
|
|
|
let!(:status7) { Status.create!(account: alice, text: 'Tanuki') }
|
|
|
|
|
|
|
|
let!(:status_pin1) { StatusPin.create!(account: alice, status: status5, created_at: 5.days.ago) }
|
|
|
|
let!(:status_pin2) { StatusPin.create!(account: alice, status: status6, created_at: 2.years.ago) }
|
|
|
|
let!(:status_pin3) { StatusPin.create!(account: alice, status: status7, created_at: 10.minutes.ago) }
|
2017-05-22 20:53:01 -04:00
|
|
|
|
2016-09-07 18:33:07 -04:00
|
|
|
before do
|
|
|
|
status3.media_attachments.create!(account: alice, file: fixture_file_upload('files/attachment.jpg', 'image/jpeg'))
|
2016-02-29 13:42:08 -05:00
|
|
|
end
|
|
|
|
|
2016-09-07 18:33:07 -04:00
|
|
|
context 'atom' do
|
|
|
|
before do
|
2017-05-22 20:53:01 -04:00
|
|
|
get :show, params: { username: alice.username, max_id: status4.stream_entry.id, since_id: status1.stream_entry.id }, format: 'atom'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns @account' do
|
|
|
|
expect(assigns(:account)).to eq alice
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns @entries' do
|
|
|
|
entries = assigns(:entries).to_a
|
|
|
|
expect(entries.size).to eq 2
|
|
|
|
expect(entries[0].status).to eq status3
|
|
|
|
expect(entries[1].status).to eq status2
|
2016-09-07 18:33:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success with Atom' do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-06 15:14:02 -05:00
|
|
|
context 'activitystreams2' do
|
|
|
|
before do
|
2017-07-14 21:01:39 -04:00
|
|
|
get :show, params: { username: alice.username }, format: 'json'
|
2017-02-06 15:14:02 -05:00
|
|
|
end
|
|
|
|
|
2017-05-22 20:53:01 -04:00
|
|
|
it 'assigns @account' do
|
|
|
|
expect(assigns(:account)).to eq alice
|
|
|
|
end
|
|
|
|
|
2017-02-06 15:14:02 -05:00
|
|
|
it 'returns http success with Activity Streams 2.0' do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
end
|
2017-08-13 22:16:43 -04:00
|
|
|
|
|
|
|
it 'returns application/activity+json' do
|
|
|
|
expect(response.content_type).to eq 'application/activity+json'
|
|
|
|
end
|
2017-02-06 15:14:02 -05:00
|
|
|
end
|
|
|
|
|
2017-09-04 06:53:18 -04:00
|
|
|
context 'html without since_id nor max_id' do
|
|
|
|
before do
|
|
|
|
get :show, params: { username: alice.username }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns @account' do
|
|
|
|
expect(assigns(:account)).to eq alice
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns @pinned_statuses' do
|
|
|
|
pinned_statuses = assigns(:pinned_statuses).to_a
|
|
|
|
expect(pinned_statuses.size).to eq 3
|
|
|
|
expect(pinned_statuses[0]).to eq status7
|
|
|
|
expect(pinned_statuses[1]).to eq status5
|
|
|
|
expect(pinned_statuses[2]).to eq status6
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'html with since_id and max_id' do
|
2016-09-07 18:33:07 -04:00
|
|
|
before do
|
2017-05-22 20:53:01 -04:00
|
|
|
get :show, params: { username: alice.username, max_id: status4.id, since_id: status1.id }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns @account' do
|
|
|
|
expect(assigns(:account)).to eq alice
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns @statuses' do
|
|
|
|
statuses = assigns(:statuses).to_a
|
|
|
|
expect(statuses.size).to eq 2
|
|
|
|
expect(statuses[0]).to eq status3
|
|
|
|
expect(statuses[1]).to eq status2
|
2016-09-07 18:33:07 -04:00
|
|
|
end
|
|
|
|
|
2017-09-04 06:53:18 -04:00
|
|
|
it 'assigns an empty array to @pinned_statuses' do
|
2017-08-25 12:50:52 -04:00
|
|
|
pinned_statuses = assigns(:pinned_statuses).to_a
|
2017-09-04 06:53:18 -04:00
|
|
|
expect(pinned_statuses.size).to eq 0
|
2017-08-25 12:50:52 -04:00
|
|
|
end
|
|
|
|
|
2016-09-07 18:33:07 -04:00
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
end
|
2016-02-29 13:42:08 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|