mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
5acec087ca
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.1) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.1) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.1) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.1, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
CSS Linting / lint (push) Has been cancelled
59 lines
1.4 KiB
Ruby
59 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Webhook do
|
|
let(:webhook) { Fabricate(:webhook) }
|
|
|
|
describe 'Validations' do
|
|
it { is_expected.to validate_presence_of(:events) }
|
|
|
|
it 'requires non-empty events value' do
|
|
record = described_class.new(events: [])
|
|
record.valid?
|
|
|
|
expect(record).to model_have_error_on_field(:events)
|
|
end
|
|
|
|
it 'requires valid events value from EVENTS' do
|
|
record = described_class.new(events: ['account.invalid'])
|
|
record.valid?
|
|
|
|
expect(record).to model_have_error_on_field(:events)
|
|
end
|
|
end
|
|
|
|
describe 'Normalizations' do
|
|
describe 'events' do
|
|
it { is_expected.to normalize(:events).from(['account.approved', 'account.created ', '']).to(%w(account.approved account.created)) }
|
|
end
|
|
end
|
|
|
|
describe '#rotate_secret!' do
|
|
it 'changes the secret' do
|
|
expect { webhook.rotate_secret! }
|
|
.to change(webhook, :secret)
|
|
expect(webhook.secret)
|
|
.to_not be_blank
|
|
end
|
|
end
|
|
|
|
describe '#enable!' do
|
|
let(:webhook) { Fabricate(:webhook, enabled: false) }
|
|
|
|
it 'enables the webhook' do
|
|
expect { webhook.enable! }
|
|
.to change(webhook, :enabled?).to(true)
|
|
end
|
|
end
|
|
|
|
describe '#disable!' do
|
|
let(:webhook) { Fabricate(:webhook, enabled: true) }
|
|
|
|
it 'disables the webhook' do
|
|
expect { webhook.disable! }
|
|
.to change(webhook, :enabled?).to(false)
|
|
end
|
|
end
|
|
end
|