Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add more functional tests for DocsController.

  • Loading branch information...
commit d457e28c525da22b5da8056fc95c62f98588ed2e 1 parent 2575264
@bry4n bry4n authored
View
2  app/controllers/doc_controller.rb
@@ -1,5 +1,3 @@
-require 'redcarpet'
-
class DocController < ApplicationController
layout "layout"
View
2  app/models/section.rb
@@ -64,7 +64,7 @@ def cs_number
end
def index
- if BONSAI
+ if defined?(BONSAI)
code = self.chapter.book.code
data = {
'chapter' => self.chapter.title,
View
30 test/factories.rb
@@ -1,4 +1,17 @@
FactoryGirl.define do
+
+ sequence :number do |n|
+ n
+ end
+
+ sequence :slug do |n|
+ "title-#{n}"
+ end
+
+ sequence :title do |n|
+ "Title #{n}"
+ end
+
sequence :plain do |n|
"Doc #{n}"
end
@@ -25,5 +38,22 @@
end
factory :book do
+ code 'en'
+ end
+
+ factory :section do
+ chapter
+ html "<html></html>"
+ number { FactoryGirl.generate(:number) }
+ title { FactoryGirl.generate(:title) }
+ slug { FactoryGirl.generate(:slug) }
+ plain { FactoryGirl.generate(:plain) }
end
+
+ factory :chapter do
+ book
+ number { FactoryGirl.generate(:number) }
+ title { FactoryGirl.generate(:title) }
+ end
+
end
View
45 test/functional/doc_controller_test.rb
@@ -1,6 +1,7 @@
require File.expand_path("../../test_helper", __FILE__)
class DocControllerTest < ActionController::TestCase
+
test "should get index" do
book = FactoryGirl.create(:book, :code =>'en')
get :index
@@ -34,4 +35,48 @@ class DocControllerTest < ActionController::TestCase
assert_redirected_to '/docs/git-commit'
end
+ test "gets the blog page" do
+ get :blog, :year => 2009, :month => '02', :day => 11, :slug => "moved-to-github-pages"
+ assert_response :success
+ end
+
+ test "gets the reference page" do
+ get :ref
+ assert_response :success
+ end
+
+ test "gets the book page" do
+ book = FactoryGirl.create(:book, :code =>'en')
+ get :book, :lang => 'en'
+ assert_response :success
+ end
+
+ test "gets the book section page" do
+ end
+
+ test "gets the progit page" do
+ section = FactoryGirl.create(:section)
+ get :progit, :chapter => section.chapter.number, :section => section.number
+ assert_response :success
+ end
+
+ test "gets the videos page" do
+ get :videos
+ assert_response :success
+ end
+
+ test "should redirect to videos page" do
+ get :watch, :id => 'bad-slug'
+ assert_redirected_to videos_path
+ end
+
+ test "watches the video" do
+ get :watch, :id => 'get-going'
+ assert_response :success
+ end
+
+ test "gets the external links page" do
+ get :ext
+ assert_response :success
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.