2021-03-11 07:30:15 +01:00
|
|
|
# frozen_string_literal: true
|
2020-11-03 01:24:20 +01:00
|
|
|
|
|
|
|
describe CustomWizard::Log do
|
|
|
|
before do
|
2024-10-16 13:52:03 +02:00
|
|
|
CustomWizard::Log.create(
|
|
|
|
"first-test-wizard",
|
|
|
|
"perform_first_action",
|
|
|
|
"first_test_user",
|
|
|
|
"First log message",
|
|
|
|
5.minutes.ago,
|
|
|
|
)
|
|
|
|
CustomWizard::Log.create(
|
|
|
|
"second-test-wizard",
|
|
|
|
"perform_second_action",
|
|
|
|
"second_test_user",
|
|
|
|
"Second log message",
|
|
|
|
3.minutes.ago,
|
|
|
|
)
|
|
|
|
CustomWizard::Log.create(
|
|
|
|
"third-test-wizard",
|
|
|
|
"perform_third_action",
|
|
|
|
"third_test_user",
|
|
|
|
"Third log message",
|
|
|
|
1.minutes.ago,
|
|
|
|
)
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
it "creates logs" do
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(CustomWizard::Log.list.logs.length).to eq(3)
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
it "lists logs by time created" do
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(CustomWizard::Log.list.logs.first.message).to eq("Third log message")
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
it "paginates logs" do
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(CustomWizard::Log.list(0, 2).logs.length).to eq(2)
|
2020-11-03 01:24:20 +01:00
|
|
|
end
|
2021-09-09 08:07:12 +02:00
|
|
|
|
|
|
|
it "lists logs by wizard" do
|
2024-10-16 13:52:03 +02:00
|
|
|
expect(CustomWizard::Log.list(0, 2, "third-test-wizard").logs.length).to eq(1)
|
2021-09-09 08:07:12 +02:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|