From c394656ed877469a90ae86106cbcbbd82fd72751 Mon Sep 17 00:00:00 2001 From: KC Maddever Date: Mon, 30 Aug 2021 21:45:57 +0800 Subject: [PATCH] DEV: update tests for split log fields --- spec/components/custom_wizard/log_spec.rb | 6 +++--- spec/requests/custom_wizard/admin/logs_controller_spec.rb | 6 +++--- spec/serializers/custom_wizard/log_serializer_spec.rb | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spec/components/custom_wizard/log_spec.rb b/spec/components/custom_wizard/log_spec.rb index 30fd0173..62f2e6df 100644 --- a/spec/components/custom_wizard/log_spec.rb +++ b/spec/components/custom_wizard/log_spec.rb @@ -3,9 +3,9 @@ require_relative '../../plugin_helper' describe CustomWizard::Log do before do - CustomWizard::Log.create("First log message") - CustomWizard::Log.create("Second log message") - CustomWizard::Log.create("Third log message") + CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message') + CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message') + CustomWizard::Log.create('third-test-wizard', 'perform_third_action', 'third_test_user', 'Third log message') end it "creates logs" do diff --git a/spec/requests/custom_wizard/admin/logs_controller_spec.rb b/spec/requests/custom_wizard/admin/logs_controller_spec.rb index 28b7d785..5aaf9578 100644 --- a/spec/requests/custom_wizard/admin/logs_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/logs_controller_spec.rb @@ -5,9 +5,9 @@ describe CustomWizard::AdminLogsController do fab!(:admin_user) { Fabricate(:user, admin: true) } before do - CustomWizard::Log.create("First log message") - CustomWizard::Log.create("Second log message") - CustomWizard::Log.create("Third log message") + CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message') + CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message') + CustomWizard::Log.create('third-test-wizard', 'perform_third_action', 'third_test_user', 'Third log message') sign_in(admin_user) end diff --git a/spec/serializers/custom_wizard/log_serializer_spec.rb b/spec/serializers/custom_wizard/log_serializer_spec.rb index bde16199..b452b9c5 100644 --- a/spec/serializers/custom_wizard/log_serializer_spec.rb +++ b/spec/serializers/custom_wizard/log_serializer_spec.rb @@ -6,14 +6,17 @@ describe CustomWizard::LogSerializer do fab!(:user) { Fabricate(:user) } it 'should return log attributes' do - CustomWizard::Log.create("First log message") - CustomWizard::Log.create("Second log message") + CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message') + CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message') json_array = ActiveModel::ArraySerializer.new( CustomWizard::Log.list(0), each_serializer: CustomWizard::LogSerializer ).as_json expect(json_array.length).to eq(2) + expect(json_array[0][:wizard]).to eq("second-test-wizard") + expect(json_array[0][:action]).to eq("perform_second_action") + expect(json_array[0][:user]).to eq("second_test_user") expect(json_array[0][:message]).to eq("Second log message") end end