Sha256: 64a90f73a648932b8ad65630a71caac3f6803c627a12bdf543f1dfd6eacacc25

Contents?: true

Size: 1.29 KB

Versions: 15

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Admin::BlogsController do
  before :each do
    @blog = Blog.new
    Blog.stubs(:find).returns(@blog)
    Blog.any_instance.stubs(:save).returns(true)
    Blog.any_instance.stubs(:to_param).returns('1')
  end

  it 'gets index action' do
    Blog.stubs(:find).returns([@blog])
    get :index
    response.should render_template(:index)
  end

  it 'gets show action' do
    get :show, :id => 1
    response.should render_template(:show)
  end

  it 'gets new action' do
    get :new
    response.should render_template(:new)
  end

  it 'posts create action and renders new template when model is invalid' do
    Blog.any_instance.stubs(:save).returns(false)
    post :create
    response.should render_template(:new)
  end

  it 'posts create action and redirects' do
    post :create
    response.should be_redirect
  end

  it 'gets edit action' do
    get :edit, :id => 1
    response.should render_template(:edit)
  end

  it 'puts update action and renders edit template when model is invalid' do
    Blog.any_instance.stubs(:save).returns(false)
    put :update, :id => 1
    response.should render_template(:edit)
  end

  it 'puts update action and redirects' do
    Blog.any_instance.stubs(:save).returns(true)
    put :update, :id => 1
    response.should be_redirect
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blog_logic-1.4.15 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.14 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.13 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.12 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.11 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.10 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.9 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.8 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.7 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.6 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.5 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.4 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.3 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.2 spec/controllers/admin/blogs_controller_spec.rb
blog_logic-1.4.1 spec/controllers/admin/blogs_controller_spec.rb