Sha256: ec03b95de0a92b5ac28e598d45137b9a7e5b782eab14c2de3dd90d893df8c86d

Contents?: true

Size: 1.78 KB

Versions: 11

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe Admin::SitesController do
  before :all do
    Site.destroy_all
    @site_1 = Site.make
    @site_2 = Site.make
  end

  it "index action should render index template" do
    get :index
    response.should render_template(:index)
  end

  it "show action should render show template" do
    get :show, :id => Site.first.id
    response.should render_template(:show)
  end

  it "new action should render new template" do
    get :new
    response.should render_template(:new)
  end

  it "create action should render new template when model is invalid" do
    Site.any_instance.stubs(:valid?).returns(false)
    post :create
    response.should render_template(:new)
  end

  it "create action should redirect when model is valid" do
    Site.any_instance.stubs(:valid?).returns(true)
    Site.any_instance.stubs(:activate!).returns(true)
    post :create, :site => {:state => nil}
    response.should redirect_to(admin_site_url(assigns[:site]))
  end

  it "edit action should render edit template" do
    get :edit, :id => Site.first.id
    response.should render_template(:edit)
  end

  it "update action should render edit template when model is invalid" do
    Site.any_instance.stubs(:valid?).returns(false)
    put :update, :id => Site.first.id
    response.should render_template(:edit)
  end

  it "update action should redirect when model is valid" do
    Site.any_instance.stubs(:valid?).returns(true)
    put :update, :id => Site.first.id, :site => {:state => nil}
    response.should redirect_to(admin_site_url(assigns[:site]))
  end

  it "destroy action should destroy model and redirect to index action" do
    site = Site.first
    delete :destroy, :id => site.id
    response.should redirect_to(admin_sites_url)
    Site.where(:id => site.id).first.should be_nil
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
site_logic-1.9.13 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.12 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.11 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.10 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.9 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.8 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.7 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.6 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.5 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.4 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.3 spec/controllers/admin/sites_controller_spec.rb