forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a67984
commit 4d9186a
Showing
7 changed files
with
299 additions
and
2 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
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,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe AccountSearch do | ||
describe 'a non-discoverable account becoming discoverable' do | ||
let(:account) { Account.find_by(username: 'search_test_account_1') } | ||
|
||
context 'when picking a non-discoverable account' do | ||
it 'its bio is not in the AccountsIndex' do | ||
results = AccountsIndex.filter(term: { username: account.username }) | ||
expect(results.count).to eq(1) | ||
expect(results.first.text).to be_nil | ||
end | ||
end | ||
|
||
context 'when the non-discoverable account becomes discoverable' do | ||
it 'its bio is added to the AccountsIndex' do | ||
account.discoverable = true | ||
account.save! | ||
|
||
results = AccountsIndex.filter(term: { username: account.username }) | ||
expect(results.count).to eq(1) | ||
expect(results.first.text).to eq(account.note) | ||
end | ||
end | ||
end | ||
|
||
describe 'a discoverable account becoming non-discoverable' do | ||
let(:account) { Account.find_by(username: 'search_test_account_0') } | ||
|
||
context 'when picking an discoverable account' do | ||
it 'has its bio in the AccountsIndex' do | ||
results = AccountsIndex.filter(term: { username: account.username }) | ||
expect(results.count).to eq(1) | ||
expect(results.first.text).to eq(account.note) | ||
end | ||
end | ||
|
||
context 'when the discoverable account becomes non-discoverable' do | ||
it 'its bio is removed from the AccountsIndex' do | ||
account.discoverable = false | ||
account.save! | ||
|
||
results = AccountsIndex.filter(term: { username: account.username }) | ||
expect(results.count).to eq(1) | ||
expect(results.first.text).to be_nil | ||
end | ||
end | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
spec/search/models/concerns/account_statuses_search_spec.rb
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,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe AccountStatusesSearch do | ||
describe 'a non-indexable account becoming indexable' do | ||
let(:account) { Account.find_by(username: 'search_test_account_1') } | ||
|
||
context 'when picking a non-indexable account' do | ||
it 'has no statuses in the PublicStatusesIndex' do | ||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(0) | ||
end | ||
|
||
it 'has statuses in the StatusesIndex' do | ||
expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count) | ||
end | ||
end | ||
|
||
context 'when the non-indexable account becomes indexable' do | ||
it 'adds the public statuses to the PublicStatusesIndex' do | ||
account.indexable = true | ||
account.save! | ||
|
||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.where(visibility: :public).count) | ||
expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count) | ||
end | ||
end | ||
end | ||
|
||
describe 'an indexable account becoming non-indexable' do | ||
let(:account) { Account.find_by(username: 'search_test_account_0') } | ||
|
||
context 'when picking an indexable account' do | ||
it 'has statuses in the PublicStatusesIndex' do | ||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.where(visibility: :public).count) | ||
end | ||
|
||
it 'has statuses in the StatusesIndex' do | ||
expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count) | ||
end | ||
end | ||
|
||
context 'when the indexable account becomes non-indexable' do | ||
it 'removes the statuses from the PublicStatusesIndex' do | ||
account.indexable = false | ||
account.save! | ||
|
||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(0) | ||
expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count) | ||
end | ||
end | ||
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