[36517] Fix placeholder filter returning query object, not AR collection (#9071)

We depend on the query for correct sorting by name.

https://community.openproject.com/work_packages/36517
pull/9078/head
Oliver Günther 4 years ago committed by GitHub
parent aba54d4a00
commit a023ccf372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/placeholder_users_controller.rb
  2. 2
      app/models/queries/placeholder_users/orders/default_order.rb
  3. 2
      frontend/src/app/sentry/sentry-reporter.ts
  4. 16
      spec/features/placeholder_users/index_spec.rb
  5. 5
      spec/support/pages/admin/placeholder_users/index.rb

@ -42,7 +42,7 @@ class PlaceholderUsersController < ApplicationController
destroy]
def index
@placeholder_users = PlaceholderUsers::PlaceholderUserFilterCell.filter params
@placeholder_users = PlaceholderUsers::PlaceholderUserFilterCell.query params
respond_to do |format|
format.html do

@ -32,6 +32,6 @@ class Queries::PlaceholderUsers::Orders::DefaultOrder < Queries::BaseOrder
self.model = PlaceholderUser
def self.key
/\A(id|name)\z/
/\A(id|name|created_at|updated_at)\z/
end
end

@ -175,7 +175,7 @@ export class SentryReporter implements ErrorReporter {
private filterEvent(event:SentryEvent):SentryEvent|null {
const unsupportedBrowser = document.body.classList.contains('-unsupported-browser');
if (unsupportedBrowser) {
console.warn("Browser is not supported, skipping sentry reporting completely.")
console.warn("Browser is not supported, skipping sentry reporting completely.");
return null;
}

@ -33,17 +33,17 @@ describe 'index placeholder users', type: :feature do
let!(:anonymous) { FactoryBot.create :anonymous }
let!(:placeholder_user_1) do
FactoryBot.create(:placeholder_user,
name: 'One',
name: 'B',
created_at: 3.minute.ago)
end
let!(:placeholder_user_2) do
FactoryBot.create(:placeholder_user,
name: 'Two',
name: 'A',
created_at: 2.minute.ago)
end
let!(:placeholder_user_3) do
FactoryBot.create(:placeholder_user,
name: 'Three',
name: 'C',
created_at: 1.minute.ago)
end
let(:index_page) { Pages::Admin::PlaceholderUsers::Index.new }
@ -58,11 +58,17 @@ describe 'index placeholder users', type: :feature do
# so first ones created are on top.
index_page.expect_listed(placeholder_user_1, placeholder_user_2, placeholder_user_3)
index_page.order_by('Name')
index_page.expect_ordered(placeholder_user_2, placeholder_user_1, placeholder_user_3)
index_page.order_by('Name')
index_page.expect_ordered(placeholder_user_3, placeholder_user_1, placeholder_user_2)
index_page.order_by('Created on')
index_page.expect_listed(placeholder_user_3, placeholder_user_2, placeholder_user_1)
index_page.expect_ordered(placeholder_user_3, placeholder_user_2, placeholder_user_1)
index_page.order_by('Created on')
index_page.expect_listed(placeholder_user_1, placeholder_user_2, placeholder_user_3)
index_page.expect_ordered(placeholder_user_1, placeholder_user_2, placeholder_user_3)
index_page.filter_by_name(placeholder_user_3.name)
index_page.expect_listed(placeholder_user_3)

@ -41,6 +41,11 @@ module Pages
expect(rows.map(&:text)).to include(*placeholder_users.map(&:name))
end
def expect_ordered(*placeholder_users)
rows = page.all 'td.name'
expect(rows.map(&:text)).to eq(placeholder_users.map(&:name))
end
def expect_not_listed(*users)
rows = page.all 'td.name'
expect(rows.map(&:text)).to_not include(*users.map(&:name))

Loading…
Cancel
Save