.circleci
.dependabot
.github
app
bin
config
db
dist
lib
log
nanobox
public
spec
controllers
activitypub
admin
api
v1
v2
web
base_controller_spec.rb
oembed_controller_spec.rb
proofs_controller_spec.rb
push_controller_spec.rb
salmon_controller_spec.rb
subscriptions_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
remote_unfollows_controller_spec.rb
shares_controller_spec.rb
statuses_controller_spec.rb
stream_entries_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
docker-compose.yml
package.json
postcss.config.js
priv-config
scalingo.json
yarn.lock
66 lines
2.1 KiB
Ruby
66 lines
2.1 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Api::SalmonController, type: :controller do
|
|
render_views
|
|
|
|
let(:account) { Fabricate(:user, account: Fabricate(:account, username: 'catsrgr8')).account }
|
|
|
|
before do
|
|
stub_request(:get, "https://quitter.no/.well-known/host-meta").to_return(request_fixture('.host-meta.txt'))
|
|
stub_request(:get, "https://quitter.no/.well-known/webfinger?resource=acct:gargron@quitter.no").to_return(request_fixture('webfinger.txt'))
|
|
stub_request(:get, "https://quitter.no/api/statuses/user_timeline/7477.atom").to_return(request_fixture('feed.txt'))
|
|
stub_request(:get, "https://quitter.no/avatar/7477-300-20160211190340.png").to_return(request_fixture('avatar.txt'))
|
|
end
|
|
|
|
describe 'POST #update' do
|
|
context 'with valid post data' do
|
|
before do
|
|
post :update, params: { id: account.id }, body: File.read(Rails.root.join('spec', 'fixtures', 'salmon', 'mention.xml'))
|
|
end
|
|
|
|
it 'contains XML in the request body' do
|
|
expect(request.body.read).to be_a String
|
|
end
|
|
|
|
it 'returns http success' do
|
|
expect(response).to have_http_status(202)
|
|
end
|
|
|
|
it 'creates remote account' do
|
|
expect(Account.find_by(username: 'gargron', domain: 'quitter.no')).to_not be_nil
|
|
end
|
|
|
|
it 'creates status' do
|
|
expect(Status.find_by(uri: 'tag:quitter.no,2016-03-20:noticeId=1276923:objectType=note')).to_not be_nil
|
|
end
|
|
|
|
it 'creates mention for target account' do
|
|
expect(account.mentions.count).to eq 1
|
|
end
|
|
end
|
|
|
|
context 'with empty post data' do
|
|
before do
|
|
post :update, params: { id: account.id }, body: ''
|
|
end
|
|
|
|
it 'returns http client error' do
|
|
expect(response).to have_http_status(400)
|
|
end
|
|
end
|
|
|
|
context 'with invalid post data' do
|
|
before do
|
|
service = double(call: false)
|
|
allow(VerifySalmonService).to receive(:new).and_return(service)
|
|
|
|
post :update, params: { id: account.id }, body: File.read(Rails.root.join('spec', 'fixtures', 'salmon', 'mention.xml'))
|
|
end
|
|
|
|
it 'returns http client error' do
|
|
expect(response).to have_http_status(401)
|
|
end
|
|
end
|
|
end
|
|
end
|