[add] added query string support
This commit was merged in pull request #2.
This commit is contained in:
29
spec/support/request_spec_shared.rb
Normal file
29
spec/support/request_spec_shared.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.shared_examples 'POST /admin/client 201' do
|
||||
it 'creates client that can read/write and returns 201' do
|
||||
expect(json_response).not_to be_empty
|
||||
expect(json_response['name']).to eq valid_client[:name]
|
||||
expect(json_response['api_key'].length).to eq 82
|
||||
expect(response).to have_http_status(201)
|
||||
api_key = json_response['api_key']
|
||||
# check if request was parsed properly
|
||||
get "/admin/clients/#{valid_client[:name]}", headers: api_key_header(admin_client)
|
||||
expect(json_response).not_to be_empty
|
||||
expect(json_response['name']).to eq valid_client[:name]
|
||||
expect(json_response['description']).to eq valid_client[:description]
|
||||
expect(json_response['permission']).to eq valid_client[:permission]
|
||||
expect(json_response['public_ip']).to eq valid_client[:public_ip]
|
||||
expect(response).to have_http_status(200)
|
||||
# test the new client write
|
||||
put '/client', headers: api_key_header(nil, api_key)
|
||||
expect(json_response).not_to be_empty
|
||||
expect(response).to have_http_status(200)
|
||||
ipv4 = json_response['ipv4']
|
||||
# test the new client read
|
||||
get "/clients/#{valid_client[:name]}", headers: api_key_header(nil, api_key)
|
||||
expect(json_response).not_to be_empty
|
||||
expect(response).to have_http_status(200)
|
||||
expect(json_response['ipv4']).to eq ipv4
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user