Skip to content
Snippets Groups Projects
Commit 71d67e65 authored by Karlo Soriano's avatar Karlo Soriano Committed by karlo57
Browse files

Contributors graphs feature for GitLab

Created tests and refactored some code along the way

Added stat graph util spec, refactored code

finsihed up tests and refactors

finsihed up tests and refactors
parent b9d989dc
No related branches found
No related tags found
1 merge request!4212Contributors Graph
#Use this file to set/override Jasmine configuration options
#You can remove it if you don't need it.
#This file is loaded *after* jasmine.yml is interpreted.
#
#Example: using a different boot file.
#Jasmine.configure do |config|
# @config.boot_dir = '/absolute/path/to/boot_dir'
# @config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
#end
#
require 'spec_helper'
require 'gitlab/git_stats_log_parser'
describe LogParser do
describe "#self.parse_log" do
context "log_from_git is a valid log" do
it "returns the correct log" do
fake_log = "Karlo Soriano
2013-05-09
14 files changed, 471 insertions(+)
Dmitriy Zaporozhets
2013-05-08
1 file changed, 6 insertions(+), 1 deletion(-)
Dmitriy Zaporozhets
2013-05-08
6 files changed, 19 insertions(+), 3 deletions(-)
Dmitriy Zaporozhets
2013-05-08
3 files changed, 29 insertions(+), 3 deletions(-)";
lp = LogParser.parse_log(fake_log)
lp.should eq([
{author: "Karlo Soriano", date: "2013-05-09", additions: 471},
{author: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 6, deletions: 1},
{author: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 19, deletions: 3},
{author: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 29, deletions: 3}])
end
end
end
end
\ No newline at end of file
require 'spec_helper'
describe Gitlab::GitStats do
describe "#parsed_log" do
let(:stats) { Gitlab::GitStats.new(nil, nil) }
before(:each) do
stats.stub(:log).and_return("anything")
end
context "LogParser#parse_log returns 'test'" do
it "returns 'test'" do
LogParser.stub(:parse_log).and_return("test")
stats.parsed_log.should eq("test")
end
end
end
describe "#log" do
let(:repo) { Repository.new(nil, nil) }
let(:gs) { Gitlab::GitStats.new(repo.raw, repo.root_ref) }
before(:each) do
repo.stub(:raw).and_return(nil)
repo.stub(:root_ref).and_return(nil)
repo.raw.stub(:git)
end
context "repo.git.run returns 'test'" do
it "returns 'test'" do
repo.raw.git.stub(:run).and_return("test")
gs.log.should eq("test")
end
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment