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.

74 lines
2.2 KiB

  1. require 'rails_helper'
  2. describe InstancePresenter do
  3. let(:instance_presenter) { InstancePresenter.new }
  4. it "delegates site_description to Setting" do
  5. Setting.site_description = "Site desc"
  6. expect(instance_presenter.site_description).to eq "Site desc"
  7. end
  8. it "delegates site_extended_description to Setting" do
  9. Setting.site_extended_description = "Extended desc"
  10. expect(instance_presenter.site_extended_description).to eq "Extended desc"
  11. end
  12. it "delegates open_registrations to Setting" do
  13. Setting.open_registrations = false
  14. expect(instance_presenter.open_registrations).to eq false
  15. end
  16. it "delegates closed_registrations_message to Setting" do
  17. Setting.closed_registrations_message = "Closed message"
  18. expect(instance_presenter.closed_registrations_message).to eq "Closed message"
  19. end
  20. it "delegates contact_email to Setting" do
  21. Setting.site_contact_email = "admin@example.com"
  22. expect(instance_presenter.site_contact_email).to eq "admin@example.com"
  23. end
  24. describe "contact_account" do
  25. it "returns the account for the site contact username" do
  26. Setting.site_contact_username = "aaa"
  27. account = Fabricate(:account, username: "aaa")
  28. expect(instance_presenter.contact_account).to eq(account)
  29. end
  30. end
  31. describe "user_count" do
  32. it "returns the number of site users" do
  33. cache = double
  34. allow(Rails).to receive(:cache).and_return(cache)
  35. allow(cache).to receive(:fetch).with("user_count").and_return(123)
  36. expect(instance_presenter.user_count).to eq(123)
  37. end
  38. end
  39. describe "status_count" do
  40. it "returns the number of local statuses" do
  41. cache = double
  42. allow(Rails).to receive(:cache).and_return(cache)
  43. allow(cache).to receive(:fetch).with("local_status_count").and_return(234)
  44. expect(instance_presenter.status_count).to eq(234)
  45. end
  46. end
  47. describe "domain_count" do
  48. it "returns the number of known domains" do
  49. cache = double
  50. allow(Rails).to receive(:cache).and_return(cache)
  51. allow(cache).to receive(:fetch).with("distinct_domain_count").and_return(345)
  52. expect(instance_presenter.domain_count).to eq(345)
  53. end
  54. end
  55. end