about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2023-03-09 08:27:48 -0500
committerGitHub <noreply@github.com>2023-03-09 14:27:48 +0100
commit2f7a663b0bccd7b5de1fa47b89a7bdc7591e69ec (patch)
tree6e2872ee1d4f071c8dbe78ea0c636b44e3c2c743
parent684a970b3c7ce19ec419c4db52b67a3b0903f493 (diff)
Explicitly set github repo in instance presenter spec (#24036)
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock1
-rw-r--r--spec/presenters/instance_presenter_spec.rb24
3 files changed, 24 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile
index eaaf1bf1f..7a836b6ba 100644
--- a/Gemfile
+++ b/Gemfile
@@ -117,6 +117,7 @@ end
 
 group :test do
   gem 'capybara', '~> 3.38'
+  gem 'climate_control'
   gem 'faker', '~> 3.1'
   gem 'json-schema', '~> 3.0'
   gem 'rack-test', '~> 2.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index bd1aece57..e5ad5bfe5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -784,6 +784,7 @@ DEPENDENCIES
   capybara (~> 3.38)
   charlock_holmes (~> 0.7.7)
   chewy (~> 7.2)
+  climate_control
   cocoon (~> 1.2)
   color_diff (~> 0.1)
   concurrent-ruby
diff --git a/spec/presenters/instance_presenter_spec.rb b/spec/presenters/instance_presenter_spec.rb
index 29170a79a..795abd8b4 100644
--- a/spec/presenters/instance_presenter_spec.rb
+++ b/spec/presenters/instance_presenter_spec.rb
@@ -89,8 +89,28 @@ describe InstancePresenter do
   end
 
   describe '#source_url' do
-    it 'returns "https://github.com/mastodon/mastodon"' do
-      expect(instance_presenter.source_url).to eq('https://github.com/mastodon/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 mastodon repo URL' do
+        expect(instance_presenter.source_url).to eq('https://github.com/mastodon/mastodon')
+      end
     end
   end