feat: update organization slug max limit (#18911)

This commit is contained in:
Gabriel Quaresma 2023-01-04 16:13:34 -03:00 committed by GitHub
parent 3a87a2e60f
commit 575852f940
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -48,7 +48,7 @@ class Organization < ApplicationRecord
validates :secret, length: { is: 100 }, allow_nil: true
validates :secret, uniqueness: true
validates :slug, exclusion: { in: ReservedWords.all, message: :reserved_word }
validates :slug, format: { with: SLUG_REGEXP }, length: { in: 2..18 }
validates :slug, format: { with: SLUG_REGEXP }, length: { in: 2..30 }
validates :slug, presence: true, uniqueness: { case_sensitive: false }
validates :spent_credits_count, presence: true
validates :summary, length: { maximum: 250 }

View file

@ -83,7 +83,7 @@
</div>
<div class="crayons-field">
<%= f.label :slug, class: "crayons-field__label" %>
<%= f.text_field :slug, maxlength: 18, minlength: 2, class: "crayons-textfield" %>
<%= f.text_field :slug, maxlength: 30, minlength: 2, class: "crayons-textfield" %>
<p class="crayons-field__description"><%= t("views.settings.org.admin.form.slug", slug: app_url(@organization.slug)) %></p>
</div>

View file

@ -1,6 +1,6 @@
require "rails_helper"
RSpec.describe Organization, type: :model do
RSpec.describe Organization do
let(:organization) { create(:organization) }
describe "validations" do
@ -27,7 +27,7 @@ RSpec.describe Organization, type: :model do
it { is_expected.to validate_length_of(:name).is_at_most(50) }
it { is_expected.to validate_length_of(:proof).is_at_most(1500) }
it { is_expected.to validate_length_of(:secret).is_equal_to(100) }
it { is_expected.to validate_length_of(:slug).is_at_least(2).is_at_most(18) }
it { is_expected.to validate_length_of(:slug).is_at_least(2).is_at_most(30) }
it { is_expected.to validate_length_of(:story).is_at_most(640) }
it { is_expected.to validate_length_of(:tag_line).is_at_most(60) }
it { is_expected.to validate_length_of(:tech_stack).is_at_most(640) }