diff options
author | Rémy Coutable <remy@rymai.me> | 2018-06-13 10:41:00 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-06-13 10:41:00 +0300 |
commit | 886b81e5c71529f1d61c4de4c16aab6171e1600e (patch) | |
tree | ac93a814cbdb73c722eae6d671be36a3ebb98ad5 /spec/requests/api/commits_spec.rb | |
parent | a84cdff0dbb6a20a26c7e25a81f4bdf0a33b9bfc (diff) | |
parent | 404ef05002e067d057dabafb4945d79a49d028bc (diff) |
Merge branch 'commits_api_with_stats' into 'master'
Added with_stats option to GET /projects/:id/repository/commits (API)
See merge request gitlab-org/gitlab-ce!19484
Diffstat (limited to 'spec/requests/api/commits_spec.rb')
-rw-r--r-- | spec/requests/api/commits_spec.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 7e3277c4cab..e73d1a252f5 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -18,14 +18,14 @@ describe API::Commits do describe 'GET /projects/:id/repository/commits' do let(:route) { "/projects/#{project_id}/repository/commits" } - shared_examples_for 'project commits' do + shared_examples_for 'project commits' do |schema: 'public_api/v4/commits'| it "returns project commits" do commit = project.repository.commit get api(route, current_user) expect(response).to have_gitlab_http_status(200) - expect(response).to match_response_schema('public_api/v4/commits') + expect(response).to match_response_schema(schema) expect(json_response.first['id']).to eq(commit.id) expect(json_response.first['committer_name']).to eq(commit.committer_name) expect(json_response.first['committer_email']).to eq(commit.committer_email) @@ -161,6 +161,23 @@ describe API::Commits do end end + context 'with_stats optional parameter' do + let(:project) { create(:project, :public, :repository) } + + it_behaves_like 'project commits', schema: 'public_api/v4/commits_with_stats' do + let(:route) { "/projects/#{project_id}/repository/commits?with_stats=true" } + + it 'include commits details' do + commit = project.repository.commit + get api(route, current_user) + + expect(json_response.first['stats']['additions']).to eq(commit.stats.additions) + expect(json_response.first['stats']['deletions']).to eq(commit.stats.deletions) + expect(json_response.first['stats']['total']).to eq(commit.stats.total) + end + end + end + context 'with pagination params' do let(:page) { 1 } let(:per_page) { 5 } |