]>
cat aescling's git repositories - mastodon.git/blob - spec/controllers/api/v1/accounts/credentials_controller_spec.rb
3 describe Api
::V1::Accounts::CredentialsController do
6 let(:user) { Fabricate(:user, account
: Fabricate(:account, username
: 'alice')) }
7 let(:token) { Fabricate(:accessible_access_token, resource_owner_id
: user
.id
, scopes
: scopes
) }
9 context
'with an oauth token' do
11 allow(controller
).to
receive(:doorkeeper_token) { token
}
14 describe
'GET #show' do
15 let(:scopes) { 'read:accounts' }
17 it
'returns http success' do
19 expect(response
).to
have_http_status(200)
23 describe
'PATCH #update' do
24 let(:scopes) { 'write:accounts' }
26 describe
'with valid data' do
28 allow(ActivityPub
::UpdateDistributionWorker).to
receive(:perform_async)
30 patch
:update, params
: {
31 display_name
: "Alice Isn't Dead",
32 note
: "Hi!\n\nToot toot!
",
33 avatar: fixture_file_upload('files/avatar.gif', 'image/gif'),
34 header: fixture_file_upload('files/attachment.jpg', 'image/jpeg'),
42 it 'returns http success' do
43 expect(response).to have_http_status(200)
46 it 'updates account info' do
49 expect(user.account.display_name).to eq("Alice Isn
't Dead")
50 expect(user.account.note).to eq("Hi!\n\nToot toot!
")
51 expect(user.account.avatar).to exist
52 expect(user.account.header).to exist
53 expect(user.setting_default_privacy).to eq('unlisted')
54 expect(user.setting_default_sensitive).to eq(true)
57 it 'queues up an account update distribution' do
58 expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(user.account_id)
62 describe 'with invalid data' do
64 note = 'This is too long. '
65 note = note + 'a' * (Account
::MAX_NOTE_LENGTH - note
.length +
1)
66 patch
:update, params
: { note
: note
}
69 it
'returns http unprocessable entity' do
70 expect(response
).to
have_http_status(:unprocessable_entity)
76 context
'without an oauth token' do
78 allow(controller
).to
receive(:doorkeeper_token) { nil }
81 describe
'GET #show' do
82 it
'returns http unauthorized' do
84 expect(response
).to
have_http_status(:unauthorized)
88 describe
'PATCH #update' do
89 it
'returns http unauthorized' do
90 patch
:update, params
: { note
: 'Foo' }
91 expect(response
).to
have_http_status(:unauthorized)
This page took 0.088815 seconds and 4 git commands to generate.