Add model TelegramBot
This commit is contained in:
parent
ee431d86d1
commit
dc1d803c79
5 changed files with 39 additions and 1 deletions
5
app/models/telegram_bot.rb
Normal file
5
app/models/telegram_bot.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TelegramBot < ApplicationRecord
|
||||
validates :secret, presence: true
|
||||
end
|
11
db/migrate/20181129131751_create_telegram_bots.rb
Normal file
11
db/migrate/20181129131751_create_telegram_bots.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateTelegramBots < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :telegram_bots do |t|
|
||||
t.timestamps null: false
|
||||
|
||||
t.string :secret, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2018_11_26_132402) do
|
||||
ActiveRecord::Schema.define(version: 2018_11_29_131751) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -30,4 +30,10 @@ ActiveRecord::Schema.define(version: 2018_11_26_132402) do
|
|||
t.text "comment"
|
||||
end
|
||||
|
||||
create_table "telegram_bots", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "secret", null: false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
7
factories/telegram_bots.rb
Normal file
7
factories/telegram_bots.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :telegram_bot do
|
||||
secret { SecureRandom.hex }
|
||||
end
|
||||
end
|
9
spec/models/telegram_bot_spec.rb
Normal file
9
spec/models/telegram_bot_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TelegramBot, type: :model do
|
||||
subject { create :telegram_bot }
|
||||
|
||||
it { is_expected.to validate_presence_of :secret }
|
||||
end
|
Reference in a new issue