API v1 specs for user, config and navigation endpoints
This commit is contained in:
parent
900cc91197
commit
02f1940694
3 changed files with 124 additions and 2 deletions
|
|
@ -13,7 +13,37 @@ describe 'API v1', type: :apivore, order: :defined do
|
|||
|
||||
subject { SwaggerCheckerFile.instance_for Rails.root.join('doc', 'swagger.v1.yml') }
|
||||
|
||||
it 'tests all documented routes' do
|
||||
is_expected.to validate_all_paths
|
||||
context 'has valid paths' do
|
||||
context 'user' do
|
||||
# create multiple users to make sure we're getting the authenticated user, not just any
|
||||
let!(:other_user_1) { create :user }
|
||||
let!(:user) { create :user }
|
||||
let!(:other_user_2) { create :user }
|
||||
|
||||
it { is_expected.to validate(:get, '/user', 200, api_auth) }
|
||||
it { is_expected.to validate(:get, '/user', 401) }
|
||||
|
||||
context 'with invalid access token' do
|
||||
let(:api_access_token) { 'abc' }
|
||||
it { is_expected.to validate(:get, '/user', 401, api_auth) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'config' do
|
||||
it { is_expected.to validate(:get, '/config', 200, api_auth) }
|
||||
it { is_expected.to validate(:get, '/config', 401) }
|
||||
end
|
||||
|
||||
context 'navigation' do
|
||||
it { is_expected.to validate(:get, '/navigation', 200, api_auth) }
|
||||
it { is_expected.to validate(:get, '/navigation', 401) }
|
||||
end
|
||||
end
|
||||
|
||||
# needs to be last context so it is always run at the end
|
||||
context 'and finally' do
|
||||
it 'tests all documented routes' do
|
||||
is_expected.to validate_all_paths
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ FactoryBot.define do
|
|||
create :workgroup, role_admin: true, user_ids: [user.id]
|
||||
end
|
||||
end
|
||||
|
||||
trait :ordergroup do
|
||||
after :create do |user, evaluator|
|
||||
create :ordergroup, user_ids: [user.id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
factory :group do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue