mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-08-18 05:54:57 +00:00
* spelling: account Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: affiliated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: appearance Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: autosuggest Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: cacheable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: component Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: conversations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: domain.example Clarify what's distinct and use RFC friendly domain space. Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: environment Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: exceeds Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: functional Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: inefficiency Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: not Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: notifications Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: occurring Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: position Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: progress Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: promotable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: reblogging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: repetitive Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: resolve Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: saturated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: similar Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: strategies Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: success Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: targeting Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: thumbnails Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unauthorized Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unsensitizes Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: validations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: various Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
87 lines
2.7 KiB
Ruby
87 lines
2.7 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe TagManager do
|
|
describe '#local_domain?' do
|
|
# The following comparisons MUST be case-insensitive.
|
|
|
|
around do |example|
|
|
original_local_domain = Rails.configuration.x.local_domain
|
|
Rails.configuration.x.local_domain = 'domain.example.com'
|
|
|
|
example.run
|
|
|
|
Rails.configuration.x.local_domain = original_local_domain
|
|
end
|
|
|
|
it 'returns true for nil' do
|
|
expect(TagManager.instance.local_domain?(nil)).to eq true
|
|
end
|
|
|
|
it 'returns true if the slash-stripped string equals to local domain' do
|
|
expect(TagManager.instance.local_domain?('DoMaIn.Example.com/')).to eq true
|
|
end
|
|
|
|
it 'returns false for irrelevant string' do
|
|
expect(TagManager.instance.local_domain?('DoMaIn.Example.com!')).to eq false
|
|
end
|
|
end
|
|
|
|
describe '#web_domain?' do
|
|
# The following comparisons MUST be case-insensitive.
|
|
|
|
around do |example|
|
|
original_web_domain = Rails.configuration.x.web_domain
|
|
Rails.configuration.x.web_domain = 'domain.example.com'
|
|
|
|
example.run
|
|
|
|
Rails.configuration.x.web_domain = original_web_domain
|
|
end
|
|
|
|
it 'returns true for nil' do
|
|
expect(TagManager.instance.web_domain?(nil)).to eq true
|
|
end
|
|
|
|
it 'returns true if the slash-stripped string equals to web domain' do
|
|
expect(TagManager.instance.web_domain?('DoMaIn.Example.com/')).to eq true
|
|
end
|
|
|
|
it 'returns false for string with irrelevant characters' do
|
|
expect(TagManager.instance.web_domain?('DoMaIn.Example.com!')).to eq false
|
|
end
|
|
end
|
|
|
|
describe '#normalize_domain' do
|
|
it 'returns nil if the given parameter is nil' do
|
|
expect(TagManager.instance.normalize_domain(nil)).to eq nil
|
|
end
|
|
|
|
it 'returns normalized domain' do
|
|
expect(TagManager.instance.normalize_domain('DoMaIn.Example.com/')).to eq 'domain.example.com'
|
|
end
|
|
end
|
|
|
|
describe '#local_url?' do
|
|
around do |example|
|
|
original_web_domain = Rails.configuration.x.web_domain
|
|
example.run
|
|
Rails.configuration.x.web_domain = original_web_domain
|
|
end
|
|
|
|
it 'returns true if the normalized string with port is local URL' do
|
|
Rails.configuration.x.web_domain = 'domain.example.com:42'
|
|
expect(TagManager.instance.local_url?('https://DoMaIn.Example.com:42/')).to eq true
|
|
end
|
|
|
|
it 'returns true if the normalized string without port is local URL' do
|
|
Rails.configuration.x.web_domain = 'domain.example.com'
|
|
expect(TagManager.instance.local_url?('https://DoMaIn.Example.com/')).to eq true
|
|
end
|
|
|
|
it 'returns false for string with irrelevant characters' do
|
|
Rails.configuration.x.web_domain = 'domain.example.com'
|
|
expect(TagManager.instance.local_url?('https://domain.example.net/')).to eq false
|
|
end
|
|
end
|
|
end
|