|
|
|
@ -21,6 +21,7 @@ describe Api::V1::Statuses::FavouritesController do
|
|
|
|
|
post :create, params: { status_id: status.id }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with public status' do
|
|
|
|
|
it 'returns http success' do
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
|
end
|
|
|
|
@ -33,7 +34,7 @@ describe Api::V1::Statuses::FavouritesController do
|
|
|
|
|
expect(user.account.favourited?(status)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'return json with updated attributes' do
|
|
|
|
|
it 'returns json with updated attributes' do
|
|
|
|
|
hash_body = body_as_json
|
|
|
|
|
|
|
|
|
|
expect(hash_body[:id]).to eq status.id.to_s
|
|
|
|
@ -42,7 +43,17 @@ describe Api::V1::Statuses::FavouritesController do
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with private status of not-followed account' do
|
|
|
|
|
let(:status) { Fabricate(:status, visibility: :private) }
|
|
|
|
|
|
|
|
|
|
it 'returns http not found' do
|
|
|
|
|
expect(response).to have_http_status(404)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'POST #destroy' do
|
|
|
|
|
context 'with public status' do
|
|
|
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
@ -61,6 +72,27 @@ describe Api::V1::Statuses::FavouritesController do
|
|
|
|
|
it 'updates the favourited attribute' do
|
|
|
|
|
expect(user.account.favourited?(status)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns json with updated attributes' do
|
|
|
|
|
hash_body = body_as_json
|
|
|
|
|
|
|
|
|
|
expect(hash_body[:id]).to eq status.id.to_s
|
|
|
|
|
expect(hash_body[:favourites_count]).to eq 0
|
|
|
|
|
expect(hash_body[:favourited]).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with private status that was not favourited' do
|
|
|
|
|
let(:status) { Fabricate(:status, visibility: :private) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
post :destroy, params: { status_id: status.id }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns http not found' do
|
|
|
|
|
expect(response).to have_http_status(404)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|