2012-10-20 00:30:00 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2012-10-20 22:38:11 +02:00
|
|
|
shared_examples_for "column_chart" do
|
|
|
|
it 'should be a column chart' do
|
|
|
|
chart.should be_a GitStats::StatsView::Charts::Chart
|
|
|
|
chart.options[:chart][:type].should == "column"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for "datetime_chart" do
|
|
|
|
it 'should be a datetime chart' do
|
|
|
|
chart.should be_a GitStats::StatsView::Charts::Chart
|
|
|
|
chart.options[:xAxis][:type].should == "datetime"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-20 00:30:00 +02:00
|
|
|
describe GitStats::StatsView::Charts::RepoCharts do
|
|
|
|
let(:charts) { GitStats::StatsView::Charts::All.new(repo) }
|
|
|
|
|
|
|
|
context 'files_by_extension chart' do
|
|
|
|
let(:repo) { double(files_by_extension_count: {'.rb' => 5, '.txt' => 3}) }
|
2012-10-20 22:38:11 +02:00
|
|
|
let(:chart) { charts.files_by_extension }
|
2012-10-20 00:30:00 +02:00
|
|
|
|
2012-10-20 22:38:11 +02:00
|
|
|
it_behaves_like "column_chart"
|
2012-10-20 00:30:00 +02:00
|
|
|
|
|
|
|
it 'should have 1 data series with files_by_extension_count' do
|
|
|
|
chart.should have(1).data
|
|
|
|
chart.options[:xAxis][:categories].should == %w(.rb .txt)
|
|
|
|
chart.data[0][:data].should == [5, 3]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'lines_by_extension chart' do
|
|
|
|
let(:repo) { double(lines_by_extension: {'.rb' => 50, '.txt' => 30}) }
|
2012-10-20 22:38:11 +02:00
|
|
|
let(:chart) { charts.lines_by_extension }
|
2012-10-20 00:30:00 +02:00
|
|
|
|
2012-10-20 22:38:11 +02:00
|
|
|
it_behaves_like "column_chart"
|
2012-10-20 00:30:00 +02:00
|
|
|
|
|
|
|
it 'should have 1 data series with lines_by_extension' do
|
|
|
|
chart.should have(1).data
|
|
|
|
chart.options[:xAxis][:categories].should == %w(.rb .txt)
|
|
|
|
chart.data[0][:data].should == [50, 30]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'files_by_date chart' do
|
|
|
|
let(:repo) { double(commits: [double(date: 5)], files_count_each_day: [10, 15, 12, 20]) }
|
2012-10-20 22:38:11 +02:00
|
|
|
let(:chart) { charts.files_by_date }
|
2012-10-20 00:30:00 +02:00
|
|
|
|
2012-10-20 22:38:11 +02:00
|
|
|
it_behaves_like "datetime_chart"
|
2012-10-20 00:30:00 +02:00
|
|
|
|
|
|
|
it 'should have 1 data series with files_by_date' do
|
|
|
|
chart.should have(1).data
|
|
|
|
chart.data[0][:data].should == [10, 15, 12, 20]
|
|
|
|
chart.data[0][:pointStart].should == 5000
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'lines_by_date chart' do
|
|
|
|
let(:repo) { double(commits: [double(date: 6)], lines_count_each_day: [100, 150, 120, 200]) }
|
2012-10-20 22:38:11 +02:00
|
|
|
let(:chart) { charts.lines_by_date }
|
2012-10-20 00:30:00 +02:00
|
|
|
|
2012-10-20 22:38:11 +02:00
|
|
|
it_behaves_like "datetime_chart"
|
2012-10-20 00:30:00 +02:00
|
|
|
|
|
|
|
it 'should have 1 data series with lines_by_date' do
|
|
|
|
chart.should have(1).data
|
|
|
|
chart.data[0][:data].should == [100, 150, 120, 200]
|
|
|
|
chart.data[0][:pointStart].should == 6000
|
|
|
|
end
|
|
|
|
end
|
2012-10-20 22:38:11 +02:00
|
|
|
|
|
|
|
context 'lines_added_by_author chart' do
|
|
|
|
let(:repo) { double(commits: [double(date: 6)], lines_added_by_author: {double(email: 'author1') => 50, double(email: 'author2') => 30}) }
|
|
|
|
let(:chart) { charts.lines_added_by_author }
|
|
|
|
|
|
|
|
it_behaves_like "column_chart"
|
|
|
|
|
|
|
|
it 'should have 1 data series with lines_added_by_author' do
|
|
|
|
chart.should have(1).data
|
|
|
|
chart.options[:xAxis][:categories].should == %w(author1 author2)
|
|
|
|
chart.data[0][:data].should == [50, 30]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'lines_deleted_by_author chart' do
|
|
|
|
let(:repo) { double(commits: [double(date: 6)], lines_deleted_by_author: {double(email: 'author1') => 30, double(email: 'author2') => 50}) }
|
|
|
|
let(:chart) { charts.lines_deleted_by_author }
|
|
|
|
|
|
|
|
it_behaves_like "column_chart"
|
|
|
|
|
|
|
|
it 'should have 1 data series with lines_deleted_by_author' do
|
|
|
|
chart.should have(1).data
|
|
|
|
chart.options[:xAxis][:categories].should == %w(author1 author2)
|
|
|
|
chart.data[0][:data].should == [30, 50]
|
|
|
|
end
|
|
|
|
end
|
2012-10-20 00:30:00 +02:00
|
|
|
end
|