mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Use shared_example for does not update username scenarios
This commit is contained in:
parent
ceb9c8ff84
commit
d7cd60dfdd
1 changed files with 15 additions and 27 deletions
|
@ -114,15 +114,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when updated username is not unique for domain' do
|
shared_examples 'does not update username' do
|
||||||
before do
|
|
||||||
Fabricate(:account,
|
|
||||||
username: updated_username,
|
|
||||||
domain: 'example.com',
|
|
||||||
inbox_url: "https://example.com/#{updated_username}/inbox",
|
|
||||||
outbox_url: "https://example.com/#{updated_username}/outbox")
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates profile' do
|
it 'updates profile' do
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(sender.reload.display_name).to eq 'Totally modified now'
|
expect(sender.reload.display_name).to eq 'Totally modified now'
|
||||||
|
@ -134,6 +126,18 @@ RSpec.describe ActivityPub::Activity::Update do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when updated username is not unique for domain' do
|
||||||
|
before do
|
||||||
|
Fabricate(:account,
|
||||||
|
username: updated_username,
|
||||||
|
domain: 'example.com',
|
||||||
|
inbox_url: "https://example.com/#{updated_username}/inbox",
|
||||||
|
outbox_url: "https://example.com/#{updated_username}/outbox")
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'does not update username'
|
||||||
|
end
|
||||||
|
|
||||||
context 'when webfinger of updated username does not contain updated username' do
|
context 'when webfinger of updated username does not contain updated username' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:#{updated_handle}")
|
stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:#{updated_handle}")
|
||||||
|
@ -155,15 +159,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates profile' do
|
include_examples 'does not update username'
|
||||||
subject.perform
|
|
||||||
expect(sender.reload.display_name).to eq 'Totally modified now'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not update username' do
|
|
||||||
subject.perform
|
|
||||||
expect(sender.reload.username).to eq original_username
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when webfinger request of updated username fails' do
|
context 'when webfinger request of updated username fails' do
|
||||||
|
@ -172,15 +168,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
||||||
.to_return(status: 404)
|
.to_return(status: 404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates profile' do
|
include_examples 'does not update username'
|
||||||
subject.perform
|
|
||||||
expect(sender.reload.display_name).to eq 'Totally modified now'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not update username' do
|
|
||||||
subject.perform
|
|
||||||
expect(sender.reload.username).to eq original_username
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue