Skip to content
This repository has been archived by the owner on Nov 17, 2018. It is now read-only.
Permalink
Browse files
Use AS::Concern instead of Plain Old Ruby
  • Loading branch information
steveklabnik committed Jan 14, 2013
1 parent 744c9d0 commit 30af3c1fb5717e867d53ce95562e9fe45afc3db9
Showing 1 changed file with 34 additions and 33 deletions.
@@ -1,49 +1,50 @@
require 'test_helper'
require 'active_support/concern'

module PostsControllerBehavior
def self.included(controller)
controller.instance_eval do
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:posts)
end
extend ActiveSupport::Concern

test "should get new" do
get :new
assert_response :success
end
included do
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:posts)
end

test "should create post" do
assert_difference('Post.count') do
post :create, post: { body: @post.body, private: @post.private, title: @post.title }
end
test "should get new" do
get :new
assert_response :success
end

assert_redirected_to post_path(assigns(:post))
test "should create post" do
assert_difference('Post.count') do
post :create, post: { body: @post.body, private: @post.private, title: @post.title }
end

test "should show post" do
get :show, id: @post
assert_response :success
end
assert_redirected_to post_path(assigns(:post))
end

test "should get edit" do
get :edit, id: @post
assert_response :success
end
test "should show post" do
get :show, id: @post
assert_response :success
end

test "should update post" do
put :update, id: @post, post: { body: @post.body, private: @post.private, title: @post.title }
assert_redirected_to post_path(assigns(:post))
end
test "should get edit" do
get :edit, id: @post
assert_response :success
end

test "should destroy post" do
assert_difference('Post.count', -1) do
delete :destroy, id: @post
end
test "should update post" do
put :update, id: @post, post: { body: @post.body, private: @post.private, title: @post.title }
assert_redirected_to post_path(assigns(:post))
end

assert_redirected_to posts_path
test "should destroy post" do
assert_difference('Post.count', -1) do
delete :destroy, id: @post
end

assert_redirected_to posts_path
end
end
end

0 comments on commit 30af3c1

Please sign in to comment.