2020-11-03 01:24:20 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe CustomWizard::LogSerializer do
|
|
|
|
fab!(:user) { Fabricate(:user) }
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
it 'should return log attributes' do
|
2023-05-01 22:49:44 +02:00
|
|
|
CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message', 1.day.ago)
|
2021-08-30 15:45:57 +02:00
|
|
|
CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message')
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-03 01:24:20 +01:00
|
|
|
json_array = ActiveModel::ArraySerializer.new(
|
2021-09-09 08:07:12 +02:00
|
|
|
CustomWizard::Log.list(0).logs,
|
2020-11-03 01:24:20 +01:00
|
|
|
each_serializer: CustomWizard::LogSerializer
|
2021-03-11 07:30:15 +01:00
|
|
|
).as_json
|
2020-11-03 01:24:20 +01:00
|
|
|
expect(json_array.length).to eq(2)
|
2021-08-30 15:45:57 +02:00
|
|
|
expect(json_array[0][:action]).to eq("perform_second_action")
|
2021-09-09 08:07:12 +02:00
|
|
|
expect(json_array[0][:username]).to eq('second_test_user')
|
2020-11-03 01:24:20 +01:00
|
|
|
expect(json_array[0][:message]).to eq("Second log message")
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|