Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/gitlab/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Client < API
include Tags
include Todos
include Users
include Versions

# Text representation of the client, masking private token.
#
Expand Down
18 changes: 18 additions & 0 deletions lib/gitlab/client/versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class Gitlab::Client
# Defines methods related to version
# @see https://docs.gitlab.com/ce/api/version.html
module Versions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to follow the existing pattern for API calls. Please let me know if there is a more appropriate location for this method call.

# Returns server version.
# @see https://docs.gitlab.com/ce/api/version.html
#
# @example
# Gitlab.version
#
# @return [Array<Gitlab::ObjectifiedHash>]
def version
get('/version')
end
end
end
4 changes: 4 additions & 0 deletions spec/fixtures/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "8.13.0-pre",
"revision": "4e963fe"
}
22 changes: 22 additions & 0 deletions spec/gitlab/client/versions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Client do
describe '.version' do
before do
stub_get('/version', 'version')
end

let!(:version) { Gitlab.version }

it 'gets the correct resource' do
expect(a_get('/version')).to have_been_made
end

it 'returns information about gitlab server' do
expect(version.version).to eq('8.13.0-pre')
expect(version.revision).to eq('4e963fe')
end
end
end