mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add order and show_in_roadmap fields to PostStatus
This commit is contained in:
@@ -11,6 +11,8 @@ class PostStatusDashboard < Administrate::BaseDashboard
|
|||||||
id: Field::Number,
|
id: Field::Number,
|
||||||
name: Field::String,
|
name: Field::String,
|
||||||
color: ColorField,
|
color: ColorField,
|
||||||
|
order: Field::Number,
|
||||||
|
show_in_roadmap: Field::Boolean,
|
||||||
created_at: Field::DateTime,
|
created_at: Field::DateTime,
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
}.freeze
|
}.freeze
|
||||||
@@ -23,6 +25,8 @@ class PostStatusDashboard < Administrate::BaseDashboard
|
|||||||
COLLECTION_ATTRIBUTES = %i[
|
COLLECTION_ATTRIBUTES = %i[
|
||||||
name
|
name
|
||||||
color
|
color
|
||||||
|
order
|
||||||
|
show_in_roadmap
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# SHOW_PAGE_ATTRIBUTES
|
# SHOW_PAGE_ATTRIBUTES
|
||||||
@@ -31,6 +35,8 @@ class PostStatusDashboard < Administrate::BaseDashboard
|
|||||||
id
|
id
|
||||||
name
|
name
|
||||||
color
|
color
|
||||||
|
order
|
||||||
|
show_in_roadmap
|
||||||
created_at
|
created_at
|
||||||
updated_at
|
updated_at
|
||||||
].freeze
|
].freeze
|
||||||
@@ -41,6 +47,8 @@ class PostStatusDashboard < Administrate::BaseDashboard
|
|||||||
FORM_ATTRIBUTES = %i[
|
FORM_ATTRIBUTES = %i[
|
||||||
name
|
name
|
||||||
color
|
color
|
||||||
|
order
|
||||||
|
show_in_roadmap
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# COLLECTION_FILTERS
|
# COLLECTION_FILTERS
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class PostStatus < ApplicationRecord
|
class PostStatus < ApplicationRecord
|
||||||
validates :name, presence: true, uniqueness: true
|
validates :name, presence: true, uniqueness: true
|
||||||
validates :color, format: { with: /\A#(?:[0-9a-fA-F]{3}){1,2}\z/ }
|
validates :color, format: { with: /\A#(?:[0-9a-fA-F]{3}){1,2}\z/ }
|
||||||
|
validates :order, numericality: { only_integer: true, greater_than: 0 }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class AddOrderAndShowInRoadmapToPostStatuses < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :post_statuses, :order, :integer, null: false, default: 999
|
||||||
|
add_column :post_statuses, :show_in_roadmap, :boolean, null: false, default: false
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2019_08_25_093234) do
|
ActiveRecord::Schema.define(version: 2019_08_26_154118) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -28,6 +28,8 @@ ActiveRecord::Schema.define(version: 2019_08_25_093234) do
|
|||||||
t.string "color", null: false
|
t.string "color", null: false
|
||||||
t.datetime "created_at", precision: 6, null: false
|
t.datetime "created_at", precision: 6, null: false
|
||||||
t.datetime "updated_at", precision: 6, null: false
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
|
t.integer "order", default: 999, null: false
|
||||||
|
t.boolean "show_in_roadmap", default: false, null: false
|
||||||
t.index ["name"], name: "index_post_statuses_on_name", unique: true
|
t.index ["name"], name: "index_post_statuses_on_name", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,7 @@ FactoryBot.define do
|
|||||||
factory :post_status do
|
factory :post_status do
|
||||||
sequence(:name) { |n| "Post Status #{n}" }
|
sequence(:name) { |n| "Post Status #{n}" }
|
||||||
color { '#ffffff' }
|
color { '#ffffff' }
|
||||||
|
sequence(:order) { |n| n }
|
||||||
|
show_in_roadmap { true }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,4 +36,18 @@ RSpec.describe PostStatus, type: :model do
|
|||||||
expect(valid_color).to be_valid
|
expect(valid_color).to be_valid
|
||||||
expect(valid_color2).to be_valid
|
expect(valid_color2).to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'must have a order of type integer and positive' do
|
||||||
|
nil_order = FactoryBot.build(:post_status, order: nil)
|
||||||
|
empty_order = FactoryBot.build(:post_status, order: '')
|
||||||
|
decimal_order = FactoryBot.build(:post_status, order: 1.1)
|
||||||
|
negative_order = FactoryBot.build(:post_status, order: -1)
|
||||||
|
zero_order = FactoryBot.build(:post_status, order: 0)
|
||||||
|
|
||||||
|
expect(nil_order).to be_invalid
|
||||||
|
expect(empty_order).to be_invalid
|
||||||
|
expect(decimal_order).to be_invalid
|
||||||
|
expect(negative_order).to be_invalid
|
||||||
|
expect(zero_order).to be_invalid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user