diff options
Diffstat (limited to 'railties/guides/code/getting_started/test')
18 files changed, 154 insertions, 0 deletions
diff --git a/railties/guides/code/getting_started/test/fixtures/.gitkeep b/railties/guides/code/getting_started/test/fixtures/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/railties/guides/code/getting_started/test/fixtures/.gitkeep diff --git a/railties/guides/code/getting_started/test/fixtures/comments.yml b/railties/guides/code/getting_started/test/fixtures/comments.yml new file mode 100644 index 0000000000..d33da386bf --- /dev/null +++ b/railties/guides/code/getting_started/test/fixtures/comments.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html + +one: + commenter: MyString + body: MyText + post: + +two: + commenter: MyString + body: MyText + post: diff --git a/railties/guides/code/getting_started/test/fixtures/posts.yml b/railties/guides/code/getting_started/test/fixtures/posts.yml new file mode 100644 index 0000000000..8b0f75a33d --- /dev/null +++ b/railties/guides/code/getting_started/test/fixtures/posts.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html + +one: + name: MyString + title: MyString + content: MyText + +two: + name: MyString + title: MyString + content: MyText diff --git a/railties/guides/code/getting_started/test/fixtures/tags.yml b/railties/guides/code/getting_started/test/fixtures/tags.yml new file mode 100644 index 0000000000..8485668908 --- /dev/null +++ b/railties/guides/code/getting_started/test/fixtures/tags.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html + +one: + name: MyString + post: + +two: + name: MyString + post: diff --git a/railties/guides/code/getting_started/test/functional/.gitkeep b/railties/guides/code/getting_started/test/functional/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/railties/guides/code/getting_started/test/functional/.gitkeep diff --git a/railties/guides/code/getting_started/test/functional/comments_controller_test.rb b/railties/guides/code/getting_started/test/functional/comments_controller_test.rb new file mode 100644 index 0000000000..2ec71b4ec5 --- /dev/null +++ b/railties/guides/code/getting_started/test/functional/comments_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/railties/guides/code/getting_started/test/functional/home_controller_test.rb b/railties/guides/code/getting_started/test/functional/home_controller_test.rb new file mode 100644 index 0000000000..0d9bb47c3e --- /dev/null +++ b/railties/guides/code/getting_started/test/functional/home_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class HomeControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/railties/guides/code/getting_started/test/functional/posts_controller_test.rb b/railties/guides/code/getting_started/test/functional/posts_controller_test.rb new file mode 100644 index 0000000000..b8f7b07820 --- /dev/null +++ b/railties/guides/code/getting_started/test/functional/posts_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class PostsControllerTest < ActionController::TestCase + setup do + @post = posts(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:posts) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create post" do + assert_difference('Post.count') do + post :create, post: @post.attributes + end + + assert_redirected_to post_path(assigns(:post)) + end + + test "should show post" do + get :show, id: @post.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @post.to_param + assert_response :success + end + + test "should update post" do + put :update, id: @post.to_param, post: @post.attributes + assert_redirected_to post_path(assigns(:post)) + end + + test "should destroy post" do + assert_difference('Post.count', -1) do + delete :destroy, id: @post.to_param + end + + assert_redirected_to posts_path + end +end diff --git a/railties/guides/code/getting_started/test/integration/.gitkeep b/railties/guides/code/getting_started/test/integration/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/railties/guides/code/getting_started/test/integration/.gitkeep diff --git a/railties/guides/code/getting_started/test/performance/browsing_test.rb b/railties/guides/code/getting_started/test/performance/browsing_test.rb new file mode 100644 index 0000000000..3fea27b916 --- /dev/null +++ b/railties/guides/code/getting_started/test/performance/browsing_test.rb @@ -0,0 +1,12 @@ +require 'test_helper' +require 'rails/performance_test_help' + +class BrowsingTest < ActionDispatch::PerformanceTest + # Refer to the documentation for all available options + # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] + # :output => 'tmp/performance', :formats => [:flat] } + + def test_homepage + get '/' + end +end diff --git a/railties/guides/code/getting_started/test/test_helper.rb b/railties/guides/code/getting_started/test/test_helper.rb new file mode 100644 index 0000000000..8bf1192ffe --- /dev/null +++ b/railties/guides/code/getting_started/test/test_helper.rb @@ -0,0 +1,13 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/railties/guides/code/getting_started/test/unit/.gitkeep b/railties/guides/code/getting_started/test/unit/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/.gitkeep diff --git a/railties/guides/code/getting_started/test/unit/comment_test.rb b/railties/guides/code/getting_started/test/unit/comment_test.rb new file mode 100644 index 0000000000..b6d6131a96 --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb b/railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb new file mode 100644 index 0000000000..2518c16bd5 --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class CommentsHelperTest < ActionView::TestCase +end diff --git a/railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb b/railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb new file mode 100644 index 0000000000..4740a18dac --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class HomeHelperTest < ActionView::TestCase +end diff --git a/railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb b/railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb new file mode 100644 index 0000000000..48549c2ea1 --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class PostsHelperTest < ActionView::TestCase +end diff --git a/railties/guides/code/getting_started/test/unit/post_test.rb b/railties/guides/code/getting_started/test/unit/post_test.rb new file mode 100644 index 0000000000..6d9d463a71 --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/post_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PostTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/railties/guides/code/getting_started/test/unit/tag_test.rb b/railties/guides/code/getting_started/test/unit/tag_test.rb new file mode 100644 index 0000000000..b8498a117c --- /dev/null +++ b/railties/guides/code/getting_started/test/unit/tag_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class TagTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end |