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