Permalink
Browse files

Minor cleanups for spec passing goodness

  • Loading branch information...
1 parent 9c61577 commit 726bb9c56a1add65e6f5afcadbaaf9c399bd19a3 @courtenay courtenay committed Aug 5, 2009
@@ -22,7 +22,6 @@ def create
@user.save if @user.valid?
@user.register! if @user.valid?
unless @user.new_record?
-
redirect_back_or_default('/login')
flash[:notice] = "Thanks for signing up! Please click the link in your email to activate your account"
else
@@ -97,14 +96,14 @@ def make_admin
def find_user
@user = if admin?
current_site.all_users.find params[:id]
- elsif params[:id] == current_user.id?
+ elsif params[:id] == current_user.id
current_user
else
current_site.users.find params[:id]
end or raise ActiveRecord::RecordNotFound
end
def authorized?
- admin? || params[:id].blank? || params[:id] == current_user.permalink
+ admin? || params[:id].blank? || params[:id] == current_user.id.to_s
end
-end
+end
@@ -5,12 +5,7 @@ class User
after_create :set_first_user_as_activated
def set_first_user_as_activated
- puts "set first user as activated"
- register! && activate! if is_first_user?
- end
-
- def is_first_user?
- site.nil? or site.users.size <= 1
+ register! && activate! if site.nil? or site.users.count <= 1
end
# Returns true if the user has just been activated.
@@ -35,7 +35,6 @@ def self.authenticate(login, password)
end
def do_activation
- puts "do activation"
self.deleted_at = nil
self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
@@ -48,7 +47,6 @@ def do_delete
end
def do_activate
- puts "do activate"
@activated = true
self.activated_at = Time.now.utc
self.deleted_at = nil
@@ -72,7 +72,7 @@
it "sends an email to the user on create" do
create_user :login => "admin", :email => "admin@example.com"
- puts "sending emails"
+ response.should be_redirect
lambda{ create_user }.should change(ActionMailer::Base.deliveries, :size).by(1)
end
@@ -149,6 +149,7 @@ def create_user(options = {})
end
describe UsersController, "PUT #update" do
+ define_models :users
before do
login_as :default
current_site :default
@@ -157,7 +158,7 @@ def create_user(options = {})
describe UsersController, "(successful save)" do
define_models
- act! { put :update, :id => @user.id, :user => @attributes }
+ act! { put :update,{ :id => @user.id, :user => @attributes }}
before do
@user.stub!(:save).and_return(true)
@@ -168,11 +169,15 @@ def create_user(options = {})
describe "updating from edit form" do
define_models :stubbed
- %w(display_name openid_url website bio).each do |field|
- it "should update #{field}" do
- put :update, :id => @user.id, :user => { field, "test" }
- assigns(:user).attributes[field].should == "test"
+ %w(display_name website bio).each do |field|
+ it "should update #{field}" do
+ put :update, :id => @user.id, :user => { field => "test" }
+ assigns(:user).attributes[field].should == "test"
+ end
end
+ it "should update openid_url" do
+ put :update, :id => @user.id, :user => { 'openid_url' => 'test' }
+ assigns(:user).attributes['openid_url'].should == 'http://test/'
end
end
end

0 comments on commit 726bb9c

Please sign in to comment.