dolt 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/Gemfile.lock +25 -5
  2. data/Readme.md +90 -16
  3. data/bin/dolt +22 -4
  4. data/dolt.gemspec +10 -2
  5. data/lib/dolt/disk_repo_resolver.rb +3 -5
  6. data/lib/dolt/git/blame.rb +112 -0
  7. data/lib/dolt/git/commit.rb +73 -0
  8. data/lib/dolt/git/repository.rb +26 -24
  9. data/lib/dolt/repo_actions.rb +32 -19
  10. data/lib/dolt/sinatra/actions.rb +51 -18
  11. data/lib/dolt/sinatra/multi_repo_browser.rb +30 -3
  12. data/lib/dolt/sinatra/single_repo_browser.rb +36 -2
  13. data/lib/dolt/template_renderer.rb +7 -8
  14. data/lib/dolt/version.rb +1 -1
  15. data/lib/dolt/view.rb +3 -61
  16. data/lib/dolt/view/blame.rb +57 -0
  17. data/lib/dolt/view/blob.rb +60 -0
  18. data/lib/dolt/view/breadcrumb.rb +10 -17
  19. data/lib/dolt/{git/blob.rb → view/commit.rb} +5 -11
  20. data/lib/dolt/view/gravatar.rb +29 -0
  21. data/lib/dolt/{git/shell.rb → view/markup.rb} +10 -16
  22. data/lib/dolt/view/multi_repository.rb +27 -0
  23. data/lib/dolt/{async/deferrable_child_process.rb → view/object.rb} +11 -24
  24. data/lib/dolt/view/single_repository.rb +27 -0
  25. data/lib/dolt/view/smart_blob_renderer.rb +33 -0
  26. data/lib/dolt/view/syntax_highlight.rb +86 -0
  27. data/lib/dolt/view/tree.rb +69 -0
  28. data/test/dolt/git/blame_test.rb +128 -0
  29. data/test/dolt/git/commit_test.rb +89 -0
  30. data/test/dolt/git/repository_test.rb +24 -73
  31. data/test/dolt/repo_actions_test.rb +77 -15
  32. data/test/dolt/sinatra/actions_test.rb +168 -8
  33. data/test/dolt/template_renderer_test.rb +44 -10
  34. data/test/dolt/templates/blame_test.rb +56 -0
  35. data/test/dolt/{views → templates}/blob_test.rb +44 -34
  36. data/test/dolt/templates/commits_test.rb +61 -0
  37. data/test/dolt/templates/raw_test.rb +41 -0
  38. data/test/dolt/templates/tree_test.rb +51 -0
  39. data/test/dolt/view/blame_test.rb +122 -0
  40. data/test/dolt/view/blob_test.rb +90 -0
  41. data/test/dolt/view/breadcrumb_test.rb +46 -0
  42. data/test/dolt/view/commit_test.rb +31 -0
  43. data/test/dolt/view/gravatar_test.rb +30 -0
  44. data/test/dolt/view/markup_test.rb +30 -0
  45. data/test/dolt/{git/blob_test.rb → view/multi_repository_test.rb} +10 -24
  46. data/test/dolt/view/object_test.rb +71 -0
  47. data/test/dolt/view/single_repository_test.rb +30 -0
  48. data/test/dolt/{view_test.rb → view/syntax_highlight_test.rb} +40 -27
  49. data/test/dolt/view/tree_test.rb +115 -0
  50. data/test/test_helper.rb +18 -13
  51. data/vendor/ui/css/gitorious.css +20 -8
  52. data/views/blame.erb +41 -0
  53. data/views/blob.erb +6 -9
  54. data/views/commits.erb +23 -0
  55. data/views/index.erb +25 -0
  56. data/views/raw.erb +19 -0
  57. data/views/tree.erb +28 -26
  58. metadata +156 -26
  59. data/lib/dolt/git/tree.rb +0 -65
  60. data/lib/dolt/view/highlighter.rb +0 -52
  61. data/test/dolt/git/shell_test.rb +0 -112
  62. data/test/dolt/git/tree_test.rb +0 -120
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+
19
+ module Dolt
20
+ module View
21
+ module Tree
22
+ def tree_url(repository, ref, path)
23
+ repo_url(repository, "/tree/#{ref}:#{path}")
24
+ end
25
+
26
+ def tree_entries(tree)
27
+ sort(tree.entries.select { |e| e[:type] == :tree }) +
28
+ sort(tree.entries.select { |e| e[:type] == :blob })
29
+ end
30
+
31
+ def tree_context(repo, ref, path)
32
+ acc = ""
33
+ pieces = path.sub(/^\.?\//, "").split("/")
34
+ total = 5 + pieces.length
35
+ colspan = total
36
+ pieces.inject("") do |html, dir|
37
+ padding_td = tree_table_padding_td(acc.sub(/^\.?\//, ""))
38
+ url = object_url(repo, ref, acc, { :type => :tree, :name => dir })
39
+ acc << "/#{dir}"
40
+ colspan -= 1
41
+ <<-HTML
42
+ #{html}
43
+ <tr>
44
+ #{padding_td}
45
+ <td colspan="#{colspan}">
46
+ <a href=\"#{url}\">
47
+ <i class="icon icon-folder-open"></i> #{dir}
48
+ </a>
49
+ </td>
50
+ </tr>
51
+ HTML
52
+ end
53
+ end
54
+
55
+ def tree_table_padding_td(path)
56
+ "<td></td>" * tree_table_padding_width(path)
57
+ end
58
+
59
+ def tree_table_padding_width(path)
60
+ path.split("/").length
61
+ end
62
+
63
+ private
64
+ def sort(entries)
65
+ entries.sort_by { |e| e[:name] }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,128 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "dolt/git/blame"
20
+
21
+ describe Dolt::Git::Blame do
22
+ include EM::MiniTest::Spec
23
+
24
+ describe "parse" do
25
+ before do
26
+ @blame = <<-GIT
27
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 1 1 17
28
+ author Christian Johansen
29
+ author-mail <christian@cjohansen.no>
30
+ author-time 1347282459
31
+ author-tz +0200
32
+ committer Christian Johansen
33
+ committer-mail <christian@cjohansen.no>
34
+ committer-time 1347282459
35
+ committer-tz +0200
36
+ summary Working Moron server for viewing blobs
37
+ filename lib/moron/view.rb
38
+ # encoding: utf-8
39
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 2 2
40
+ #--
41
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 3 3
42
+ # Copyright (C) 2012 Gitorious AS
43
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 4 4
44
+ #
45
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 5 5
46
+ # This program is free software: you can redistribute it and/or modify
47
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 6 6
48
+ # it under the terms of the GNU Affero General Public License as published by
49
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 7 7
50
+ # the Free Software Foundation, either version 3 of the License, or
51
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 8 8
52
+ # (at your option) any later version.
53
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 9 9
54
+ #
55
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 10 10
56
+ # This program is distributed in the hope that it will be useful,
57
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 11 11
58
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
59
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 12 12
60
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 13 13
62
+ # GNU Affero General Public License for more details.
63
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 14 14
64
+ #
65
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 15 15
66
+ # You should have received a copy of the GNU Affero General Public License
67
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 16 16
68
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
69
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 17 17
70
+ #++
71
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 20 18 1
72
+
73
+ beb65bee5619c651532179b19421363ead2c2a44 19 19 1
74
+ author Christian Johansen
75
+ author-mail <christian@gitorious.com>
76
+ author-time 1348128947
77
+ author-tz +0200
78
+ committer Christian Johansen
79
+ committer-mail <christian@gitorious.com>
80
+ committer-time 1348128947
81
+ committer-tz +0200
82
+ summary Helpers are modules again
83
+ previous 05f0137175fe341545587a544315cd4a6cc2c824 lib/dolt/view.rb
84
+ filename lib/dolt/view.rb
85
+ dir = File.join(File.dirname(__FILE__), "view")
86
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 30 20 1
87
+
88
+ beb65bee5619c651532179b19421363ead2c2a44 21 21 2
89
+ Dir.entries(dir).select { |f| f =~ /\.rb$/ }.map do |file|
90
+ beb65bee5619c651532179b19421363ead2c2a44 22 22
91
+ require(File.join(dir, file))
92
+ 906d67b4f3e5de7364ba9b57d174d8998d53ced6 58 23 1
93
+ end
94
+ GIT
95
+
96
+ @blame = Dolt::Git::Blame.parse_porcelain(@blame)
97
+ end
98
+
99
+ it "has chunks" do
100
+ assert_equal 5, @blame.chunks.length
101
+ end
102
+
103
+ it "has chunk with commit meta data" do
104
+ chunk = @blame.chunks.first
105
+ author = chunk[:author]
106
+ committer = chunk[:committer]
107
+
108
+ assert_equal "906d67b4f3e5de7364ba9b57d174d8998d53ced6", chunk[:oid]
109
+ assert_equal "Christian Johansen", author[:name]
110
+ assert_equal "christian@cjohansen.no", author[:mail]
111
+ assert_equal "2012-09-10 17:07:39", author[:time].strftime("%Y-%m-%d %H:%M:%S")
112
+ assert_equal "Christian Johansen", committer[:name]
113
+ assert_equal "christian@cjohansen.no", committer[:mail]
114
+ assert_equal "2012-09-10 17:07:39", committer[:time].strftime("%Y-%m-%d %H:%M:%S")
115
+ assert_equal "Working Moron server for viewing blobs", chunk[:summary]
116
+ end
117
+
118
+ it "has chunk with lines" do
119
+ chunk = @blame.chunks.first
120
+ assert_equal 18, chunk[:lines].length
121
+ assert_equal "# Copyright (C) 2012 Gitorious AS", chunk[:lines][2]
122
+ end
123
+
124
+ it "repeats commit meta" do
125
+ assert_equal @blame.chunks[2][:committer], @blame.chunks[0][:committer]
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "dolt/git/commit"
20
+
21
+ describe Dolt::Git::Commit do
22
+ include EM::MiniTest::Spec
23
+
24
+ describe "parse" do
25
+ before do
26
+ @log = <<-GIT
27
+ commit dc0846b6c98a3f6db1172629329b70ada80598bb
28
+ Author: Christian Johansen <christian@gitorious.com>
29
+ Date: Thu Sep 20 15:55:52 2012 +0200
30
+
31
+ Add rough blame
32
+
33
+ commit 222eef3679553c9da2897144e03a5844f6e77586
34
+ Author: Christian Johansen <christian@gitorious.com>
35
+ Date: Wed Sep 19 12:27:54 2012 +0200
36
+
37
+ Rewrite template/views. Use EMRugged for Git.
38
+
39
+ - Not complete, still some failing tests
40
+ - View helpers need to change
41
+
42
+ commit 06293404488d9cc72e70eb2ae25aa609af73dada
43
+ Author: Christian Johansen <christian@gitorious.com>
44
+ Date: Tue Sep 11 20:03:14 2012 +0200
45
+
46
+ Rename FileSystemRepositoryResolver to DiskRepoResolver
47
+
48
+ commit 7a3d69a2327bb9575bb520fe30c6abb3bbd0b719
49
+ Author: Christian Johansen <christian@gitorious.com>
50
+ Date: Tue Sep 11 19:57:22 2012 +0200
51
+
52
+ One more rename: "Dolt" is shorter, better
53
+
54
+ commit eabcd577e921d01aeaf777d2daac565f88ab174c
55
+ Author: Christian Johansen <christian@gitorious.com>
56
+ Date: Tue Sep 11 15:25:50 2012 +0200
57
+
58
+ Moron was taken, going with Addlepate
59
+
60
+ GIT
61
+
62
+ @commits = Dolt::Git::Commit.parse_log(@log)
63
+ end
64
+
65
+ it "has commits" do
66
+ assert_equal 5, @commits.length
67
+ end
68
+
69
+ it "has commit oids" do
70
+ assert_equal "dc0846b6c98a3f6db1172629329b70ada80598bb", @commits[0][:oid]
71
+ assert_equal "222eef3679553c9da2897144e03a5844f6e77586", @commits[1][:oid]
72
+ assert_equal "06293404488d9cc72e70eb2ae25aa609af73dada", @commits[2][:oid]
73
+ assert_equal "7a3d69a2327bb9575bb520fe30c6abb3bbd0b719", @commits[3][:oid]
74
+ assert_equal "eabcd577e921d01aeaf777d2daac565f88ab174c", @commits[4][:oid]
75
+ end
76
+
77
+ it "has author" do
78
+ expected = {
79
+ :name => "Christian Johansen",
80
+ :email => "christian@gitorious.com"
81
+ }
82
+ assert_equal expected, @commits.first[:author]
83
+ end
84
+
85
+ it "has commit date" do
86
+ assert_equal "2012-09-11", @commits.last[:date].strftime("%Y-%m-%d")
87
+ end
88
+ end
89
+ end
@@ -17,93 +17,44 @@
17
17
  #++
18
18
  require "test_helper"
19
19
  require "dolt/git/repository"
20
- require "dolt/async/when"
21
-
22
- class FakeGit
23
- attr_reader :cmds, :deferreds
24
-
25
- def initialize
26
- @cmds = []
27
- @deferreds = []
28
- end
29
-
30
- def show(path, ref)
31
- git("show", path, ref)
32
- end
33
-
34
- def ls_tree(path, ref)
35
- git("ls-tree", path, ref)
36
- end
37
-
38
- def git(*args)
39
- cmds << args
40
- deferred = When::Deferred.new
41
- deferreds << deferred.resolver
42
- deferred.promise
43
- end
44
-
45
- def last_command; cmds.last; end
46
- def last_resolver; deferreds.last; end
47
- end
48
20
 
49
21
  describe Dolt::Git::Repository do
50
- before { @git = FakeGit.new }
22
+ include EM::MiniTest::Spec
51
23
 
52
- describe "#blob" do
53
- it "uses git-show to cat file at ref" do
54
- repo = Dolt::Git::Repository.new("gitorious", @git)
55
- repo.blob("models/repository.rb", "master")
24
+ describe "#blame" do
25
+ before { @repository = Dolt::Git::Repository.new(".") }
56
26
 
57
- assert_equal ["show", "models/repository.rb", "master"], @git.last_command
27
+ it "returns deferrable" do
28
+ deferrable = @repository.blame("master", "Gemfile")
29
+ assert deferrable.respond_to?(:callback)
30
+ assert deferrable.respond_to?(:errback)
58
31
  end
59
32
 
60
- it "defaults to showing the file at HEAD" do
61
- repo = Dolt::Git::Repository.new("gitorious", @git)
62
- repo.blob("models/repository.rb")
63
-
64
- assert_equal ["show", "models/repository.rb", "HEAD"], @git.last_command
65
- end
66
-
67
- it "invokes callback with blob object" do
68
- repo = Dolt::Git::Repository.new("gitorious", @git)
69
- d = repo.blob("models/repository.rb")
70
-
71
- d.callback do |blob|
72
- assert_equal "class Repository;end", blob.raw
33
+ it "yields blame" do
34
+ @repository.blame("master", "Gemfile").callback do |blame|
35
+ assert Dolt::Git::Blame === blame
36
+ done!
73
37
  end
74
-
75
- @git.last_resolver.resolve("class Repository;end")
38
+ wait!
76
39
  end
77
40
  end
78
41
 
79
- describe "#tree" do
80
- it "uses git ls-tree to list tree" do
81
- repo = Dolt::Git::Repository.new("gitorious", @git)
82
- repo.tree("app/models", "master")
42
+ describe "#log" do
43
+ before { @repository = Dolt::Git::Repository.new(".") }
83
44
 
84
- assert_equal ["ls-tree", "app/models", "master"], @git.last_command
45
+ it "returns deferrable" do
46
+ deferrable = @repository.log("master", "Gemfile", 1)
47
+ assert deferrable.respond_to?(:callback)
48
+ assert deferrable.respond_to?(:errback)
85
49
  end
86
50
 
87
- it "defaults to listing tree at HEAD" do
88
- repo = Dolt::Git::Repository.new("gitorious", @git)
89
- repo.tree("app/models")
90
-
91
- assert_equal ["ls-tree", "app/models", "HEAD"], @git.last_command
92
- end
93
-
94
- it "invokes callback with tree object" do
95
- repo = Dolt::Git::Repository.new("gitorious", @git)
96
- d = repo.tree("app/models")
97
-
98
- d.callback do |tree|
99
- assert_equal 3, tree.entries.length
51
+ it "yields commits" do
52
+ @repository.log("master", "dolt.gemspec", 2).callback do |log|
53
+ assert_equal 2, log.length
54
+ assert Hash === log[0]
55
+ done!
100
56
  end
101
-
102
- @git.last_resolver.resolve(<<-GIT)
103
- 100644 blob e90021f89616ddf86855d05337c188408d3b417e .gitmodules
104
- 100644 blob c80ee3697054566d1a4247d80be78ec3ddfde295 Gemfile
105
- 100644 blob 0053b3c95b0d9faa4916f7cd5e559c2b0f138027 Gemfile.lock
106
- GIT
57
+ wait!
107
58
  end
108
59
  end
109
60
  end
@@ -23,12 +23,17 @@ class Repository
23
23
  attr_reader :name
24
24
  def initialize(name); @name = name; end
25
25
 
26
- def blob(path, ref)
26
+ def rev_parse(rev)
27
27
  @deferred = When::Deferred.new
28
28
  @deferred.promise
29
29
  end
30
30
 
31
- def tree(path, ref)
31
+ def blame(ref, path)
32
+ @deferred = When::Deferred.new
33
+ @deferred.promise
34
+ end
35
+
36
+ def log(ref, path, limit)
32
37
  @deferred = When::Deferred.new
33
38
  @deferred.promise
34
39
  end
@@ -57,46 +62,103 @@ describe Dolt::RepoActions do
57
62
 
58
63
  describe "#blob" do
59
64
  it "resolves repository" do
60
- @actions.blob("gitorious", "app", "master")
65
+ @actions.blob("gitorious", "master", "app")
61
66
 
62
67
  assert_equal ["gitorious"], @resolver.resolved.map(&:name)
63
68
  end
64
69
 
65
- it "yields blob, repo, ref and base_tree_url to block" do
70
+ it "yields path, blob, repo, ref and base_tree_url to block" do
66
71
  data = nil
67
- @actions.blob("gitorious", "app", "babd120") do |status, d|
72
+ @actions.blob("gitorious", "babd120", "app") do |err, d|
68
73
  data = d
69
74
  end
70
75
 
71
- repo = @resolver.resolved.last
72
- repo.resolve_promise "Blob"
76
+ @resolver.resolved.last.resolve_promise("Blob")
73
77
 
74
78
  assert_equal({
75
- :blob => "Blob",
76
- :repository => repo,
77
- :ref => "babd120"
78
- }, data)
79
+ :blob => "Blob",
80
+ :repository => "gitorious",
81
+ :ref => "babd120",
82
+ :path => "app"
83
+ }, data)
79
84
  end
80
85
  end
81
86
 
82
87
  describe "#tree" do
83
88
  it "resolves repository" do
84
- @actions.tree("gitorious", "app", "master")
89
+ @actions.tree("gitorious", "master", "app")
85
90
 
86
91
  assert_equal ["gitorious"], @resolver.resolved.map(&:name)
87
92
  end
88
93
 
89
94
  it "yields tree, repo and ref to block" do
90
95
  data = nil
91
- @actions.tree("gitorious", "app", "babd120") do |status, d|
96
+ @actions.tree("gitorious", "babd120", "app") do |err, d|
92
97
  data = d
93
98
  end
94
99
 
95
100
  repo = @resolver.resolved.last
96
101
  repo.resolve_promise "Tree"
97
102
 
98
- expected = { :tree => "Tree", :repository => repo, :ref => "babd120" }
103
+ expected = {
104
+ :tree => "Tree",
105
+ :repository => "gitorious",
106
+ :ref => "babd120",
107
+ :path => "app"
108
+ }
109
+ assert_equal expected, data
110
+ end
111
+ end
112
+
113
+ describe "#blame" do
114
+ it "resolves repository" do
115
+ @actions.blame("gitorious", "master", "app")
116
+
117
+ assert_equal ["gitorious"], @resolver.resolved.map(&:name)
118
+ end
119
+
120
+ it "yields blame, repo and ref to block" do
121
+ data = nil
122
+ @actions.blame("gitorious", "babd120", "app") do |err, d|
123
+ data = d
124
+ end
125
+
126
+ repo = @resolver.resolved.last
127
+ repo.resolve_promise "Blame"
128
+
129
+ expected = {
130
+ :blame => "Blame",
131
+ :repository => "gitorious",
132
+ :ref => "babd120",
133
+ :path => "app"
134
+ }
99
135
  assert_equal expected, data
100
136
  end
101
- end
137
+ end
138
+
139
+ describe "#history" do
140
+ it "resolves repository" do
141
+ @actions.history("gitorious", "master", "app", 1)
142
+
143
+ assert_equal ["gitorious"], @resolver.resolved.map(&:name)
144
+ end
145
+
146
+ it "yields commits, repo and ref to block" do
147
+ data = nil
148
+ @actions.history("gitorious", "babd120", "app", 2) do |err, d|
149
+ data = d
150
+ end
151
+
152
+ repo = @resolver.resolved.last
153
+ repo.resolve_promise "History"
154
+
155
+ expected = {
156
+ :commits => "History",
157
+ :repository => "gitorious",
158
+ :ref => "babd120",
159
+ :path => "app"
160
+ }
161
+ assert_equal expected, data
162
+ end
163
+ end
102
164
  end