2021-03-11 07:30:15 +01:00
|
|
|
# frozen_string_literal: true
|
2020-11-03 01:24:20 +01:00
|
|
|
|
|
|
|
describe CustomWizard::AdminLogsController do
|
|
|
|
fab!(:admin_user) { Fabricate(:user, admin: true) }
|
2021-09-09 08:07:12 +02:00
|
|
|
let(:template) { get_wizard_fixture("wizard") }
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
before do
|
2024-10-16 13:52:03 +02:00
|
|
|
%w[first second third].each_with_index do |key, index|
|
2021-09-09 08:07:12 +02:00
|
|
|
temp = template.dup
|
|
|
|
temp["id"] = "#{key}_test_wizard"
|
|
|
|
CustomWizard::Template.save(temp, skip_jobs: true)
|
2024-10-16 13:52:03 +02:00
|
|
|
CustomWizard::Log.create(
|
|
|
|
"#{key}_test_wizard",
|
|
|
|
"perform_#{key}_action",
|
|
|
|
"#{key}_test_user",
|
|
|
|
"#{key} log message",
|
|
|
|
)
|
2021-09-09 08:07:12 +02:00
|
|
|
end
|
2020-11-03 01:24:20 +01:00
|
|
|
sign_in(admin_user)
|
|
|
|
end
|
|
|
|
|
2021-09-09 08:07:12 +02:00
|
|
|
it "returns a list of wizards" do
|
2020-11-03 01:24:20 +01:00
|
|
|
get "/admin/wizards/logs.json"
|
|
|
|
expect(response.parsed_body.length).to eq(3)
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2021-09-09 08:07:12 +02:00
|
|
|
it "returns a list of logs for a wizard" do
|
|
|
|
get "/admin/wizards/logs/first_test_wizard.json"
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(response.parsed_body["logs"].length).to eq(1)
|
2021-09-09 08:07:12 +02:00
|
|
|
end
|
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
it "paginates" do
|
2021-09-09 08:07:12 +02:00
|
|
|
get "/admin/wizards/logs/first_test_wizard.json", params: { page: 1 }
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(response.parsed_body["logs"].length).to eq(0)
|
2021-09-09 08:07:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns total logs for a wizard" do
|
|
|
|
get "/admin/wizards/logs/first_test_wizard.json"
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(response.parsed_body["total"]).to eq(1)
|
2021-09-09 08:07:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns basic wizard" do
|
|
|
|
get "/admin/wizards/logs/first_test_wizard.json"
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(response.parsed_body["wizard"]["id"]).to eq("first_test_wizard")
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|