@@ -347,13 +347,13 class RepositoriesController < ApplicationController | |||||
347 | :all, :group => :commit_date, |
|
347 | :all, :group => :commit_date, | |
348 | :conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) |
|
348 | :conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) | |
349 | commits_by_month = [0] * 12 |
|
349 | commits_by_month = [0] * 12 | |
350 |
commits_by_day.each {|c| commits_by_month[c.first.to_date.month |
|
350 | commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } | |
351 |
|
351 | |||
352 | changes_by_day = Change.count( |
|
352 | changes_by_day = Change.count( | |
353 | :all, :group => :commit_date, :include => :changeset, |
|
353 | :all, :group => :commit_date, :include => :changeset, | |
354 | :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) |
|
354 | :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) | |
355 | changes_by_month = [0] * 12 |
|
355 | changes_by_month = [0] * 12 | |
356 |
changes_by_day.each {|c| changes_by_month[c.first.to_date.month |
|
356 | changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } | |
357 |
|
357 | |||
358 | fields = [] |
|
358 | fields = [] | |
359 | 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)} |
|
359 | 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)} |
@@ -201,6 +201,11 class RepositoriesControllerTest < ActionController::TestCase | |||||
201 | end |
|
201 | end | |
202 |
|
202 | |||
203 | def test_graph_commits_per_month |
|
203 | def test_graph_commits_per_month | |
|
204 | # Make sure there's some data to display | |||
|
205 | latest = Project.find(1).repository.changesets.maximum(:commit_date) | |||
|
206 | assert_not_nil latest | |||
|
207 | Date.stubs(:today).returns(latest.to_date + 10) | |||
|
208 | ||||
204 | get :graph, :id => 1, :graph => 'commits_per_month' |
|
209 | get :graph, :id => 1, :graph => 'commits_per_month' | |
205 | assert_response :success |
|
210 | assert_response :success | |
206 | assert_equal 'image/svg+xml', @response.content_type |
|
211 | assert_equal 'image/svg+xml', @response.content_type |
General Comments 0
You need to be logged in to leave comments.
Login now