Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
jumph4x opened this Issue · 6 comments

2 participants

Denis Ivanov Ryan Bigg
Denis Ivanov

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?

Denis Ivanov

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
Ryan Bigg
Collaborator

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" }
Denis Ivanov

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?

Denis Ivanov

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?

Ryan Bigg
Collaborator

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

Denis Ivanov jumph4x referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Denis Ivanov jumph4x referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Denis Ivanov

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

Ryan Bigg radar closed this
David Demers fonemstr referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Thomas von Deyen tvdeyen referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.