mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
b7bb850efd
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
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
80 lines
1.8 KiB
Ruby
80 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe 'Invites' do
|
|
include ActionView::RecordIdentifier
|
|
|
|
let(:user) { Fabricate :user }
|
|
|
|
before { sign_in user }
|
|
|
|
describe 'Viewing invites' do
|
|
it 'Lists existing user invites' do
|
|
invite = Fabricate :invite, user: user
|
|
|
|
visit invites_path
|
|
|
|
within css_id(invite) do
|
|
expect(page)
|
|
.to have_content(invite.uses)
|
|
.and have_private_cache_control
|
|
expect(copyable_field.value)
|
|
.to eq(public_invite_url(invite_code: invite.code))
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'Creating a new invite' do
|
|
it 'Saves the invite for the user' do
|
|
visit invites_path
|
|
|
|
fill_invite_form
|
|
|
|
expect { submit_form }
|
|
.to change(user.invites, :count).by(1)
|
|
end
|
|
end
|
|
|
|
describe 'Deleting an existing invite' do
|
|
it 'Expires the invite' do
|
|
invite = Fabricate :invite, user: user
|
|
|
|
visit invites_path
|
|
|
|
expect { delete_invite(invite) }
|
|
.to change { invite.reload.expired? }.to(true)
|
|
|
|
within css_id(invite) do
|
|
expect(page).to have_content I18n.t('invites.expired')
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def copyable_field
|
|
within '.input-copy' do
|
|
find(:field, type: :text, readonly: true)
|
|
end
|
|
end
|
|
|
|
def submit_form
|
|
click_on I18n.t('invites.generate')
|
|
end
|
|
|
|
def delete_invite(invite)
|
|
within css_id(invite) do
|
|
click_on I18n.t('invites.delete')
|
|
end
|
|
end
|
|
|
|
def fill_invite_form
|
|
select I18n.t('invites.max_uses', count: 100),
|
|
from: I18n.t('simple_form.labels.defaults.max_uses')
|
|
select I18n.t("invites.expires_in.#{30.minutes.to_i}"),
|
|
from: I18n.t('simple_form.labels.defaults.expires_in')
|
|
check I18n.t('simple_form.labels.defaults.autofollow')
|
|
end
|
|
end
|