2017-04-09 08:47:25 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe InstancePresenter do
|
|
|
|
let(:instance_presenter) { InstancePresenter.new }
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#description' do
|
2017-05-30 09:03:35 -04:00
|
|
|
around do |example|
|
2022-10-04 21:47:56 -04:00
|
|
|
site_description = Setting.site_short_description
|
2017-05-30 09:03:35 -04:00
|
|
|
example.run
|
2022-10-04 21:47:56 -04:00
|
|
|
Setting.site_short_description = site_description
|
2017-05-30 09:03:35 -04:00
|
|
|
end
|
2017-04-09 08:47:25 -04:00
|
|
|
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'delegates site_description to Setting' do
|
|
|
|
Setting.site_short_description = 'Site desc'
|
|
|
|
expect(instance_presenter.description).to eq 'Site desc'
|
2017-05-30 09:03:35 -04:00
|
|
|
end
|
2017-04-09 08:47:25 -04:00
|
|
|
end
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#extended_description' do
|
2017-05-30 09:03:35 -04:00
|
|
|
around do |example|
|
|
|
|
site_extended_description = Setting.site_extended_description
|
|
|
|
example.run
|
|
|
|
Setting.site_extended_description = site_extended_description
|
|
|
|
end
|
|
|
|
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'delegates site_extended_description to Setting' do
|
|
|
|
Setting.site_extended_description = 'Extended desc'
|
|
|
|
expect(instance_presenter.extended_description).to eq 'Extended desc'
|
2017-05-30 09:03:35 -04:00
|
|
|
end
|
2017-04-09 08:47:25 -04:00
|
|
|
end
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#email' do
|
2017-05-30 09:03:35 -04:00
|
|
|
around do |example|
|
|
|
|
site_contact_email = Setting.site_contact_email
|
|
|
|
example.run
|
|
|
|
Setting.site_contact_email = site_contact_email
|
|
|
|
end
|
|
|
|
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'delegates contact_email to Setting' do
|
|
|
|
Setting.site_contact_email = 'admin@example.com'
|
|
|
|
expect(instance_presenter.contact.email).to eq 'admin@example.com'
|
2017-05-30 09:03:35 -04:00
|
|
|
end
|
2017-04-09 08:47:25 -04:00
|
|
|
end
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#account' do
|
2017-05-30 09:03:35 -04:00
|
|
|
around do |example|
|
|
|
|
site_contact_username = Setting.site_contact_username
|
|
|
|
example.run
|
|
|
|
Setting.site_contact_username = site_contact_username
|
|
|
|
end
|
|
|
|
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'returns the account for the site contact username' do
|
|
|
|
Setting.site_contact_username = 'aaa'
|
|
|
|
account = Fabricate(:account, username: 'aaa')
|
2022-10-04 21:47:56 -04:00
|
|
|
expect(instance_presenter.contact.account).to eq(account)
|
2017-04-09 08:47:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#user_count' do
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'returns the number of site users' do
|
2018-02-17 16:35:05 -05:00
|
|
|
Rails.cache.write 'user_count', 123
|
2017-04-09 08:47:25 -04:00
|
|
|
|
|
|
|
expect(instance_presenter.user_count).to eq(123)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#status_count' do
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'returns the number of local statuses' do
|
2018-02-17 16:35:05 -05:00
|
|
|
Rails.cache.write 'local_status_count', 234
|
2017-04-09 08:47:25 -04:00
|
|
|
|
|
|
|
expect(instance_presenter.status_count).to eq(234)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#domain_count' do
|
2023-02-18 17:38:14 -05:00
|
|
|
it 'returns the number of known domains' do
|
2018-02-17 16:35:05 -05:00
|
|
|
Rails.cache.write 'distinct_domain_count', 345
|
2017-04-09 08:47:25 -04:00
|
|
|
|
|
|
|
expect(instance_presenter.domain_count).to eq(345)
|
|
|
|
end
|
|
|
|
end
|
2018-12-21 02:59:56 -05:00
|
|
|
|
2022-10-04 21:47:56 -04:00
|
|
|
describe '#version' do
|
|
|
|
it 'returns string' do
|
|
|
|
expect(instance_presenter.version).to be_a String
|
2018-12-21 02:59:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#source_url' do
|
2021-07-13 09:46:20 -04:00
|
|
|
it 'returns "https://github.com/mastodon/mastodon"' do
|
|
|
|
expect(instance_presenter.source_url).to eq('https://github.com/mastodon/mastodon')
|
2018-12-21 02:59:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#thumbnail' do
|
|
|
|
it 'returns SiteUpload' do
|
|
|
|
thumbnail = Fabricate(:site_upload, var: 'thumbnail')
|
|
|
|
expect(instance_presenter.thumbnail).to eq(thumbnail)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#mascot' do
|
|
|
|
it 'returns SiteUpload' do
|
|
|
|
mascot = Fabricate(:site_upload, var: 'mascot')
|
|
|
|
expect(instance_presenter.mascot).to eq(mascot)
|
|
|
|
end
|
|
|
|
end
|
2017-04-09 08:47:25 -04:00
|
|
|
end
|