Skip to content

Commit

Permalink
Add event's name validation
Browse files Browse the repository at this point in the history
We've been using the event's name to know what kind of event it is.

I think we should add the name presence validator,
what do you think about it?

If should be more validations, please let me know, and also, if the
validation is not needed/desired feel free to close the pr.
  • Loading branch information
JuanVqz committed Aug 7, 2023
1 parent e274f1b commit e6c1247
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/models/signalman/event.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Signalman::Event < ApplicationRecord
validates :name, presence: true

scope :requests, ->{ where(name: "process_action.action_controller") }
scope :mails, ->{ where(name: "deliver.action_mailer") }
scope :queries, ->{ where(name: "sql.active_record") }
Expand Down
7 changes: 0 additions & 7 deletions test/models/signalman/entry_test.rb

This file was deleted.

11 changes: 11 additions & 0 deletions test/models/signalman/event_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "test_helper"

class Signalman::EventTest < ActiveSupport::TestCase
test "is valid" do
assert Signalman::Event.new(name: "sql.active_record").valid?
end

test "is not valid" do
assert_not Signalman::Event.new.valid?
end
end

0 comments on commit e6c1247

Please sign in to comment.