summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <ash@the-rebellion.net>2018-07-19 13:36:44 +1000
committerAsh McKenzie <ash@the-rebellion.net>2018-07-20 22:28:58 +1000
commitdd4bd1d7342f6b32e651b84f0f181634f3ac00d4 (patch)
tree06bddee27e16376683abdf5c9e08815e8983a9e2
parent3042a7213fa9f15bd76ad3f0cd9837d6cdea7007 (diff)
downloadgitlab-shell-dd4bd1d7342f6b32e651b84f0f181634f3ac00d4.tar.gz
Add #base_api_endpoint for re-usability
-rw-r--r--lib/http_helper.rb6
-rw-r--r--spec/gitlab_net_spec.rb8
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/http_helper.rb b/lib/http_helper.rb
index b1a100e..305df48 100644
--- a/lib/http_helper.rb
+++ b/lib/http_helper.rb
@@ -7,8 +7,12 @@ module HTTPHelper
@config ||= GitlabConfig.new
end
+ def base_api_endpoint
+ "#{config.gitlab_url}/api/v4"
+ end
+
def host
- "#{config.gitlab_url}/api/v4/internal"
+ "#{base_api_endpoint}/internal"
end
def http_client_for(uri, options = {})
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index 8e06fa8..5e3b196 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -353,6 +353,14 @@ describe GitlabNet, vcr: true do
end
end
+ describe :base_api_endpoint do
+ let(:net) { GitlabNet.new }
+ subject { net.send :base_api_endpoint }
+
+ it { should include(net.send(:config).gitlab_url) }
+ it("uses API version 4") { should end_with("api/v4") }
+ end
+
describe :host do
let(:net) { GitlabNet.new }
subject { net.send :host }