Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 7c06474

Browse files
committed
Merge pull request #37 from codeclimate/fix_ca_file_path
Fix ca file absolute path.
2 parents 65f4c5f + 4221c54 commit 7c06474

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/cc/service/http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def http(options = {})
6565
#
6666
# Returns a String path.
6767
def ca_file
68-
@ca_file ||= File.expand_path('../../../config/cacert.pem', __FILE__)
68+
@ca_file ||= ENV.fetch("CODECLIMATE_CA_FILE", File.expand_path('../../../../config/cacert.pem', __FILE__))
6969
end
7070

7171
end

test/invocation_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def initialize
118118
def increment(key)
119119
@incremented_keys << key
120120
end
121+
122+
def timing(key, value)
123+
end
121124
end
122125

123126
class FakeLogger

test/service_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,18 @@ def test_validates_events
66
CC::Service.new(:foo, {}, {})
77
end
88
end
9+
10+
def test_default_path_to_ca_file
11+
s = CC::Service.new({}, {name: "test"})
12+
assert_equal(File.expand_path("../../config/cacert.pem", __FILE__), s.ca_file)
13+
assert File.exist?(s.ca_file)
14+
end
15+
16+
def test_custom_path_to_ca_file
17+
ENV["CODECLIMATE_CA_FILE"] = "/tmp/cacert.pem"
18+
s = CC::Service.new({}, {name: "test"})
19+
assert_equal("/tmp/cacert.pem", s.ca_file)
20+
ensure
21+
ENV.delete("CODECLIMATE_CA_FILE")
22+
end
923
end

0 commit comments

Comments
 (0)