.cache
.circleci
.dependabot
.github
app
bin
config
db
dist
lib
log
nanobox
public
spec
controllers
activitypub
admin
api
v1
accounts
admin
apps
instances
lists
polls
push
statuses
timelines
accounts_controller_spec.rb
apps_controller_spec.rb
blocks_controller_spec.rb
bookmarks_controller_spec.rb
conversations_controller_spec.rb
custom_emojis_controller_spec.rb
domain_blocks_controller_spec.rb
endorsements_controller_spec.rb
favourites_controller_spec.rb
filters_controller_spec.rb
follow_requests_controller_spec.rb
instances_controller_spec.rb
lists_controller_spec.rb
markers_controller_spec.rb
media_controller_spec.rb
mutes_controller_spec.rb
notifications_controller_spec.rb
polls_controller_spec.rb
reports_controller_spec.rb
statuses_controller_spec.rb
streaming_controller_spec.rb
suggestions_controller_spec.rb
v2
web
base_controller_spec.rb
oembed_controller_spec.rb
proofs_controller_spec.rb
auth
concerns
oauth
settings
well_known
about_controller_spec.rb
account_follow_controller_spec.rb
account_unfollow_controller_spec.rb
accounts_controller_spec.rb
application_controller_spec.rb
authorize_interactions_controller_spec.rb
emojis_controller_spec.rb
follower_accounts_controller_spec.rb
following_accounts_controller_spec.rb
home_controller_spec.rb
intents_controller_spec.rb
invites_controller_spec.rb
manifests_controller_spec.rb
media_controller_spec.rb
relationships_controller_spec.rb
remote_follow_controller_spec.rb
remote_interaction_controller_spec.rb
shares_controller_spec.rb
statuses_controller_spec.rb
tags_controller_spec.rb
fabricators
features
fixtures
helpers
lib
mailers
models
policies
presenters
requests
routing
serializers
services
support
validators
views
workers
rails_helper.rb
spec_helper.rb
streaming
vendor
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.js
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.profile
.rspec
.rubocop.yml
.ruby-version
.sass-lint.yml
.slugignore
.yarnclean
AUTHORS.md
Aptfile
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
babel.config.js
boxfile.yml
config.ru
crowdin.yml
docker-compose.yml
package.json
postcss.config.js
priv-config
scalingo.json
yarn.lock
119 lines
3.2 KiB
Ruby
119 lines
3.2 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Api::V1::StatusesController, type: :controller do
|
|
render_views
|
|
|
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: app, scopes: scopes) }
|
|
|
|
context 'with an oauth token' do
|
|
before do
|
|
allow(controller).to receive(:doorkeeper_token) { token }
|
|
end
|
|
|
|
describe 'GET #show' do
|
|
let(:scopes) { 'read:statuses' }
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
it 'returns http success' do
|
|
get :show, params: { id: status.id }
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
end
|
|
|
|
describe 'GET #context' do
|
|
let(:scopes) { 'read:statuses' }
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
before do
|
|
Fabricate(:status, account: user.account, thread: status)
|
|
end
|
|
|
|
it 'returns http success' do
|
|
get :context, params: { id: status.id }
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
end
|
|
|
|
describe 'POST #create' do
|
|
let(:scopes) { 'write:statuses' }
|
|
|
|
before do
|
|
post :create, params: { status: 'Hello world' }
|
|
end
|
|
|
|
it 'returns http success' do
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
end
|
|
|
|
describe 'DELETE #destroy' do
|
|
let(:scopes) { 'write:statuses' }
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
before do
|
|
post :destroy, params: { id: status.id }
|
|
end
|
|
|
|
it 'returns http success' do
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
|
|
it 'removes the status' do
|
|
expect(Status.find_by(id: status.id)).to be nil
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'without an oauth token' do
|
|
before do
|
|
allow(controller).to receive(:doorkeeper_token) { nil }
|
|
end
|
|
|
|
context 'with a private status' do
|
|
let(:status) { Fabricate(:status, account: user.account, visibility: :private) }
|
|
|
|
describe 'GET #show' do
|
|
it 'returns http unautharized' do
|
|
get :show, params: { id: status.id }
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
end
|
|
|
|
describe 'GET #context' do
|
|
before do
|
|
Fabricate(:status, account: user.account, thread: status)
|
|
end
|
|
|
|
it 'returns http unautharized' do
|
|
get :context, params: { id: status.id }
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'with a public status' do
|
|
let(:status) { Fabricate(:status, account: user.account, visibility: :public) }
|
|
|
|
describe 'GET #show' do
|
|
it 'returns http success' do
|
|
get :show, params: { id: status.id }
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
end
|
|
|
|
describe 'GET #context' do
|
|
before do
|
|
Fabricate(:status, account: user.account, thread: status)
|
|
end
|
|
|
|
it 'returns http success' do
|
|
get :context, params: { id: status.id }
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|