[devise] RSpec 2, Devise and Rails 3

110 views
Skip to first unread message

Joseph DelCioppio

unread,
May 22, 2010, 11:12:41 AM5/22/10
to Devise
Guys,

Have we gotten any closer to making RSpec2 and Devise work better
together? It seems that this issue has been dropped. Is there
anything I can do to help this process?

Joe

Joey Beninghove

unread,
May 22, 2010, 10:49:31 PM5/22/10
to plataforma...@googlegroups.com
I actually have this working right now with Devise edge.  Just simple include Devise::TestHelpers in your RSpec2 spec and use the sign_in helper method.  Here's an example:

describe AssessmentsController do
    include Devise::TestHelpers

    context "logged in" do
        before(:each) do
            @user = Factory.create(:user)  # <-- uses factory_girl
            sign_in @user
        end
    end
end

Then everything seems to be working for me and solves the "undefined method 'authenicate_user!'" error I used to get.

Hope that helps,
Joey

José Valim

unread,
May 23, 2010, 4:18:49 AM5/23/10
to plataforma...@googlegroups.com
Just one note, you need latest Rspec.
--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/

Joseph DelCioppio

unread,
May 23, 2010, 2:46:52 PM5/23/10
to Devise
Thanks guys this worked great.

I'm gonna ask one more since I"m here.

I'd like the "Update" action of the Registrations controller to
redirect back to the edit page. How can I get this done? Can I
override the Update action if I created my own controller?

Joe

On May 23, 4:18 am, José Valim <jose.va...@gmail.com> wrote:
> Just one note, you need latest Rspec.
>
> On Sun, May 23, 2010 at 4:49 AM, Joey Beninghove
> <joeybeningh...@gmail.com>wrote:

José Valim

unread,
May 23, 2010, 3:10:25 PM5/23/10
to plataforma...@googlegroups.com
I have a good idea:

1) Fork devise

2) Change the registrations controller to redirect to a customizable path. Instead of the following:

http://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb#L34

Something like that:

  redirect_to after_update_path_for(resource)

And then define this after_update_path_for in the controller which just triggers the default implementation.

3) Send me a pull request

This way it would be straight forward to change the after update path without a need to duplicate the whole action! And others will be able to benefit from your work as well!

Wdyt? :)

Joseph DelCioppio

unread,
May 23, 2010, 5:18:31 PM5/23/10
to Devise
Jose,

I will do my very best. I hope I can help!

Joe

On May 23, 3:10 pm, José Valim <jose.va...@gmail.com> wrote:
> I have a good idea:
>
> 1) Fork devise
>
> 2) Change the registrations controller to redirect to a customizable path.
> Instead of the following:
>
> http://github.com/plataformatec/devise/blob/master/app/controllers/de...

Joseph DelCioppio

unread,
May 23, 2010, 6:03:05 PM5/23/10
to Devise
Jose,

Alright I forked you, added after_update_path so that user can
seperately configure the update path if they want but it will still
default to root if they don't do anything. Trying to run "bundle
install" so I can run the test suite, including the tests that I
wrote, but I get the following error with Bundler, any idea why?

No compatible versions could be found for required dependencies:
Conflict on: "dm-core":
* dm-core (1.0.0.rc2) activated by dm-core (>= 0, runtime)
* dm-core (~> 0.10.3, runtime) required by dm-timestamps (>= 0,
runtime)
All possible versions of origin requirements conflict.

I'm still trying to learn bundler so I'm not totally sure what its
telling me. I think its saying that I've got 1.0.0.rc2 of dm-core,
but dm-timestamps wants 0.10.3?

Joe

On May 23, 5:18 pm, Joseph DelCioppio <joseph.delciop...@gmail.com>
wrote:

José Valim

unread,
May 23, 2010, 6:06:42 PM5/23/10
to plataforma...@googlegroups.com
Just comment the dm part from Gemfile for this while (but do not commit the commented result). Note also that you will need a rails checkout to run the tests.

Joseph DelCioppio

unread,
May 24, 2010, 10:24:45 AM5/24/10
to Devise
Jose,

Ok I submitted a pull request. This is my first contribution to open-
source so I hope I sent the request correctly.

Joe

José Valim

unread,
May 24, 2010, 10:29:46 AM5/24/10
to plataforma...@googlegroups.com
I didn't get an e-mail yet, but could you open an issue in the Devise's issues tracker with a link to your commit?

Thanks a bunch and congratulations!
Reply all
Reply to author
Forward
0 new messages