about summary refs log tree commit diff
path: root/spec/presenters
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2023-04-14 19:22:47 -0500
committerStarfall <us@starfall.systems>2023-04-14 19:22:47 -0500
commit4fe1689de43f4404eb9530fcfbcbfb26d6c1c13a (patch)
tree6811b845bb7f4966b10dcefa3dea404246f161c7 /spec/presenters
parent65c1e53a32cabcdbb7bca57002bb0f6acdebe07e (diff)
parentbed63f6dae0879ac840066b031229e0d139089cd (diff)
Merge remote-tracking branch 'glitch/main' HEAD main
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/familiar_followers_presenter_spec.rb4
-rw-r--r--spec/presenters/instance_presenter_spec.rb58
2 files changed, 42 insertions, 20 deletions
diff --git a/spec/presenters/familiar_followers_presenter_spec.rb b/spec/presenters/familiar_followers_presenter_spec.rb
index 17be4b971..607e3002f 100644
--- a/spec/presenters/familiar_followers_presenter_spec.rb
+++ b/spec/presenters/familiar_followers_presenter_spec.rb
@@ -4,12 +4,12 @@ require 'rails_helper'
 
 RSpec.describe FamiliarFollowersPresenter do
   describe '#accounts' do
+    subject { described_class.new(requested_accounts, account.id) }
+
     let(:account) { Fabricate(:account) }
     let(:familiar_follower) { Fabricate(:account) }
     let(:requested_accounts) { Fabricate.times(2, :account) }
 
-    subject { described_class.new(requested_accounts, account.id) }
-
     before do
       familiar_follower.follow!(requested_accounts.first)
       account.follow!(familiar_follower)
diff --git a/spec/presenters/instance_presenter_spec.rb b/spec/presenters/instance_presenter_spec.rb
index f4c415d2f..f20dce593 100644
--- a/spec/presenters/instance_presenter_spec.rb
+++ b/spec/presenters/instance_presenter_spec.rb
@@ -1,7 +1,9 @@
+# frozen_string_literal: true
+
 require 'rails_helper'
 
 describe InstancePresenter do
-  let(:instance_presenter) { InstancePresenter.new }
+  let(:instance_presenter) { described_class.new }
 
   describe '#description' do
     around do |example|
@@ -10,9 +12,9 @@ describe InstancePresenter do
       Setting.site_short_description = site_description
     end
 
-    it "delegates site_description to Setting" do
-      Setting.site_short_description = "Site desc"
-      expect(instance_presenter.description).to eq "Site desc"
+    it 'delegates site_description to Setting' do
+      Setting.site_short_description = 'Site desc'
+      expect(instance_presenter.description).to eq 'Site desc'
     end
   end
 
@@ -23,9 +25,9 @@ describe InstancePresenter do
       Setting.site_extended_description = site_extended_description
     end
 
-    it "delegates site_extended_description to Setting" do
-      Setting.site_extended_description = "Extended desc"
-      expect(instance_presenter.extended_description).to eq "Extended desc"
+    it 'delegates site_extended_description to Setting' do
+      Setting.site_extended_description = 'Extended desc'
+      expect(instance_presenter.extended_description).to eq 'Extended desc'
     end
   end
 
@@ -36,9 +38,9 @@ describe InstancePresenter do
       Setting.site_contact_email = site_contact_email
     end
 
-    it "delegates contact_email to Setting" do
-      Setting.site_contact_email = "admin@example.com"
-      expect(instance_presenter.contact.email).to eq "admin@example.com"
+    it 'delegates contact_email to Setting' do
+      Setting.site_contact_email = 'admin@example.com'
+      expect(instance_presenter.contact.email).to eq 'admin@example.com'
     end
   end
 
@@ -49,15 +51,15 @@ describe InstancePresenter do
       Setting.site_contact_username = site_contact_username
     end
 
-    it "returns the account for the site contact username" do
-      Setting.site_contact_username = "aaa"
-      account = Fabricate(:account, username: "aaa")
+    it 'returns the account for the site contact username' do
+      Setting.site_contact_username = 'aaa'
+      account = Fabricate(:account, username: 'aaa')
       expect(instance_presenter.contact.account).to eq(account)
     end
   end
 
   describe '#user_count' do
-    it "returns the number of site users" do
+    it 'returns the number of site users' do
       Rails.cache.write 'user_count', 123
 
       expect(instance_presenter.user_count).to eq(123)
@@ -65,7 +67,7 @@ describe InstancePresenter do
   end
 
   describe '#status_count' do
-    it "returns the number of local statuses" do
+    it 'returns the number of local statuses' do
       Rails.cache.write 'local_status_count', 234
 
       expect(instance_presenter.status_count).to eq(234)
@@ -73,7 +75,7 @@ describe InstancePresenter do
   end
 
   describe '#domain_count' do
-    it "returns the number of known domains" do
+    it 'returns the number of known domains' do
       Rails.cache.write 'distinct_domain_count', 345
 
       expect(instance_presenter.domain_count).to eq(345)
@@ -87,8 +89,28 @@ describe InstancePresenter do
   end
 
   describe '#source_url' do
-    it 'returns "https://github.com/glitch-soc/mastodon"' do
-      expect(instance_presenter.source_url).to eq('https://github.com/glitch-soc/mastodon')
+    context 'with the GITHUB_REPOSITORY env variable set' do
+      around do |example|
+        ClimateControl.modify GITHUB_REPOSITORY: 'other/repo' do
+          example.run
+        end
+      end
+
+      it 'uses the env variable to build a repo URL' do
+        expect(instance_presenter.source_url).to eq('https://github.com/other/repo')
+      end
+    end
+
+    context 'without the GITHUB_REPOSITORY env variable set' do
+      around do |example|
+        ClimateControl.modify GITHUB_REPOSITORY: nil do
+          example.run
+        end
+      end
+
+      it 'defaults to the core glitch-soc repo URL' do
+        expect(instance_presenter.source_url).to eq('https://github.com/glitch-soc/mastodon')
+      end
     end
   end