Skip to content

Commit

Permalink
fix(ruby): fix scripts client
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Oct 17, 2024
1 parent b7c35c1 commit 52b2fd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions service/lib/agama/http/clients/scripts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@

require "uri"
require "net/http"
require "json"

module Agama
module HTTP
module Clients
# HTTP client to interact with the scripts API.
class Scripts
def initialize
@base_url = "http://localhost/api"
@base_url = "http://localhost/api/"
end

# Runs the scripts
def run(group)
Net::HTTP.post(uri("/api/scripts/run"), group, headers)
Net::HTTP.post(uri("scripts/run"), group.to_json, headers)
end

private
Expand All @@ -44,8 +45,8 @@ def uri(path)

def headers
@headers = {
Accept: "application/json",
Authorization: "Bearer #{auth_token}"
"Content-Type": "application/json",
Authorization: "Bearer #{auth_token}"
}
end

Expand Down
6 changes: 3 additions & 3 deletions service/test/agama/http/clients/scripts_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
describe "#run" do
it "calls the end-point to run the scripts" do
url = URI("http://localhost/api/scripts/run")
expect(Net::HTTP).to receive(:post).with(url, "post", {
Accept: "application/json",
Authorization: "Bearer 123456"
expect(Net::HTTP).to receive(:post).with(url, "post".to_json, {
"Content-Type": "application/json",
Authorization: "Bearer 123456"
})
scripts.run("post")
end
Expand Down

0 comments on commit 52b2fd8

Please sign in to comment.