You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.1 KiB

  1. require 'rails_helper'
  2. describe InstancePresenter do
  3. let(:instance_presenter) { InstancePresenter.new }
  4. context do
  5. around do |example|
  6. site_description = Setting.site_description
  7. example.run
  8. Setting.site_description = site_description
  9. end
  10. it "delegates site_description to Setting" do
  11. Setting.site_description = "Site desc"
  12. expect(instance_presenter.site_description).to eq "Site desc"
  13. end
  14. end
  15. context do
  16. around do |example|
  17. site_extended_description = Setting.site_extended_description
  18. example.run
  19. Setting.site_extended_description = site_extended_description
  20. end
  21. it "delegates site_extended_description to Setting" do
  22. Setting.site_extended_description = "Extended desc"
  23. expect(instance_presenter.site_extended_description).to eq "Extended desc"
  24. end
  25. end
  26. context do
  27. around do |example|
  28. site_contact_email = Setting.site_contact_email
  29. example.run
  30. Setting.site_contact_email = site_contact_email
  31. end
  32. it "delegates contact_email to Setting" do
  33. Setting.site_contact_email = "admin@example.com"
  34. expect(instance_presenter.site_contact_email).to eq "admin@example.com"
  35. end
  36. end
  37. describe "contact_account" do
  38. around do |example|
  39. site_contact_username = Setting.site_contact_username
  40. example.run
  41. Setting.site_contact_username = site_contact_username
  42. end
  43. it "returns the account for the site contact username" do
  44. Setting.site_contact_username = "aaa"
  45. account = Fabricate(:account, username: "aaa")
  46. expect(instance_presenter.contact_account).to eq(account)
  47. end
  48. end
  49. describe "user_count" do
  50. it "returns the number of site users" do
  51. Rails.cache.write 'user_count', 123
  52. expect(instance_presenter.user_count).to eq(123)
  53. end
  54. end
  55. describe "status_count" do
  56. it "returns the number of local statuses" do
  57. Rails.cache.write 'local_status_count', 234
  58. expect(instance_presenter.status_count).to eq(234)
  59. end
  60. end
  61. describe "domain_count" do
  62. it "returns the number of known domains" do
  63. Rails.cache.write 'distinct_domain_count', 345
  64. expect(instance_presenter.domain_count).to eq(345)
  65. end
  66. end
  67. describe '#version_number' do
  68. it 'returns Mastodon::Version' do
  69. expect(instance_presenter.version_number).to be(Mastodon::Version)
  70. end
  71. end
  72. describe '#source_url' do
  73. it 'returns "https://github.com/glitch-soc/mastodon"' do
  74. expect(instance_presenter.source_url).to eq('https://github.com/glitch-soc/mastodon')
  75. end
  76. end
  77. describe '#thumbnail' do
  78. it 'returns SiteUpload' do
  79. thumbnail = Fabricate(:site_upload, var: 'thumbnail')
  80. expect(instance_presenter.thumbnail).to eq(thumbnail)
  81. end
  82. end
  83. describe '#hero' do
  84. it 'returns SiteUpload' do
  85. hero = Fabricate(:site_upload, var: 'hero')
  86. expect(instance_presenter.hero).to eq(hero)
  87. end
  88. end
  89. describe '#mascot' do
  90. it 'returns SiteUpload' do
  91. mascot = Fabricate(:site_upload, var: 'mascot')
  92. expect(instance_presenter.mascot).to eq(mascot)
  93. end
  94. end
  95. end