mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00: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)
|
where(key_hash: hashed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validates :description, length: { maximum: 255 }
|
||||||
|
|
||||||
after_initialize :generate_key
|
after_initialize :generate_key
|
||||||
|
|
||||||
def 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 :user }
|
||||||
it { is_expected.to belong_to :created_by }
|
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
|
it "generates a key when saving" do
|
||||||
api_key = ApiKey.new
|
api_key = ApiKey.new
|
||||||
|
Loading…
x
Reference in New Issue
Block a user