diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-12-18 16:55:15 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-12-18 16:55:15 +0100 |
commit | 034ffc079e40e0c723173b5998242803cc28dc50 (patch) | |
tree | fee1b208be2068cf372ab23f268a66ca51cc2dc3 /spec/controllers/api/v1/accounts | |
parent | 36d27e289177fdec5332539c94b8192022a412f2 (diff) | |
parent | 5bf100f87be571e86305f3ab244183fc46f1ede2 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - app/controllers/admin/base_controller.rb Some refactoring made upstream, no real conflict. - app/javascript/mastodon/features/compose/components/compose_form.js Updated using upstream's code but using maxChars instead of the hardcoded length of 500 characters per toot. - app/javascript/styles/mastodon/components.scss Upstream redesigned the onboarding modal. Not sure why we had a conflict there.
Diffstat (limited to 'spec/controllers/api/v1/accounts')
-rw-r--r-- | spec/controllers/api/v1/accounts/pins_controller_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/accounts/pins_controller_spec.rb b/spec/controllers/api/v1/accounts/pins_controller_spec.rb new file mode 100644 index 000000000..c71935df2 --- /dev/null +++ b/spec/controllers/api/v1/accounts/pins_controller_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Api::V1::Accounts::PinsController, type: :controller do + let(:john) { Fabricate(:user, account: Fabricate(:account, username: 'john')) } + let(:kevin) { Fabricate(:user, account: Fabricate(:account, username: 'kevin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: john.id, scopes: 'write:accounts') } + + before do + kevin.account.followers << john.account + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + subject { post :create, params: { account_id: kevin.account.id } } + + it 'returns 200' do + expect(response).to have_http_status(200) + end + + it 'creates account_pin' do + expect do + subject + end.to change { AccountPin.where(account: john.account, target_account: kevin.account).count }.by(1) + end + end + + describe 'DELETE #destroy' do + subject { delete :destroy, params: { account_id: kevin.account.id } } + + before do + Fabricate(:account_pin, account: john.account, target_account: kevin.account) + end + + it 'returns 200' do + expect(response).to have_http_status(200) + end + + it 'destroys account_pin' do + expect do + subject + end.to change { AccountPin.where(account: john.account, target_account: kevin.account).count }.by(-1) + end + end +end |