1
0
Fork 0
forked from gitea/nas

Merge remote-tracking branch 'parent/main' into upstream-20231124

This commit is contained in:
KMY 2023-11-24 09:07:40 +09:00
commit c5e4020922
206 changed files with 1987 additions and 965 deletions

View file

@ -0,0 +1,35 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Admin Dimensions' do
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) }
describe 'GET /api/v1/admin/dimensions' do
context 'when not authorized' do
it 'returns http forbidden' do
post '/api/v1/admin/dimensions', params: { account_id: account.id, limit: 2 }
expect(response)
.to have_http_status(403)
end
end
context 'with correct scope' do
let(:scopes) { 'admin:read' }
it 'returns http success and status json' do
post '/api/v1/admin/dimensions', params: { account_id: account.id, limit: 2 }, headers: headers
expect(response)
.to have_http_status(200)
expect(body_as_json)
.to be_an(Array)
end
end
end
end

View file

@ -35,7 +35,7 @@ RSpec.describe 'Domain Allows' do
end
context 'when there are allowed domains' do
let!(:domain_allows) { Fabricate.times(5, :domain_allow) }
let!(:domain_allows) { Fabricate.times(2, :domain_allow) }
let(:expected_response) do
domain_allows.map do |domain_allow|
{
@ -53,7 +53,7 @@ RSpec.describe 'Domain Allows' do
end
context 'with limit param' do
let(:params) { { limit: 2 } }
let(:params) { { limit: 1 } }
it 'returns only the requested number of allowed domains' do
subject

View file

@ -0,0 +1,35 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Admin Measures' do
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) }
describe 'GET /api/v1/admin/measures' do
context 'when not authorized' do
it 'returns http forbidden' do
post '/api/v1/admin/measures', params: { account_id: account.id, limit: 2 }
expect(response)
.to have_http_status(403)
end
end
context 'with correct scope' do
let(:scopes) { 'admin:read' }
it 'returns http success and status json' do
post '/api/v1/admin/measures', params: { account_id: account.id, limit: 2 }, headers: headers
expect(response)
.to have_http_status(200)
expect(body_as_json)
.to be_an(Array)
end
end
end
end

View file

@ -0,0 +1,35 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Admin Retention' do
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) }
describe 'GET /api/v1/admin/retention' do
context 'when not authorized' do
it 'returns http forbidden' do
post '/api/v1/admin/retention', params: { account_id: account.id, limit: 2 }
expect(response)
.to have_http_status(403)
end
end
context 'with correct scope' do
let(:scopes) { 'admin:read' }
it 'returns http success and status json' do
post '/api/v1/admin/retention', params: { account_id: account.id, limit: 2 }, headers: headers
expect(response)
.to have_http_status(200)
expect(body_as_json)
.to be_an(Array)
end
end
end
end