Guest User

Untitled

a guest
Jun 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. require 'test_helper'
  2.  
  3. class Admin::BlogsControllerTest < ActionController::TestCase
  4. context "Admin Blogs controller" do
  5. context "on GET to :new" do
  6. setup do
  7. get :new
  8. end
  9.  
  10. should_respond_with :success
  11. should_assign_to :current_blog
  12. should_render_template :new
  13. should_render_a_form
  14. end
  15.  
  16. context "on POST to :create" do
  17. setup do
  18. post :create, :blog => {:title => 'Blog', :description => "saldjf"}
  19. end
  20.  
  21. teardown do
  22. Blog.destroy_all
  23. end
  24.  
  25. should_redirect_to "Admin::Blog#show" do
  26. blog = Blog.first
  27. admin_blog_path(blog)
  28. end
  29.  
  30. should "create blog" do
  31. assert Blog.exists?(:title => 'Blog')
  32. end
  33.  
  34. end
  35.  
  36. context "on GET to :show" do
  37. setup do
  38. current_blog = Factory(:blog)
  39. get :show, :id => current_blog.id
  40. end
  41.  
  42. should_respond_with :success
  43. should_assign_to :current_blog
  44. should_render_template :show
  45. end
  46. end
  47. end
Add Comment
Please, Sign In to add comment