Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

currentURL fails in Ember 1.12.0-beta.1 before calls to visit #10850

Closed
backspace opened this issue Apr 8, 2015 · 1 comment
Closed

currentURL fails in Ember 1.12.0-beta.1 before calls to visit #10850

backspace opened this issue Apr 8, 2015 · 1 comment

Comments

@backspace
Copy link

TLDR: calling currentURL() in acceptance tests before any calls to visit() worked in Ember 1.11 but throws an error in Ember 1.12.0-beta.1.

I have an acceptance test that interacts with a modal-like search interface that is accessible from some routes in the application. I wrote some helper methods to reduce repetition in the tests, they look something like this:

var searchFor = function(query) {
  showSearch();

  fillIn('.search-pane input', query);
};

var showSearch = function() {
  andThen(function() {
    if (currentURL().indexOf('path with access to the search') === -1) {
      visit('path with access to the search')
    }
  });

  // Show the search if not already showing
  andThen(function() {
    if (find('.search-pane input').length === 0) {
      click('.search div');
    }
  });
};

This way I can searchFor('something') and not have to care whether I’m at the right path or whether the search interface is currently showing.

In Ember 1.12.0-beta.1, I can no longer check currentURL() to see whether I need to navigate somewhere before searching because it throws undefined is not a function at this line, specifically from the call to property_get(router, 'location').

Is this a desired change? Maybe it makes sense to require a call to visit() before checking the URL, but it was an unexpected change to work around. If a call to visit() is to be required, maybe there could be an error message to that effect?

Some demonstrative JS Bins, adapted from the other current currentURL issue:

Working in Ember 1.11.0
Broken in Ember 1.12.0-beta.1
Still broken after #10805 (hopefully I have the right script tags there, it’s also copied from the other issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants