diff options
Diffstat (limited to 'spec/requests/api/repositories_spec.rb')
-rw-r--r-- | spec/requests/api/repositories_spec.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index d3262b8056b..a576e1ab1ee 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -22,7 +22,7 @@ RSpec.describe API::Repositories do expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers - expect(json_response).to be_an Array + expect(json_response).to be_an(Array) first_commit = json_response.first expect(first_commit['name']).to eq('bar') @@ -73,6 +73,25 @@ RSpec.describe API::Repositories do end end end + + context 'keyset pagination mode' do + let(:first_response) do + get api(route, current_user), params: { pagination: "keyset" } + + Gitlab::Json.parse(response.body) + end + + it 'paginates using keysets' do + page_token = first_response.last["id"] + + get api(route, current_user), params: { pagination: "keyset", page_token: page_token } + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to be_an(Array) + expect(json_response).not_to eq(first_response) + expect(json_response.map { |t| t["id"] }).not_to include(page_token) + end + end end context 'when unauthenticated', 'and project is public' do @@ -354,6 +373,7 @@ RSpec.describe API::Repositories do expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present + expect(json_response['web_url']).to be_present end it "compares branches with explicit merge-base mode" do @@ -365,6 +385,7 @@ RSpec.describe API::Repositories do expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present + expect(json_response['web_url']).to be_present end it "compares branches with explicit straight mode" do @@ -376,6 +397,7 @@ RSpec.describe API::Repositories do expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present + expect(json_response['web_url']).to be_present end it "compares tags" do @@ -384,6 +406,7 @@ RSpec.describe API::Repositories do expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present + expect(json_response['web_url']).to be_present end it "compares commits" do @@ -393,6 +416,7 @@ RSpec.describe API::Repositories do expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_falsey + expect(json_response['web_url']).to be_present end it "compares commits in reverse order" do @@ -401,6 +425,7 @@ RSpec.describe API::Repositories do expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present + expect(json_response['web_url']).to be_present end it "compare commits between different projects with non-forked relation" do |