FEATURE: Make staff action logs page support infinite loading

This commit is contained in:
Bianca Nenciu
2019-06-06 06:02:53 +03:00
committed by Sam
parent b510006ca8
commit e0c821ebb0
5 changed files with 176 additions and 120 deletions

View File

@ -31,6 +31,26 @@ describe Admin::StaffActionLogsController do
)
end
it 'generates logs with pages' do
1.upto(4).each do |idx|
StaffActionLogger.new(Discourse.system_user).log_site_setting_change("title", "value #{idx - 1}", "value #{idx}")
end
get "/admin/logs/staff_action_logs.json", params: { limit: 3 }
json = JSON.parse(response.body)
expect(response.status).to eq(200)
expect(json["staff_action_logs"].length).to eq(3)
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 4")
get "/admin/logs/staff_action_logs.json", params: { limit: 3, page: 1 }
json = JSON.parse(response.body)
expect(response.status).to eq(200)
expect(json["staff_action_logs"].length).to eq(1)
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 1")
end
context 'When staff actions are extended' do
let(:plugin_extended_action) { :confirmed_ham }
before { UserHistory.stubs(:staff_actions).returns([plugin_extended_action]) }