On Thu, Jan 28, 2010 at 9:48 AM, Benjamin Podszun <
benjamin.pods...@gmail.com> wrote:

> I cannot even write more than a helo world in ruby, but - if you want
> to trust someone that claims to be incompentent right away:
>

(snip)

Your analysis of the code is either a tribute to Ruby's/Rails' degree of
readability or to your competence as a programmer.


> If this blows up your system I'm not to blame, but I'd just try to
> comment this single line in make_activation_code. I suspect that this
> leads to users being created without an activation code, which again
> should treat them as activated by default.
>

Actually, the first sign of something blowing up in the application should
be for any of the tests to fail after implementing a change in behaviour.
(The tests can be run using the command `rake test` - to prepare for this
you need to create an entry for the test RAILS_ENV in config/database.yml
and create a separate database for running the tests).

The UsersControllerTest (test/functional/users_controller_test.rb) has a
test/specification that reads as follows:

    should "requires the user to activate himself after posting valid data"
do
      create_user
      assert_equal nil, User.authenticate('qu...@example.com', 'quire')
      assert !...@controller.send(:logged_in?), 'controller.send(:logged_in?)
should be false'
    end

Enough theory...

For this to work both with local installs that do not require the activation
mails to be sent and on public sites where this is a requirement to prevent
spam accounts, on should probably introduce a setting that specifies whether
email confirmation should be required. An additional test case could verify
this behaviour:

    should "not require account confirmation if not specified in application
settings" do
      GitoriousConfig['skip_account_confirmation'] = true
      create_user
      assert_not_nil User.authenticate('qu...@example.com', 'quire')
      assert @controller.send(:logged_in?), 'controller.send(:logged_in?)
should be true'
    end

Still, for activation to be performed immediately, you could add a line in
app/controllers/users_controller.rb in the create method (after the line
that reads "@user.save!"):

@user.activate

This would be what they call a hack :-)

Cheers,
- Marius

-- 
To post to this group, send email to gitorious@googlegroups.com
To unsubscribe from this group, send email to
gitorious+unsubscr...@googlegroups.com

Reply via email to