Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:33:36+00:00 2026-05-23T13:33:36+00:00

When a new user is created they are given a password. I want to

  • 0

When a new user is created they are given a password.

I want to test the case when the user updates or changes their password.

User.rb

 validates :password, :on => :create,
                :presence => true,
                :confirmation => true,
                :length => {:within => 6..12}

before_validation :make_password, :on => :create

In spec/models/user_spec.rb I have the following:

describe “password validations” do
before(:each) do
@user = Factory(:user)
end

it "should reject passwords that are too long" do
  too_long_password = "a" * 13
  @user.update_attributes(@attr.merge(:password => too_long_password, :password_confirmation => too_long_password)).should_not be_valid
end

end

Does not work.
Now how do I test for the update?
Any ideas appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:33:36+00:00Added an answer on May 23, 2026 at 1:33 pm

    remove the :on => :create clause from the validates. Removing this will activate the validation during create and update.

     validates :password,:presence => true,
                         :confirmation => true,
                         :length => {:within => 6..12}
    

    You have not mentioned but you can also remove :on => :create, if it is needed in the before_validation too

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, I want a user to create a new fanclub for a given
I'm trying to test that a UserProfile model is created as a new User
When the program starts, a new JFrame is created. Once the user clicks the
How can create a New user in ORACLE with full access (alter, delete, select,
Im trying to test my successfully creates a new user after login (using authlogic).
In a view I'm trying to create a new user and then log them
I have a database called ADB. When I create a new user/role, that user
When you create a new web user control in visual studio it by default
One of my web pages allows the user to create a new record, and,
Is it possible to create a new process on windows with a different user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.