mirror of
https://github.com/mastodon/mastodon.git
synced 2025-12-03 21:03:39 +00:00
Use shared_example for does not update username scenarios
This commit is contained in:
parent
e1ce48753d
commit
3975ce0780
|
|
@ -114,15 +114,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
|||
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
|
||||
|
||||
shared_examples 'does not update username' do
|
||||
it 'updates profile' do
|
||||
subject.perform
|
||||
expect(sender.reload.display_name).to eq 'Totally modified now'
|
||||
|
|
@ -134,6 +126,18 @@ RSpec.describe ActivityPub::Activity::Update do
|
|||
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
|
||||
before do
|
||||
stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:#{updated_handle}")
|
||||
|
|
@ -155,15 +159,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
|||
)
|
||||
end
|
||||
|
||||
it 'updates profile' do
|
||||
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
|
||||
include_examples 'does not update username'
|
||||
end
|
||||
|
||||
context 'when webfinger request of updated username fails' do
|
||||
|
|
@ -172,15 +168,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
|||
.to_return(status: 404)
|
||||
end
|
||||
|
||||
it 'updates profile' do
|
||||
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
|
||||
include_examples 'does not update username'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user