summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/blobs_controller.rb12
-rw-r--r--test/functional/blobs_controller_test.rb8
2 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/blobs_controller.rb b/app/controllers/blobs_controller.rb
index c2240c1..25e98d5 100644
--- a/app/controllers/blobs_controller.rb
+++ b/app/controllers/blobs_controller.rb
@@ -87,7 +87,17 @@ class BlobsController < ApplicationController
:name => @blob.basename
})
@commits = @git.log(@ref, desplat_path(@path))
- expires_in 30.minutes
+ expires_in 30.minutes
+ respond_to do |wants|
+ wants.html
+ wants.json {render :json =>
+ @commits.map{|c|{
+ :author => c.author.name,
+ :sha => c.id,
+ :message => c.short_message,
+ :committed_date => c.committed_date}
+ }.to_json}
+ end
end
protected
diff --git a/test/functional/blobs_controller_test.rb b/test/functional/blobs_controller_test.rb
index c624309..8900eb3 100644
--- a/test/functional/blobs_controller_test.rb
+++ b/test/functional/blobs_controller_test.rb
@@ -146,6 +146,14 @@ class BlobsControllerTest < ActionController::TestCase
assert_equal 5, assigns(:commits).size
assert_match(/max-age=\d+, private/, @response.headers['Cache-Control'])
end
+
+ should "get the history as json" do
+ get :history, :project_id => @project.to_param, :repository_id => @repository.to_param,
+ :branch_and_path => ["master","README.txt"], :format => "json"
+ assert_response :success
+ json_body = JSON.parse(@response.body)
+ assert_equal 5, json_body.size
+ end
end
end
end