From 55f322085d0507640366b7a774fe7819771ff54b Mon Sep 17 00:00:00 2001 From: Jacopo Date: Sat, 18 Nov 2017 15:06:55 +0100 Subject: Adds ordering to projects contributors in API Allows ordering in GET api/v4/projects/:project_id/repository/contributors through `order_by` and `sort` params. The available `order_by` options are: name|email|commits. The available `sort` options are: asc|desc. --- spec/factories/commits.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'spec/factories') diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb index f4f12a095fc..4e2d8e8969e 100644 --- a/spec/factories/commits.rb +++ b/spec/factories/commits.rb @@ -2,15 +2,28 @@ require_relative '../support/repo_helpers' FactoryGirl.define do factory :commit do - git_commit RepoHelpers.sample_commit + transient do + author nil + end + + git_commit do + commit = RepoHelpers.sample_commit + + if author + commit.author_email = author.email + commit.author_name = author.name + end + + commit + end project initialize_with do new(git_commit, project) end - after(:build) do |commit| - allow(commit).to receive(:author).and_return build(:author) + after(:build) do |commit, evaluator| + allow(commit).to receive(:author).and_return(evaluator.author || build(:author)) end trait :without_author do -- cgit v1.2.1