Sha256: f39c1b792136e3db365a14f2c0f7a1694d5e8c41f7a1895251ef9dcd4197df9f

Contents?: true

Size: 1.81 KB

Versions: 11

Compression:

Stored size: 1.81 KB

Contents

require File.dirname(__FILE__) + '/../../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.2 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.1 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.9.0 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.8.0 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.7.1 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.7.0 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.6.10 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.6.9 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.6.8 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.6.7 spec/controllers/admin/sites_controller_spec.rb
site_logic-1.6.6 spec/controllers/admin/sites_controller_spec.rb