mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
DEV: Set a limit for ApiKey#description (#21502)
This commit is contained in:
parent
f160f073b0
commit
9f283eb836
@ -17,6 +17,8 @@ class ApiKey < ActiveRecord::Base
|
||||
where(key_hash: hashed)
|
||||
}
|
||||
|
||||
validates :description, length: { maximum: 255 }
|
||||
|
||||
after_initialize :generate_key
|
||||
|
||||
def generate_key
|
||||
|
@ -6,6 +6,7 @@ RSpec.describe ApiKey do
|
||||
|
||||
it { is_expected.to belong_to :user }
|
||||
it { is_expected.to belong_to :created_by }
|
||||
it { is_expected.to validate_length_of(:description).is_at_most(255) }
|
||||
|
||||
it "generates a key when saving" do
|
||||
api_key = ApiKey.new
|
||||
|
Loading…
Reference in New Issue
Block a user