From 1b6726354f2f5582294eb1053c35632b56dec41e Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Sat, 16 Oct 2010 21:14:37 -0700 Subject: [PATCH] Backfill specs for RegistrationsController#create. Remove RegistrationsController#new (which just called super, so it's not necessary). --- app/controllers/registrations_controller.rb | 4 --- .../registrations_controller_spec.rb | 25 ++++++++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index b29887112..6b79b180b 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -3,10 +3,6 @@ # the COPYRIGHT file. class RegistrationsController < Devise::RegistrationsController - def new - super - end - def create begin user = User.instantiate!(params[:user]) diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index a1f9328a7..828e6a4e4 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -11,12 +11,29 @@ describe RegistrationsController do before do request.env["devise.mapping"] = Devise.mappings[:user] + @valid_params = {"user" => {"username" => "jdoe", + "email" => "jdoe@example.com", + "password" => "password", + "password_confirmation" => "password", + "person" => { + "profile" => { + "first_name" => "John", + "last_name" => "Doe"}}}} end - describe "#new" do - it "succeeds" do - get :new - response.should be_success + describe "#create" do + context "with valid parameters" do + it "creates a user" do + lambda { get :create, @valid_params }.should change(User, :count).by(1) + end + it "sets the flash" do + get :create, @valid_params + flash[:notice].should_not be_empty + end + it "redirects to the root path" do + get :create, @valid_params + response.should redirect_to root_path + end end end end