Introduce Glitch::Note (#193)

This is a model for attaching a single note to a single other entity.
For #193, we'll use it for annotating blocks, mutes, and account-level
domain blocks.
This commit is contained in:
David Yip 2018-01-18 13:34:01 -06:00
parent 00ce2be148
commit a37753179d
No known key found for this signature in database
GPG Key ID: 7DA0036508FCC0CC
5 changed files with 43 additions and 1 deletions

15
app/models/glitch/note.rb Normal file
View File

@ -0,0 +1,15 @@
# == Schema Information
#
# Table name: glitch_notes
#
# id :integer not null, primary key
# target_id :integer not null
# target_type :string not null
# note :text not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Glitch::Note < ApplicationRecord
belongs_to :target, polymorphic: true
end

View File

@ -0,0 +1,11 @@
class CreateGlitchNotes < ActiveRecord::Migration[5.1]
def change
create_table :glitch_notes do |t|
t.bigint :target_id, null: false
t.string :target_type, null: false
t.text :note, null: false
t.index [:target_id, :target_type]
t.timestamps
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: 20180106000232) do
ActiveRecord::Schema.define(version: 20180118192721) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -182,6 +182,15 @@ ActiveRecord::Schema.define(version: 20180106000232) do
t.index ["account_id"], name: "index_glitch_keyword_mutes_on_account_id"
end
create_table "glitch_notes", force: :cascade do |t|
t.bigint "target_id", null: false
t.string "target_type", null: false
t.text "note", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["target_id", "target_type"], name: "index_glitch_notes_on_target_id_and_target_type"
end
create_table "imports", force: :cascade do |t|
t.integer "type", null: false
t.boolean "approved", default: false, null: false

View File

@ -0,0 +1,2 @@
Fabricator('Glitch::Note') do
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Glitch::Note, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end