Authlogic and password and password confirmation attributes - inaccessible?

Posted by adam on Stack Overflow See other posts from Stack Overflow or by adam
Published on 2010-04-10T07:02:17Z Indexed on 2010/04/10 7:13 UTC
Read the original article Hit count: 506

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

© Stack Overflow or respective owner

Related posts about authlogic

Related posts about ruby-on-rails