stitches 5.1.0.RC1 → 5.1.0.RC2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e87005e3080477f7dc3d927596ea5cdeab14f4b004cd20744894088866f5b2b
4
- data.tar.gz: e50f73f746ccc1b283bad98619f9a4e70a56f91c3f0e11faec66e375cfb7055f
3
+ metadata.gz: 74c049e2d66d366adce255f0fd8d41b6eb0e121669225b1fbce4dbd8ccb19b10
4
+ data.tar.gz: 8d8b6b8d5cc2e57b4e21a5a9097ccd14b462087c82ce6c30cfd2e6b4617c49c5
5
5
  SHA512:
6
- metadata.gz: 84cf005517476feb055dbb1d22142d3b17749a7cdd01cb1135de3c00c9d29ca40e034dd2ee23a5d259bcf346458e1aea12cef301145df583f587fb9038d38b63
7
- data.tar.gz: 4e592659a77f77ff2f6eb7c6d3b217ab6f36fd52dcf2fdaf3f16ad0e2950f7a8af69efa9a7c880d13100307aecf513c6eed4a1f31392ea1067a97ff9a21634b1
6
+ metadata.gz: 343c659a9e37f29caadad39b2c0d66496f164efea60e9a499daec8bb156fd5e90801af304d2bc0ac307c00ee4934b400ea4f22db4e7a996b9d7d114751a5a55c
7
+ data.tar.gz: dfaa3c860b35fbbbd44ba3c99d4ac1a1ce820de42393ddaa9d93cb12fb0062ad03d14cfb2a7f0ab64dfe5fa83ecd72271c30aa222923ba9fc5cecb35501d8311
data/README.md CHANGED
@@ -72,7 +72,7 @@ end
72
72
 
73
73
  1. `X-StitchFix-Calling-Service` request header (preferred)
74
74
  2. `api_client&.name` — the stitches-authenticated ApiClient (works when API keys are enabled)
75
- 3. `"N/A"` — fallback when neither is available
75
+ 3. `""` (empty string) — fallback when neither is available
76
76
 
77
77
  This is backwards compatible. When `disable_api_key_support` is false, the
78
78
  stitches middleware still populates `api_client`, so the fallback returns the
@@ -5,8 +5,8 @@ module Stitches
5
5
  def calling_service_name
6
6
  @calling_service_name ||=
7
7
  request.headers[HEADER].presence ||
8
- api_client&.name ||
9
- "N/A"
8
+ (respond_to?(:api_client, true) && api_client&.name) ||
9
+ ""
10
10
  end
11
11
  end
12
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stitches
4
- VERSION = '5.1.0.RC1'
4
+ VERSION = '5.1.0.RC2'
5
5
  end
@@ -50,15 +50,37 @@ describe Stitches::CallingServiceName do
50
50
 
51
51
  context "when neither header nor api_client is present" do
52
52
  it "returns 'unknown'" do
53
- expect(fake_controller.calling_service_name).to eq("N/A")
53
+ expect(fake_controller.calling_service_name).to eq("")
54
54
  end
55
55
  end
56
56
 
57
57
  context "when api_client is nil" do
58
58
  let(:fake_api_client) { nil }
59
59
 
60
- it "returns 'unknown'" do
61
- expect(fake_controller.calling_service_name).to eq("N/A")
60
+ it "returns empty string" do
61
+ expect(fake_controller.calling_service_name).to eq("")
62
+ end
63
+ end
64
+
65
+ context "when api_client method is not defined" do
66
+ let(:fake_controller) {
67
+ req = fake_request
68
+ Object.new.tap { |c|
69
+ c.extend(described_class)
70
+ c.define_singleton_method(:request) { req }
71
+ }
72
+ }
73
+
74
+ it "returns empty string" do
75
+ expect(fake_controller.calling_service_name).to eq("")
76
+ end
77
+
78
+ context "and header is present" do
79
+ let(:headers) { {"X-StitchFix-Calling-Service" => "fixops"} }
80
+
81
+ it "returns the header value" do
82
+ expect(fake_controller.calling_service_name).to eq("fixops")
83
+ end
62
84
  end
63
85
  end
64
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stitches
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0.RC1
4
+ version: 5.1.0.RC2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stitch Fix Engineering