require 'spec_helper' describe Admin::SetupController do describe :new do it "should be successful" do get :new response.should be_success end it "should set a flash error message when a spud user exists" do SpudUser.stubs(:count).returns(1) get :new flash[:error].should_not be_blank end it "should redirect to the admin login form when there is already a user" do SpudUser.stubs(:count).returns(1) get :new response.should redirect_to(admin_login_path) end end describe :create do it "should create a new user" do lambda { post :create, :spud_user => FactoryGirl.attributes_for(:spud_user) }.should change(SpudUser, :count).by(1) end it "should redirect to the admin dashboard when first admin user has been created" do post :create, :spud_user => FactoryGirl.attributes_for(:spud_user) response.should redirect_to(admin_root_path) end end end