Skip to content

Add failing specs for scope and relative url#2173

Closed
LTe wants to merge 1 commit intoheartcombo:masterfrom
LTe:relative_url_and_scope
Closed

Add failing specs for scope and relative url#2173
LTe wants to merge 1 commit intoheartcombo:masterfrom
LTe:relative_url_and_scope

Conversation

@LTe
Copy link
Copy Markdown

@LTe LTe commented Dec 11, 2012

When I use in application

ENV['RAILS_RELATIVE_URL_ROOT'] = 'my_app'

and in my routes

scope :my_app do
  devise_for :users
end

devise double render relative part of URL. I am including a test that does not pass.

test_returns_to_the_default_redirect_location_considering_the_relative_url_root_and_scope(FailureTest) [/home/lite/work/devise/test/failure_app_test.rb:67]: <"http://test.host/scoped/scoped_admin/sign_in"> expected but was <"http://test.host/scoped/scoped/scoped_admins/sign_in">.

@josevalim
Copy link
Copy Markdown
Contributor

Thanks for the pull request but I don't understand how the test is supposed to pass. You are setting a route scoped to "scoped" and then relative_url_options to "/scoped", so they must appear duplicated in the generated path. If you have Devise scoped to "/admin" and your application relative url set to "/foo/bar", you want the final route to be "/foo/bar/admin/". I don't see why it should not appear duplicated given they are the same.

What am I missing?

@LTe
Copy link
Copy Markdown
Author

LTe commented Dec 13, 2012

When I set relative_url_options to /foo/bar I need to put all my routes inside:

scope 'foo/bar' do
  # routes
end

When I define devise inside foo/bar

scope 'foo/bar' do
  devise_for :users
end

then devise will generate #{relative_url_options}/#{scope}/#{users} so /foo/bar/foo/bar/users. Of course I can execute devise_for :users outside scope block. It looks a bit inconsistent. Should I always execute devise_for outside scope method?

@josevalim
Copy link
Copy Markdown
Contributor

When I set relative_url_options to /foo/bar I need to put all my routes inside scoped

That is not supposed to be true. Setting the relative_url_options is supposed to be transparent and it should not require changes in your router. If it requires, it is a bug in Rails.

@josevalim josevalim closed this Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants