mastodon/spec/system/admin/rules_spec.rb
Claire aa04efb92a
Some checks are pending
Bundler Audit / security (push) Waiting to run
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
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (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
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-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.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (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.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (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.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Move server rule creation form to its own page (#34637)
2025-05-14 09:43:07 +00:00

86 lines
2.1 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Rules' do
describe 'Managing rules' do
before { sign_in Fabricate(:admin_user) }
describe 'Viewing rules' do
let!(:rule) { Fabricate :rule, text: 'This is a rule' }
it 'lists existing records' do
visit admin_rules_path
expect(page)
.to have_content(I18n.t('admin.rules.title'))
.and have_content(rule.text)
click_on(rule.text)
expect(page)
.to have_content(I18n.t('admin.rules.title'))
end
end
describe 'Creating a new rule' do
it 'creates new record with valid attributes' do
visit admin_rules_path
click_on I18n.t('admin.rules.add_new')
# Invalid submission
fill_in 'rule_text', with: ''
expect { submit_form }
.to_not change(Rule, :count)
expect(page)
.to have_content(/error below/)
# Valid submission
fill_in 'rule_text', with: 'No yelling on the bus!'
expect { submit_form }
.to change(Rule, :count).by(1)
expect(page)
.to have_content(I18n.t('admin.rules.title'))
end
def submit_form
click_on I18n.t('admin.rules.add_new')
end
end
describe 'Editing an existing rule' do
let!(:rule) { Fabricate :rule, text: 'Rule text' }
it 'updates with valid attributes' do
visit admin_rules_path
# Invalid submission
click_on rule.text
fill_in 'rule_text', with: ''
expect { submit_form }
.to_not change(rule.reload, :updated_at)
# Valid update
fill_in 'rule_text', with: 'What day is this?'
expect { submit_form }
.to(change { rule.reload.text })
end
def submit_form
click_on(submit_button)
end
end
describe 'Destroy a rule' do
let!(:rule) { Fabricate :rule }
it 'removes the record' do
visit admin_rules_path
expect { click_on I18n.t('admin.rules.delete') }
.to change { rule.reload.discarded? }.to(true)
end
end
end
end