mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Convert admin/invites
controller specs to system specs (#32450)
Some checks are pending
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
CSS Linting / 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
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
Some checks are pending
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
CSS Linting / 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
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
This commit is contained in:
parent
9e8f099d38
commit
c40cd79c4d
|
@ -1,4 +1,4 @@
|
|||
%tr
|
||||
%tr{ id: dom_id(invite) }
|
||||
%td
|
||||
.input-copy
|
||||
.input-copy__wrapper
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::InvitesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
subject { get :index, params: { available: true } }
|
||||
|
||||
let!(:invite) { Fabricate(:invite) }
|
||||
|
||||
it 'renders index page' do
|
||||
expect(subject).to render_template :index
|
||||
expect(response.body)
|
||||
.to include(invite.code)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
subject { post :create, params: { invite: { max_uses: '10', expires_in: 1800 } } }
|
||||
|
||||
it 'succeeds to create a invite' do
|
||||
expect { subject }.to change(Invite, :count).by(1)
|
||||
expect(subject).to redirect_to admin_invites_path
|
||||
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: invite.id } }
|
||||
|
||||
let!(:invite) { Fabricate(:invite, expires_at: nil) }
|
||||
|
||||
it 'expires invite' do
|
||||
expect(subject).to redirect_to admin_invites_path
|
||||
expect(invite.reload).to be_expired
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #deactivate_all' do
|
||||
before { Fabricate(:invite, expires_at: nil) }
|
||||
|
||||
it 'expires all invites, then redirects to admin_invites_path' do
|
||||
expect { post :deactivate_all }
|
||||
.to change { Invite.exists?(expires_at: nil) }
|
||||
.from(true)
|
||||
.to(false)
|
||||
|
||||
expect(response).to redirect_to admin_invites_path
|
||||
end
|
||||
end
|
||||
end
|
63
spec/system/admin/invites_spec.rb
Normal file
63
spec/system/admin/invites_spec.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Invites' do
|
||||
describe 'Invite interaction' do
|
||||
let!(:invite) { Fabricate(:invite, expires_at: nil) }
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it 'allows invite listing and creation' do
|
||||
visit admin_invites_path
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.invites.title'))
|
||||
for_invite(invite) do
|
||||
expect(find('input').value)
|
||||
.to include(invite.code)
|
||||
end
|
||||
|
||||
select I18n.t('invites.max_uses', count: 10), from: max_use_field
|
||||
|
||||
expect { generate_invite }
|
||||
.to change(Invite, :count).by(1)
|
||||
expect(user.invites.last)
|
||||
.to have_attributes(max_uses: 10)
|
||||
end
|
||||
|
||||
it 'allows invite expiration' do
|
||||
visit admin_invites_path
|
||||
|
||||
for_invite(invite) do
|
||||
expect { expire_invite }
|
||||
.to change { invite.reload.expired? }.from(false).to(true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'allows invite deactivation' do
|
||||
visit admin_invites_path
|
||||
|
||||
expect { click_on I18n.t('admin.invites.deactivate_all') }
|
||||
.to change { Invite.exists?(expires_at: nil) }.from(true).to(false)
|
||||
end
|
||||
|
||||
def for_invite(invite, &block)
|
||||
within("#invite_#{invite.id}", &block)
|
||||
end
|
||||
|
||||
def expire_invite
|
||||
click_on I18n.t('invites.delete')
|
||||
end
|
||||
|
||||
def generate_invite
|
||||
click_on I18n.t('invites.generate')
|
||||
end
|
||||
|
||||
def max_use_field
|
||||
I18n.t('simple_form.labels.defaults.max_uses')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user