|
|
@ -4,6 +4,7 @@ RSpec.describe AccountsController, type: :controller do |
|
|
|
render_views |
|
|
|
render_views |
|
|
|
|
|
|
|
|
|
|
|
let(:alice) { Fabricate(:account, username: 'alice') } |
|
|
|
let(:alice) { Fabricate(:account, username: 'alice') } |
|
|
|
|
|
|
|
let(:eve) { Fabricate(:user) } |
|
|
|
|
|
|
|
|
|
|
|
describe 'GET #show' do |
|
|
|
describe 'GET #show' do |
|
|
|
let!(:status1) { Status.create!(account: alice, text: 'Hello world') } |
|
|
|
let!(:status1) { Status.create!(account: alice, text: 'Hello world') } |
|
|
@ -19,93 +20,123 @@ RSpec.describe AccountsController, type: :controller do |
|
|
|
let!(:status_pin3) { StatusPin.create!(account: alice, status: status7, created_at: 10.minutes.ago) } |
|
|
|
let!(:status_pin3) { StatusPin.create!(account: alice, status: status7, created_at: 10.minutes.ago) } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
|
|
|
|
alice.block!(eve.account) |
|
|
|
status3.media_attachments.create!(account: alice, file: fixture_file_upload('files/attachment.jpg', 'image/jpeg')) |
|
|
|
status3.media_attachments.create!(account: alice, file: fixture_file_upload('files/attachment.jpg', 'image/jpeg')) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'atom' do |
|
|
|
shared_examples 'responses' do |
|
|
|
before do |
|
|
|
before do |
|
|
|
get :show, params: { username: alice.username, max_id: status4.stream_entry.id, since_id: status1.stream_entry.id }, format: 'atom' |
|
|
|
sign_in(current_user) if defined? current_user |
|
|
|
|
|
|
|
get :show, params: { |
|
|
|
|
|
|
|
username: alice.username, |
|
|
|
|
|
|
|
max_id: (max_id if defined? max_id), |
|
|
|
|
|
|
|
since_id: (since_id if defined? since_id), |
|
|
|
|
|
|
|
current_user: (current_user if defined? current_user), |
|
|
|
|
|
|
|
}, format: format |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @account' do |
|
|
|
it 'assigns @account' do |
|
|
|
expect(assigns(:account)).to eq alice |
|
|
|
expect(assigns(:account)).to eq alice |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @entries' do |
|
|
|
it 'returns http success' do |
|
|
|
entries = assigns(:entries).to_a |
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
expect(entries.size).to eq 2 |
|
|
|
|
|
|
|
expect(entries[0].status).to eq status3 |
|
|
|
|
|
|
|
expect(entries[1].status).to eq status2 |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'returns http success with Atom' do |
|
|
|
it 'returns correct format' do |
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
expect(response.content_type).to eq content_type |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'activitystreams2' do |
|
|
|
context 'atom' do |
|
|
|
before do |
|
|
|
let(:format) { 'atom' } |
|
|
|
get :show, params: { username: alice.username }, format: 'json' |
|
|
|
let(:content_type) { 'application/atom+xml' } |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @account' do |
|
|
|
shared_examples 'responsed streams' do |
|
|
|
expect(assigns(:account)).to eq alice |
|
|
|
it 'assigns @entries' do |
|
|
|
|
|
|
|
entries = assigns(:entries).to_a |
|
|
|
|
|
|
|
expect(entries.size).to eq expected_statuses.size |
|
|
|
|
|
|
|
entries.each.zip(expected_statuses.each) do |entry, expected_status| |
|
|
|
|
|
|
|
expect(entry.status).to eq expected_status |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'returns http success with Activity Streams 2.0' do |
|
|
|
include_examples 'responses' |
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
|
|
|
|
|
|
|
|
context 'without max_id nor since_id' do |
|
|
|
|
|
|
|
let(:expected_statuses) { [status7, status6, status5, status4, status3, status2, status1] } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'responsed streams' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'returns application/activity+json' do |
|
|
|
context 'with max_id and since_id' do |
|
|
|
expect(response.content_type).to eq 'application/activity+json' |
|
|
|
let(:max_id) { status4.stream_entry.id } |
|
|
|
|
|
|
|
let(:since_id) { status1.stream_entry.id } |
|
|
|
|
|
|
|
let(:expected_statuses) { [status3, status2] } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'responsed streams' |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'html without since_id nor max_id' do |
|
|
|
context 'activitystreams2' do |
|
|
|
before do |
|
|
|
let(:format) { 'json' } |
|
|
|
get :show, params: { username: alice.username } |
|
|
|
let(:content_type) { 'application/activity+json' } |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @account' do |
|
|
|
include_examples 'responses' |
|
|
|
expect(assigns(:account)).to eq alice |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context 'html' do |
|
|
|
|
|
|
|
let(:format) { nil } |
|
|
|
|
|
|
|
let(:content_type) { 'text/html' } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shared_examples 'responsed statuses' do |
|
|
|
it 'assigns @pinned_statuses' do |
|
|
|
it 'assigns @pinned_statuses' do |
|
|
|
pinned_statuses = assigns(:pinned_statuses).to_a |
|
|
|
pinned_statuses = assigns(:pinned_statuses).to_a |
|
|
|
expect(pinned_statuses.size).to eq 3 |
|
|
|
expect(pinned_statuses.size).to eq expected_pinned_statuses.size |
|
|
|
expect(pinned_statuses[0]).to eq status7 |
|
|
|
pinned_statuses.each.zip(expected_pinned_statuses.each) do |pinned_status, expected_pinned_status| |
|
|
|
expect(pinned_statuses[1]).to eq status5 |
|
|
|
expect(pinned_status).to eq expected_pinned_status |
|
|
|
expect(pinned_statuses[2]).to eq status6 |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'returns http success' do |
|
|
|
it 'assigns @statuses' do |
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
statuses = assigns(:statuses).to_a |
|
|
|
|
|
|
|
expect(statuses.size).to eq expected_statuses.size |
|
|
|
|
|
|
|
statuses.each.zip(expected_statuses.each) do |status, expected_status| |
|
|
|
|
|
|
|
expect(status).to eq expected_status |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'html with since_id and max_id' do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
get :show, params: { username: alice.username, max_id: status4.id, since_id: status1.id } |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @account' do |
|
|
|
include_examples 'responses' |
|
|
|
expect(assigns(:account)).to eq alice |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @statuses' do |
|
|
|
context 'with anonymous visitor' do |
|
|
|
statuses = assigns(:statuses).to_a |
|
|
|
context 'without since_id nor max_id' do |
|
|
|
expect(statuses.size).to eq 2 |
|
|
|
let(:expected_statuses) { [status7, status6, status5, status4, status3, status2, status1] } |
|
|
|
expect(statuses[0]).to eq status3 |
|
|
|
let(:expected_pinned_statuses) { [status7, status5, status6] } |
|
|
|
expect(statuses[1]).to eq status2 |
|
|
|
|
|
|
|
|
|
|
|
include_examples 'responsed statuses' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns an empty array to @pinned_statuses' do |
|
|
|
context 'with since_id nor max_id' do |
|
|
|
pinned_statuses = assigns(:pinned_statuses).to_a |
|
|
|
let(:max_id) { status4.id } |
|
|
|
expect(pinned_statuses.size).to eq 0 |
|
|
|
let(:since_id) { status1.id } |
|
|
|
|
|
|
|
let(:expected_statuses) { [status3, status2] } |
|
|
|
|
|
|
|
let(:expected_pinned_statuses) { [] } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'responsed statuses' |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'returns http success' do |
|
|
|
context 'with blocked visitor' do |
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
let(:current_user) { eve } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context 'without since_id nor max_id' do |
|
|
|
|
|
|
|
let(:expected_statuses) { [] } |
|
|
|
|
|
|
|
let(:expected_pinned_statuses) { [] } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'responsed statuses' |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|