mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-22 17:38:07 +01:00
Clean up of RSpec/LetSetup
within spec/controllers
(#28446)
This commit is contained in:
parent
c753b1ad35
commit
f32d672d2f
6 changed files with 36 additions and 17 deletions
|
@ -55,11 +55,6 @@ RSpec/LetSetup:
|
|||
- 'spec/controllers/auth/confirmations_controller_spec.rb'
|
||||
- 'spec/controllers/auth/passwords_controller_spec.rb'
|
||||
- 'spec/controllers/auth/sessions_controller_spec.rb'
|
||||
- 'spec/controllers/follower_accounts_controller_spec.rb'
|
||||
- 'spec/controllers/following_accounts_controller_spec.rb'
|
||||
- 'spec/controllers/oauth/authorized_applications_controller_spec.rb'
|
||||
- 'spec/controllers/oauth/tokens_controller_spec.rb'
|
||||
- 'spec/controllers/settings/imports_controller_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/delete_spec.rb'
|
||||
- 'spec/lib/vacuum/applications_vacuum_spec.rb'
|
||||
- 'spec/lib/vacuum/preview_cards_vacuum_spec.rb'
|
||||
|
|
|
@ -48,6 +48,13 @@ describe FollowerAccountsController do
|
|||
|
||||
it 'returns followers' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
orderedItems: contain_exactly(
|
||||
include(follow_from_bob.account.username),
|
||||
include(follow_from_chris.account.username)
|
||||
)
|
||||
)
|
||||
expect(body['totalItems']).to eq 2
|
||||
expect(body['partOf']).to be_present
|
||||
end
|
||||
|
|
|
@ -48,6 +48,13 @@ describe FollowingAccountsController do
|
|||
|
||||
it 'returns followers' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
orderedItems: contain_exactly(
|
||||
include(follow_of_bob.target_account.username),
|
||||
include(follow_of_chris.target_account.username)
|
||||
)
|
||||
)
|
||||
expect(body['totalItems']).to eq 2
|
||||
expect(body['partOf']).to be_present
|
||||
end
|
||||
|
|
|
@ -63,5 +63,9 @@ describe Oauth::AuthorizedApplicationsController do
|
|||
it 'removes subscriptions for the application\'s access tokens' do
|
||||
expect(Web::PushSubscription.where(user: user).count).to eq 0
|
||||
end
|
||||
|
||||
it 'removes the web_push_subscription' do
|
||||
expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,5 +20,9 @@ RSpec.describe Oauth::TokensController do
|
|||
it 'removes web push subscription for token' do
|
||||
expect(Web::PushSubscription.where(access_token: access_token).count).to eq 0
|
||||
end
|
||||
|
||||
it 'removes the web_push_subscription' do
|
||||
expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ RSpec.describe Settings::ImportsController do
|
|||
it 'assigns the expected imports', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(assigns(:recent_imports)).to eq [import]
|
||||
expect(assigns(:recent_imports)).to_not include(other_import)
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
end
|
||||
end
|
||||
|
@ -138,6 +139,7 @@ RSpec.describe Settings::ImportsController do
|
|||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, type: import_type, state: :finished) }
|
||||
|
||||
before do
|
||||
rows.each { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
bulk_import.update(total_items: bulk_import.rows.count, processed_items: bulk_import.rows.count, imported_items: 0)
|
||||
end
|
||||
|
||||
|
@ -152,11 +154,11 @@ RSpec.describe Settings::ImportsController do
|
|||
context 'with follows' do
|
||||
let(:import_type) { 'following' }
|
||||
|
||||
let!(:rows) do
|
||||
let(:rows) do
|
||||
[
|
||||
{ 'acct' => 'foo@bar' },
|
||||
{ 'acct' => 'user@bar', 'show_reblogs' => false, 'notify' => true, 'languages' => %w(fr de) },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
]
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "Account address,Show boosts,Notify on new posts,Languages\nfoo@bar,true,false,\nuser@bar,false,true,\"fr, de\"\n"
|
||||
|
@ -165,11 +167,11 @@ RSpec.describe Settings::ImportsController do
|
|||
context 'with blocks' do
|
||||
let(:import_type) { 'blocking' }
|
||||
|
||||
let!(:rows) do
|
||||
let(:rows) do
|
||||
[
|
||||
{ 'acct' => 'foo@bar' },
|
||||
{ 'acct' => 'user@bar' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
]
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "foo@bar\nuser@bar\n"
|
||||
|
@ -178,11 +180,11 @@ RSpec.describe Settings::ImportsController do
|
|||
context 'with mutes' do
|
||||
let(:import_type) { 'muting' }
|
||||
|
||||
let!(:rows) do
|
||||
let(:rows) do
|
||||
[
|
||||
{ 'acct' => 'foo@bar' },
|
||||
{ 'acct' => 'user@bar', 'hide_notifications' => false },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
]
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "Account address,Hide notifications\nfoo@bar,true\nuser@bar,false\n"
|
||||
|
@ -191,11 +193,11 @@ RSpec.describe Settings::ImportsController do
|
|||
context 'with domain blocks' do
|
||||
let(:import_type) { 'domain_blocking' }
|
||||
|
||||
let!(:rows) do
|
||||
let(:rows) do
|
||||
[
|
||||
{ 'domain' => 'bad.domain' },
|
||||
{ 'domain' => 'evil.domain' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
]
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "bad.domain\nevil.domain\n"
|
||||
|
@ -204,11 +206,11 @@ RSpec.describe Settings::ImportsController do
|
|||
context 'with bookmarks' do
|
||||
let(:import_type) { 'bookmarks' }
|
||||
|
||||
let!(:rows) do
|
||||
let(:rows) do
|
||||
[
|
||||
{ 'uri' => 'https://foo.com/1' },
|
||||
{ 'uri' => 'https://foo.com/2' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
]
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "https://foo.com/1\nhttps://foo.com/2\n"
|
||||
|
@ -217,11 +219,11 @@ RSpec.describe Settings::ImportsController do
|
|||
context 'with lists' do
|
||||
let(:import_type) { 'lists' }
|
||||
|
||||
let!(:rows) do
|
||||
let(:rows) do
|
||||
[
|
||||
{ 'list_name' => 'Amigos', 'acct' => 'user@example.com' },
|
||||
{ 'list_name' => 'Frenemies', 'acct' => 'user@org.org' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
]
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "Amigos,user@example.com\nFrenemies,user@org.org\n"
|
||||
|
|
Loading…
Reference in a new issue