fix pageless plugin with scrape method

When including a scrape function to pageless, the data after scraping was
being dumped into the DOM incorrectly. This fixes that, and includes a test
for the announcements page.

(The bug was originally seen on the inbox, but rather than write a spec for
code that won't last much longer, I wrote the test for somewhere else.)

Change-Id: If4ca0cbed89dcf6e6e24e814f75824266422cbfa
Reviewed-on: https://gerrit.instructure.com/4992
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Selenium <selenium@instructure.com>
This commit is contained in:
Zach Wily 2011-08-07 21:51:14 -06:00
parent 39b3c13545
commit 9ec09415d2
3 changed files with 20 additions and 1 deletions

View File

@ -169,7 +169,7 @@
$.get( settings.url
, settings.params
, function (data, text, xhr) {
$.isFunction(settings.scrape) ? settings.scrape(data, xhr) : data;
var data = $.isFunction(settings.scrape) ? settings.scrape(data, xhr) : data;
loader ? loader.before(data) : element.append(data);
loading(FALSE);
// if there is a complete callback we call it

View File

@ -246,6 +246,7 @@ I18n.scoped('wiki.sidebar', function(I18n) {
loaderMsg: I18n.t('loading_more_results', "Loading more results"),
scrape: function(data, xhr) {
this.totalPages = parseInt(xhr.getResponseHeader('X-Total-Pages'));
return data;
}
});
}

View File

@ -0,0 +1,18 @@
require File.expand_path(File.dirname(__FILE__) + '/common')
describe "announcements selenium tests" do
it_should_behave_like "in-process server selenium tests"
it "should not show JSON when loading more assignments via pageless" do
course_with_student_logged_in
50.times { @course.announcements.create!(:title => 'Hi there!', :message => 'Announcement time!') }
get "/courses/#{@course.id}/announcements"
start = driver.find_elements(:css, "#topic_list .topic").length
driver.execute_script('window.scrollTo(0, 100000)')
keep_trying_until { driver.find_elements(:css, "#topic_list .topic").length > start }
driver.find_element(:id, "topic_list").text.should_not match /discussion_topic/
end
end