Skip to content

Commit

Permalink
Merge pull request #11 from rihards/master
Browse files Browse the repository at this point in the history
Added a limit parameter.
  • Loading branch information
Guy Nathan committed Oct 26, 2015
2 parents 875480e + 4d2fd23 commit 58d95f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/ginatra/core/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def commits params = {}
else
result = @commits
end

if params[:limit]
result = result[0..params[:limit]-1]
end

commits_by(result, params[:by])
end

Expand Down
10 changes: 6 additions & 4 deletions spec/requests/stat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
full_params = {from: "9 Feb 2015",
til: "9 March 2015",
by: "Nathan Dao",
in: "repo_1"}
in: "repo_1",
limit: 2}

# Test all combinations of params
(0..4).to_a.each do |size|
(0..5).to_a.each do |size|
full_params.keys.combination(size).to_a.each do |combi|
params = combi.inject({}) { |p, k|
p.merge!({k => full_params[k]})
Expand Down Expand Up @@ -44,9 +45,10 @@
full_params = {from: "9 Feb 2015",
til: "9 March 2015",
by: "Nathan Dao",
in: "repo_1"}
in: "repo_1",
limit: 2}

(0..4).to_a.each do |size|
(0..5).to_a.each do |size|
full_params.keys.combination(size).to_a.each do |combi|
params = combi.inject({}) { |p, k|
p.merge!({k => full_params[k]})
Expand Down

0 comments on commit 58d95f1

Please sign in to comment.