Class: BelongsToTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- BelongsToTest
- Defined in:
- lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_expose_a_new_comment_on_new ⇒ Object
- #test_expose_a_newly_create_comment_on_create ⇒ Object
- #test_expose_all_comments_as_instance_variable_on_index ⇒ Object
- #test_expose_the_resquested_comment_on_edit ⇒ Object
- #test_expose_the_resquested_comment_on_show ⇒ Object
- #test_the_resquested_comment_is_destroyed_on_destroy ⇒ Object
- #test_update_the_requested_object_on_update ⇒ Object
Instance Method Details
#setup ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 17 def setup Post.expects(:find).with('37').returns(mock_post) mock_post.expects(:comments).returns(Comment) @controller.stubs(:resource_url).returns('/') @controller.stubs(:collection_url).returns('/') end |
#test_expose_a_new_comment_on_new ⇒ Object
39 40 41 42 43 44 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 39 def test_expose_a_new_comment_on_new Comment.expects(:build).returns(mock_comment) get :new, :post_id => '37' assert_equal mock_post, assigns(:post) assert_equal mock_comment, assigns(:comment) end |
#test_expose_a_newly_create_comment_on_create ⇒ Object
53 54 55 56 57 58 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 53 def test_expose_a_newly_create_comment_on_create Comment.expects(:build).with({'these' => 'params'}).returns(mock_comment(:save => true)) post :create, :post_id => '37', :comment => {:these => 'params'} assert_equal mock_post, assigns(:post) assert_equal mock_comment, assigns(:comment) end |
#test_expose_all_comments_as_instance_variable_on_index ⇒ Object
25 26 27 28 29 30 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 25 def test_expose_all_comments_as_instance_variable_on_index Comment.expects(:find).with(:all).returns([mock_comment]) get :index, :post_id => '37' assert_equal mock_post, assigns(:post) assert_equal [mock_comment], assigns(:comments) end |
#test_expose_the_resquested_comment_on_edit ⇒ Object
46 47 48 49 50 51 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 46 def test_expose_the_resquested_comment_on_edit Comment.expects(:find).with('42').returns(mock_comment) get :edit, :id => '42', :post_id => '37' assert_equal mock_post, assigns(:post) assert_equal mock_comment, assigns(:comment) end |
#test_expose_the_resquested_comment_on_show ⇒ Object
32 33 34 35 36 37 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 32 def test_expose_the_resquested_comment_on_show Comment.expects(:find).with('42').returns(mock_comment) get :show, :id => '42', :post_id => '37' assert_equal mock_post, assigns(:post) assert_equal mock_comment, assigns(:comment) end |
#test_the_resquested_comment_is_destroyed_on_destroy ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 68 def test_the_resquested_comment_is_destroyed_on_destroy Comment.expects(:find).with('42').returns(mock_comment) mock_comment.expects(:destroy) delete :destroy, :id => '42', :post_id => '37' assert_equal mock_post, assigns(:post) assert_equal mock_comment, assigns(:comment) end |
#test_update_the_requested_object_on_update ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/vendor/plugins/inherited_resources/test/belongs_to_test.rb', line 60 def test_update_the_requested_object_on_update Comment.expects(:find).with('42').returns(mock_comment) mock_comment.expects(:update_attributes).with({'these' => 'params'}).returns(true) put :update, :id => '42', :post_id => '37', :comment => {:these => 'params'} assert_equal mock_post, assigns(:post) assert_equal mock_comment, assigns(:comment) end |