1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Fix specs

This commit is contained in:
Emelia Smith 2024-07-27 17:31:14 +02:00
parent becc24a3b1
commit 48fafc7389
No known key found for this signature in database
2 changed files with 25 additions and 4 deletions

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe REST::AccountSerializer do
subject { serialized_record_json(account, described_class) }
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: true) }
let(:user) { Fabricate(:user, role: role) }
let(:account) { user.account }
@ -20,10 +20,10 @@ describe REST::AccountSerializer do
end
context 'when the account has a highlighted role' do
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: true) }
it 'returns the expected role' do
expect(subject['roles'].first).to include({ 'name' => 'Role' })
expect(subject['roles'].first).to include({ 'name' => 'Fancy User' })
end
it 'does not expose the roles permissions' do
@ -32,7 +32,7 @@ describe REST::AccountSerializer do
end
context 'when the account has a non-highlighted role' do
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: false) }
let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: false) }
it 'returns empty roles' do
expect(subject['roles']).to eq []

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe REST::CredentialAccountSerializer do
subject { serialized_record_json(account, described_class) }
let(:role) { Fabricate(:user_role, name: 'Fancy User') }
let(:user) { Fabricate(:user, role: role) }
let(:account) { user.account }
context 'when the account has a role' do
it 'returns the expected role' do
expect(subject['roles'].first).to include({ 'name' => 'Fancy User' })
end
it 'exposes the role permissions' do
expect(subject['roles'].first).to include({ 'permissions' => role.computed_permissions.to_s })
end
end
end