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 712389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:50:34+00:00 2026-05-14T04:50:34+00:00

Im trying to test my successfully creates a new user after login (using authlogic).

  • 0

Im trying to test my successfully creates a new user after login (using authlogic). Ive added a couple of new fields to the user so just want to make sure that the user is saved properly.

The problem is despite creating a valid user factory, whenever i try to grab its attributes to post to the create method, password and password confirmation are being ommitted. I presuem this is a security method that authlogic performs in the background. This results in validations failing and the test failing.

Im wondering how do i get round this problem? I could just type the attributes out by hand but that doesnt seem very dry.

 context "on POST to :create" do
            context "on posting a valid user" do
                setup do
                    @user = Factory.build(:user)
                    post :create, :user => @user.attributes
                end
                should "be valid" do
                    assert @user.valid?
                end
                should_redirect_to("users sentences index page") { sentences_path() }
                should "add user to the db" do
                    assert User.find_by_username(@user.username)
                end
            end


##User factory
Factory.define :user do |f|
  f.username {Factory.next(:username) }
  f.email { Factory.next(:email)}
  f.password_confirmation  "password"
  f.password "password"
  f.native_language {|nl| nl.association(:language)}
  f.second_language {|nl| nl.association(:language)}
end
  • 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-14T04:50:34+00:00Added an answer on May 14, 2026 at 4:50 am

    You definitely can’t read the password and password_confirmation from the User object. You will need to merge in the :password and :password_confirmation to the @user.attributes hash. If you store that hash somewhere common with the rest of your factory definitions, it is not super dry, but it is better than hardcoding it into your test.

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

Sidebar

Related Questions

just trying to test for equality in this piece of code, but getting a
I'm trying to test using SFML's full screen mode, however it crashes every time
I am trying to test a sinatra app using minitest and capybara but get
I'm trying to test in-app billing using my own sku/product ID upgrade_to_premium. As I
I am using alfresco 4. I have created a new site called test and
I've been trying to create new local user accounts on windows 7 machine. I
I'm trying to test my grails app using integration test that makes http requests.
Trying to test the option of replacing our internal data access layer with Entity
I trying to test an AccountController that uses DotNetOpenAuth but I am running into
I am trying to test some async methods involving the HttpClient work with vs

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.