This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spec coverage on Settings/ controllers specs (mastodon#24221)
- Loading branch information
1 parent
a2a6630
commit 36eeb70
Showing
7 changed files
with
204 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,50 @@ | |
expect(response).to have_http_status(200) | ||
end | ||
end | ||
|
||
describe 'POST #create' do | ||
context 'with valid alias' do | ||
before { stub_resolver } | ||
|
||
it 'creates an alias for the user' do | ||
expect do | ||
post :create, params: { account_alias: { acct: '[email protected]' } } | ||
end.to change(AccountAlias, :count).by(1) | ||
|
||
expect(response).to redirect_to(settings_aliases_path) | ||
end | ||
end | ||
|
||
context 'with invalid alias' do | ||
it 'does not create an alias for the user' do | ||
expect do | ||
post :create, params: { account_alias: { acct: 'format-wrong' } } | ||
end.to_not change(AccountAlias, :count) | ||
|
||
expect(response).to have_http_status(200) | ||
end | ||
end | ||
end | ||
|
||
describe 'DELETE #destroy' do | ||
let(:account_alias) do | ||
AccountAlias.new(account: user.account, acct: '[email protected]').tap do |account_alias| | ||
account_alias.save(validate: false) | ||
end | ||
end | ||
|
||
it 'removes an alias' do | ||
delete :destroy, params: { id: account_alias.id } | ||
|
||
expect(response).to redirect_to(settings_aliases_path) | ||
expect { account_alias.reload }.to raise_error(ActiveRecord::RecordNotFound) | ||
end | ||
end | ||
|
||
private | ||
|
||
def stub_resolver | ||
resolver = instance_double(ResolveAccountService, call: Fabricate(:account)) | ||
allow(ResolveAccountService).to receive(:new).and_return(resolver) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
describe Settings::Migration::RedirectsController do | ||
render_views | ||
|
||
let!(:user) { Fabricate(:user) } | ||
let!(:user) { Fabricate(:user, password: 'testtest') } | ||
|
||
before do | ||
sign_in user, scope: :user | ||
|
@@ -17,4 +17,47 @@ | |
expect(response).to have_http_status(200) | ||
end | ||
end | ||
|
||
describe 'POST #create' do | ||
context 'with valid params' do | ||
before { stub_resolver } | ||
|
||
it 'redirects to the settings migration path' do | ||
post :create, params: { form_redirect: { acct: '[email protected]', current_password: 'testtest' } } | ||
|
||
expect(response).to redirect_to(settings_migration_path) | ||
end | ||
end | ||
|
||
context 'with non valid params' do | ||
it 'returns success and renders the new page' do | ||
post :create, params: { form_redirect: { acct: '' } } | ||
|
||
expect(response).to have_http_status(200) | ||
expect(response).to render_template(:new) | ||
end | ||
end | ||
end | ||
|
||
describe 'DELETE #destroy' do | ||
let(:account) { Fabricate(:account) } | ||
|
||
before do | ||
user.account.update(moved_to_account_id: account.id) | ||
end | ||
|
||
it 'resets the account and sends an update' do | ||
delete :destroy | ||
|
||
expect(response).to redirect_to(settings_migration_path) | ||
expect(user.account.reload.moved_to_account).to be_nil | ||
end | ||
end | ||
|
||
private | ||
|
||
def stub_resolver | ||
resolver = instance_double(ResolveAccountService, call: Fabricate(:account)) | ||
allow(ResolveAccountService).to receive(:new).and_return(resolver) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
Fabricator(:featured_tag) do | ||
account | ||
tag | ||
name 'Tag' | ||
end |