Permalink
Browse files

Make tests pass

  • Loading branch information...
1 parent dead43c commit 46e8127fc3a207ed39565966b2634e63b9f600a8 @nickh nickh committed with schacon Apr 6, 2012
Showing with 17 additions and 9 deletions.
  1. +1 −1 app/controllers/doc_controller.rb
  2. +8 −0 test/functional/doc_controller_test.rb
  3. +8 −8 test/unit/doc_version_test.rb
@@ -16,7 +16,7 @@ def man
end
if doc_version.nil?
- redirect_to :index
+ redirect_to :ref
else
@doc = doc_version.doc
end
@@ -12,11 +12,19 @@ class DocControllerTest < ActionController::TestCase
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")
+ 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
@@ -3,21 +3,21 @@
class DocVersionTest < ActiveSupport::TestCase
test 'finds most recent version' do
range = 0..3
- file = Factory(:doc_file, :name => 'test-command')
- docs = range.map{|i| Factory(:doc, :plain => "Doc #{i}")}
- vers = range.map{|i| Factory(:version, :name => "v#{i}.0")}
- dver = range.map{|i| Factory(:doc_version, :doc_file => file, :version => vers[i], :doc => docs[i])}
+ file = FactoryGirl.create(:doc_file, :name => 'test-command')
+ docs = range.map{|i| FactoryGirl.create(:doc, :plain => "Doc #{i}")}
+ vers = range.map{|i| FactoryGirl.create(:version, :name => "v#{i}.0")}
+ dver = range.map{|i| FactoryGirl.create(:doc_version, :doc_file => file, :version => vers[i], :doc => docs[i])}
dv = DocVersion.latest_for('test-command')
assert_equal docs[3], dv.doc
end
test 'finds a specific version' do
range = 0..3
- file = Factory(:doc_file, :name => 'test-command')
- docs = range.map{|i| Factory(:doc, :plain => "Doc #{i}")}
- vers = range.map{|i| Factory(:version, :name => "v#{i}.0")}
- dver = range.map{|i| Factory(:doc_version, :doc_file => file, :version => vers[i], :doc => docs[i])}
+ file = FactoryGirl.create(:doc_file, :name => 'test-command')
+ docs = range.map{|i| FactoryGirl.create(:doc, :plain => "Doc #{i}")}
+ vers = range.map{|i| FactoryGirl.create(:version, :name => "v#{i}.0")}
+ dver = range.map{|i| FactoryGirl.create(:doc_version, :doc_file => file, :version => vers[i], :doc => docs[i])}
dv = DocVersion.for_version('test-command', 'v2.0')
assert_equal docs[2], dv.doc

0 comments on commit 46e8127

Please sign in to comment.