Skip to content

Commit

Permalink
Merge pull request #147 from mmozuras/doc-controller-tests
Browse files Browse the repository at this point in the history
Fix #141: fix doc_controller tests
  • Loading branch information
Jason Long committed Jun 11, 2012
2 parents 1e71eb1 + faebe27 commit 0e42c69
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
3 changes: 3 additions & 0 deletions test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
factory :version do
name :version_name
end

factory :book do
end
end
62 changes: 29 additions & 33 deletions test/functional/doc_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
require File.expand_path("../../test_helper", __FILE__)

class DocControllerTest < ActionController::TestCase
# test "should get index" do
# get :index
# assert_response :success
# end
test "should get index" do
book = FactoryGirl.create(:book, :code =>'en')
get :index
assert_response :success
end

# test "should get file" do
# get :file
# assert_response :success
# end
test "gets the latest version of a man page" do
file = FactoryGirl.create(:doc_file, :name => 'test-command')
doc = FactoryGirl.create(:doc, :plain => "Doc 1", :blob_sha => "d670460b4b4aece5915caf5c68d12f560a9fe3e4")
vers = FactoryGirl.create(:version, :name => "v1.0", :vorder => Version.version_to_num("1.0"))
dver = FactoryGirl.create(:doc_version, :doc_file => file, :version => vers, :doc => doc)
get :man, :file => 'test-command'
assert_response :success
end

# test "gets the latest version of a man page" do
# file = FactoryGirl.create(:doc_file, :name => 'test-command')
# doc = FactoryGirl.create(:doc, :plain => "Doc 1")
# vers = FactoryGirl.create(:version, :name => "v1.0")
# dver = FactoryGirl.create(:doc_version, :doc_file => file, :version => vers, :doc => doc)
# get :man, :file => 'test-command'
# assert_response :success
# end
test "gets a specific version of a man page" do
file = FactoryGirl.create(:doc_file, :name => 'test-command')
doc = FactoryGirl.create(:doc, :plain => "Doc 1", :blob_sha => "d670460b4b4aece5915caf5c68d12f560a9fe3e4")
vers = FactoryGirl.create(:version, :name => "v1.0", :vorder => Version.version_to_num("1.0"))
dver = FactoryGirl.create(:doc_version, :doc_file => file, :version => vers, :doc => doc)
get :man, :file => 'test-command', :version => 'v1.0'
assert_response :success
end

# test "gets a specific version of a man page" do
# file = FactoryGirl.create(:doc_file, :name => 'test-command')
# doc = FactoryGirl.create(:doc, :plain => "Doc 1")
# vers = FactoryGirl.create(:version, :name => "v1.0")
# dver = FactoryGirl.create(:doc_version, :doc_file => file, :version => vers, :doc => doc)
# get :man, :file => 'test-command', :version => 'v1.0'
# assert_response :success
# end

# test "tries to prepend 'git-' to find a command" do
# file = FactoryGirl.create(:doc_file, :name => 'git-commit')
# doc = FactoryGirl.create(:doc, :plain => "Doc 1")
# vers = FactoryGirl.create(:version, :name => "v1.0")
# dver = FactoryGirl.create(:doc_version, :doc_file => file, :version => vers, :doc => doc)
# get :man, :file => 'commit', :version => 'v1.0'
# assert_response :success
# end
test "tries to prepend 'git-' to find a command" do
file = FactoryGirl.create(:doc_file, :name => 'git-commit')
doc = FactoryGirl.create(:doc, :plain => "Doc 1")
vers = FactoryGirl.create(:version, :name => "v1.0")
dver = FactoryGirl.create(:doc_version, :doc_file => file, :version => vers, :doc => doc)
get :man, :file => 'commit', :version => 'v1.0'
assert_redirected_to '/docs/git-commit'
end

end

0 comments on commit 0e42c69

Please sign in to comment.