Skip to content

Commit afdacb0

Browse files
committed
Make sure manifest is generated in a detached context
1 parent b799e21 commit afdacb0

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.0.14] - 2025-02-02
2+
3+
- Put manifest into detached context by default
4+
15
## [0.0.12] - 2025-01-28
26

37
- Fix potential issue with default serializer inheritance/overriding

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-http-command-connector (0.0.12)
4+
foobara-http-command-connector (0.0.14)
55
foobara
66

77
GEM
@@ -54,7 +54,7 @@ GEM
5454
foobara-type-generator
5555
foobara-typescript-react-command-form-generator
5656
foobara-typescript-remote-command-generator
57-
foobara (0.0.51)
57+
foobara (0.0.55)
5858
bigdecimal
5959
foobara-util
6060
foobara-autocrud-generator (0.0.1)
@@ -188,14 +188,14 @@ GEM
188188
diff-lcs (>= 1.2.0, < 2.0)
189189
rspec-support (~> 3.13.0)
190190
rspec-support (3.13.2)
191-
rubocop (1.71.0)
191+
rubocop (1.71.1)
192192
json (~> 2.3)
193193
language_server-protocol (>= 3.17.0)
194194
parallel (~> 1.10)
195195
parser (>= 3.3.0.2)
196196
rainbow (>= 2.2.2, < 4.0)
197197
regexp_parser (>= 2.9.3, < 3.0)
198-
rubocop-ast (>= 1.36.2, < 2.0)
198+
rubocop-ast (>= 1.38.0, < 2.0)
199199
ruby-progressbar (~> 1.7)
200200
unicode-display_width (>= 2.4.0, < 4.0)
201201
rubocop-ast (1.38.0)
@@ -260,4 +260,4 @@ RUBY VERSION
260260
ruby 3.4.1p0
261261

262262
BUNDLED WITH
263-
2.6.2
263+
2.6.3

spec/foobara/command_connectors_http/http_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ def compute
154154
expect(manifest[:organization].keys).to match_array(%i[SomeOrg global_organization])
155155
expect(manifest[:command][:"SomeOrg::SomeDomain::SomeCommand"][:description]).to eq("just some command")
156156
end
157+
158+
context "when generating manifest via Describe" do
159+
let(:request) { described_class::Request.new(path: "/manifest") }
160+
161+
it "includes the organization" do
162+
manifest = described_class::Commands::Describe.run!(
163+
manifestable: command_connector,
164+
request:,
165+
detached: false
166+
)
167+
168+
expect(manifest[:organization].keys).to match_array(%i[SomeOrg global_organization])
169+
expect(manifest[:command][:"SomeOrg::SomeDomain::SomeCommand"][:description]).to eq("just some command")
170+
end
171+
end
157172
end
158173
end
159174
end
@@ -965,6 +980,8 @@ def transform(result)
965980

966981
context "with describe path" do
967982
let(:path) { "/describe/ComputeExponent" }
983+
let(:query_string) { "" }
984+
let(:body) { "" }
968985

969986
it "describes the command" do
970987
expect(response.status).to be(200)

src/http/commands/describe.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,33 @@ module CommandConnectors
33
class Http < Foobara::CommandConnector
44
module Commands
55
class Describe < Foobara::CommandConnector::Commands::Describe
6+
inputs do
7+
manifestable :duck
8+
request :duck
9+
detached :boolean, default: true
10+
end
11+
612
def stamp_request_metadata
713
manifest[:metadata] = super.merge(url: request.url)
814
end
15+
16+
def in_detached_context(&)
17+
Thread.foobara_with_var("foobara_manifest_context", detached: true, &)
18+
end
19+
20+
def build_manifest
21+
if detached_context?
22+
in_detached_context do
23+
super
24+
end
25+
else
26+
super
27+
end
28+
end
29+
30+
def detached_context?
31+
detached
32+
end
933
end
1034
end
1135
end

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Foobara
22
module HttpCommandConnector
3-
VERSION = "0.0.12".freeze
3+
VERSION = "0.0.14".freeze
44

55
local_ruby_version = File.read("#{__dir__}/.ruby-version").chomp
66
local_ruby_version_minor = local_ruby_version[/\A(\d+\.\d+)\.\d+\z/, 1]

0 commit comments

Comments
 (0)