diff options
author | ThibG <thib@sitedethib.com> | 2018-06-24 15:27:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-24 15:27:51 +0200 |
commit | c18d55e8c25d47a81f99f5ea018d58eecb206a79 (patch) | |
tree | fe8d33304593499d6c9f87e59a23a51d4d45f9b0 /spec | |
parent | f364a27922b19efb312959a562a7541cf9d89e97 (diff) | |
parent | 4b0f27ba7822befed76f8368b472c6ade6977cb2 (diff) |
Merge pull request #553 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/remote_unfollows_controller_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/remote_unfollows_controller_spec.rb b/spec/controllers/remote_unfollows_controller_spec.rb new file mode 100644 index 000000000..223ed64af --- /dev/null +++ b/spec/controllers/remote_unfollows_controller_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe RemoteUnfollowsController do + render_views + + describe '#create' do + subject { post :create, params: { acct: acct } } + + let(:current_user) { Fabricate(:user, account: current_account) } + let(:current_account) { Fabricate(:account) } + let(:remote_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox')).account } + before do + sign_in current_user + current_account.follow!(remote_account) + stub_request(:post, 'http://example.com/inbox'){ { status: 200 } } + end + + context 'when successfully unfollow remote account' do + let(:acct) {"acct:#{ remote_account.username }@#{ remote_account.domain }"} + + it do + is_expected.to render_template :success + expect(current_account.following?(remote_account)).to be false + end + end + + context 'when fails to unfollow remote account' do + let(:acct) {"acct:#{ remote_account.username + '_test' }@#{ remote_account.domain }"} + + it do + is_expected.to render_template :error + expect(current_account.following?(remote_account)).to be true + end + end + end +end |