Admin Head Defines Ajax URIs in Terms of URLs not Paths #1508

Closed
jumph4x opened this Issue May 7, 2012 · 6 comments

2 participants

@jumph4x
Spree Commerce member

Hey guys, take a look at the admin _head.html.erb partial: https://github.com/spree/spree/blob/1-0-stable/core/app/views/spree/admin/shared/_head.html.erb#L8

Is there a reason you want to define a full _url instead of a _path?

This makes integration testing a pain in certain contexts. Specifically because the layout is inherited by all spree extensions.

Currently dealing with this when trying to test

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

Thoughts?

@jumph4x
Spree Commerce member

I have got to be missing something obvious. Trying to use 1.0.3 and 1.0.4 in development and seeing this:

ArgumentError in Spree/admin/overview#index

Showing /home/denis/.rvm/gems/ruby-1.9.2-p320/gems/spree_core-1.0.3/app/views/spree/admin/shared/_head.html.erb where line #8 raised:

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
Extracted source (around line #8):

5: 
6: <%= javascript_tag do %>
7:   ajax_urls = <%== {
8:     :product_search_json       => spree.admin_products_url(:format => 'json'),
9:     :product_search_basic_json => spree.admin_products_url(:format => 'json', :json_format => 'basic', :limit => 10),
10:     :user_search_basic_json    => spree.admin_users_url(:format => 'json', :json_format => 'basic', :limit => 10)
11:   }.to_json %>;
Trace of template inclusion: /home/denis/.rvm/gems/ruby-1.9.2-p320/gems/spree_core-1.0.3/app/views/spree/layouts/admin.html.erb
@radar
Spree Commerce member

No particular reason to be using a url and not a path I would think. Can you try switching it to path and seeing if that still works?

Alternatively:

config.action_controller.default_url_options = { :host => "localhost" }
@jumph4x
Spree Commerce member

Tried it changing absolute _urls to relative _paths and it worked as expected. Went to edit an order and add a product, the AJAX paths seemed to work fine.

Can I create a pull request?

@jumph4x
Spree Commerce member

Tried a number of things, most sane of which was:

    initializer "spree.google_base.host", :before => :load_config_initializers do |app|
      app.config.action_controller.default_url_options = { :host => "localhost" }
    end

Still no go testing the current 1.0.4. I don't want to apply this configuration in the app directly since this is a dummy app for testing an extension.

Is what I'm trying to accomplish even possible?

@radar
Spree Commerce member

Yes, go ahead and create a pull request if _path worked.

@jumph4x
Spree Commerce member

That's 3 requests one for each branch. I am hoping to test extensions in all three contexts :)

@radar radar closed this May 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment