1
0
Fork 0

Add model TelegramBot

This commit is contained in:
Alex Kotov 2018-11-29 18:24:37 +05:00
parent ee431d86d1
commit dc1d803c79
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
5 changed files with 39 additions and 1 deletions

View file

@ -0,0 +1,5 @@
# frozen_string_literal: true
class TelegramBot < ApplicationRecord
validates :secret, presence: true
end

View 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

View file

@ -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

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :telegram_bot do
secret { SecureRandom.hex }
end
end

View 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