Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - README.md - app/helpers/statuses_helper.rb Upstream moved account helpers to their own file, we had extra helpers there, moved too. - app/lib/sanitize_config.rb - app/models/user.rb - app/serializers/initial_state_serializer.rb - config/locales/simple_form.en.yml - spec/lib/sanitize_config_spec.rb
This commit is contained in:
4
spec/fixtures/xml/mastodon.atom
vendored
4
spec/fixtures/xml/mastodon.atom
vendored
@@ -123,7 +123,7 @@
|
||||
<published>2016-10-10T00:41:31Z</published>
|
||||
<updated>2016-10-10T00:41:31Z</updated>
|
||||
<title>Social media needs MOAR cats! http://kickass.zone/media/3</title>
|
||||
<content type="html"><p>Social media needs MOAR cats! <a rel="nofollow noopener" href="http://kickass.zone/media/3">http://kickass.zone/media/3</a></p></content>
|
||||
<content type="html"><p>Social media needs MOAR cats! <a rel="nofollow noopener noreferrer" href="http://kickass.zone/media/3">http://kickass.zone/media/3</a></p></content>
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||
<link rel="self" type="application/atom+xml" href="http://kickass.zone/users/localhost/updates/9.atom"/>
|
||||
<link rel="alternate" type="text/html" href="http://kickass.zone/users/localhost/updates/9"/>
|
||||
@@ -135,7 +135,7 @@
|
||||
<published>2016-10-10T00:38:39Z</published>
|
||||
<updated>2016-10-10T00:38:39Z</updated>
|
||||
<title>http://kickass.zone/media/2</title>
|
||||
<content type="html"><p><a rel="nofollow noopener" href="http://kickass.zone/media/2">http://kickass.zone/media/2</a></p></content>
|
||||
<content type="html"><p><a rel="nofollow noopener noreferrer" href="http://kickass.zone/media/2">http://kickass.zone/media/2</a></p></content>
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||
<link rel="self" type="application/atom+xml" href="http://kickass.zone/users/localhost/updates/8.atom"/>
|
||||
<link rel="alternate" type="text/html" href="http://kickass.zone/users/localhost/updates/8"/>
|
||||
|
67
spec/helpers/accounts_helper_spec.rb
Normal file
67
spec/helpers/accounts_helper_spec.rb
Normal file
@@ -0,0 +1,67 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountsHelper, type: :helper do
|
||||
def set_not_embedded_view
|
||||
params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}"
|
||||
params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}"
|
||||
end
|
||||
|
||||
def set_embedded_view
|
||||
params[:controller] = StatusesHelper::EMBEDDED_CONTROLLER
|
||||
params[:action] = StatusesHelper::EMBEDDED_ACTION
|
||||
end
|
||||
|
||||
describe '#display_name' do
|
||||
it 'uses the display name when it exists' do
|
||||
account = Account.new(display_name: "Display", username: "Username")
|
||||
|
||||
expect(helper.display_name(account)).to eq "Display"
|
||||
end
|
||||
|
||||
it 'uses the username when display name is nil' do
|
||||
account = Account.new(display_name: nil, username: "Username")
|
||||
|
||||
expect(helper.display_name(account)).to eq "Username"
|
||||
end
|
||||
end
|
||||
|
||||
describe '#acct' do
|
||||
it 'is fully qualified for embedded local accounts' do
|
||||
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
|
||||
set_embedded_view
|
||||
account = Account.new(domain: nil, username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@local_domain'
|
||||
end
|
||||
|
||||
it 'is fully qualified for embedded foreign accounts' do
|
||||
set_embedded_view
|
||||
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@foreign_server.com'
|
||||
end
|
||||
|
||||
it 'is fully qualified for non embedded foreign accounts' do
|
||||
set_not_embedded_view
|
||||
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@foreign_server.com'
|
||||
end
|
||||
|
||||
it 'is fully qualified for non embedded local accounts' do
|
||||
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
|
||||
set_not_embedded_view
|
||||
account = Account.new(domain: nil, username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@local_domain'
|
||||
end
|
||||
end
|
||||
end
|
@@ -3,7 +3,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
|
||||
include StatusesHelper
|
||||
include AccountsHelper
|
||||
|
||||
describe '#admin_account_link_to' do
|
||||
context 'account is nil' do
|
||||
|
@@ -1,20 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe StatusesHelper, type: :helper do
|
||||
describe '#display_name' do
|
||||
it 'uses the display name when it exists' do
|
||||
account = Account.new(display_name: "Display", username: "Username")
|
||||
|
||||
expect(helper.display_name(account)).to eq "Display"
|
||||
end
|
||||
|
||||
it 'uses the username when display name is nil' do
|
||||
account = Account.new(display_name: nil, username: "Username")
|
||||
|
||||
expect(helper.display_name(account)).to eq "Username"
|
||||
end
|
||||
end
|
||||
|
||||
describe '#stream_link_target' do
|
||||
it 'returns nil if it is not an embedded view' do
|
||||
set_not_embedded_view
|
||||
@@ -29,46 +15,6 @@ RSpec.describe StatusesHelper, type: :helper do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#acct' do
|
||||
it 'is fully qualified for embedded local accounts' do
|
||||
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
|
||||
set_embedded_view
|
||||
account = Account.new(domain: nil, username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@local_domain'
|
||||
end
|
||||
|
||||
it 'is fully qualified for embedded foreign accounts' do
|
||||
set_embedded_view
|
||||
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@foreign_server.com'
|
||||
end
|
||||
|
||||
it 'is fully qualified for non embedded foreign accounts' do
|
||||
set_not_embedded_view
|
||||
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@foreign_server.com'
|
||||
end
|
||||
|
||||
it 'is fully qualified for non embedded local accounts' do
|
||||
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
|
||||
set_not_embedded_view
|
||||
account = Account.new(domain: nil, username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@local_domain'
|
||||
end
|
||||
end
|
||||
|
||||
def set_not_embedded_view
|
||||
params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}"
|
||||
params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}"
|
||||
|
@@ -80,7 +80,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
||||
end
|
||||
|
||||
context 'in a remote status' do
|
||||
let(:status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com'), text: 'Habt ihr ein paar gute Links zu #<span class="tag"><a href="https://quitter.se/tag/wannacry" target="_blank" rel="tag noopener" title="https://quitter.se/tag/wannacry">Wannacry</a></span> herumfliegen? Ich will mal unter <br> <a href="https://github.com/qbi/WannaCry" target="_blank" rel="noopener" title="https://github.com/qbi/WannaCry">https://github.com/qbi/WannaCry</a> was sammeln. !<a href="http://sn.jonkman.ca/group/416/id" target="_blank" rel="noopener" title="http://sn.jonkman.ca/group/416/id">security</a> ') }
|
||||
let(:status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com'), text: 'Habt ihr ein paar gute Links zu #<span class="tag"><a href="https://quitter.se/tag/wannacry" target="_blank" rel="tag noopener noreferrer" title="https://quitter.se/tag/wannacry">Wannacry</a></span> herumfliegen? Ich will mal unter <br> <a href="https://github.com/qbi/WannaCry" target="_blank" rel="noopener noreferrer" title="https://github.com/qbi/WannaCry">https://github.com/qbi/WannaCry</a> was sammeln. !<a href="http://sn.jonkman.ca/group/416/id" target="_blank" rel="noopener noreferrer" title="http://sn.jonkman.ca/group/416/id">security</a> ') }
|
||||
|
||||
it 'parses out URLs' do
|
||||
expect(a_request(:get, 'https://github.com/qbi/WannaCry')).to have_been_made.at_least_once
|
||||
|
@@ -28,12 +28,12 @@ RSpec.describe VerifyLinkService, type: :service do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a link contains an <a rel="noopener"> back' do
|
||||
context 'when a link contains an <a rel="noopener noreferrer"> back' do
|
||||
let(:html) do
|
||||
<<-HTML
|
||||
<!doctype html>
|
||||
<body>
|
||||
<a href="#{ActivityPub::TagManager.instance.url_for(account)}" rel="noopener me" target="_blank">Follow me on Mastodon</a>
|
||||
<a href="#{ActivityPub::TagManager.instance.url_for(account)}" rel="me noopener noreferrer" target="_blank">Follow me on Mastodon</a>
|
||||
</body>
|
||||
HTML
|
||||
end
|
||||
|
Reference in New Issue
Block a user