From 3e0467333471576735d225baec289c1e67e1a09c Mon Sep 17 00:00:00 2001 From: randx Date: Sat, 10 Nov 2012 23:33:10 +0200 Subject: [PATCH] Added feature test for stats --- app/views/repositories/stats.html.haml | 4 ++-- features/project/commits/commits.feature | 4 ++++ features/steps/project/project_browse_commits.rb | 6 ++++++ features/steps/shared/paths.rb | 4 ++++ lib/gitlab/git_stats.rb | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/views/repositories/stats.html.haml b/app/views/repositories/stats.html.haml index bf68dc28a..a0a9377d2 100644 --- a/app/views/repositories/stats.html.haml +++ b/app/views/repositories/stats.html.haml @@ -16,9 +16,9 @@ %br %div#activity-chart .span7 - %h4 Top 100 Committers: + %h4 Top 50 Committers: %ol.styled - - @stats.authors[0...100].each do |author| + - @stats.authors[0...50].each do |author| %li = image_tag gravatar_icon(author.email, 16), class: 'avatar s16' = author.name diff --git a/features/project/commits/commits.feature b/features/project/commits/commits.feature index f5a11048b..56069cdc9 100644 --- a/features/project/commits/commits.feature +++ b/features/project/commits/commits.feature @@ -23,3 +23,7 @@ Feature: Project Browse commits Scenario: I browse commits for a specific path Given I visit my project's commits page for a specific path Then I see breadcrumb links + + Scenario: I browse commits stats + Given I visit my project's commits stats page + Then I see commits stats diff --git a/features/steps/project/project_browse_commits.rb b/features/steps/project/project_browse_commits.rb index 036b62973..428c14a80 100644 --- a/features/steps/project/project_browse_commits.rb +++ b/features/steps/project/project_browse_commits.rb @@ -51,4 +51,10 @@ class ProjectBrowseCommits < Spinach::FeatureSteps find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path}\/commits\/master\z/) find('ul.breadcrumb li:last a')['href'].should match(%r{master/app/models/project\.rb\z}) end + + Then 'I see commits stats' do + page.should have_content 'Stats for master' + page.should have_content 'Committers' + page.should have_content 'Total commits' + end end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index e24555543..33a940274 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -125,6 +125,10 @@ module SharedPaths visit project_commits_path(@project, @project.root_ref + "/app/models/project.rb", {limit: 5}) end + Given 'I visit my project\'s commits stats page' do + visit stats_project_repository_path(@project) + end + Given "I visit my project's network page" do # Stub Graph::JsonBuilder max_size to speed up test (10 commits vs. 650) Gitlab::Graph::JsonBuilder.stub(max_count: 10) diff --git a/lib/gitlab/git_stats.rb b/lib/gitlab/git_stats.rb index a83c10ff2..943748695 100644 --- a/lib/gitlab/git_stats.rb +++ b/lib/gitlab/git_stats.rb @@ -29,7 +29,7 @@ module Gitlab protected def collect_authors - shortlog = repo.git.shortlog({:e => true, :s => true }, ref) + shortlog = repo.git.shortlog({e: true, s: true }, ref) authors = [] -- 2.11.0