[add] initial commit
This commit is contained in:
31
spec/support/request_spec_helper.rb
Normal file
31
spec/support/request_spec_helper.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RequestSpecHelper
|
||||
def json_response
|
||||
JSON.parse(response.body)
|
||||
end
|
||||
|
||||
def api_key_header(client, api_key = nil)
|
||||
api_key ||= [RynDNS::Application::API_KEY_PREFIX, client.name_id, client.description].join('.')
|
||||
{ RynDNS::Application::API_KEY_HEADER =>
|
||||
api_key }
|
||||
end
|
||||
|
||||
def parse_permission(perm_r, perm_w, perm_x)
|
||||
"#{'r' if perm_r}#{'w' if perm_w}#{'x' if perm_x}"
|
||||
end
|
||||
|
||||
def list_equals_db?(client_list)
|
||||
return false unless Client.count == client_list.count
|
||||
|
||||
client_list.each do |client|
|
||||
db_client = Client.find_by name: client[:name.to_s]
|
||||
return false unless db_client.description == client[:description.to_s] &&
|
||||
db_client.permission == client[:permission.to_s] &&
|
||||
db_client.public_ip == client[:public_ip.to_s] &&
|
||||
db_client.ipv4 == client[:ipv4.to_s]
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user