logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

instance_presenter_spec.rb (3049B)


  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. open_registrations = Setting.open_registrations
  29. example.run
  30. Setting.open_registrations = open_registrations
  31. end
  32. it "delegates open_registrations to Setting" do
  33. Setting.open_registrations = false
  34. expect(instance_presenter.open_registrations).to eq false
  35. end
  36. end
  37. context do
  38. around do |example|
  39. closed_registrations_message = Setting.closed_registrations_message
  40. example.run
  41. Setting.closed_registrations_message = closed_registrations_message
  42. end
  43. it "delegates closed_registrations_message to Setting" do
  44. Setting.closed_registrations_message = "Closed message"
  45. expect(instance_presenter.closed_registrations_message).to eq "Closed message"
  46. end
  47. end
  48. context do
  49. around do |example|
  50. site_contact_email = Setting.site_contact_email
  51. example.run
  52. Setting.site_contact_email = site_contact_email
  53. end
  54. it "delegates contact_email to Setting" do
  55. Setting.site_contact_email = "admin@example.com"
  56. expect(instance_presenter.site_contact_email).to eq "admin@example.com"
  57. end
  58. end
  59. describe "contact_account" do
  60. around do |example|
  61. site_contact_username = Setting.site_contact_username
  62. example.run
  63. Setting.site_contact_username = site_contact_username
  64. end
  65. it "returns the account for the site contact username" do
  66. Setting.site_contact_username = "aaa"
  67. account = Fabricate(:account, username: "aaa")
  68. expect(instance_presenter.contact_account).to eq(account)
  69. end
  70. end
  71. describe "user_count" do
  72. it "returns the number of site users" do
  73. Rails.cache.write 'user_count', 123
  74. expect(instance_presenter.user_count).to eq(123)
  75. end
  76. end
  77. describe "status_count" do
  78. it "returns the number of local statuses" do
  79. Rails.cache.write 'local_status_count', 234
  80. expect(instance_presenter.status_count).to eq(234)
  81. end
  82. end
  83. describe "domain_count" do
  84. it "returns the number of known domains" do
  85. Rails.cache.write 'distinct_domain_count', 345
  86. expect(instance_presenter.domain_count).to eq(345)
  87. end
  88. end
  89. end