about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-06-24 13:31:43 -0500
committerStarfall <us@starfall.systems>2022-06-24 13:31:43 -0500
commitd83f17f6763a1ffb3569eac73330cb09c557acea (patch)
tree92d392eed60a7d60bbd01e8544202db19a37e3d5 /spec
parentb9c901007b9a5772d2553a5770fa479954eec58f (diff)
parent63f79874b59b3ba28c0f940b9d36ea7aacb44c93 (diff)
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'spec')
-rw-r--r--spec/fabricators/webhook_fabricator.rb5
-rw-r--r--spec/helpers/application_helper_spec.rb7
-rw-r--r--spec/models/webhook_spec.rb32
-rw-r--r--spec/validators/url_validator_spec.rb2
4 files changed, 38 insertions, 8 deletions
diff --git a/spec/fabricators/webhook_fabricator.rb b/spec/fabricators/webhook_fabricator.rb
new file mode 100644
index 000000000..fa4f17b55
--- /dev/null
+++ b/spec/fabricators/webhook_fabricator.rb
@@ -0,0 +1,5 @@
+Fabricator(:webhook) do
+  url { Faker::Internet.url }
+  secret { SecureRandom.hex }
+  events { Webhook::EVENTS }
+end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index b9d38d8c6..20ee32aa0 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -59,13 +59,6 @@ describe ApplicationHelper do
     end
   end
 
-  describe 'favicon_path' do
-    it 'returns /favicon.ico on production environment' do
-      expect(Rails.env).to receive(:production?).and_return(true)
-      expect(helper.favicon_path).to eq '/favicon.ico'
-    end
-  end
-
   describe 'open_registrations?' do
     it 'returns true when open for registrations' do
       without_partial_double_verification do
diff --git a/spec/models/webhook_spec.rb b/spec/models/webhook_spec.rb
new file mode 100644
index 000000000..60c3d9524
--- /dev/null
+++ b/spec/models/webhook_spec.rb
@@ -0,0 +1,32 @@
+require 'rails_helper'
+
+RSpec.describe Webhook, type: :model do
+  let(:webhook) { Fabricate(:webhook) }
+
+  describe '#rotate_secret!' do
+    it 'changes the secret' do
+      previous_value = webhook.secret
+      webhook.rotate_secret!
+      expect(webhook.secret).to_not be_blank
+      expect(webhook.secret).to_not eq previous_value
+    end
+  end
+
+  describe '#enable!' do
+    before do
+      webhook.disable!
+    end
+
+    it 'enables the webhook' do
+      webhook.enable!
+      expect(webhook.enabled?).to be true
+    end
+  end
+
+  describe '#disable!' do
+    it 'disables the webhook' do
+      webhook.disable!
+      expect(webhook.enabled?).to be false
+    end
+  end
+end
diff --git a/spec/validators/url_validator_spec.rb b/spec/validators/url_validator_spec.rb
index a44878a44..85eadeb63 100644
--- a/spec/validators/url_validator_spec.rb
+++ b/spec/validators/url_validator_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe URLValidator, type: :validator do
       let(:compliant) { false }
 
       it 'calls errors.add' do
-        expect(errors).to have_received(:add).with(attribute, I18n.t('applications.invalid_url'))
+        expect(errors).to have_received(:add).with(attribute, :invalid)
       end
     end